Search in sources :

Example 1 with RoleEntity

use of io.gravitee.am.management.handlers.management.api.model.RoleEntity in project gravitee-access-management by gravitee-io.

the class SystemRoleResource method convert.

private RoleEntity convert(Role role) {
    RoleEntity roleEntity = new RoleEntity(role);
    roleEntity.setAvailablePermissions(Permission.allPermissions(role.getAssignableType()).stream().map(permission -> permission.name().toLowerCase()).collect(Collectors.toList()));
    roleEntity.setPermissions(Permission.flatten(role.getPermissionAcls()));
    return roleEntity;
}
Also used : RoleEntity(io.gravitee.am.management.handlers.management.api.model.RoleEntity)

Example 2 with RoleEntity

use of io.gravitee.am.management.handlers.management.api.model.RoleEntity in project gravitee-access-management by gravitee-io.

the class SystemRoleResourceTest method shouldGetSystemRole.

@Test
public void shouldGetSystemRole() {
    final String roleId = "role-id";
    final Role mockRole = new Role();
    mockRole.setId(roleId);
    mockRole.setName("role-name");
    doReturn(Single.just(mockRole)).when(roleService).findById(ReferenceType.PLATFORM, Platform.DEFAULT, roleId);
    final Response response = target("platform").path("roles").path(roleId).request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    final RoleEntity role = readEntity(response, RoleEntity.class);
    assertEquals(roleId, role.getId());
}
Also used : Role(io.gravitee.am.model.Role) Response(javax.ws.rs.core.Response) RoleEntity(io.gravitee.am.management.handlers.management.api.model.RoleEntity) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 3 with RoleEntity

use of io.gravitee.am.management.handlers.management.api.model.RoleEntity in project gravitee-access-management by gravitee-io.

the class RoleResource method convert.

/**
 * Special converter that just fill permissions from Role.oauthScope attribute for compatibility with v2.
 */
private RoleEntity convert(Role role) {
    RoleEntity roleEntity = new RoleEntity(role);
    roleEntity.setPermissions(role.getOauthScopes());
    return roleEntity;
}
Also used : RoleEntity(io.gravitee.am.management.handlers.management.api.model.RoleEntity)

Example 4 with RoleEntity

use of io.gravitee.am.management.handlers.management.api.model.RoleEntity in project gravitee-access-management by gravitee-io.

the class RoleResource method convert.

private RoleEntity convert(Role role) {
    RoleEntity roleEntity = new RoleEntity(role);
    roleEntity.setAvailablePermissions(Permission.allPermissions(role.getAssignableType()).stream().map(permission -> permission.name().toLowerCase()).collect(Collectors.toList()));
    roleEntity.setPermissions(Permission.flatten(role.getPermissionAcls()));
    return roleEntity;
}
Also used : RoleEntity(io.gravitee.am.management.handlers.management.api.model.RoleEntity)

Aggregations

RoleEntity (io.gravitee.am.management.handlers.management.api.model.RoleEntity)4 JerseySpringTest (io.gravitee.am.management.handlers.management.api.JerseySpringTest)1 Role (io.gravitee.am.model.Role)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1