Skip to content

Commit

Permalink
test(): Refactor the test class and add credential test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawven committed May 21, 2024
1 parent b7cb8c7 commit db4503b
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void actualRequestCredentials() {
Mockito.when(request.method()).thenReturn(HttpMethods.GET.name());
Mockito.when(request.header(CorsHeaderFilter.ORIGIN)).thenReturn("https://domain2.com");
Mockito.doReturn(CorsMeta.builder()
.allowedOrigins( "https://domain1.com","https://domain2.com")
.allowedOrigins("https://domain1.com", "https://domain2.com")
.allowCredentials(true)
.build()
.applyDefault())
Expand Down Expand Up @@ -400,8 +400,13 @@ void preflightRequestCredentials() {
Mockito.when(request.header(CorsHeaderFilter.ACCESS_CONTROL_REQUEST_HEADERS))
.thenReturn("Header1");
Mockito.doReturn(CorsMeta.builder()
.allowedOrigins("https://domain1.com", "https://domain2.com", "http://domain3.example")
.allowedHeaders("Header1").allowCredentials(true).build().applyDefault()).when(build).getCors();
.allowedOrigins("https://domain1.com", "https://domain2.com", "http://domain3.example")
.allowedHeaders("Header1")
.allowCredentials(true)
.build()
.applyDefault())
.when(build)
.getCors();
processor.preLightProcess(request, response, HttpStatus.NO_CONTENT.getCode());
}

Expand All @@ -419,6 +424,4 @@ void preventDuplicatedVaryHeaders() {
Assertions.assertTrue(
response.header(CorsHeaderFilter.VARY).contains(CorsHeaderFilter.ACCESS_CONTROL_REQUEST_HEADERS));
}


}

0 comments on commit db4503b

Please sign in to comment.