use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenPermissionsPolicyConfiguredThenPermissionsPolicyHeaderInResponse.
@Test
public void getWhenPermissionsPolicyConfiguredThenPermissionsPolicyHeaderInResponse() throws Exception {
this.spring.register(PermissionsPolicyConfig.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");
}
use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenHpkpWithCustomAgeThenPublicKeyPinsReportOnlyHeaderWithCustomAgeInResponse.
@Test
public void getWhenHpkpWithCustomAgeThenPublicKeyPinsReportOnlyHeaderWithCustomAgeInResponse() throws Exception {
this.spring.register(HpkpConfigCustomAge.class).autowire();
ResultMatcher pinsReportOnly = header().string(HttpHeaders.PUBLIC_KEY_PINS_REPORT_ONLY, "max-age=604800 ; pin-sha256=\"d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=\"");
// @formatter:off
MvcResult mvcResult = this.mvc.perform(get("/").secure(true)).andExpect(pinsReportOnly).andReturn();
// @formatter:on
assertThat(mvcResult.getResponse().getHeaderNames()).containsExactly(HttpHeaders.PUBLIC_KEY_PINS_REPORT_ONLY);
}
use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenHpkpWithReportUriThenPublicKeyPinsReportOnlyHeaderWithReportUriInResponse.
@Test
public void getWhenHpkpWithReportUriThenPublicKeyPinsReportOnlyHeaderWithReportUriInResponse() throws Exception {
this.spring.register(HpkpConfigWithReportURI.class).autowire();
ResultMatcher pinsReportOnly = header().string(HttpHeaders.PUBLIC_KEY_PINS_REPORT_ONLY, "max-age=5184000 ; pin-sha256=\"d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=\" ; report-uri=\"https://example.net/pkp-report\"");
// @formatter:off
MvcResult mvcResult = this.mvc.perform(get("/").secure(true)).andExpect(pinsReportOnly).andReturn();
// @formatter:on
assertThat(mvcResult.getResponse().getHeaderNames()).containsExactly(HttpHeaders.PUBLIC_KEY_PINS_REPORT_ONLY);
}
use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenHpkpWithMultiplePinsThenPublicKeyPinsReportOnlyHeaderWithMultiplePinsInResponse.
@Test
public void getWhenHpkpWithMultiplePinsThenPublicKeyPinsReportOnlyHeaderWithMultiplePinsInResponse() throws Exception {
this.spring.register(HpkpConfigWithPins.class).autowire();
ResultMatcher pinsReportOnly = header().string(HttpHeaders.PUBLIC_KEY_PINS_REPORT_ONLY, "max-age=5184000 ; pin-sha256=\"d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=\" ; pin-sha256=\"E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=\"");
// @formatter:off
MvcResult mvcResult = this.mvc.perform(get("/").secure(true)).andExpect(pinsReportOnly).andReturn();
// @formatter:on
assertThat(mvcResult.getResponse().getHeaderNames()).containsExactly(HttpHeaders.PUBLIC_KEY_PINS_REPORT_ONLY);
}
use of org.springframework.test.web.servlet.ResultMatcher in project spring-security by spring-projects.
the class HeadersConfigurerTests method getWhenContentSecurityPolicyWithReportOnlyThenContentSecurityPolicyReportOnlyHeaderInResponse.
@Test
public void getWhenContentSecurityPolicyWithReportOnlyThenContentSecurityPolicyReportOnlyHeaderInResponse() throws Exception {
this.spring.register(ContentSecurityPolicyReportOnlyConfig.class).autowire();
ResultMatcher cspReportOnly = header().string(HttpHeaders.CONTENT_SECURITY_POLICY_REPORT_ONLY, "default-src 'self'; script-src trustedscripts.example.com");
// @formatter:off
MvcResult mvcResult = this.mvc.perform(get("/").secure(true)).andExpect(cspReportOnly).andReturn();
// @formatter:on
assertThat(mvcResult.getResponse().getHeaderNames()).containsExactly(HttpHeaders.CONTENT_SECURITY_POLICY_REPORT_ONLY);
}
Aggregations