Apply allowedOriginPatterns in SockJsService
See gh-26108
This commit is contained in:
@@ -215,7 +215,7 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
||||
@Test // SPR-12283
|
||||
public void handleInfoOptionsWithOriginAndCorsHeadersDisabled() {
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain2.example");
|
||||
this.service.setAllowedOrigins(Collections.singletonList("*"));
|
||||
this.service.setAllowedOriginPatterns(Collections.singletonList("*"));
|
||||
this.service.setSuppressCors(true);
|
||||
|
||||
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Last-Modified");
|
||||
@@ -223,10 +223,12 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
||||
assertThat(this.service.getCorsConfiguration(this.servletRequest)).isNull();
|
||||
|
||||
this.service.setAllowedOrigins(Collections.singletonList("https://mydomain1.example"));
|
||||
this.service.setAllowedOriginPatterns(Collections.emptyList());
|
||||
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.FORBIDDEN);
|
||||
assertThat(this.service.getCorsConfiguration(this.servletRequest)).isNull();
|
||||
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.example", "https://mydomain2.example", "http://mydomain3.example"));
|
||||
this.service.setAllowedOriginPatterns(Collections.emptyList());
|
||||
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
|
||||
assertThat(this.service.getCorsConfiguration(this.servletRequest)).isNull();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user