// Path: src/main/java/com/lyubenblagoev/postfixrest/security/JwtTokenProvider.java
// @Component
// public class JwtTokenProvider {
// 
//     @Value("${users.jwt.secret-key:secret}")
//     private String secretKey = "secret";
// 
//     @Value("${users.jwt.expire-after-millis:900000}")
//     private long validityInMilliseconds = 900000;
// 
//     public String createToken(String username, Collection<? extends GrantedAuthority> authorities) {
//         Date now = new Date();
//         Date validity = new Date(now.getTime() + validityInMilliseconds);
//         return Jwts.builder()
//                 .setSubject(username)
//                 .claim("auth", authorities.stream().map(a -> a.getAuthority()).collect(Collectors.toList()))
//                 .setIssuedAt(now)
//                 .setExpiration(validity)
//                 .signWith(SignatureAlgorithm.HS256, secretKey)
//                 .compact();
//     }
// 
//     public boolean validateToken(String token) {
//         try {
//             Jwts.parser()
//                     .setSigningKey(secretKey)
//                     .parseClaimsJws(token);
//             return true;
//         } catch (JwtException e) {
//             return false;
//         }
//     }
// 
//     public String getUsername(String token) {
//         return Jwts.parser()
//                 .setSigningKey(secretKey)
//                 .parseClaimsJws(token)
//                 .getBody()
//                 .getSubject();
//     }
// 
// }


import com.lyubenblagoev.postfixrest.security.JwtTokenProvider;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import java.util.Collections;
import static org.hamcrest.Matchers.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
package com.lyubenblagoev.postfixrest.controller;




@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles({"dev"})
@TestMethodOrder(OrderAnnotation.class)
class DomainControllerIntegrationTest {

    public static final String PATH_API_V_1_DOMAINS = "/api/v1/domains";

    private final MockMvc mockMvc;
// Path: src/main/java/com/lyubenblagoev/postfixrest/security/JwtTokenProvider.java
// @Component
// public class JwtTokenProvider {
// 
//     @Value("${users.jwt.secret-key:secret}")
//     private String secretKey = "secret";
// 
//     @Value("${users.jwt.expire-after-millis:900000}")
//     private long validityInMilliseconds = 900000;
// 
//     public String createToken(String username, Collection<? extends GrantedAuthority> authorities) {
//         Date now = new Date();
//         Date validity = new Date(now.getTime() + validityInMilliseconds);
//         return Jwts.builder()
//                 .setSubject(username)
//                 .claim("auth", authorities.stream().map(a -> a.getAuthority()).collect(Collectors.toList()))
//                 .setIssuedAt(now)
//                 .setExpiration(validity)
//                 .signWith(SignatureAlgorithm.HS256, secretKey)
//                 .compact();
//     }
// 
//     public boolean validateToken(String token) {
//         try {
//             Jwts.parser()
//                     .setSigningKey(secretKey)
//                     .parseClaimsJws(token);
//             return true;
//         } catch (JwtException e) {
//             return false;
//         }
//     }
// 
//     public String getUsername(String token) {
//         return Jwts.parser()
//                 .setSigningKey(secretKey)
//                 .parseClaimsJws(token)
//                 .getBody()
//                 .getSubject();
//     }
// 
// }


// Path: src/test/java/com/lyubenblagoev/postfixrest/controller/DomainControllerIntegrationTest.java
import com.lyubenblagoev.postfixrest.security.JwtTokenProvider;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import java.util.Collections;
import static org.hamcrest.Matchers.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

package com.lyubenblagoev.postfixrest.controller;




@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles({"dev"})
@TestMethodOrder(OrderAnnotation.class)
class DomainControllerIntegrationTest {

    public static final String PATH_API_V_1_DOMAINS = "/api/v1/domains";

    private final MockMvc mockMvc;
    private final JwtTokenProvider jwtTokenProvider;