Search in sources :

Example 6 with Authorizable

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));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) StandardPermission(io.cdap.cdap.proto.security.StandardPermission) ApplicationPermission(io.cdap.cdap.proto.security.ApplicationPermission) GrantedPermission(io.cdap.cdap.proto.security.GrantedPermission) Permission(io.cdap.cdap.proto.security.Permission) GrantedPermission(io.cdap.cdap.proto.security.GrantedPermission) Authorizable(io.cdap.cdap.proto.security.Authorizable)

Aggregations

Authorizable (io.cdap.cdap.proto.security.Authorizable)6 Permission (io.cdap.cdap.proto.security.Permission)4 GrantedPermission (io.cdap.cdap.proto.security.GrantedPermission)3 Principal (io.cdap.cdap.proto.security.Principal)2 StandardPermission (io.cdap.cdap.proto.security.StandardPermission)2 Test (org.junit.Test)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 NamespaceSummary (io.cdap.cdap.api.NamespaceSummary)1 ArtifactSummary (io.cdap.cdap.api.artifact.ArtifactSummary)1 DraftId (io.cdap.cdap.datapipeline.draft.DraftId)1 NamespaceMeta (io.cdap.cdap.proto.NamespaceMeta)1 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)1 ApplicationPermission (io.cdap.cdap.proto.security.ApplicationPermission)1 UnauthorizedException (io.cdap.cdap.security.spi.authorization.UnauthorizedException)1 HttpResponse (io.cdap.common.http.HttpResponse)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1