@ -54,7 +54,7 @@ public class AclImplTests {
// ========================================================================================================
// ========================================================================================================
@Before
@Before
public void setUp ( ) throws Exception {
public void setUp ( ) {
SecurityContextHolder . getContext ( ) . setAuthentication ( auth ) ;
SecurityContextHolder . getContext ( ) . setAuthentication ( auth ) ;
authzStrategy = mock ( AclAuthorizationStrategy . class ) ;
authzStrategy = mock ( AclAuthorizationStrategy . class ) ;
mockAuditLogger = mock ( AuditLogger . class ) ;
mockAuditLogger = mock ( AuditLogger . class ) ;
@ -63,12 +63,12 @@ public class AclImplTests {
}
}
@After
@After
public void tearDown ( ) throws Exception {
public void tearDown ( ) {
SecurityContextHolder . clearContext ( ) ;
SecurityContextHolder . clearContext ( ) ;
}
}
@Test ( expected = IllegalArgumentException . class )
@Test ( expected = IllegalArgumentException . class )
public void constructorsRejectNullObjectIdentity ( ) throws Exception {
public void constructorsRejectNullObjectIdentity ( ) {
try {
try {
new AclImpl ( null , 1 , authzStrategy , pgs , null , null , true , new PrincipalSid (
new AclImpl ( null , 1 , authzStrategy , pgs , null , null , true , new PrincipalSid (
"joe" ) ) ;
"joe" ) ) ;
@ -80,7 +80,7 @@ public class AclImplTests {
}
}
@Test ( expected = IllegalArgumentException . class )
@Test ( expected = IllegalArgumentException . class )
public void constructorsRejectNullId ( ) throws Exception {
public void constructorsRejectNullId ( ) {
try {
try {
new AclImpl ( objectIdentity , null , authzStrategy , pgs , null , null , true ,
new AclImpl ( objectIdentity , null , authzStrategy , pgs , null , null , true ,
new PrincipalSid ( "joe" ) ) ;
new PrincipalSid ( "joe" ) ) ;
@ -93,7 +93,7 @@ public class AclImplTests {
@SuppressWarnings ( "deprecation" )
@SuppressWarnings ( "deprecation" )
@Test ( expected = IllegalArgumentException . class )
@Test ( expected = IllegalArgumentException . class )
public void constructorsRejectNullAclAuthzStrategy ( ) throws Exception {
public void constructorsRejectNullAclAuthzStrategy ( ) {
try {
try {
new AclImpl ( objectIdentity , 1 , null , new DefaultPermissionGrantingStrategy (
new AclImpl ( objectIdentity , 1 , null , new DefaultPermissionGrantingStrategy (
mockAuditLogger ) , null , null , true , new PrincipalSid ( "joe" ) ) ;
mockAuditLogger ) , null , null , true , new PrincipalSid ( "joe" ) ) ;
@ -105,7 +105,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void insertAceRejectsNullParameters ( ) throws Exception {
public void insertAceRejectsNullParameters ( ) {
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
try {
try {
@ -123,7 +123,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void insertAceAddsElementAtCorrectIndex ( ) throws Exception {
public void insertAceAddsElementAtCorrectIndex ( ) {
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
MockAclService service = new MockAclService ( ) ;
MockAclService service = new MockAclService ( ) ;
@ -166,7 +166,7 @@ public class AclImplTests {
}
}
@Test ( expected = NotFoundException . class )
@Test ( expected = NotFoundException . class )
public void insertAceFailsForNonExistentElement ( ) throws Exception {
public void insertAceFailsForNonExistentElement ( ) {
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
MockAclService service = new MockAclService ( ) ;
MockAclService service = new MockAclService ( ) ;
@ -180,7 +180,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void deleteAceKeepsInitialOrdering ( ) throws Exception {
public void deleteAceKeepsInitialOrdering ( ) {
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
MockAclService service = new MockAclService ( ) ;
MockAclService service = new MockAclService ( ) ;
@ -217,7 +217,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void deleteAceFailsForNonExistentElement ( ) throws Exception {
public void deleteAceFailsForNonExistentElement ( ) {
AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl (
AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl (
new SimpleGrantedAuthority ( "ROLE_OWNERSHIP" ) , new SimpleGrantedAuthority (
new SimpleGrantedAuthority ( "ROLE_OWNERSHIP" ) , new SimpleGrantedAuthority (
"ROLE_AUDITING" ) , new SimpleGrantedAuthority ( "ROLE_GENERAL" ) ) ;
"ROLE_AUDITING" ) , new SimpleGrantedAuthority ( "ROLE_GENERAL" ) ) ;
@ -232,7 +232,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void isGrantingRejectsEmptyParameters ( ) throws Exception {
public void isGrantingRejectsEmptyParameters ( ) {
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
Sid ben = new PrincipalSid ( "ben" ) ;
Sid ben = new PrincipalSid ( "ben" ) ;
@ -251,7 +251,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void isGrantingGrantsAccessForAclWithNoParent ( ) throws Exception {
public void isGrantingGrantsAccessForAclWithNoParent ( ) {
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
"ROLE_GENERAL" , "ROLE_GUEST" ) ;
"ROLE_GENERAL" , "ROLE_GUEST" ) ;
auth . setAuthenticated ( true ) ;
auth . setAuthenticated ( true ) ;
@ -297,7 +297,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void isGrantingGrantsAccessForInheritableAcls ( ) throws Exception {
public void isGrantingGrantsAccessForInheritableAcls ( ) {
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
"ROLE_GENERAL" ) ;
"ROLE_GENERAL" ) ;
auth . setAuthenticated ( true ) ;
auth . setAuthenticated ( true ) ;
@ -379,7 +379,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void updatedAceValuesAreCorrectlyReflectedInAcl ( ) throws Exception {
public void updatedAceValuesAreCorrectlyReflectedInAcl ( ) {
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
"ROLE_GENERAL" ) ;
"ROLE_GENERAL" ) ;
auth . setAuthenticated ( true ) ;
auth . setAuthenticated ( true ) ;
@ -411,7 +411,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void auditableEntryFlagsAreUpdatedCorrectly ( ) throws Exception {
public void auditableEntryFlagsAreUpdatedCorrectly ( ) {
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
"ROLE_AUDITING" , "ROLE_GENERAL" ) ;
"ROLE_AUDITING" , "ROLE_GENERAL" ) ;
auth . setAuthenticated ( true ) ;
auth . setAuthenticated ( true ) ;
@ -449,7 +449,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void gettersAndSettersAreConsistent ( ) throws Exception {
public void gettersAndSettersAreConsistent ( ) {
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
Authentication auth = new TestingAuthenticationToken ( "ben" , "ignored" ,
"ROLE_GENERAL" ) ;
"ROLE_GENERAL" ) ;
auth . setAuthenticated ( true ) ;
auth . setAuthenticated ( true ) ;
@ -485,7 +485,7 @@ public class AclImplTests {
}
}
@Test
@Test
public void isSidLoadedBehavesAsExpected ( ) throws Exception {
public void isSidLoadedBehavesAsExpected ( ) {
List < Sid > loadedSids = Arrays . asList ( new PrincipalSid ( "ben" ) ,
List < Sid > loadedSids = Arrays . asList ( new PrincipalSid ( "ben" ) ,
new GrantedAuthoritySid ( "ROLE_IGNORED" ) ) ;
new GrantedAuthoritySid ( "ROLE_IGNORED" ) ) ;
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null ,
MutableAcl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null ,
@ -513,22 +513,21 @@ public class AclImplTests {
}
}
@Test ( expected = NotFoundException . class )
@Test ( expected = NotFoundException . class )
public void insertAceRaisesNotFoundExceptionForIndexLessThanZero ( ) throws Exception {
public void insertAceRaisesNotFoundExceptionForIndexLessThanZero ( ) {
AclImpl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
AclImpl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
acl . insertAce ( - 1 , mock ( Permission . class ) , mock ( Sid . class ) , true ) ;
acl . insertAce ( - 1 , mock ( Permission . class ) , mock ( Sid . class ) , true ) ;
}
}
@Test ( expected = NotFoundException . class )
@Test ( expected = NotFoundException . class )
public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero ( ) throws Exception {
public void deleteAceRaisesNotFoundExceptionForIndexLessThanZero ( ) {
AclImpl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
AclImpl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
acl . deleteAce ( - 1 ) ;
acl . deleteAce ( - 1 ) ;
}
}
@Test ( expected = NotFoundException . class )
@Test ( expected = NotFoundException . class )
public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize ( )
public void insertAceRaisesNotFoundExceptionForIndexGreaterThanSize ( ) {
throws Exception {
AclImpl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
AclImpl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
// Insert at zero, OK.
// Insert at zero, OK.
@ -539,7 +538,7 @@ public class AclImplTests {
// SEC-1151
// SEC-1151
@Test ( expected = NotFoundException . class )
@Test ( expected = NotFoundException . class )
public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize ( ) throws Exception {
public void deleteAceRaisesNotFoundExceptionForIndexEqualToSize ( ) {
AclImpl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
AclImpl acl = new AclImpl ( objectIdentity , 1 , authzStrategy , pgs , null , null ,
true , new PrincipalSid ( "joe" ) ) ;
true , new PrincipalSid ( "joe" ) ) ;
acl . insertAce ( 0 , mock ( Permission . class ) , mock ( Sid . class ) , true ) ;
acl . insertAce ( 0 , mock ( Permission . class ) , mock ( Sid . class ) , true ) ;
@ -549,7 +548,7 @@ public class AclImplTests {
// SEC-1795
// SEC-1795
@Test
@Test
public void changingParentIsSuccessful ( ) throws Exception {
public void changingParentIsSuccessful ( ) {
AclImpl parentAcl = new AclImpl ( objectIdentity , 1L , authzStrategy ,
AclImpl parentAcl = new AclImpl ( objectIdentity , 1L , authzStrategy ,
mockAuditLogger ) ;
mockAuditLogger ) ;
AclImpl childAcl = new AclImpl ( objectIdentity , 2L , authzStrategy , mockAuditLogger ) ;
AclImpl childAcl = new AclImpl ( objectIdentity , 2L , authzStrategy , mockAuditLogger ) ;