parent
08104eb06c
commit
3f543d0fbd
|
@ -26,6 +26,8 @@ import org.springframework.security.acls.model.Acl;
|
||||||
import org.springframework.security.acls.model.AclService;
|
import org.springframework.security.acls.model.AclService;
|
||||||
import org.springframework.security.acls.model.ObjectIdentity;
|
import org.springframework.security.acls.model.ObjectIdentity;
|
||||||
import org.springframework.security.acls.model.ObjectIdentityRetrievalStrategy;
|
import org.springframework.security.acls.model.ObjectIdentityRetrievalStrategy;
|
||||||
|
import org.springframework.security.acls.model.Permission;
|
||||||
|
import org.springframework.security.acls.model.Sid;
|
||||||
import org.springframework.security.acls.model.SidRetrievalStrategy;
|
import org.springframework.security.acls.model.SidRetrievalStrategy;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
|
||||||
|
@ -37,7 +39,6 @@ import org.springframework.security.core.Authentication;
|
||||||
public class AclPermissionEvaluatorTests {
|
public class AclPermissionEvaluatorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void hasPermissionReturnsTrueIfAclGrantsPermission() throws Exception {
|
public void hasPermissionReturnsTrueIfAclGrantsPermission() throws Exception {
|
||||||
AclService service = mock(AclService.class);
|
AclService service = mock(AclService.class);
|
||||||
AclPermissionEvaluator pe = new AclPermissionEvaluator(service);
|
AclPermissionEvaluator pe = new AclPermissionEvaluator(service);
|
||||||
|
@ -48,8 +49,8 @@ public class AclPermissionEvaluatorTests {
|
||||||
pe.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
|
pe.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
|
||||||
Acl acl = mock(Acl.class);
|
Acl acl = mock(Acl.class);
|
||||||
|
|
||||||
when(service.readAclById(any(ObjectIdentity.class), anyList())).thenReturn(acl);
|
when(service.readAclById(any(ObjectIdentity.class), anyListOf(Sid.class))).thenReturn(acl);
|
||||||
when(acl.isGranted(anyList(), anyList(), eq(false))).thenReturn(true);
|
when(acl.isGranted(anyListOf(Permission.class), anyListOf(Sid.class), eq(false))).thenReturn(true);
|
||||||
|
|
||||||
assertThat(pe.hasPermission(mock(Authentication.class), new Object(), "READ")).isTrue();
|
assertThat(pe.hasPermission(mock(Authentication.class), new Object(), "READ")).isTrue();
|
||||||
}
|
}
|
||||||
|
@ -68,8 +69,8 @@ public class AclPermissionEvaluatorTests {
|
||||||
pe.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
|
pe.setSidRetrievalStrategy(mock(SidRetrievalStrategy.class));
|
||||||
Acl acl = mock(Acl.class);
|
Acl acl = mock(Acl.class);
|
||||||
|
|
||||||
when(service.readAclById(any(ObjectIdentity.class), anyList())).thenReturn(acl);
|
when(service.readAclById(any(ObjectIdentity.class), anyListOf(Sid.class))).thenReturn(acl);
|
||||||
when(acl.isGranted(anyList(), anyList(), eq(false))).thenReturn(true);
|
when(acl.isGranted(anyListOf(Permission.class), anyListOf(Sid.class), eq(false))).thenReturn(true);
|
||||||
|
|
||||||
assertThat(pe.hasPermission(mock(Authentication.class), new Object(), "write")).isTrue();
|
assertThat(pe.hasPermission(mock(Authentication.class), new Object(), "write")).isTrue();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue