use of org.springframework.security.web.header.writers.HstsHeaderWriter in project spring-security by spring-projects.
the class HstsHeaderWriterTests method maxAgeAndIncludeSubdomainsCustomConstructorWriteHeaders.
@Test
public void maxAgeAndIncludeSubdomainsCustomConstructorWriteHeaders() {
request.setSecure(false);
writer = new HstsHeaderWriter(AnyRequestMatcher.INSTANCE, 15768000, false);
writer.writeHeaders(request, response);
assertThat(response.getHeaderNames().size()).isEqualTo(1);
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo("max-age=15768000");
}
use of org.springframework.security.web.header.writers.HstsHeaderWriter in project spring-security by spring-projects.
the class HstsHeaderWriterTests method setup.
@Before
public void setup() {
request = new MockHttpServletRequest();
request.setSecure(true);
response = new MockHttpServletResponse();
writer = new HstsHeaderWriter();
}
use of org.springframework.security.web.header.writers.HstsHeaderWriter in project spring-security by spring-projects.
the class HstsHeaderWriterTests method maxAgeCustomConstructorWriteHeaders.
@Test
public void maxAgeCustomConstructorWriteHeaders() {
writer = new HstsHeaderWriter(15768000);
writer.writeHeaders(request, response);
assertThat(response.getHeaderNames().size()).isEqualTo(1);
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo("max-age=15768000 ; includeSubDomains");
}
use of org.springframework.security.web.header.writers.HstsHeaderWriter in project spring-security by spring-projects.
the class HstsHeaderWriterTests method allArgsCustomConstructorWriteHeaders.
@Test
public void allArgsCustomConstructorWriteHeaders() {
request.setSecure(false);
writer = new HstsHeaderWriter(AnyRequestMatcher.INSTANCE, 15768000, false);
writer.writeHeaders(request, response);
assertThat(response.getHeaderNames().size()).isEqualTo(1);
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo("max-age=15768000");
}
use of org.springframework.security.web.header.writers.HstsHeaderWriter in project spring-security by spring-projects.
the class HstsHeaderWriterTests method includeSubDomainsCustomConstructorWriteHeaders.
@Test
public void includeSubDomainsCustomConstructorWriteHeaders() {
writer = new HstsHeaderWriter(false);
writer.writeHeaders(request, response);
assertThat(response.getHeaderNames().size()).isEqualTo(1);
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo("max-age=31536000");
}
Aggregations