use of io.cdap.cdap.proto.security.Authorizable in project cdap by caskdata.
the class DatasetServiceAuthorizationTest method grantAndAssertSuccess.
private void grantAndAssertSuccess(EntityId entityId, EntityType childType, Principal principal, Set<? extends Permission> permissions) throws AccessException {
Set<GrantedPermission> existingPrivileges = accessController.listGrants(principal);
Authorizable authorizable = Authorizable.fromEntityId(entityId, childType);
accessController.grant(authorizable, principal, permissions);
ImmutableSet.Builder<GrantedPermission> expectedPrivilegesAfterGrant = ImmutableSet.builder();
for (Permission permission : permissions) {
expectedPrivilegesAfterGrant.add(new GrantedPermission(authorizable, permission));
}
Assert.assertEquals(Sets.union(existingPrivileges, expectedPrivilegesAfterGrant.build()), accessController.listGrants(principal));
}
Aggregations