use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class SecurityConfigTests method testObjectEquals.
@Test
public void testObjectEquals() throws Exception {
SecurityConfig security1 = new SecurityConfig("TEST");
SecurityConfig security2 = new SecurityConfig("TEST");
assertThat(security2).isEqualTo(security1);
// SEC-311: Must observe symmetry requirement of Object.equals(Object) contract
String securityString1 = "TEST";
assertThat(securityString1).isNotSameAs(security1);
String securityString2 = "NOT_EQUAL";
assertThat(!security1.equals(securityString2)).isTrue();
SecurityConfig security3 = new SecurityConfig("NOT_EQUAL");
assertThat(!security1.equals(security3)).isTrue();
MockConfigAttribute mock1 = new MockConfigAttribute("TEST");
assertThat(security1).isEqualTo(mock1);
MockConfigAttribute mock2 = new MockConfigAttribute("NOT_EQUAL");
assertThat(security1).isNotEqualTo(mock2);
Integer int1 = Integer.valueOf(987);
assertThat(security1).isNotEqualTo(int1);
}
use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class SecuredAnnotationSecurityMetadataSourceTests method classLevelAttributesAreFound.
@Test
public void classLevelAttributesAreFound() {
Collection<ConfigAttribute> attrs = this.mds.findAttributes(BusinessService.class);
assertThat(attrs).isNotNull();
// expect 1 annotation
assertThat(attrs).hasSize(1);
// should have 1 SecurityConfig
SecurityConfig sc = (SecurityConfig) attrs.toArray()[0];
assertThat(sc.getAttribute()).isEqualTo("ROLE_USER");
}
use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class AfterInvocationProviderManagerTests method testSupportsSecureObjectIteration.
@Test
public void testSupportsSecureObjectIteration() throws Exception {
AfterInvocationProviderManager manager = new AfterInvocationProviderManager();
List list = new Vector();
list.add(new MockAfterInvocationProvider("swap1", MethodInvocation.class, new SecurityConfig("GIVE_ME_SWAP1")));
list.add(new MockAfterInvocationProvider("swap2", MethodInvocation.class, new SecurityConfig("GIVE_ME_SWAP2")));
list.add(new MockAfterInvocationProvider("swap3", MethodInvocation.class, new SecurityConfig("GIVE_ME_SWAP3")));
manager.setProviders(list);
manager.afterPropertiesSet();
// assertFalse(manager.supports(FilterInvocation.class));
assertThat(manager.supports(MethodInvocation.class)).isTrue();
}
use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class AfterInvocationProviderManagerTests method testRejectsNonAfterInvocationProviders.
@Test
public void testRejectsNonAfterInvocationProviders() {
AfterInvocationProviderManager manager = new AfterInvocationProviderManager();
List list = new Vector();
list.add(new MockAfterInvocationProvider("swap1", MethodInvocation.class, new SecurityConfig("GIVE_ME_SWAP1")));
list.add(Integer.valueOf(45));
list.add(new MockAfterInvocationProvider("swap3", MethodInvocation.class, new SecurityConfig("GIVE_ME_SWAP3")));
try {
manager.setProviders(list);
fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) {
assertThat(true).isTrue();
}
}
use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class NullRunAsManagerTests method testNeverSupportsAttribute.
@Test
public void testNeverSupportsAttribute() {
NullRunAsManager runAs = new NullRunAsManager();
assertThat(runAs.supports(new SecurityConfig("X"))).isFalse();
}
Aggregations