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);
}
}
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;
}
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));
}
}
}
Aggregations