@Test void testConvertToInheritedPermissions() { Sid role1Sid = new GrantedAuthoritySid("ROLE_role1"); Sid role2Sid = new GrantedAuthoritySid("ROLE_role2"); Sid role3Sid = new GrantedAuthoritySid("ROLE_role3"); Acl parentPackageAcl = mock(Acl.class); ObjectIdentity parentPackageObjectIdentity = new ObjectIdentityImpl("package", "parent"); LabelledObjectIdentity labelledParentPackageObjectIdentity = LabelledObjectIdentity.create("package", "sys_md_package", "package", "parent", "Parent"); when(parentPackageAcl.getObjectIdentity()).thenReturn(parentPackageObjectIdentity); Acl packageAcl = mock(Acl.class); ObjectIdentity packageObjectIdentity = new ObjectIdentityImpl("package", "pack"); LabelledObjectIdentity labelledPackageObjectIdentity = LabelledObjectIdentity.create("package", "sys_md_package", "package", "pack", "Pack"); when(packageAcl.getObjectIdentity()).thenReturn(packageObjectIdentity); InheritedPermissionsResult input = getInheritedPermissionsResult(packageAcl, parentPackageAcl, role1Sid, role2Sid, role3Sid); doReturn(labelledPackageObjectIdentity) .when(entityHelper) .getLabelledObjectIdentity(packageObjectIdentity); doReturn(labelledParentPackageObjectIdentity) .when(entityHelper) .getLabelledObjectIdentity(parentPackageObjectIdentity); Set<LabelledPermission> actual = resolver.convertToInheritedPermissions(input); LabelledPermission role3Permission = LabelledPermission.create(role3Sid, null, PermissionSet.WRITEMETA, Collections.emptySet()); LabelledPermission role1Permission = LabelledPermission.create(role1Sid, null, null, singleton(role3Permission)); LabelledPermission parentPermission = LabelledPermission.create( null, LabelledObjectIdentity.create( "package", "sys_md_package", "package", "parent", "Parent"), null, singleton(role1Permission)); LabelledPermission packPermission = LabelledPermission.create( null, LabelledObjectIdentity.create("package", "sys_md_package", "package", "pack", "Pack"), PermissionSet.READ, singleton(parentPermission)); LabelledPermission role2Permission = LabelledPermission.create(role2Sid, null, PermissionSet.WRITE, Collections.emptySet()); Set<LabelledPermission> expected = new HashSet<>(Arrays.asList(role2Permission, packPermission)); assertEquals(expected, actual); }
Set<LabelledPermission> convertToInheritedPermissions( InheritedPermissionsResult inheritedPermissionsResult) { List<InheritedUserPermissionsResult> parentRolePermissions = inheritedPermissionsResult.getRequestedAclParentRolesPermissions(); InheritedAclPermissionsResult parentAclPermissions = inheritedPermissionsResult.getParentAclPermission(); return convertToInheritedPermissions(parentRolePermissions, parentAclPermissions); }
PermissionInheritanceResolver { Set<LabelledPermission> convertToInheritedPermissions( InheritedPermissionsResult inheritedPermissionsResult) { List<InheritedUserPermissionsResult> parentRolePermissions = inheritedPermissionsResult.getRequestedAclParentRolesPermissions(); InheritedAclPermissionsResult parentAclPermissions = inheritedPermissionsResult.getParentAclPermission(); return convertToInheritedPermissions(parentRolePermissions, parentAclPermissions); } }
PermissionInheritanceResolver { Set<LabelledPermission> convertToInheritedPermissions( InheritedPermissionsResult inheritedPermissionsResult) { List<InheritedUserPermissionsResult> parentRolePermissions = inheritedPermissionsResult.getRequestedAclParentRolesPermissions(); InheritedAclPermissionsResult parentAclPermissions = inheritedPermissionsResult.getParentAclPermission(); return convertToInheritedPermissions(parentRolePermissions, parentAclPermissions); } PermissionInheritanceResolver(UserRoleTools userRoleTools, EntityHelper entityHelper); }
PermissionInheritanceResolver { Set<LabelledPermission> convertToInheritedPermissions( InheritedPermissionsResult inheritedPermissionsResult) { List<InheritedUserPermissionsResult> parentRolePermissions = inheritedPermissionsResult.getRequestedAclParentRolesPermissions(); InheritedAclPermissionsResult parentAclPermissions = inheritedPermissionsResult.getParentAclPermission(); return convertToInheritedPermissions(parentRolePermissions, parentAclPermissions); } PermissionInheritanceResolver(UserRoleTools userRoleTools, EntityHelper entityHelper); Set<LabelledPermission> getInheritedPermissions(Acl acl, Sid sid); }
PermissionInheritanceResolver { Set<LabelledPermission> convertToInheritedPermissions( InheritedPermissionsResult inheritedPermissionsResult) { List<InheritedUserPermissionsResult> parentRolePermissions = inheritedPermissionsResult.getRequestedAclParentRolesPermissions(); InheritedAclPermissionsResult parentAclPermissions = inheritedPermissionsResult.getParentAclPermission(); return convertToInheritedPermissions(parentRolePermissions, parentAclPermissions); } PermissionInheritanceResolver(UserRoleTools userRoleTools, EntityHelper entityHelper); Set<LabelledPermission> getInheritedPermissions(Acl acl, Sid sid);  }