Default X-Xss-Protection header value to "0"
Closes gh-9631
This commit is contained in:
committed by
Steve Riesenberg
parent
dcda899c8c
commit
27059ced87
@@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
/**
|
||||
* @author Rob Winch
|
||||
* @author Ankur Pathak
|
||||
* @author Daniel Garnier-Moiroux
|
||||
*
|
||||
*/
|
||||
public class XXssProtectionHeaderWriterTests {
|
||||
@@ -49,43 +50,11 @@ public class XXssProtectionHeaderWriterTests {
|
||||
|
||||
@Test
|
||||
public void writeHeaders() {
|
||||
this.writer.writeHeaders(this.request, this.response);
|
||||
assertThat(this.response.getHeaderNames()).hasSize(1);
|
||||
assertThat(this.response.getHeaderValues("X-XSS-Protection")).containsOnly("1; mode=block");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeHeadersNoBlock() {
|
||||
this.writer.setBlock(false);
|
||||
this.writer.writeHeaders(this.request, this.response);
|
||||
assertThat(this.response.getHeaderNames()).hasSize(1);
|
||||
assertThat(this.response.getHeaderValues("X-XSS-Protection")).containsOnly("1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeHeadersDisabled() {
|
||||
this.writer.setBlock(false);
|
||||
this.writer.setEnabled(false);
|
||||
this.writer.writeHeaders(this.request, this.response);
|
||||
assertThat(this.response.getHeaderNames()).hasSize(1);
|
||||
assertThat(this.response.getHeaderValues("X-XSS-Protection")).containsOnly("0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setEnabledFalseWithBlockTrue() {
|
||||
this.writer.setEnabled(false);
|
||||
this.writer.writeHeaders(this.request, this.response);
|
||||
assertThat(this.response.getHeaderNames()).hasSize(1);
|
||||
assertThat(this.response.getHeaderValues("X-XSS-Protection")).containsOnly("0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setBlockTrueWithEnabledFalse() {
|
||||
this.writer.setBlock(false);
|
||||
this.writer.setEnabled(false);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.writer.setBlock(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeHeaderWhenNotPresent() {
|
||||
String value = new String("value");
|
||||
|
||||
@@ -46,23 +46,6 @@ public class XXssProtectionServerHttpHeadersWriterTests {
|
||||
|
||||
@Test
|
||||
public void writeHeadersWhenNoHeadersThenWriteHeaders() {
|
||||
this.writer.writeHttpHeaders(this.exchange);
|
||||
assertThat(this.headers).hasSize(1);
|
||||
assertThat(this.headers.get(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION))
|
||||
.containsOnly("1 ; mode=block");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeHeadersWhenBlockFalseThenWriteHeaders() {
|
||||
this.writer.setBlock(false);
|
||||
this.writer.writeHttpHeaders(this.exchange);
|
||||
assertThat(this.headers).hasSize(1);
|
||||
assertThat(this.headers.get(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION)).containsOnly("1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeHeadersWhenEnabledFalseThenWriteHeaders() {
|
||||
this.writer.setEnabled(false);
|
||||
this.writer.writeHttpHeaders(this.exchange);
|
||||
assertThat(this.headers).hasSize(1);
|
||||
assertThat(this.headers.get(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION)).containsOnly("0");
|
||||
|
||||
Reference in New Issue
Block a user