Search in sources :

Example 1 with RoleId

use of com.bakdata.conquery.models.identifiable.ids.specific.RoleId in project conquery by bakdata.

the class RoleUITest method execute.

@Override
public void execute(StandaloneSupport conquery) throws Exception {
    MetaStorage storage = conquery.getMetaStorage();
    Role mandator = new Role("testMandatorName", "testMandatorLabel", storage);
    RoleId mandatorId = mandator.getId();
    User user = new User("testUser@test.de", "testUserName", storage);
    UserId userId = user.getId();
    try {
        ConqueryPermission permission = DatasetPermission.onInstance(Ability.READ.asSet(), new DatasetId("testDatasetId"));
        storage.addRole(mandator);
        storage.addUser(user);
        // override permission object, because it might have changed by the subject
        // owning the permission
        mandator.addPermission(permission);
        user.addRole(mandator);
        URI classBase = HierarchyHelper.hierarchicalPath(conquery.defaultAdminURIBuilder(), RoleUIResource.class, "getRole").buildFromMap(Map.of(ROLE_ID, mandatorId.toString()));
        Response response = conquery.getClient().target(classBase).request().get();
        assertThat(response.getStatus()).isEqualTo(200);
        // Check for Freemarker Errors
        assertThat(response.readEntity(String.class).toLowerCase()).doesNotContain(List.of("freemarker", "debug"));
    } finally {
        storage.removeRole(mandatorId);
        storage.removeUser(userId);
    }
}
Also used : Role(com.bakdata.conquery.models.auth.entities.Role) Response(javax.ws.rs.core.Response) ConqueryPermission(com.bakdata.conquery.models.auth.permissions.ConqueryPermission) User(com.bakdata.conquery.models.auth.entities.User) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) UserId(com.bakdata.conquery.models.identifiable.ids.specific.UserId) RoleUIResource(com.bakdata.conquery.resources.admin.ui.RoleUIResource) RoleId(com.bakdata.conquery.models.identifiable.ids.specific.RoleId) URI(java.net.URI) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)

Example 2 with RoleId

use of com.bakdata.conquery.models.identifiable.ids.specific.RoleId in project conquery by bakdata.

the class User method getEffectivePermissions.

@Override
public Set<ConqueryPermission> getEffectivePermissions() {
    Set<ConqueryPermission> permissions = getPermissions();
    for (RoleId roleId : roles) {
        Role role = storage.getRole(roleId);
        if (role == null) {
            log.warn("Could not find role {} to gather permissions", roleId);
            continue;
        }
        permissions = Sets.union(permissions, role.getEffectivePermissions());
    }
    for (Group group : storage.getAllGroups()) {
        if (!group.containsMember(this)) {
            continue;
        }
        permissions = Sets.union(permissions, group.getEffectivePermissions());
    }
    return permissions;
}
Also used : ConqueryPermission(com.bakdata.conquery.models.auth.permissions.ConqueryPermission) RoleId(com.bakdata.conquery.models.identifiable.ids.specific.RoleId)

Example 3 with RoleId

use of com.bakdata.conquery.models.identifiable.ids.specific.RoleId in project conquery by bakdata.

the class IntegrationUtils method importPermissionConstellation.

/**
 * Load the constellation of roles, users and permissions into the provided storage.
 */
public static void importPermissionConstellation(MetaStorage storage, Role[] roles, RequiredUser[] rUsers) {
    for (Role role : roles) {
        storage.addRole(role);
    }
    for (RequiredUser rUser : rUsers) {
        User user = rUser.getUser();
        storage.addUser(user);
        RoleId[] rolesInjected = rUser.getRolesInjected();
        for (RoleId mandatorId : rolesInjected) {
            user.addRole(storage.getRole(mandatorId));
        }
    }
}
Also used : Role(com.bakdata.conquery.models.auth.entities.Role) User(com.bakdata.conquery.models.auth.entities.User) RoleId(com.bakdata.conquery.models.identifiable.ids.specific.RoleId)

Aggregations

RoleId (com.bakdata.conquery.models.identifiable.ids.specific.RoleId)3 Role (com.bakdata.conquery.models.auth.entities.Role)2 User (com.bakdata.conquery.models.auth.entities.User)2 ConqueryPermission (com.bakdata.conquery.models.auth.permissions.ConqueryPermission)2 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)1 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)1 UserId (com.bakdata.conquery.models.identifiable.ids.specific.UserId)1 RoleUIResource (com.bakdata.conquery.resources.admin.ui.RoleUIResource)1 URI (java.net.URI)1 Response (javax.ws.rs.core.Response)1