Polish AssertJ assertions
Polish AssertJ assertions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,10 +38,10 @@ public class CookieClearingLogoutHandlerTests {
|
||||
request.setContextPath("");
|
||||
CookieClearingLogoutHandler handler = new CookieClearingLogoutHandler("my_cookie");
|
||||
handler.logout(request, response, mock(Authentication.class));
|
||||
assertThat(response.getCookies().length).isEqualTo(1);
|
||||
assertThat(response.getCookies()).hasSize(1);
|
||||
for (Cookie c : response.getCookies()) {
|
||||
assertThat(c.getPath()).isEqualTo("/");
|
||||
assertThat(c.getMaxAge()).isEqualTo(0);
|
||||
assertThat(c.getMaxAge()).isZero();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ public class CookieClearingLogoutHandlerTests {
|
||||
CookieClearingLogoutHandler handler = new CookieClearingLogoutHandler(
|
||||
"my_cookie", "my_cookie_too");
|
||||
handler.logout(request, response, mock(Authentication.class));
|
||||
assertThat(response.getCookies().length).isEqualTo(2);
|
||||
assertThat(response.getCookies()).hasSize(2);
|
||||
for (Cookie c : response.getCookies()) {
|
||||
assertThat(c.getPath()).isEqualTo("/app");
|
||||
assertThat(c.getMaxAge()).isEqualTo(0);
|
||||
assertThat(c.getMaxAge()).isZero();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -124,7 +124,7 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSourceTests {
|
||||
PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails details = (PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails) o;
|
||||
List<GrantedAuthority> gas = details.getGrantedAuthorities();
|
||||
assertThat(gas).as("Granted authorities should not be null").isNotNull();
|
||||
assertThat(gas.size()).isEqualTo(expectedRoles.length);
|
||||
assertThat(gas).hasSize(expectedRoles.length);
|
||||
|
||||
Collection<String> expectedRolesColl = Arrays.asList(expectedRoles);
|
||||
Collection<String> gasRolesSet = new HashSet<String>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,7 +49,7 @@ public class WebXmlJ2eeDefinedRolesRetrieverTests {
|
||||
Set<String> j2eeRoles = rolesRetriever.getMappableAttributes();
|
||||
assertThat(j2eeRoles).isNotNull();
|
||||
assertThat(j2eeRoles.size()).withFailMessage("J2eeRoles expected size: " + ROLE1TO4_EXPECTED_ROLES.size()
|
||||
+ ", actual size: " + j2eeRoles.size()).isEqualTo(ROLE1TO4_EXPECTED_ROLES.size());
|
||||
+ ", actual size: " + j2eeRoles).hasSize(ROLE1TO4_EXPECTED_ROLES.size());
|
||||
assertThat(j2eeRoles).withFailMessage("J2eeRoles expected contents (arbitrary order).isTrue(): "
|
||||
+ ROLE1TO4_EXPECTED_ROLES + ", actual content: " + j2eeRoles).containsAll(ROLE1TO4_EXPECTED_ROLES);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -98,11 +98,7 @@ public class AbstractRememberMeServicesTests {
|
||||
assertThat(encoded.endsWith("=")).isFalse();
|
||||
String[] decoded = services.decodeCookie(encoded);
|
||||
|
||||
assertThat(decoded.length).isEqualTo(4);
|
||||
assertThat(decoded[0]).isEqualTo("name");
|
||||
assertThat(decoded[1]).isEqualTo("cookie");
|
||||
assertThat(decoded[2]).isEqualTo("tokens");
|
||||
assertThat(decoded[3]).isEqualTo("blah");
|
||||
assertThat(decoded).containsExactly("name", "cookie", "tokens", "blah");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,13 +108,13 @@ public class AbstractRememberMeServicesTests {
|
||||
MockRememberMeServices services = new MockRememberMeServices(uds);
|
||||
|
||||
String[] decoded = services.decodeCookie(services.encodeCookie(cookie));
|
||||
assertThat(decoded.length).isEqualTo(4);
|
||||
assertThat(decoded).hasSize(4);
|
||||
assertThat(decoded[0]).isEqualTo("http://id.openid.zz");
|
||||
|
||||
// Check https (SEC-1410)
|
||||
cookie[0] = "https://id.openid.zz";
|
||||
decoded = services.decodeCookie(services.encodeCookie(cookie));
|
||||
assertThat(decoded.length).isEqualTo(4);
|
||||
assertThat(decoded).hasSize(4);
|
||||
assertThat(decoded[0]).isEqualTo("https://id.openid.zz");
|
||||
}
|
||||
|
||||
|
||||
@@ -144,11 +144,11 @@ public class DigestAuthUtilsTests {
|
||||
|
||||
@Test
|
||||
public void testSplitWorksWithDifferentDelimiters() {
|
||||
assertThat(DigestAuthUtils.split("18/rod", "/").length).isEqualTo(2);
|
||||
assertThat(DigestAuthUtils.split("18/rod", "/")).hasSize(2);
|
||||
assertThat(DigestAuthUtils.split("18/rod", "!")).isNull();
|
||||
|
||||
// only guarantees to split at FIRST delimiter, not EACH delimiter
|
||||
assertThat(DigestAuthUtils.split("18|rod|foo|bar", "|").length).isEqualTo(2);
|
||||
assertThat(DigestAuthUtils.split("18|rod|foo|bar", "|")).hasSize(2);
|
||||
}
|
||||
|
||||
public void testAuthorizationHeaderWithCommasIsSplitCorrectly() {
|
||||
@@ -157,6 +157,6 @@ public class DigestAuthUtilsTests {
|
||||
|
||||
String[] parts = DigestAuthUtils.splitIgnoringQuotes(header, ',');
|
||||
|
||||
assertThat(parts.length).isEqualTo(8);
|
||||
assertThat(parts).hasSize(8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DigestAuthenticationEntryPointTests {
|
||||
|
||||
String decodedNonce = new String(Base64.decodeBase64(nonce.getBytes()));
|
||||
String[] nonceTokens = StringUtils.delimitedListToStringArray(decodedNonce, ":");
|
||||
assertThat(nonceTokens.length).isEqualTo(2);
|
||||
assertThat(nonceTokens).hasSize(2);
|
||||
|
||||
String expectedNonceSignature = DigestUtils.md5Hex(nonceTokens[0] + ":" + "key");
|
||||
assertThat(nonceTokens[1]).isEqualTo(expectedNonceSignature);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,13 +60,11 @@ public class CacheControlHeadersWriterTests {
|
||||
public void writeHeaders() {
|
||||
this.writer.writeHeaders(this.request, this.response);
|
||||
|
||||
assertThat(this.response.getHeaderNames().size()).isEqualTo(3);
|
||||
assertThat(this.response.getHeaderValues("Cache-Control")).isEqualTo(
|
||||
Arrays.asList("no-cache, no-store, max-age=0, must-revalidate"));
|
||||
assertThat(this.response.getHeaderValues("Pragma"))
|
||||
.isEqualTo(Arrays.asList("no-cache"));
|
||||
assertThat(this.response.getHeaderValues("Expires"))
|
||||
.isEqualTo(Arrays.asList("0"));
|
||||
assertThat(this.response.getHeaderNames()).hasSize(3);
|
||||
assertThat(this.response.getHeaderValues("Cache-Control")).containsExactly(
|
||||
"no-cache, no-store, max-age=0, must-revalidate");
|
||||
assertThat(this.response.getHeaderValues("Pragma")).containsOnly("no-cache");
|
||||
assertThat(this.response.getHeaderValues("Expires")).containsOnly("0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,13 +78,11 @@ public class CacheControlHeadersWriterTests {
|
||||
|
||||
this.writer.writeHeaders(this.request, this.response);
|
||||
|
||||
assertThat(this.response.getHeaderNames().size()).isEqualTo(3);
|
||||
assertThat(this.response.getHeaderValues("Cache-Control")).isEqualTo(
|
||||
Arrays.asList("no-cache, no-store, max-age=0, must-revalidate"));
|
||||
assertThat(this.response.getHeaderValues("Pragma"))
|
||||
.isEqualTo(Arrays.asList("no-cache"));
|
||||
assertThat(this.response.getHeaderValues("Expires"))
|
||||
.isEqualTo(Arrays.asList("0"));
|
||||
assertThat(this.response.getHeaderNames()).hasSize(3);
|
||||
assertThat(this.response.getHeaderValues("Cache-Control")).containsExactly(
|
||||
"no-cache, no-store, max-age=0, must-revalidate");
|
||||
assertThat(this.response.getHeaderValues("Pragma")).containsOnly("no-cache");
|
||||
assertThat(this.response.getHeaderValues("Expires")).containsOnly("0");
|
||||
}
|
||||
|
||||
// gh-2953
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ public class ContentSecurityPolicyHeaderWriterTests {
|
||||
public void writeHeadersContentSecurityPolicyDefault() {
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Content-Security-Policy")).isEqualTo(DEFAULT_POLICY_DIRECTIVES);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ContentSecurityPolicyHeaderWriterTests {
|
||||
writer = new ContentSecurityPolicyHeaderWriter(policyDirectives);
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Content-Security-Policy")).isEqualTo(policyDirectives);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ContentSecurityPolicyHeaderWriterTests {
|
||||
writer.setReportOnly(true);
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Content-Security-Policy-Report-Only")).isEqualTo(DEFAULT_POLICY_DIRECTIVES);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ContentSecurityPolicyHeaderWriterTests {
|
||||
writer.setReportOnly(true);
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Content-Security-Policy-Report-Only")).isEqualTo(policyDirectives);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public class HstsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||
"max-age=15768000");
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class HstsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||
"max-age=15768000");
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class HstsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||
"max-age=15768000 ; includeSubDomains");
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class HstsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||
"max-age=31536000");
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class HstsHeaderWriterTests {
|
||||
public void writeHeadersDefaultValues() {
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||
"max-age=31536000 ; includeSubDomains");
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class HstsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||
"max-age=31536000");
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class HstsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||
"max-age=1 ; includeSubDomains");
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class HstsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||
"max-age=31536000 ; includeSubDomains");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ public class ReferrerPolicyHeaderWriterTests {
|
||||
public void writeHeadersReferrerPolicyDefault() {
|
||||
this.writer.writeHeaders(this.request, this.response);
|
||||
|
||||
assertThat(this.response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(this.response.getHeaderNames()).hasSize(1);
|
||||
assertThat(this.response.getHeader("Referrer-Policy")).isEqualTo(DEFAULT_REFERRER_POLICY);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ReferrerPolicyHeaderWriterTests {
|
||||
|
||||
this.writer.writeHeaders(this.request, this.response);
|
||||
|
||||
assertThat(this.response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(this.response.getHeaderNames()).hasSize(1);
|
||||
assertThat(this.response.getHeader("Referrer-Policy")).isEqualTo("same-origin");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -90,7 +90,7 @@ public class StaticHeaderWriterTests {
|
||||
|
||||
factory.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(2);
|
||||
assertThat(response.getHeaderNames()).hasSize(2);
|
||||
assertThat(response.getHeaderValues(pragma.getName())).isEqualTo(
|
||||
pragma.getValues());
|
||||
assertThat(response.getHeaderValues(cacheControl.getName())).isEqualTo(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,6 @@ package org.springframework.security.web.header.writers;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
@@ -47,8 +45,8 @@ public class XContentTypeOptionsHeaderWriterTests {
|
||||
public void writeHeaders() {
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderValues("X-Content-Type-Options")).isEqualTo(
|
||||
Arrays.asList("nosniff"));
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeaderValues("X-Content-Type-Options")).containsExactly(
|
||||
"nosniff");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,6 @@ package org.springframework.security.web.header.writers;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
@@ -47,9 +45,8 @@ public class XXssProtectionHeaderWriterTests {
|
||||
public void writeHeaders() {
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderValues("X-XSS-Protection")).isEqualTo(
|
||||
Arrays.asList("1; mode=block"));
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeaderValues("X-XSS-Protection")).containsOnly("1; mode=block");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,9 +55,8 @@ public class XXssProtectionHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderValues("X-XSS-Protection")).isEqualTo(
|
||||
Arrays.asList("1"));
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeaderValues("X-XSS-Protection")).containsOnly("1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,9 +66,8 @@ public class XXssProtectionHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderValues("X-XSS-Protection")).isEqualTo(
|
||||
Arrays.asList("0"));
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeaderValues("X-XSS-Protection")).containsOnly("0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,9 +76,8 @@ public class XXssProtectionHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderValues("X-XSS-Protection")).isEqualTo(
|
||||
Arrays.asList("0"));
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeaderValues("X-XSS-Protection")).containsOnly("0");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -82,7 +82,7 @@ public class FrameOptionsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
||||
.isEqualTo("ALLOW-FROM " + allowFromValue);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class FrameOptionsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
||||
.isEqualTo("DENY");
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class FrameOptionsHeaderWriterTests {
|
||||
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
||||
.isEqualTo("SAMEORIGIN");
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class FrameOptionsHeaderWriterTests {
|
||||
writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.DENY);
|
||||
writer.writeHeaders(request, response);
|
||||
|
||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
||||
assertThat(response.getHeaderNames()).hasSize(1);
|
||||
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
||||
.isEqualTo("DENY");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,7 +48,7 @@ public class SavedRequestAwareWrapperTests {
|
||||
MockHttpServletRequest savedRequest = new MockHttpServletRequest();
|
||||
savedRequest.setCookies(new Cookie[] { new Cookie("cookie", "fromsaved") });
|
||||
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, newRequest);
|
||||
assertThat(wrapper.getCookies().length).isEqualTo(1);
|
||||
assertThat(wrapper.getCookies()).hasSize(1);
|
||||
assertThat(wrapper.getCookies()[0].getValue()).isEqualTo("fromnew");
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class SavedRequestAwareWrapperTests {
|
||||
wrappedRequest.setParameter("action", "bar");
|
||||
assertThat(wrapper.getParameter("action")).isEqualTo("bar");
|
||||
// Both values should be set, but "bar" should be first
|
||||
assertThat(wrapper.getParameterValues("action").length).isEqualTo(2);
|
||||
assertThat(wrapper.getParameterValues("action")).hasSize(2);
|
||||
assertThat(wrapper.getParameterValues("action")[0]).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ public class SavedRequestAwareWrapperTests {
|
||||
MockHttpServletRequest wrappedRequest = new MockHttpServletRequest();
|
||||
wrappedRequest.setParameter("action", "foo");
|
||||
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, wrappedRequest);
|
||||
assertThat(wrapper.getParameterValues("action").length).isEqualTo(1);
|
||||
assertThat(wrapper.getParameterValues("action")).hasSize(1);
|
||||
assertThat(wrapper.getParameterMap()).hasSize(1);
|
||||
assertThat(((String[]) wrapper.getParameterMap().get("action")).length).isEqualTo(1);
|
||||
assertThat(((String[]) wrapper.getParameterMap().get("action"))).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,7 +135,7 @@ public class SavedRequestAwareWrapperTests {
|
||||
assertThat(wrapper.getParameterValues("action")).isEqualTo(new Object[] { "bar", "foo" });
|
||||
// Check map is consistent
|
||||
String[] valuesFromMap = (String[]) wrapper.getParameterMap().get("action");
|
||||
assertThat(valuesFromMap.length).isEqualTo(2);
|
||||
assertThat(valuesFromMap).hasSize(2);
|
||||
assertThat(valuesFromMap[0]).isEqualTo("bar");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user