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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -61,14 +61,14 @@ public class AuditLoggerTests {
|
||||||
public void nonAuditableAceIsIgnored() {
|
public void nonAuditableAceIsIgnored() {
|
||||||
AccessControlEntry ace = mock(AccessControlEntry.class);
|
AccessControlEntry ace = mock(AccessControlEntry.class);
|
||||||
logger.logIfNeeded(true, ace);
|
logger.logIfNeeded(true, ace);
|
||||||
assertThat(bytes.size()).isEqualTo(0);
|
assertThat(bytes.size()).isZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() throws Exception {
|
public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() throws Exception {
|
||||||
when(ace.isAuditSuccess()).thenReturn(false);
|
when(ace.isAuditSuccess()).thenReturn(false);
|
||||||
logger.logIfNeeded(true, ace);
|
logger.logIfNeeded(true, ace);
|
||||||
assertThat(bytes.size()).isEqualTo(0);
|
assertThat(bytes.size()).isZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -76,20 +76,20 @@ public class AuditLoggerTests {
|
||||||
when(ace.isAuditSuccess()).thenReturn(true);
|
when(ace.isAuditSuccess()).thenReturn(true);
|
||||||
|
|
||||||
logger.logIfNeeded(true, ace);
|
logger.logIfNeeded(true, ace);
|
||||||
assertThat(bytes.toString().startsWith("GRANTED due to ACE")).isTrue();
|
assertThat(bytes.toString()).startsWith("GRANTED due to ACE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void failureIsntLoggedIfAceDoesntRequireFailureAudit() throws Exception {
|
public void failureIsntLoggedIfAceDoesntRequireFailureAudit() throws Exception {
|
||||||
when(ace.isAuditFailure()).thenReturn(false);
|
when(ace.isAuditFailure()).thenReturn(false);
|
||||||
logger.logIfNeeded(false, ace);
|
logger.logIfNeeded(false, ace);
|
||||||
assertThat(bytes.size()).isEqualTo(0);
|
assertThat(bytes.size()).isZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void failureIsLoggedIfAceRequiresFailureAudit() throws Exception {
|
public void failureIsLoggedIfAceRequiresFailureAudit() throws Exception {
|
||||||
when(ace.isAuditFailure()).thenReturn(true);
|
when(ace.isAuditFailure()).thenReturn(true);
|
||||||
logger.logIfNeeded(false, ace);
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -57,10 +57,7 @@ public class GrantedAuthorityFromAssertionAttributesUserDetailsServiceTests {
|
||||||
assertion, "ticket");
|
assertion, "ticket");
|
||||||
UserDetails user = uds.loadUserDetails(token);
|
UserDetails user = uds.loadUserDetails(token);
|
||||||
Set<String> roles = AuthorityUtils.authorityListToSet(user.getAuthorities());
|
Set<String> roles = AuthorityUtils.authorityListToSet(user.getAuthorities());
|
||||||
assertThat(roles.size()).isEqualTo(4);
|
assertThat(roles).containsExactlyInAnyOrder(
|
||||||
assertThat(roles).contains("role_a1");
|
"role_a1", "role_a2", "role_b", "role_c");
|
||||||
assertThat(roles).contains("role_a2");
|
|
||||||
assertThat(roles).contains("role_b");
|
|
||||||
assertThat(roles).contains("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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -299,7 +299,7 @@ public class MessageSecurityMetadataSourceRegistryTests {
|
||||||
if (attrs == null) {
|
if (attrs == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
assertThat(attrs.size()).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
return attrs.iterator().next().toString();
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -65,8 +65,7 @@ public class FilterSecurityMetadataSourceBeanDefinitionParserTests {
|
||||||
.getBean("fids");
|
.getBean("fids");
|
||||||
Collection<ConfigAttribute> cad = fids
|
Collection<ConfigAttribute> cad = fids
|
||||||
.getAttributes(createFilterInvocation("/anything", "GET"));
|
.getAttributes(createFilterInvocation("/anything", "GET"));
|
||||||
assertThat(cad).isNotNull();
|
assertThat(cad).contains(new SecurityConfig("ROLE_A"));
|
||||||
assertThat(cad.contains(new SecurityConfig("ROLE_A"))).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -80,7 +79,7 @@ public class FilterSecurityMetadataSourceBeanDefinitionParserTests {
|
||||||
ConfigAttribute[] cad = fids
|
ConfigAttribute[] cad = fids
|
||||||
.getAttributes(createFilterInvocation("/anything", "GET"))
|
.getAttributes(createFilterInvocation("/anything", "GET"))
|
||||||
.toArray(new ConfigAttribute[0]);
|
.toArray(new ConfigAttribute[0]);
|
||||||
assertThat(cad.length).isEqualTo(1);
|
assertThat(cad).hasSize(1);
|
||||||
assertThat(cad[0].toString()).isEqualTo("hasRole('ROLE_A')");
|
assertThat(cad[0].toString()).isEqualTo("hasRole('ROLE_A')");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +97,7 @@ public class FilterSecurityMetadataSourceBeanDefinitionParserTests {
|
||||||
.getBean("fids");
|
.getBean("fids");
|
||||||
Collection<ConfigAttribute> cad = fids
|
Collection<ConfigAttribute> cad = fids
|
||||||
.getAttributes(createFilterInvocation("/secure", "GET"));
|
.getAttributes(createFilterInvocation("/secure", "GET"));
|
||||||
assertThat(cad).isNotNull();
|
assertThat(cad).containsExactly(new SecurityConfig("ROLE_A"));
|
||||||
assertThat(cad).hasSize(1);
|
|
||||||
assertThat(cad.contains(new SecurityConfig("ROLE_A"))).isTrue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
// SEC-1213. Check the order
|
||||||
Advisor[] advisors = ((Advised) target).getAdvisors();
|
Advisor[] advisors = ((Advised) target).getAdvisors();
|
||||||
assertThat(advisors.length).isEqualTo(1);
|
assertThat(advisors).hasSize(1);
|
||||||
assertThat(((MethodSecurityMetadataSourceAdvisor) advisors[0]).getOrder()).isEqualTo(1001);
|
assertThat(((MethodSecurityMetadataSourceAdvisor) advisors[0]).getOrder()).isEqualTo(1001);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ public class GlobalMethodSecurityBeanDefinitionParserTests {
|
||||||
target = (BusinessService) appContext.getBean("target");
|
target = (BusinessService) appContext.getBean("target");
|
||||||
Object[] arg = new String[] { "joe", "bob", "sam" };
|
Object[] arg = new String[] { "joe", "bob", "sam" };
|
||||||
Object[] result = target.methodReturningAnArray(arg);
|
Object[] result = target.methodReturningAnArray(arg);
|
||||||
assertThat(result.length).isEqualTo(1);
|
assertThat(result).hasSize(1);
|
||||||
assertThat(result[0]).isEqualTo("bob");
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -66,11 +66,11 @@ public class InterceptMethodsBeanDefinitionDecoratorTests implements
|
||||||
@Test
|
@Test
|
||||||
public void targetDoesntLoseApplicationListenerInterface() {
|
public void targetDoesntLoseApplicationListenerInterface() {
|
||||||
assertThat(appContext.getBeansOfType(ApplicationListener.class)).hasSize(1);
|
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(
|
appContext.publishEvent(new AuthenticationSuccessEvent(
|
||||||
new TestingAuthenticationToken("user", "")));
|
new TestingAuthenticationToken("user", "")));
|
||||||
|
|
||||||
assertThat(target instanceof ApplicationListener<?>).isTrue();
|
assertThat(target).isInstanceOf(ApplicationListener.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -56,7 +56,7 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
||||||
@Test
|
@Test
|
||||||
public void methodWithRolesAllowedHasCorrectAttribute() throws Exception {
|
public void methodWithRolesAllowedHasCorrectAttribute() throws Exception {
|
||||||
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
||||||
assertThat(accessAttributes.length).isEqualTo(1);
|
assertThat(accessAttributes).hasSize(1);
|
||||||
assertThat(accessAttributes[0].toString()).isEqualTo("ROLE_ADMIN");
|
assertThat(accessAttributes[0].toString()).isEqualTo("ROLE_ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
||||||
this.mds.setDefaultRolePrefix("CUSTOMPREFIX_");
|
this.mds.setDefaultRolePrefix("CUSTOMPREFIX_");
|
||||||
|
|
||||||
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
||||||
assertThat(accessAttributes.length).isEqualTo(1);
|
assertThat(accessAttributes).hasSize(1);
|
||||||
assertThat(accessAttributes[0].toString()).isEqualTo("CUSTOMPREFIX_ADMIN");
|
assertThat(accessAttributes[0].toString()).isEqualTo("CUSTOMPREFIX_ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
||||||
this.mds.setDefaultRolePrefix("");
|
this.mds.setDefaultRolePrefix("");
|
||||||
|
|
||||||
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
||||||
assertThat(accessAttributes.length).isEqualTo(1);
|
assertThat(accessAttributes).hasSize(1);
|
||||||
assertThat(accessAttributes[0].toString()).isEqualTo("ADMIN");
|
assertThat(accessAttributes[0].toString()).isEqualTo("ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,14 +113,14 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
||||||
this.mds.setDefaultRolePrefix(null);
|
this.mds.setDefaultRolePrefix(null);
|
||||||
|
|
||||||
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
ConfigAttribute[] accessAttributes = findAttributes("adminMethod");
|
||||||
assertThat(accessAttributes.length).isEqualTo(1);
|
assertThat(accessAttributes).hasSize(1);
|
||||||
assertThat(accessAttributes[0].toString()).isEqualTo("ADMIN");
|
assertThat(accessAttributes[0].toString()).isEqualTo("ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void alreadyHasDefaultPrefix() throws Exception {
|
public void alreadyHasDefaultPrefix() throws Exception {
|
||||||
ConfigAttribute[] accessAttributes = findAttributes("roleAdminMethod");
|
ConfigAttribute[] accessAttributes = findAttributes("roleAdminMethod");
|
||||||
assertThat(accessAttributes.length).isEqualTo(1);
|
assertThat(accessAttributes).hasSize(1);
|
||||||
assertThat(accessAttributes[0].toString()).isEqualTo("ROLE_ADMIN");
|
assertThat(accessAttributes[0].toString()).isEqualTo("ROLE_ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,6 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||||
Collection<ConfigAttribute> attrs = this.mds.findAttributes(method,
|
Collection<ConfigAttribute> attrs = this.mds.findAttributes(method,
|
||||||
BusinessService.class);
|
BusinessService.class);
|
||||||
|
|
||||||
assertThat(attrs).isNotNull();
|
|
||||||
|
|
||||||
// expect 2 attributes
|
// expect 2 attributes
|
||||||
assertThat(attrs).hasSize(2);
|
assertThat(attrs).hasSize(2);
|
||||||
|
|
||||||
|
@ -147,7 +145,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||||
|
|
||||||
// should have 2 SecurityConfigs
|
// should have 2 SecurityConfigs
|
||||||
for (ConfigAttribute sc : attrs) {
|
for (ConfigAttribute sc : attrs) {
|
||||||
assertThat(sc instanceof SecurityConfig).isTrue();
|
assertThat(sc).isInstanceOf(SecurityConfig.class);
|
||||||
|
|
||||||
if (sc.getAttribute().equals("ROLE_USER")) {
|
if (sc.getAttribute().equals("ROLE_USER")) {
|
||||||
user = true;
|
user = true;
|
||||||
|
@ -158,7 +156,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
// expect to have ROLE_USER and ROLE_ADMIN
|
// expect to have ROLE_USER and ROLE_ADMIN
|
||||||
assertThat(user && admin).isTrue();
|
assertThat(user).isEqualTo(admin).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// SEC-1491
|
// SEC-1491
|
||||||
|
@ -168,8 +166,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||||
new CustomSecurityAnnotationMetadataExtractor());
|
new CustomSecurityAnnotationMetadataExtractor());
|
||||||
Collection<ConfigAttribute> attrs = mds.findAttributes(
|
Collection<ConfigAttribute> attrs = mds.findAttributes(
|
||||||
CustomAnnotatedService.class);
|
CustomAnnotatedService.class);
|
||||||
assertThat(attrs).hasSize(1);
|
assertThat(attrs).containsOnly(SecurityEnum.ADMIN);
|
||||||
assertThat(attrs.toArray()[0]).isEqualTo(SecurityEnum.ADMIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -181,8 +178,8 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
assertThat(attrs[0].getAttribute()).isEqualTo("CUSTOM");
|
assertThat(attrs).extracting("attribute").containsOnly("CUSTOM");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -194,8 +191,8 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
assertThat(attrs[0].getAttribute()).isEqualTo("CUSTOM");
|
assertThat(attrs).extracting("attribute").containsOnly("CUSTOM");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -206,15 +203,15 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
assertThat(attrs[0].getAttribute()).isEqualTo("CUSTOM");
|
assertThat(attrs).extracting("attribute").containsOnly("CUSTOM");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void proxyFactoryInterfaceAttributesFound() throws Exception {
|
public void proxyFactoryInterfaceAttributesFound() throws Exception {
|
||||||
MockMethodInvocation mi = MethodInvocationFactory.createSec2150MethodInvocation();
|
MockMethodInvocation mi = MethodInvocationFactory.createSec2150MethodInvocation();
|
||||||
Collection<ConfigAttribute> attributes = mds.getAttributes(mi);
|
Collection<ConfigAttribute> attributes = mds.getAttributes(mi);
|
||||||
assertThat(attributes.size()).isEqualTo(1);
|
assertThat(attributes).hasSize(1);
|
||||||
assertThat(attributes).extracting("attribute").containsOnly("ROLE_PERSON");
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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(
|
ConfigAttribute[] attrs = mds.getAttributes(voidImpl1).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||||
assertThat(pre.getAuthorizeExpression()).isNotNull();
|
assertThat(pre.getAuthorizeExpression()).isNotNull();
|
||||||
|
@ -102,7 +102,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(voidImpl2).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(voidImpl2).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||||
assertThat(pre.getAuthorizeExpression().getExpressionString()).isEqualTo("someExpression");
|
assertThat(pre.getAuthorizeExpression().getExpressionString()).isEqualTo("someExpression");
|
||||||
|
@ -115,7 +115,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(voidImpl3).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(voidImpl3).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||||
assertThat(pre.getAuthorizeExpression().getExpressionString()).isEqualTo("permitAll");
|
assertThat(pre.getAuthorizeExpression().getExpressionString()).isEqualTo("permitAll");
|
||||||
|
@ -128,7 +128,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(listImpl1).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(listImpl1).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(2);
|
assertThat(attrs).hasSize(2);
|
||||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||||
assertThat(attrs[1] instanceof PostInvocationExpressionAttribute).isTrue();
|
assertThat(attrs[1] instanceof PostInvocationExpressionAttribute).isTrue();
|
||||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||||
|
@ -143,7 +143,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(notherListImpl1).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(notherListImpl1).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||||
assertThat(pre.getFilterExpression()).isNotNull();
|
assertThat(pre.getFilterExpression()).isNotNull();
|
||||||
|
@ -157,7 +157,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(notherListImpl2).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(notherListImpl2).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
assertThat(attrs[0] instanceof PreInvocationExpressionAttribute).isTrue();
|
||||||
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
PreInvocationExpressionAttribute pre = (PreInvocationExpressionAttribute) attrs[0];
|
||||||
assertThat(pre.getFilterExpression()).isNotNull();
|
assertThat(pre.getFilterExpression()).isNotNull();
|
||||||
|
@ -171,7 +171,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtClassLevel).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -179,7 +179,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtInterfaceLevel).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -187,14 +187,14 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||||
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray(
|
ConfigAttribute[] attrs = mds.getAttributes(annotatedAtMethodLevel).toArray(
|
||||||
new ConfigAttribute[0]);
|
new ConfigAttribute[0]);
|
||||||
|
|
||||||
assertThat(attrs.length).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void proxyFactoryInterfaceAttributesFound() throws Exception {
|
public void proxyFactoryInterfaceAttributesFound() throws Exception {
|
||||||
MockMethodInvocation mi = MethodInvocationFactory.createSec2150MethodInvocation();
|
MockMethodInvocation mi = MethodInvocationFactory.createSec2150MethodInvocation();
|
||||||
Collection<ConfigAttribute> attributes = mds.getAttributes(mi);
|
Collection<ConfigAttribute> attributes = mds.getAttributes(mi);
|
||||||
assertThat(attributes.size()).isEqualTo(1);
|
assertThat(attributes).hasSize(1);
|
||||||
Expression expression = (Expression) ReflectionTestUtils.getField(attributes
|
Expression expression = (Expression) ReflectionTestUtils.getField(attributes
|
||||||
.iterator().next(), "authorizeExpression");
|
.iterator().next(), "authorizeExpression");
|
||||||
assertThat(expression.getExpressionString()).isEqualTo("hasRole('ROLE_PERSON')");
|
assertThat(expression.getExpressionString()).isEqualTo("hasRole('ROLE_PERSON')");
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class AbstractAccessDecisionManagerTests {
|
||||||
list.add(voter);
|
list.add(voter);
|
||||||
list.add(denyVoter);
|
list.add(denyVoter);
|
||||||
MockDecisionManagerImpl mock = new MockDecisionManagerImpl(list);
|
MockDecisionManagerImpl mock = new MockDecisionManagerImpl(list);
|
||||||
assertThat(mock.getDecisionVoters().size()).isEqualTo(list.size());
|
assertThat(mock.getDecisionVoters()).hasSize(list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
List<ParameterNameDiscoverer> discoverers = (List<ParameterNameDiscoverer>) ReflectionTestUtils
|
||||||
.getField(discoverer, "parameterNameDiscoverers");
|
.getField(discoverer, "parameterNameDiscoverers");
|
||||||
|
|
||||||
assertThat(discoverers.size()).isEqualTo(2);
|
assertThat(discoverers).hasSize(2);
|
||||||
|
|
||||||
ParameterNameDiscoverer annotationDisc = discoverers.get(0);
|
ParameterNameDiscoverer annotationDisc = discoverers.get(0);
|
||||||
assertThat(annotationDisc).isInstanceOf(AnnotationParameterNameDiscoverer.class);
|
assertThat(annotationDisc).isInstanceOf(AnnotationParameterNameDiscoverer.class);
|
||||||
|
@ -67,7 +67,7 @@ public class DefaultSecurityParameterNameDiscovererTests {
|
||||||
List<ParameterNameDiscoverer> discoverers = (List<ParameterNameDiscoverer>) ReflectionTestUtils
|
List<ParameterNameDiscoverer> discoverers = (List<ParameterNameDiscoverer>) ReflectionTestUtils
|
||||||
.getField(discoverer, "parameterNameDiscoverers");
|
.getField(discoverer, "parameterNameDiscoverers");
|
||||||
|
|
||||||
assertThat(discoverers.size()).isEqualTo(3);
|
assertThat(discoverers).hasSize(3);
|
||||||
assertThat(discoverers.get(0)).isInstanceOf(
|
assertThat(discoverers.get(0)).isInstanceOf(
|
||||||
LocalVariableTableParameterNameDiscoverer.class);
|
LocalVariableTableParameterNameDiscoverer.class);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class DefaultSecurityParameterNameDiscovererTests {
|
||||||
annotationDisc, "annotationClassesToUse");
|
annotationDisc, "annotationClassesToUse");
|
||||||
assertThat(annotationsToUse).containsOnly("org.springframework.security.access.method.P", P.class.getName());
|
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);
|
DefaultParameterNameDiscoverer.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,21 +218,21 @@ public class BCryptTests {
|
||||||
@Test
|
@Test
|
||||||
public void decodingCharsOutsideAsciiGivesNoResults() {
|
public void decodingCharsOutsideAsciiGivesNoResults() {
|
||||||
byte[] ba = BCrypt.decode_base64("ππππππππ", 1);
|
byte[] ba = BCrypt.decode_base64("ππππππππ", 1);
|
||||||
assertThat(ba.length).isEqualTo(0);
|
assertThat(ba).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void decodingStopsWithFirstInvalidCharacter() {
|
public void decodingStopsWithFirstInvalidCharacter() {
|
||||||
assertThat(BCrypt.decode_base64("....", 1).length).isEqualTo(1);
|
assertThat(BCrypt.decode_base64("....", 1)).hasSize(1);
|
||||||
assertThat(BCrypt.decode_base64(" ....", 1).length).isEqualTo(0);
|
assertThat(BCrypt.decode_base64(" ....", 1)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void decodingOnlyProvidesAvailableBytes() {
|
public void decodingOnlyProvidesAvailableBytes() {
|
||||||
assertThat(BCrypt.decode_base64("", 1).length).isEqualTo(0);
|
assertThat(BCrypt.decode_base64("", 1)).isEmpty();
|
||||||
assertThat(BCrypt.decode_base64("......", 3).length).isEqualTo(3);
|
assertThat(BCrypt.decode_base64("......", 3)).hasSize(3);
|
||||||
assertThat(BCrypt.decode_base64("......", 4).length).isEqualTo(4);
|
assertThat(BCrypt.decode_base64("......", 4)).hasSize(4);
|
||||||
assertThat(BCrypt.decode_base64("......", 5).length).isEqualTo(4);
|
assertThat(BCrypt.decode_base64("......", 5)).hasSize(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,8 +268,8 @@ public class BCryptTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void genSaltGeneratesCorrectSaltPrefix() {
|
public void genSaltGeneratesCorrectSaltPrefix() {
|
||||||
assertThat(BCrypt.gensalt(4).startsWith("$2a$04$")).isTrue();
|
assertThat(BCrypt.gensalt(4)).startsWith("$2a$04$");
|
||||||
assertThat(BCrypt.gensalt(31).startsWith("$2a$31$")).isTrue();
|
assertThat(BCrypt.gensalt(31)).startsWith("$2a$31$");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -30,7 +30,7 @@ public class Utf8Tests {
|
||||||
@Test
|
@Test
|
||||||
public void utf8EncodesAndDecodesCorrectly() throws Exception {
|
public void utf8EncodesAndDecodesCorrectly() throws Exception {
|
||||||
byte[] bytes = Utf8.encode("6048b75ed560785c");
|
byte[] bytes = Utf8.encode("6048b75ed560785c");
|
||||||
assertThat(bytes.length).isEqualTo(16);
|
assertThat(bytes).hasSize(16);
|
||||||
assertThat(Arrays.equals("6048b75ed560785c".getBytes("UTF-8"), bytes)).isTrue();
|
assertThat(Arrays.equals("6048b75ed560785c".getBytes("UTF-8"), bytes)).isTrue();
|
||||||
|
|
||||||
String decoded = Utf8.decode(bytes);
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
BytesKeyGenerator keyGenerator = KeyGenerators.secureRandom();
|
||||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(8);
|
assertThat(keyGenerator.getKeyLength()).isEqualTo(8);
|
||||||
byte[] key = keyGenerator.generateKey();
|
byte[] key = keyGenerator.generateKey();
|
||||||
assertThat(key.length).isEqualTo(8);
|
assertThat(key).hasSize(8);
|
||||||
byte[] key2 = keyGenerator.generateKey();
|
byte[] key2 = keyGenerator.generateKey();
|
||||||
assertThat(Arrays.equals(key, key2)).isFalse();
|
assertThat(Arrays.equals(key, key2)).isFalse();
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class KeyGeneratorsTests {
|
||||||
BytesKeyGenerator keyGenerator = KeyGenerators.secureRandom(21);
|
BytesKeyGenerator keyGenerator = KeyGenerators.secureRandom(21);
|
||||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
|
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
|
||||||
byte[] key = keyGenerator.generateKey();
|
byte[] key = keyGenerator.generateKey();
|
||||||
assertThat(key.length).isEqualTo(21);
|
assertThat(key).hasSize(21);
|
||||||
byte[] key2 = keyGenerator.generateKey();
|
byte[] key2 = keyGenerator.generateKey();
|
||||||
assertThat(Arrays.equals(key, key2)).isFalse();
|
assertThat(Arrays.equals(key, key2)).isFalse();
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class KeyGeneratorsTests {
|
||||||
BytesKeyGenerator keyGenerator = KeyGenerators.shared(21);
|
BytesKeyGenerator keyGenerator = KeyGenerators.shared(21);
|
||||||
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
|
assertThat(keyGenerator.getKeyLength()).isEqualTo(21);
|
||||||
byte[] key = keyGenerator.generateKey();
|
byte[] key = keyGenerator.generateKey();
|
||||||
assertThat(key.length).isEqualTo(21);
|
assertThat(key).hasSize(21);
|
||||||
byte[] key2 = keyGenerator.generateKey();
|
byte[] key2 = keyGenerator.generateKey();
|
||||||
assertThat(Arrays.equals(key, key2)).isTrue();
|
assertThat(Arrays.equals(key, key2)).isTrue();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class KeyGeneratorsTests {
|
||||||
StringKeyGenerator keyGenerator = KeyGenerators.string();
|
StringKeyGenerator keyGenerator = KeyGenerators.string();
|
||||||
String hexStringKey = keyGenerator.generateKey();
|
String hexStringKey = keyGenerator.generateKey();
|
||||||
assertThat(hexStringKey.length()).isEqualTo(16);
|
assertThat(hexStringKey.length()).isEqualTo(16);
|
||||||
assertThat(Hex.decode(hexStringKey).length).isEqualTo(8);
|
assertThat(Hex.decode(hexStringKey)).hasSize(8);
|
||||||
String hexStringKey2 = keyGenerator.generateKey();
|
String hexStringKey2 = keyGenerator.generateKey();
|
||||||
assertThat(hexStringKey.equals(hexStringKey2)).isFalse();
|
assertThat(hexStringKey.equals(hexStringKey2)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class EncodingUtilsTests {
|
||||||
(byte) 67, (byte) 0xC0, (byte) 0xC1, (byte) 0xC2 };
|
(byte) 67, (byte) 0xC0, (byte) 0xC1, (byte) 0xC2 };
|
||||||
byte[] two = new byte[] { (byte) 0xFF, (byte) 65, (byte) 66 };
|
byte[] two = new byte[] { (byte) 0xFF, (byte) 65, (byte) 66 };
|
||||||
byte[] subArray = EncodingUtils.subArray(bytes, 1, 4);
|
byte[] subArray = EncodingUtils.subArray(bytes, 1, 4);
|
||||||
assertThat(subArray.length).isEqualTo(3);
|
assertThat(subArray).hasSize(3);
|
||||||
assertThat(Arrays.equals(two, subArray)).isTrue();
|
assertThat(Arrays.equals(two, subArray)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class SpringSecurityLdapTemplateITests extends AbstractLdapIntegrationTes
|
||||||
protected void assertAttributeValue(Map<String, List<String>> record,
|
protected void assertAttributeValue(Map<String, List<String>> record,
|
||||||
String attributeName, String... values) {
|
String attributeName, String... values) {
|
||||||
assertThat(record.containsKey(attributeName)).isTrue();
|
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++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
assertThat(record.get(attributeName).get(i)).isEqualTo(values[i]);
|
assertThat(record.get(attributeName).get(i)).isEqualTo(values[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class NestedLdapAuthoritiesPopulatorTests extends AbstractLdapIntegration
|
||||||
circularJavaDevelopers, jDevelopers, groovyDevelopers));
|
circularJavaDevelopers, jDevelopers, groovyDevelopers));
|
||||||
|
|
||||||
LdapAuthority[] ldapAuthorities = authorities.toArray(new LdapAuthority[0]);
|
LdapAuthority[] ldapAuthorities = authorities.toArray(new LdapAuthority[0]);
|
||||||
assertThat(ldapAuthorities.length).isEqualTo(5);
|
assertThat(ldapAuthorities).hasSize(5);
|
||||||
// closure group
|
// closure group
|
||||||
assertThat(ldapAuthorities[0].getAttributes().containsKey("member")).isTrue();
|
assertThat(ldapAuthorities[0].getAttributes().containsKey("member")).isTrue();
|
||||||
assertThat(ldapAuthorities[0].getAttributes().get("member")).isNotNull();
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
Collection<ConfigAttribute> attrs = source.getAttributes(message);
|
||||||
|
|
||||||
assertThat(attrs.size()).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
ConfigAttribute attr = attrs.iterator().next();
|
ConfigAttribute attr = attrs.iterator().next();
|
||||||
assertThat(attr).isInstanceOf(MessageExpressionConfigAttribute.class);
|
assertThat(attr).isInstanceOf(MessageExpressionConfigAttribute.class);
|
||||||
assertThat(
|
assertThat(
|
||||||
|
@ -94,7 +94,7 @@ public class ExpressionBasedMessageSecurityMetadataSourceFactoryTests {
|
||||||
|
|
||||||
Collection<ConfigAttribute> attrs = source.getAttributes(message);
|
Collection<ConfigAttribute> attrs = source.getAttributes(message);
|
||||||
|
|
||||||
assertThat(attrs.size()).isEqualTo(1);
|
assertThat(attrs).hasSize(1);
|
||||||
ConfigAttribute attr = attrs.iterator().next();
|
ConfigAttribute attr = attrs.iterator().next();
|
||||||
assertThat(attr).isInstanceOf(MessageExpressionConfigAttribute.class);
|
assertThat(attr).isInstanceOf(MessageExpressionConfigAttribute.class);
|
||||||
assertThat(
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -63,7 +63,7 @@ public class SecurityMessageRepositoryTests {
|
||||||
public void findAllOnlyToCurrentUser() {
|
public void findAllOnlyToCurrentUser() {
|
||||||
Long expectedId = user.getId();
|
Long expectedId = user.getId();
|
||||||
List<Message> messages = repository.findAll();
|
List<Message> messages = repository.findAll();
|
||||||
assertThat(messages.size()).isEqualTo(3);
|
assertThat(messages).hasSize(3);
|
||||||
for (Message m : messages) {
|
for (Message m : messages) {
|
||||||
assertThat(m.getTo().getId()).isEqualTo(expectedId);
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 + " ------");
|
System.out.println("------ Test for username: " + username + " ------");
|
||||||
AbstractElement[] rootElements = this.documentDao
|
AbstractElement[] rootElements = this.documentDao
|
||||||
.findElements(Directory.ROOT_DIRECTORY);
|
.findElements(Directory.ROOT_DIRECTORY);
|
||||||
assertThat(rootElements.length).isEqualTo(3);
|
assertThat(rootElements).hasSize(3);
|
||||||
Directory homeDir = null;
|
Directory homeDir = null;
|
||||||
Directory nonHomeDir = null;
|
Directory nonHomeDir = null;
|
||||||
for (int i = 0; i < rootElements.length; i++) {
|
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());
|
System.out.println("Non-home directory..: " + nonHomeDir.getFullName());
|
||||||
|
|
||||||
AbstractElement[] homeElements = this.documentDao.findElements(homeDir);
|
AbstractElement[] homeElements = this.documentDao.findElements(homeDir);
|
||||||
assertThat(homeElements.length).isEqualTo(12); // confidential and shared
|
assertThat(homeElements).hasSize(12); // confidential and shared
|
||||||
// directories,
|
// directories,
|
||||||
// plus 10 files
|
// plus 10 files
|
||||||
|
|
||||||
AbstractElement[] nonHomeElements = this.documentDao.findElements(nonHomeDir);
|
AbstractElement[] nonHomeElements = this.documentDao.findElements(nonHomeDir);
|
||||||
assertThat(nonHomeElements.length).isEqualTo(shouldBeFiltered ? 11 : 12); // cannot
|
assertThat(nonHomeElements).hasSize(shouldBeFiltered ? 11 : 12); // cannot
|
||||||
// see
|
// see
|
||||||
// the user's
|
// the user's
|
||||||
// "confidential"
|
// "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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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
|
X509Certificate[] certificates = (X509Certificate[]) postProcessedRequest
|
||||||
.getAttribute("javax.servlet.request.X509Certificate");
|
.getAttribute("javax.servlet.request.X509Certificate");
|
||||||
|
|
||||||
assertThat(certificates.length).isEqualTo(1);
|
assertThat(certificates).hasSize(1);
|
||||||
assertThat(certificates[0].getSubjectDN().getName()).isEqualTo(
|
assertThat(certificates[0].getSubjectDN().getName()).isEqualTo(
|
||||||
"CN=rod, OU=Spring Security, O=Spring Framework");
|
"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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -38,10 +38,10 @@ public class CookieClearingLogoutHandlerTests {
|
||||||
request.setContextPath("");
|
request.setContextPath("");
|
||||||
CookieClearingLogoutHandler handler = new CookieClearingLogoutHandler("my_cookie");
|
CookieClearingLogoutHandler handler = new CookieClearingLogoutHandler("my_cookie");
|
||||||
handler.logout(request, response, mock(Authentication.class));
|
handler.logout(request, response, mock(Authentication.class));
|
||||||
assertThat(response.getCookies().length).isEqualTo(1);
|
assertThat(response.getCookies()).hasSize(1);
|
||||||
for (Cookie c : response.getCookies()) {
|
for (Cookie c : response.getCookies()) {
|
||||||
assertThat(c.getPath()).isEqualTo("/");
|
assertThat(c.getPath()).isEqualTo("/");
|
||||||
assertThat(c.getMaxAge()).isEqualTo(0);
|
assertThat(c.getMaxAge()).isZero();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,10 +53,10 @@ public class CookieClearingLogoutHandlerTests {
|
||||||
CookieClearingLogoutHandler handler = new CookieClearingLogoutHandler(
|
CookieClearingLogoutHandler handler = new CookieClearingLogoutHandler(
|
||||||
"my_cookie", "my_cookie_too");
|
"my_cookie", "my_cookie_too");
|
||||||
handler.logout(request, response, mock(Authentication.class));
|
handler.logout(request, response, mock(Authentication.class));
|
||||||
assertThat(response.getCookies().length).isEqualTo(2);
|
assertThat(response.getCookies()).hasSize(2);
|
||||||
for (Cookie c : response.getCookies()) {
|
for (Cookie c : response.getCookies()) {
|
||||||
assertThat(c.getPath()).isEqualTo("/app");
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails details = (PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails) o;
|
||||||
List<GrantedAuthority> gas = details.getGrantedAuthorities();
|
List<GrantedAuthority> gas = details.getGrantedAuthorities();
|
||||||
assertThat(gas).as("Granted authorities should not be null").isNotNull();
|
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> expectedRolesColl = Arrays.asList(expectedRoles);
|
||||||
Collection<String> gasRolesSet = new HashSet<String>();
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
Set<String> j2eeRoles = rolesRetriever.getMappableAttributes();
|
||||||
assertThat(j2eeRoles).isNotNull();
|
assertThat(j2eeRoles).isNotNull();
|
||||||
assertThat(j2eeRoles.size()).withFailMessage("J2eeRoles expected size: " + ROLE1TO4_EXPECTED_ROLES.size()
|
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(): "
|
assertThat(j2eeRoles).withFailMessage("J2eeRoles expected contents (arbitrary order).isTrue(): "
|
||||||
+ ROLE1TO4_EXPECTED_ROLES + ", actual content: " + j2eeRoles).containsAll(ROLE1TO4_EXPECTED_ROLES);
|
+ 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
assertThat(encoded.endsWith("=")).isFalse();
|
||||||
String[] decoded = services.decodeCookie(encoded);
|
String[] decoded = services.decodeCookie(encoded);
|
||||||
|
|
||||||
assertThat(decoded.length).isEqualTo(4);
|
assertThat(decoded).containsExactly("name", "cookie", "tokens", "blah");
|
||||||
assertThat(decoded[0]).isEqualTo("name");
|
|
||||||
assertThat(decoded[1]).isEqualTo("cookie");
|
|
||||||
assertThat(decoded[2]).isEqualTo("tokens");
|
|
||||||
assertThat(decoded[3]).isEqualTo("blah");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -112,13 +108,13 @@ public class AbstractRememberMeServicesTests {
|
||||||
MockRememberMeServices services = new MockRememberMeServices(uds);
|
MockRememberMeServices services = new MockRememberMeServices(uds);
|
||||||
|
|
||||||
String[] decoded = services.decodeCookie(services.encodeCookie(cookie));
|
String[] decoded = services.decodeCookie(services.encodeCookie(cookie));
|
||||||
assertThat(decoded.length).isEqualTo(4);
|
assertThat(decoded).hasSize(4);
|
||||||
assertThat(decoded[0]).isEqualTo("http://id.openid.zz");
|
assertThat(decoded[0]).isEqualTo("http://id.openid.zz");
|
||||||
|
|
||||||
// Check https (SEC-1410)
|
// Check https (SEC-1410)
|
||||||
cookie[0] = "https://id.openid.zz";
|
cookie[0] = "https://id.openid.zz";
|
||||||
decoded = services.decodeCookie(services.encodeCookie(cookie));
|
decoded = services.decodeCookie(services.encodeCookie(cookie));
|
||||||
assertThat(decoded.length).isEqualTo(4);
|
assertThat(decoded).hasSize(4);
|
||||||
assertThat(decoded[0]).isEqualTo("https://id.openid.zz");
|
assertThat(decoded[0]).isEqualTo("https://id.openid.zz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,11 +144,11 @@ public class DigestAuthUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSplitWorksWithDifferentDelimiters() {
|
public void testSplitWorksWithDifferentDelimiters() {
|
||||||
assertThat(DigestAuthUtils.split("18/rod", "/").length).isEqualTo(2);
|
assertThat(DigestAuthUtils.split("18/rod", "/")).hasSize(2);
|
||||||
assertThat(DigestAuthUtils.split("18/rod", "!")).isNull();
|
assertThat(DigestAuthUtils.split("18/rod", "!")).isNull();
|
||||||
|
|
||||||
// only guarantees to split at FIRST delimiter, not EACH delimiter
|
// 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() {
|
public void testAuthorizationHeaderWithCommasIsSplitCorrectly() {
|
||||||
|
@ -157,6 +157,6 @@ public class DigestAuthUtilsTests {
|
||||||
|
|
||||||
String[] parts = DigestAuthUtils.splitIgnoringQuotes(header, ',');
|
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 decodedNonce = new String(Base64.decodeBase64(nonce.getBytes()));
|
||||||
String[] nonceTokens = StringUtils.delimitedListToStringArray(decodedNonce, ":");
|
String[] nonceTokens = StringUtils.delimitedListToStringArray(decodedNonce, ":");
|
||||||
assertThat(nonceTokens.length).isEqualTo(2);
|
assertThat(nonceTokens).hasSize(2);
|
||||||
|
|
||||||
String expectedNonceSignature = DigestUtils.md5Hex(nonceTokens[0] + ":" + "key");
|
String expectedNonceSignature = DigestUtils.md5Hex(nonceTokens[0] + ":" + "key");
|
||||||
assertThat(nonceTokens[1]).isEqualTo(expectedNonceSignature);
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -60,13 +60,11 @@ public class CacheControlHeadersWriterTests {
|
||||||
public void writeHeaders() {
|
public void writeHeaders() {
|
||||||
this.writer.writeHeaders(this.request, this.response);
|
this.writer.writeHeaders(this.request, this.response);
|
||||||
|
|
||||||
assertThat(this.response.getHeaderNames().size()).isEqualTo(3);
|
assertThat(this.response.getHeaderNames()).hasSize(3);
|
||||||
assertThat(this.response.getHeaderValues("Cache-Control")).isEqualTo(
|
assertThat(this.response.getHeaderValues("Cache-Control")).containsExactly(
|
||||||
Arrays.asList("no-cache, no-store, max-age=0, must-revalidate"));
|
"no-cache, no-store, max-age=0, must-revalidate");
|
||||||
assertThat(this.response.getHeaderValues("Pragma"))
|
assertThat(this.response.getHeaderValues("Pragma")).containsOnly("no-cache");
|
||||||
.isEqualTo(Arrays.asList("no-cache"));
|
assertThat(this.response.getHeaderValues("Expires")).containsOnly("0");
|
||||||
assertThat(this.response.getHeaderValues("Expires"))
|
|
||||||
.isEqualTo(Arrays.asList("0"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -80,13 +78,11 @@ public class CacheControlHeadersWriterTests {
|
||||||
|
|
||||||
this.writer.writeHeaders(this.request, this.response);
|
this.writer.writeHeaders(this.request, this.response);
|
||||||
|
|
||||||
assertThat(this.response.getHeaderNames().size()).isEqualTo(3);
|
assertThat(this.response.getHeaderNames()).hasSize(3);
|
||||||
assertThat(this.response.getHeaderValues("Cache-Control")).isEqualTo(
|
assertThat(this.response.getHeaderValues("Cache-Control")).containsExactly(
|
||||||
Arrays.asList("no-cache, no-store, max-age=0, must-revalidate"));
|
"no-cache, no-store, max-age=0, must-revalidate");
|
||||||
assertThat(this.response.getHeaderValues("Pragma"))
|
assertThat(this.response.getHeaderValues("Pragma")).containsOnly("no-cache");
|
||||||
.isEqualTo(Arrays.asList("no-cache"));
|
assertThat(this.response.getHeaderValues("Expires")).containsOnly("0");
|
||||||
assertThat(this.response.getHeaderValues("Expires"))
|
|
||||||
.isEqualTo(Arrays.asList("0"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gh-2953
|
// 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -43,7 +43,7 @@ public class ContentSecurityPolicyHeaderWriterTests {
|
||||||
public void writeHeadersContentSecurityPolicyDefault() {
|
public void writeHeadersContentSecurityPolicyDefault() {
|
||||||
writer.writeHeaders(request, response);
|
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);
|
assertThat(response.getHeader("Content-Security-Policy")).isEqualTo(DEFAULT_POLICY_DIRECTIVES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class ContentSecurityPolicyHeaderWriterTests {
|
||||||
writer = new ContentSecurityPolicyHeaderWriter(policyDirectives);
|
writer = new ContentSecurityPolicyHeaderWriter(policyDirectives);
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Content-Security-Policy")).isEqualTo(policyDirectives);
|
assertThat(response.getHeader("Content-Security-Policy")).isEqualTo(policyDirectives);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class ContentSecurityPolicyHeaderWriterTests {
|
||||||
writer.setReportOnly(true);
|
writer.setReportOnly(true);
|
||||||
writer.writeHeaders(request, response);
|
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);
|
assertThat(response.getHeader("Content-Security-Policy-Report-Only")).isEqualTo(DEFAULT_POLICY_DIRECTIVES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class ContentSecurityPolicyHeaderWriterTests {
|
||||||
writer.setReportOnly(true);
|
writer.setReportOnly(true);
|
||||||
writer.writeHeaders(request, response);
|
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);
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||||
"max-age=15768000");
|
"max-age=15768000");
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class HstsHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||||
"max-age=15768000");
|
"max-age=15768000");
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class HstsHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||||
"max-age=15768000 ; includeSubDomains");
|
"max-age=15768000 ; includeSubDomains");
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class HstsHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||||
"max-age=31536000");
|
"max-age=31536000");
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class HstsHeaderWriterTests {
|
||||||
public void writeHeadersDefaultValues() {
|
public void writeHeadersDefaultValues() {
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||||
"max-age=31536000 ; includeSubDomains");
|
"max-age=31536000 ; includeSubDomains");
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ public class HstsHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||||
"max-age=31536000");
|
"max-age=31536000");
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ public class HstsHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||||
"max-age=1 ; includeSubDomains");
|
"max-age=1 ; includeSubDomains");
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class HstsHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
assertThat(response.getHeader("Strict-Transport-Security")).isEqualTo(
|
||||||
"max-age=31536000 ; includeSubDomains");
|
"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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -46,7 +46,7 @@ public class ReferrerPolicyHeaderWriterTests {
|
||||||
public void writeHeadersReferrerPolicyDefault() {
|
public void writeHeadersReferrerPolicyDefault() {
|
||||||
this.writer.writeHeaders(this.request, this.response);
|
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);
|
assertThat(this.response.getHeader("Referrer-Policy")).isEqualTo(DEFAULT_REFERRER_POLICY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class ReferrerPolicyHeaderWriterTests {
|
||||||
|
|
||||||
this.writer.writeHeaders(this.request, this.response);
|
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");
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
factory.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(2);
|
assertThat(response.getHeaderNames()).hasSize(2);
|
||||||
assertThat(response.getHeaderValues(pragma.getName())).isEqualTo(
|
assertThat(response.getHeaderValues(pragma.getName())).isEqualTo(
|
||||||
pragma.getValues());
|
pragma.getValues());
|
||||||
assertThat(response.getHeaderValues(cacheControl.getName())).isEqualTo(
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.mock.web.MockHttpServletRequest;
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
|
@ -47,8 +45,8 @@ public class XContentTypeOptionsHeaderWriterTests {
|
||||||
public void writeHeaders() {
|
public void writeHeaders() {
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeaderValues("X-Content-Type-Options")).isEqualTo(
|
assertThat(response.getHeaderValues("X-Content-Type-Options")).containsExactly(
|
||||||
Arrays.asList("nosniff"));
|
"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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.mock.web.MockHttpServletRequest;
|
import org.springframework.mock.web.MockHttpServletRequest;
|
||||||
|
@ -47,9 +45,8 @@ public class XXssProtectionHeaderWriterTests {
|
||||||
public void writeHeaders() {
|
public void writeHeaders() {
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeaderValues("X-XSS-Protection")).isEqualTo(
|
assertThat(response.getHeaderValues("X-XSS-Protection")).containsOnly("1; mode=block");
|
||||||
Arrays.asList("1; mode=block"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -58,9 +55,8 @@ public class XXssProtectionHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeaderValues("X-XSS-Protection")).isEqualTo(
|
assertThat(response.getHeaderValues("X-XSS-Protection")).containsOnly("1");
|
||||||
Arrays.asList("1"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -70,9 +66,8 @@ public class XXssProtectionHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeaderValues("X-XSS-Protection")).isEqualTo(
|
assertThat(response.getHeaderValues("X-XSS-Protection")).containsOnly("0");
|
||||||
Arrays.asList("0"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -81,9 +76,8 @@ public class XXssProtectionHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeaderValues("X-XSS-Protection")).isEqualTo(
|
assertThat(response.getHeaderValues("X-XSS-Protection")).containsOnly("0");
|
||||||
Arrays.asList("0"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
||||||
.isEqualTo("ALLOW-FROM " + allowFromValue);
|
.isEqualTo("ALLOW-FROM " + allowFromValue);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class FrameOptionsHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
||||||
.isEqualTo("DENY");
|
.isEqualTo("DENY");
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ public class FrameOptionsHeaderWriterTests {
|
||||||
|
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
||||||
.isEqualTo("SAMEORIGIN");
|
.isEqualTo("SAMEORIGIN");
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class FrameOptionsHeaderWriterTests {
|
||||||
writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.DENY);
|
writer = new XFrameOptionsHeaderWriter(XFrameOptionsMode.DENY);
|
||||||
writer.writeHeaders(request, response);
|
writer.writeHeaders(request, response);
|
||||||
|
|
||||||
assertThat(response.getHeaderNames().size()).isEqualTo(1);
|
assertThat(response.getHeaderNames()).hasSize(1);
|
||||||
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
assertThat(response.getHeader(XFrameOptionsHeaderWriter.XFRAME_OPTIONS_HEADER))
|
||||||
.isEqualTo("DENY");
|
.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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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();
|
MockHttpServletRequest savedRequest = new MockHttpServletRequest();
|
||||||
savedRequest.setCookies(new Cookie[] { new Cookie("cookie", "fromsaved") });
|
savedRequest.setCookies(new Cookie[] { new Cookie("cookie", "fromsaved") });
|
||||||
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, newRequest);
|
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, newRequest);
|
||||||
assertThat(wrapper.getCookies().length).isEqualTo(1);
|
assertThat(wrapper.getCookies()).hasSize(1);
|
||||||
assertThat(wrapper.getCookies()[0].getValue()).isEqualTo("fromnew");
|
assertThat(wrapper.getCookies()[0].getValue()).isEqualTo("fromnew");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public class SavedRequestAwareWrapperTests {
|
||||||
wrappedRequest.setParameter("action", "bar");
|
wrappedRequest.setParameter("action", "bar");
|
||||||
assertThat(wrapper.getParameter("action")).isEqualTo("bar");
|
assertThat(wrapper.getParameter("action")).isEqualTo("bar");
|
||||||
// Both values should be set, but "bar" should be first
|
// 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");
|
assertThat(wrapper.getParameterValues("action")[0]).isEqualTo("bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ public class SavedRequestAwareWrapperTests {
|
||||||
MockHttpServletRequest wrappedRequest = new MockHttpServletRequest();
|
MockHttpServletRequest wrappedRequest = new MockHttpServletRequest();
|
||||||
wrappedRequest.setParameter("action", "foo");
|
wrappedRequest.setParameter("action", "foo");
|
||||||
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, wrappedRequest);
|
SavedRequestAwareWrapper wrapper = createWrapper(savedRequest, wrappedRequest);
|
||||||
assertThat(wrapper.getParameterValues("action").length).isEqualTo(1);
|
assertThat(wrapper.getParameterValues("action")).hasSize(1);
|
||||||
assertThat(wrapper.getParameterMap()).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
|
@Test
|
||||||
|
@ -135,7 +135,7 @@ public class SavedRequestAwareWrapperTests {
|
||||||
assertThat(wrapper.getParameterValues("action")).isEqualTo(new Object[] { "bar", "foo" });
|
assertThat(wrapper.getParameterValues("action")).isEqualTo(new Object[] { "bar", "foo" });
|
||||||
// Check map is consistent
|
// Check map is consistent
|
||||||
String[] valuesFromMap = (String[]) wrapper.getParameterMap().get("action");
|
String[] valuesFromMap = (String[]) wrapper.getParameterMap().get("action");
|
||||||
assertThat(valuesFromMap.length).isEqualTo(2);
|
assertThat(valuesFromMap).hasSize(2);
|
||||||
assertThat(valuesFromMap[0]).isEqualTo("bar");
|
assertThat(valuesFromMap[0]).isEqualTo("bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue