parent
a558d408a3
commit
e0aca04a28
|
@ -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.
|
||||
|
@ -61,14 +61,14 @@ public class AuditLoggerTests {
|
|||
public void nonAuditableAceIsIgnored() {
|
||||
AccessControlEntry ace = mock(AccessControlEntry.class);
|
||||
logger.logIfNeeded(true, ace);
|
||||
assertThat(bytes.size()).isEqualTo(0);
|
||||
assertThat(bytes.size()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() throws Exception {
|
||||
when(ace.isAuditSuccess()).thenReturn(false);
|
||||
logger.logIfNeeded(true, ace);
|
||||
assertThat(bytes.size()).isEqualTo(0);
|
||||
assertThat(bytes.size()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,20 +76,20 @@ public class AuditLoggerTests {
|
|||
when(ace.isAuditSuccess()).thenReturn(true);
|
||||
|
||||
logger.logIfNeeded(true, ace);
|
||||
assertThat(bytes.toString().startsWith("GRANTED due to ACE")).isTrue();
|
||||
assertThat(bytes.toString()).startsWith("GRANTED due to ACE");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureIsntLoggedIfAceDoesntRequireFailureAudit() throws Exception {
|
||||
when(ace.isAuditFailure()).thenReturn(false);
|
||||
logger.logIfNeeded(false, ace);
|
||||
assertThat(bytes.size()).isEqualTo(0);
|
||||
assertThat(bytes.size()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureIsLoggedIfAceRequiresFailureAudit() throws Exception {
|
||||
when(ace.isAuditFailure()).thenReturn(true);
|
||||
logger.logIfNeeded(false, ace);
|
||||
assertThat(bytes.toString().startsWith("DENIED due to ACE")).isTrue();
|
||||
assertThat(bytes.toString()).startsWith("DENIED due to ACE");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -57,10 +57,7 @@ public class GrantedAuthorityFromAssertionAttributesUserDetailsServiceTests {
|
|||
assertion, "ticket");
|
||||
UserDetails user = uds.loadUserDetails(token);
|
||||
Set<String> roles = AuthorityUtils.authorityListToSet(user.getAuthorities());
|
||||
assertThat(roles.size()).isEqualTo(4);
|
||||
assertThat(roles).contains("role_a1");
|
||||
assertThat(roles).contains("role_a2");
|
||||
assertThat(roles).contains("role_b");
|
||||
assertThat(roles).contains("role_c");
|
||||
assertThat(roles).containsExactlyInAnyOrder(
|
||||
"role_a1", "role_a2", "role_b", "role_c");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -299,7 +299,7 @@ public class MessageSecurityMetadataSourceRegistryTests {
|
|||
if (attrs == null) {
|
||||
return null;
|
||||
}
|
||||
assertThat(attrs.size()).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
return attrs.iterator().next().toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -65,8 +65,7 @@ public class FilterSecurityMetadataSourceBeanDefinitionParserTests {
|
|||
.getBean("fids");
|
||||
Collection<ConfigAttribute> cad = fids
|
||||
.getAttributes(createFilterInvocation("/anything", "GET"));
|
||||
assertThat(cad).isNotNull();
|
||||
assertThat(cad.contains(new SecurityConfig("ROLE_A"))).isTrue();
|
||||
assertThat(cad).contains(new SecurityConfig("ROLE_A"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -80,7 +79,7 @@ public class FilterSecurityMetadataSourceBeanDefinitionParserTests {
|
|||
ConfigAttribute[] cad = fids
|
||||
.getAttributes(createFilterInvocation("/anything", "GET"))
|
||||
.toArray(new ConfigAttribute[0]);
|
||||
assertThat(cad.length).isEqualTo(1);
|
||||
assertThat(cad).hasSize(1);
|
||||
assertThat(cad[0].toString()).isEqualTo("hasRole('ROLE_A')");
|
||||
}
|
||||
|
||||
|
@ -98,9 +97,7 @@ public class FilterSecurityMetadataSourceBeanDefinitionParserTests {
|
|||
.getBean("fids");
|
||||
Collection<ConfigAttribute> cad = fids
|
||||
.getAttributes(createFilterInvocation("/secure", "GET"));
|
||||
assertThat(cad).isNotNull();
|
||||
assertThat(cad).hasSize(1);
|
||||
assertThat(cad.contains(new SecurityConfig("ROLE_A"))).isTrue();
|
||||
assertThat(cad).containsExactly(new SecurityConfig("ROLE_A"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -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.
|
||||
|
@ -108,7 +108,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
|||
|
||||
// SEC-1213. Check the order
|
||||
Advisor[] advisors = ((Advised) target).getAdvisors();
|
||||
assertThat(advisors.length).isEqualTo(1);
|
||||
assertThat(advisors).hasSize(1);
|
||||
assertThat(((MethodSecurityMetadataSourceAdvisor) advisors[0]).getOrder()).isEqualTo(1001);
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
|||
target = (BusinessService) appContext.getBean("target");
|
||||
Object[] arg = new String[] { "joe", "bob", "sam" };
|
||||
Object[] result = target.methodReturningAnArray(arg);
|
||||
assertThat(result.length).isEqualTo(1);
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result[0]).isEqualTo("bob");
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -66,11 +66,11 @@ public class InterceptMethodsBeanDefinitionDecoratorTests implements
|
|||
@Test
|
||||
public void targetDoesntLoseApplicationListenerInterface() {
|
||||
assertThat(appContext.getBeansOfType(ApplicationListener.class)).hasSize(1);
|
||||
assertThat(appContext.getBeanNamesForType(ApplicationListener.class).length).isEqualTo(1);
|
||||
assertThat(appContext.getBeanNamesForType(ApplicationListener.class)).hasSize(1);
|
||||
appContext.publishEvent(new AuthenticationSuccessEvent(
|
||||
new TestingAuthenticationToken("user", "")));
|
||||
|
||||
assertThat(target instanceof ApplicationListener<?>).isTrue();
|
||||
assertThat(target).isInstanceOf(ApplicationListener.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -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.
|
||||
|
@ -56,7 +56,7 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
|||
@Test
|
||||
public void methodWithRolesAllowedHasCorrectAttribute() throws Exception {
|
||||
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
||||
assertThat(accessAttributes.length).isEqualTo(1);
|
||||
assertThat(accessAttributes).hasSize(1);
|
||||
assertThat(accessAttributes[0].toString()).isEqualTo("ROLE_ADMIN");
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
|||
this.mds.setDefaultRolePrefix("CUSTOMPREFIX_");
|
||||
|
||||
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
||||
assertThat(accessAttributes.length).isEqualTo(1);
|
||||
assertThat(accessAttributes).hasSize(1);
|
||||
assertThat(accessAttributes[0].toString()).isEqualTo("CUSTOMPREFIX_ADMIN");
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
|||
this.mds.setDefaultRolePrefix("");
|
||||
|
||||
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
||||
assertThat(accessAttributes.length).isEqualTo(1);
|
||||
assertThat(accessAttributes).hasSize(1);
|
||||
assertThat(accessAttributes[0].toString()).isEqualTo("ADMIN");
|
||||
}
|
||||
|
||||
|
@ -113,14 +113,14 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
|||
this.mds.setDefaultRolePrefix(null);
|
||||
|
||||
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
||||
assertThat(accessAttributes.length).isEqualTo(1);
|
||||
assertThat(accessAttributes).hasSize(1);
|
||||
assertThat(accessAttributes[0].toString()).isEqualTo("ADMIN");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alreadyHasDefaultPrefix() throws Exception {
|
||||
ConfigAttribute[] accessAttributes = findAttributes("roleAdminMethod");
|
||||
assertThat(accessAttributes.length).isEqualTo(1);
|
||||
assertThat(accessAttributes).hasSize(1);
|
||||
assertThat(accessAttributes[0].toString()).isEqualTo("ROLE_ADMIN");
|
||||
}
|
||||
|
||||
|
|
|
@ -137,8 +137,6 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
|||
Collection<ConfigAttribute> attrs = this.mds.findAttributes(method,
|
||||
BusinessService.class);
|
||||
|
||||
assertThat(attrs).isNotNull();
|
||||
|
||||
// expect 2 attributes
|
||||
assertThat(attrs).hasSize(2);
|
||||
|
||||
|
@ -147,7 +145,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
|||
|
||||
// should have 2 SecurityConfigs
|
||||
for (ConfigAttribute sc : attrs) {
|
||||
assertThat(sc instanceof SecurityConfig).isTrue();
|
||||
assertThat(sc).isInstanceOf(SecurityConfig.class);
|
||||
|
||||
if (sc.getAttribute().equals("ROLE_USER")) {
|
||||
user = true;
|
||||
|
@ -158,7 +156,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
|||
}
|
||||
|
||||
// expect to have ROLE_USER and ROLE_ADMIN
|
||||
assertThat(user && admin).isTrue();
|
||||
assertThat(user).isEqualTo(admin).isTrue();
|
||||
}
|
||||
|
||||
// SEC-1491
|
||||
|
@ -168,8 +166,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
|||
new CustomSecurityAnnotationMetadataExtractor());
|
||||
Collection<ConfigAttribute> attrs = mds.findAttributes(
|
||||
CustomAnnotatedService.class);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs.toArray()[0]).isEqualTo(SecurityEnum.ADMIN);
|
||||
assertThat(attrs).containsOnly(SecurityEnum.ADMIN);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -181,8 +178,8 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs[0].getAttribute()).isEqualTo("CUSTOM");
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs).extracting("attribute").containsOnly("CUSTOM");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -194,8 +191,8 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs[0].getAttribute()).isEqualTo("CUSTOM");
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs).extracting("attribute").containsOnly("CUSTOM");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -206,15 +203,15 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs[0].getAttribute()).isEqualTo("CUSTOM");
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs).extracting("attribute").containsOnly("CUSTOM");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void proxyFactoryInterfaceAttributesFound() throws Exception {
|
||||
MockMethodInvocation mi = MethodInvocationFactory.createSec2150MethodInvocation();
|
||||
Collection<ConfigAttribute> attributes = mds.getAttributes(mi);
|
||||
assertThat(attributes.size()).isEqualTo(1);
|
||||
assertThat(attributes).hasSize(1);
|
||||
assertThat(attributes).extracting("attribute").containsOnly("ROLE_PERSON");
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -89,7 +89,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(voidImpl1).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||
assertThat(pre.getAuthorizeExpression()).isNotNull();
|
||||
|
@ -102,7 +102,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(voidImpl2).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||
assertThat(pre.getAuthorizeExpression().getExpressionString()).isEqualTo("someExpression");
|
||||
|
@ -115,7 +115,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(voidImpl3).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||
assertThat(pre.getAuthorizeExpression().getExpressionString()).isEqualTo("permitAll");
|
||||
|
@ -128,7 +128,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(listImpl1).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(2);
|
||||
assertThat(attrs).hasSize(2);
|
||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||
assertThat(attrs[1] instanceof PostInvocationExpressionAttribute).isTrue();
|
||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||
|
@ -143,7 +143,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(notherListImpl1).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||
assertThat(pre.getFilterExpression()).isNotNull();
|
||||
|
@ -157,7 +157,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(notherListImpl2).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||
assertThat(pre.getFilterExpression()).isNotNull();
|
||||
|
@ -171,7 +171,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -179,7 +179,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -187,14 +187,14 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
|||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray(
|
||||
new ConfigAttribute[0]);
|
||||
|
||||
assertThat(attrs.length).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void proxyFactoryInterfaceAttributesFound() throws Exception {
|
||||
MockMethodInvocation mi = MethodInvocationFactory.createSec2150MethodInvocation();
|
||||
Collection<ConfigAttribute> attributes = mds.getAttributes(mi);
|
||||
assertThat(attributes.size()).isEqualTo(1);
|
||||
assertThat(attributes).hasSize(1);
|
||||
Expression expression = (Expression) ReflectionTestUtils.getField(attributes
|
||||
.iterator().next(), "authorizeExpression");
|
||||
assertThat(expression.getExpressionString()).isEqualTo("hasRole('ROLE_PERSON')");
|
||||
|
|
|
@ -87,7 +87,7 @@ public class AbstractAccessDecisionManagerTests {
|
|||
list.add(voter);
|
||||
list.add(denyVoter);
|
||||
MockDecisionManagerImpl mock = new MockDecisionManagerImpl(list);
|
||||
assertThat(mock.getDecisionVoters().size()).isEqualTo(list.size());
|
||||
assertThat(mock.getDecisionVoters()).hasSize(list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -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.
|
||||
|
@ -47,7 +47,7 @@ public class DefaultSecurityParameterNameDiscovererTests {
|
|||
List<ParameterNameDiscoverer> discoverers = (List<ParameterNameDiscoverer>) ReflectionTestUtils
|
||||
.getField(discoverer, "parameterNameDiscoverers");
|
||||
|
||||
assertThat(discoverers.size()).isEqualTo(2);
|
||||
assertThat(discoverers).hasSize(2);
|
||||
|
||||
ParameterNameDiscoverer annotationDisc = discoverers.get(0);
|
||||
assertThat(annotationDisc).isInstanceOf(AnnotationParameterNameDiscoverer.class);
|
||||
|
@ -67,7 +67,7 @@ public class DefaultSecurityParameterNameDiscovererTests {
|
|||
List<ParameterNameDiscoverer> discoverers = (List<ParameterNameDiscoverer>) ReflectionTestUtils
|
||||
.getField(discoverer, "parameterNameDiscoverers");
|
||||
|
||||
assertThat(discoverers.size()).isEqualTo(3);
|
||||
assertThat(discoverers).hasSize(3);
|
||||
assertThat(discoverers.get(0)).isInstanceOf(
|
||||
LocalVariableTableParameterNameDiscoverer.class);
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class DefaultSecurityParameterNameDiscovererTests {
|
|||
annotationDisc, "annotationClassesToUse");
|
||||
assertThat(annotationsToUse).containsOnly("org.springframework.security.access.method.P", P.class.getName());
|
||||
|
||||
assertThat(discoverers.get(2).getClass()).isEqualTo(
|
||||
assertThat(discoverers.get(2)).isInstanceOf(
|
||||
DefaultParameterNameDiscoverer.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,21 +218,21 @@ public class BCryptTests {
|
|||
@Test
|
||||
public void decodingCharsOutsideAsciiGivesNoResults() {
|
||||
byte[] ba = BCrypt.decode_base64("ππππππππ", 1);
|
||||
assertThat(ba.length).isEqualTo(0);
|
||||
assertThat(ba).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodingStopsWithFirstInvalidCharacter() {
|
||||
assertThat(BCrypt.decode_base64("....", 1).length).isEqualTo(1);
|
||||
assertThat(BCrypt.decode_base64(" ....", 1).length).isEqualTo(0);
|
||||
assertThat(BCrypt.decode_base64("....", 1)).hasSize(1);
|
||||
assertThat(BCrypt.decode_base64(" ....", 1)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodingOnlyProvidesAvailableBytes() {
|
||||
assertThat(BCrypt.decode_base64("", 1).length).isEqualTo(0);
|
||||
assertThat(BCrypt.decode_base64("......", 3).length).isEqualTo(3);
|
||||
assertThat(BCrypt.decode_base64("......", 4).length).isEqualTo(4);
|
||||
assertThat(BCrypt.decode_base64("......", 5).length).isEqualTo(4);
|
||||
assertThat(BCrypt.decode_base64("", 1)).isEmpty();
|
||||
assertThat(BCrypt.decode_base64("......", 3)).hasSize(3);
|
||||
assertThat(BCrypt.decode_base64("......", 4)).hasSize(4);
|
||||
assertThat(BCrypt.decode_base64("......", 5)).hasSize(4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,8 +268,8 @@ public class BCryptTests {
|
|||
|
||||
@Test
|
||||
public void genSaltGeneratesCorrectSaltPrefix() {
|
||||
assertThat(BCrypt.gensalt(4).startsWith("$2a$04$")).isTrue();
|
||||
assertThat(BCrypt.gensalt(31).startsWith("$2a$31$")).isTrue();
|
||||
assertThat(BCrypt.gensalt(4)).startsWith("$2a$04$");
|
||||
assertThat(BCrypt.gensalt(31)).startsWith("$2a$31$");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
|
|
@ -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.
|
||||
|
@ -30,7 +30,7 @@ public class Utf8Tests {
|
|||
@Test
|
||||
public void utf8EncodesAndDecodesCorrectly() throws Exception {
|
||||
byte[] bytes = Utf8.encode("6048b75ed560785c");
|
||||
assertThat(bytes.length).isEqualTo(16);
|
||||
assertThat(bytes).hasSize(16);
|
||||
assertThat(Arrays.equals("6048b75ed560785c".getBytes("UTF-8"), bytes)).isTrue();
|
||||
|
||||
String decoded = Utf8.decode(bytes);
|
||||
|
|
|
@ -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.
|
||||
|
@ -29,7 +29,7 @@ public class KeyGeneratorsTests {
|
|||
BytesKeyGenerator keyGenerator = KeyGenerators.secureRandom();
|
||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(8);
|
||||
byte[] key = keyGenerator.generateKey();
|
||||
assertThat(key.length).isEqualTo(8);
|
||||
assertThat(key).hasSize(8);
|
||||
byte[] key2 = keyGenerator.generateKey();
|
||||
assertThat(Arrays.equals(key, key2)).isFalse();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class KeyGeneratorsTests {
|
|||
BytesKeyGenerator keyGenerator = KeyGenerators.secureRandom(21);
|
||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
|
||||
byte[] key = keyGenerator.generateKey();
|
||||
assertThat(key.length).isEqualTo(21);
|
||||
assertThat(key).hasSize(21);
|
||||
byte[] key2 = keyGenerator.generateKey();
|
||||
assertThat(Arrays.equals(key, key2)).isFalse();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class KeyGeneratorsTests {
|
|||
BytesKeyGenerator keyGenerator = KeyGenerators.shared(21);
|
||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
|
||||
byte[] key = keyGenerator.generateKey();
|
||||
assertThat(key.length).isEqualTo(21);
|
||||
assertThat(key).hasSize(21);
|
||||
byte[] key2 = keyGenerator.generateKey();
|
||||
assertThat(Arrays.equals(key, key2)).isTrue();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class KeyGeneratorsTests {
|
|||
StringKeyGenerator keyGenerator = KeyGenerators.string();
|
||||
String hexStringKey = keyGenerator.generateKey();
|
||||
assertThat(hexStringKey.length()).isEqualTo(16);
|
||||
assertThat(Hex.decode(hexStringKey).length).isEqualTo(8);
|
||||
assertThat(Hex.decode(hexStringKey)).hasSize(8);
|
||||
String hexStringKey2 = keyGenerator.generateKey();
|
||||
assertThat(hexStringKey.equals(hexStringKey2)).isFalse();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class EncodingUtilsTests {
|
|||
(byte) 67, (byte) 0xC0, (byte) 0xC1, (byte) 0xC2 };
|
||||
byte[] two = new byte[] { (byte) 0xFF, (byte) 65, (byte) 66 };
|
||||
byte[] subArray = EncodingUtils.subArray(bytes, 1, 4);
|
||||
assertThat(subArray.length).isEqualTo(3);
|
||||
assertThat(subArray).hasSize(3);
|
||||
assertThat(Arrays.equals(two, subArray)).isTrue();
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ public class SpringSecurityLdapTemplateITests extends AbstractLdapIntegrationTes
|
|||
protected void assertAttributeValue(Map<String, List<String>> record,
|
||||
String attributeName, String... values) {
|
||||
assertThat(record.containsKey(attributeName)).isTrue();
|
||||
assertThat(record.get(attributeName).size()).isEqualTo(values.length);
|
||||
assertThat(record.get(attributeName)).hasSize(values.length);
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
assertThat(record.get(attributeName).get(i)).isEqualTo(values[i]);
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public class NestedLdapAuthoritiesPopulatorTests extends AbstractLdapIntegration
|
|||
circularJavaDevelopers, jDevelopers, groovyDevelopers));
|
||||
|
||||
LdapAuthority[] ldapAuthorities = authorities.toArray(new LdapAuthority[0]);
|
||||
assertThat(ldapAuthorities.length).isEqualTo(5);
|
||||
assertThat(ldapAuthorities).hasSize(5);
|
||||
// closure group
|
||||
assertThat(ldapAuthorities[0].getAttributes().containsKey("member")).isTrue();
|
||||
assertThat(ldapAuthorities[0].getAttributes().get("member")).isNotNull();
|
||||
|
|
|
@ -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.
|
||||
|
@ -80,7 +80,7 @@ public class ExpressionBasedMessageSecurityMetadataSourceFactoryTests {
|
|||
|
||||
Collection<ConfigAttribute> attrs = source.getAttributes(message);
|
||||
|
||||
assertThat(attrs.size()).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
ConfigAttribute attr = attrs.iterator().next();
|
||||
assertThat(attr).isInstanceOf(MessageExpressionConfigAttribute.class);
|
||||
assertThat(
|
||||
|
@ -94,7 +94,7 @@ public class ExpressionBasedMessageSecurityMetadataSourceFactoryTests {
|
|||
|
||||
Collection<ConfigAttribute> attrs = source.getAttributes(message);
|
||||
|
||||
assertThat(attrs.size()).isEqualTo(1);
|
||||
assertThat(attrs).hasSize(1);
|
||||
ConfigAttribute attr = attrs.iterator().next();
|
||||
assertThat(attr).isInstanceOf(MessageExpressionConfigAttribute.class);
|
||||
assertThat(
|
||||
|
|
|
@ -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.
|
||||
|
@ -63,7 +63,7 @@ public class SecurityMessageRepositoryTests {
|
|||
public void findAllOnlyToCurrentUser() {
|
||||
Long expectedId = user.getId();
|
||||
List<Message> messages = repository.findAll();
|
||||
assertThat(messages.size()).isEqualTo(3);
|
||||
assertThat(messages).hasSize(3);
|
||||
for (Message m : messages) {
|
||||
assertThat(m.getTo().getId()).isEqualTo(expectedId);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -102,7 +102,7 @@ public class DmsIntegrationTests extends AbstractTransactionalJUnit4SpringContex
|
|||
System.out.println("------ Test for username: " + username + " ------");
|
||||
AbstractElement[] rootElements = this.documentDao
|
||||
.findElements(Directory.ROOT_DIRECTORY);
|
||||
assertThat(rootElements.length).isEqualTo(3);
|
||||
assertThat(rootElements).hasSize(3);
|
||||
Directory homeDir = null;
|
||||
Directory nonHomeDir = null;
|
||||
for (int i = 0; i < rootElements.length; i++) {
|
||||
|
@ -117,12 +117,12 @@ public class DmsIntegrationTests extends AbstractTransactionalJUnit4SpringContex
|
|||
System.out.println("Non-home directory..: " + nonHomeDir.getFullName());
|
||||
|
||||
AbstractElement[] homeElements = this.documentDao.findElements(homeDir);
|
||||
assertThat(homeElements.length).isEqualTo(12); // confidential and shared
|
||||
assertThat(homeElements).hasSize(12); // confidential and shared
|
||||
// directories,
|
||||
// plus 10 files
|
||||
|
||||
AbstractElement[] nonHomeElements = this.documentDao.findElements(nonHomeDir);
|
||||
assertThat(nonHomeElements.length).isEqualTo(shouldBeFiltered ? 11 : 12); // cannot
|
||||
assertThat(nonHomeElements).hasSize(shouldBeFiltered ? 11 : 12); // cannot
|
||||
// see
|
||||
// the user's
|
||||
// "confidential"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
|
@ -58,7 +58,7 @@ public class SecurityMockMvcRequestPostProcessorsCertificateTests {
|
|||
X509Certificate[] certificates = (X509Certificate[]) postProcessedRequest
|
||||
.getAttribute("javax.servlet.request.X509Certificate");
|
||||
|
||||
assertThat(certificates.length).isEqualTo(1);
|
||||
assertThat(certificates).hasSize(1);
|
||||
assertThat(certificates[0].getSubjectDN().getName()).isEqualTo(
|
||||
"CN=rod, OU=Spring Security, O=Spring Framework");
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue