Search in sources :

Example 1 with AuditableAccessControlEntry

use of org.springframework.security.acls.model.AuditableAccessControlEntry in project spring-security by spring-projects.

the class AccessControlImplEntryTests method testAccessControlEntryImplGetters.

@Test
public void testAccessControlEntryImplGetters() {
    Acl mockAcl = mock(Acl.class);
    Sid sid = new PrincipalSid("johndoe");
    // Create a sample entry
    AccessControlEntry ace = new AccessControlEntryImpl(Long.valueOf(1), mockAcl, sid, BasePermission.ADMINISTRATION, true, true, true);
    // and check every get() method
    assertThat(ace.getId()).isEqualTo(new Long(1));
    assertThat(ace.getAcl()).isEqualTo(mockAcl);
    assertThat(ace.getSid()).isEqualTo(sid);
    assertThat(ace.isGranting()).isTrue();
    assertThat(ace.getPermission()).isEqualTo(BasePermission.ADMINISTRATION);
    assertThat(((AuditableAccessControlEntry) ace).isAuditFailure()).isTrue();
    assertThat(((AuditableAccessControlEntry) ace).isAuditSuccess()).isTrue();
}
Also used : AuditableAccessControlEntry(org.springframework.security.acls.model.AuditableAccessControlEntry) AuditableAccessControlEntry(org.springframework.security.acls.model.AuditableAccessControlEntry) AccessControlEntry(org.springframework.security.acls.model.AccessControlEntry) Acl(org.springframework.security.acls.model.Acl) Sid(org.springframework.security.acls.model.Sid) Test(org.junit.Test)

Example 2 with AuditableAccessControlEntry

use of org.springframework.security.acls.model.AuditableAccessControlEntry in project spring-security by spring-projects.

the class BasicLookupStrategyTests method checkEntries.

private void checkEntries(ObjectIdentity topParentOid, ObjectIdentity middleParentOid, ObjectIdentity childOid, Map<ObjectIdentity, Acl> map) throws Exception {
    assertThat(map).hasSize(3);
    MutableAcl topParent = (MutableAcl) map.get(topParentOid);
    MutableAcl middleParent = (MutableAcl) map.get(middleParentOid);
    MutableAcl child = (MutableAcl) map.get(childOid);
    // Check the retrieved versions has IDs
    assertThat(topParent.getId()).isNotNull();
    assertThat(middleParent.getId()).isNotNull();
    assertThat(child.getId()).isNotNull();
    // Check their parents were correctly retrieved
    assertThat(topParent.getParentAcl()).isNull();
    assertThat(middleParent.getParentAcl().getObjectIdentity()).isEqualTo(topParentOid);
    assertThat(child.getParentAcl().getObjectIdentity()).isEqualTo(middleParentOid);
    // Check their ACEs were correctly retrieved
    assertThat(topParent.getEntries()).hasSize(2);
    assertThat(middleParent.getEntries()).hasSize(1);
    assertThat(child.getEntries()).hasSize(1);
    // Check object identities were correctly retrieved
    assertThat(topParent.getObjectIdentity()).isEqualTo(topParentOid);
    assertThat(middleParent.getObjectIdentity()).isEqualTo(middleParentOid);
    assertThat(child.getObjectIdentity()).isEqualTo(childOid);
    // Check each entry
    assertThat(topParent.isEntriesInheriting()).isTrue();
    assertThat(Long.valueOf(1)).isEqualTo(topParent.getId());
    assertThat(new PrincipalSid("ben")).isEqualTo(topParent.getOwner());
    assertThat(Long.valueOf(1)).isEqualTo(topParent.getEntries().get(0).getId());
    assertThat(topParent.getEntries().get(0).getPermission()).isEqualTo(BasePermission.READ);
    assertThat(topParent.getEntries().get(0).getSid()).isEqualTo(new PrincipalSid("ben"));
    assertThat(((AuditableAccessControlEntry) topParent.getEntries().get(0)).isAuditFailure()).isFalse();
    assertThat(((AuditableAccessControlEntry) topParent.getEntries().get(0)).isAuditSuccess()).isFalse();
    assertThat((topParent.getEntries().get(0)).isGranting()).isTrue();
    assertThat(Long.valueOf(2)).isEqualTo(topParent.getEntries().get(1).getId());
    assertThat(topParent.getEntries().get(1).getPermission()).isEqualTo(BasePermission.WRITE);
    assertThat(topParent.getEntries().get(1).getSid()).isEqualTo(new PrincipalSid("ben"));
    assertThat(((AuditableAccessControlEntry) topParent.getEntries().get(1)).isAuditFailure()).isFalse();
    assertThat(((AuditableAccessControlEntry) topParent.getEntries().get(1)).isAuditSuccess()).isFalse();
    assertThat(topParent.getEntries().get(1).isGranting()).isFalse();
    assertThat(middleParent.isEntriesInheriting()).isTrue();
    assertThat(Long.valueOf(2)).isEqualTo(middleParent.getId());
    assertThat(new PrincipalSid("ben")).isEqualTo(middleParent.getOwner());
    assertThat(Long.valueOf(3)).isEqualTo(middleParent.getEntries().get(0).getId());
    assertThat(middleParent.getEntries().get(0).getPermission()).isEqualTo(BasePermission.DELETE);
    assertThat(middleParent.getEntries().get(0).getSid()).isEqualTo(new PrincipalSid("ben"));
    assertThat(((AuditableAccessControlEntry) middleParent.getEntries().get(0)).isAuditFailure()).isFalse();
    assertThat(((AuditableAccessControlEntry) middleParent.getEntries().get(0)).isAuditSuccess()).isFalse();
    assertThat(middleParent.getEntries().get(0).isGranting()).isTrue();
    assertThat(child.isEntriesInheriting()).isTrue();
    assertThat(Long.valueOf(3)).isEqualTo(child.getId());
    assertThat(new PrincipalSid("ben")).isEqualTo(child.getOwner());
    assertThat(Long.valueOf(4)).isEqualTo(child.getEntries().get(0).getId());
    assertThat(child.getEntries().get(0).getPermission()).isEqualTo(BasePermission.DELETE);
    assertThat(new PrincipalSid("ben")).isEqualTo(child.getEntries().get(0).getSid());
    assertThat(((AuditableAccessControlEntry) child.getEntries().get(0)).isAuditFailure()).isFalse();
    assertThat(((AuditableAccessControlEntry) child.getEntries().get(0)).isAuditSuccess()).isFalse();
    assertThat((child.getEntries().get(0)).isGranting()).isFalse();
}
Also used : AuditableAccessControlEntry(org.springframework.security.acls.model.AuditableAccessControlEntry) MutableAcl(org.springframework.security.acls.model.MutableAcl)

Aggregations

AuditableAccessControlEntry (org.springframework.security.acls.model.AuditableAccessControlEntry)2 Test (org.junit.Test)1 AccessControlEntry (org.springframework.security.acls.model.AccessControlEntry)1 Acl (org.springframework.security.acls.model.Acl)1 MutableAcl (org.springframework.security.acls.model.MutableAcl)1 Sid (org.springframework.security.acls.model.Sid)1