use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenHstsConfiguredWithPreloadInLambdaThenStrictTransportSecurityHeaderWithPreloadInResponse.
@Test
public void getWhenHstsConfiguredWithPreloadInLambdaThenStrictTransportSecurityHeaderWithPreloadInResponse() throws Exception {
this.spring.register(HstsWithPreloadInLambdaConfig.class).autowire();
ResultMatcher hsts = header().string(HttpHeaders.STRICT_TRANSPORT_SECURITY, "max-age=31536000 ; includeSubDomains ; preload");
// @formatter:off
MvcResult mvcResult = this.mvc.perform(get("/").secure(true)).andExpect(hsts).andReturn();
// @formatter:on
assertThat(mvcResult.getResponse().getHeaderNames()).containsExactly(HttpHeaders.STRICT_TRANSPORT_SECURITY);
}
use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenReferrerPolicyConfiguredThenReferrerPolicyHeaderInResponse.
@Test
public void getWhenReferrerPolicyConfiguredThenReferrerPolicyHeaderInResponse() throws Exception {
this.spring.register(ReferrerPolicyDefaultConfig.class).autowire();
ResultMatcher referrerPolicy = header().string("Referrer-Policy", ReferrerPolicy.NO_REFERRER.getPolicy());
// @formatter:off
MvcResult mvcResult = this.mvc.perform(get("/").secure(true)).andExpect(referrerPolicy).andReturn();
// @formatter:on
assertThat(mvcResult.getResponse().getHeaderNames()).containsExactly("Referrer-Policy");
}
use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenHstsConfiguredWithPreloadThenStrictTransportSecurityHeaderWithPreloadInResponse.
@Test
public void getWhenHstsConfiguredWithPreloadThenStrictTransportSecurityHeaderWithPreloadInResponse() throws Exception {
this.spring.register(HstsWithPreloadConfig.class).autowire();
ResultMatcher hsts = header().string(HttpHeaders.STRICT_TRANSPORT_SECURITY, "max-age=31536000 ; includeSubDomains ; preload");
// @formatter:off
MvcResult mvcResult = this.mvc.perform(get("/").secure(true)).andExpect(hsts).andReturn();
// @formatter:on
assertThat(mvcResult.getResponse().getHeaderNames()).containsExactly(HttpHeaders.STRICT_TRANSPORT_SECURITY);
}
use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenPermissionsPolicyConfiguredWithStringThenPermissionsPolicyHeaderInResponse.
@Test
public void getWhenPermissionsPolicyConfiguredWithStringThenPermissionsPolicyHeaderInResponse() throws Exception {
this.spring.register(PermissionsPolicyStringConfig.class).autowire();
ResultMatcher permissionsPolicy = header().string("Permissions-Policy", "geolocation=(self)");
// @formatter:off
MvcResult mvcResult = this.mvc.perform(get("/").secure(true)).andExpect(permissionsPolicy).andReturn();
// @formatter:on
assertThat(mvcResult.getResponse().getHeaderNames()).containsExactly("Permissions-Policy");
}
Aggregations