Skip to content
Snippets Groups Projects
Commit a420dfdf authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4939 Refactored Security error body test

parent d2e44a0d
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.net.URI;
import org.apache.http.HttpHeaders;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
......@@ -36,7 +35,6 @@ import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
......@@ -119,7 +117,6 @@ public class SecurityConfigurationLocalITCase {
result.andExpect(jsonPath("$.instance").value("/api"));
}
}
@Test
@SneakyThrows
......@@ -136,9 +133,7 @@ public class SecurityConfigurationLocalITCase {
};
var problemDetail = ErrorResponse
.builder(ex, HttpStatus.UNAUTHORIZED, ex.getLocalizedMessage())
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PROBLEM_JSON_VALUE)
.instance(URI.create(requestUri))
.header(HttpHeaders.WWW_AUTHENTICATE, "Bearer realm=\"Restricted Content\"")
.build()
.getBody();
......@@ -146,6 +141,7 @@ public class SecurityConfigurationLocalITCase {
objectMapper.setSerializationInclusion(Include.NON_NULL);
return objectMapper.writeValueAsString(problemDetail);
}
}
@SneakyThrows
private ResultActions doPerform(String path) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment