Search in sources :

Example 1 with UpdateRoleParams

use of com.enonic.xp.security.UpdateRoleParams in project xp by enonic.

the class SecurityServiceImplTest method testUpdateRole.

@Test
public void testUpdateRole() throws Exception {
    runAsAdmin(() -> {
        final CreateRoleParams createRole = CreateRoleParams.create().roleKey(PrincipalKey.ofRole("Role-a")).displayName("Role A").build();
        final Role role = securityService.createRole(createRole);
        final UpdateRoleParams roleUpdate = UpdateRoleParams.create(role).displayName("___Role B___").description("description").build();
        final Role updatedRoleResult = securityService.updateRole(roleUpdate);
        refresh();
        final Role updatedRole = securityService.getRole(role.getKey()).get();
        assertEquals("___Role B___", updatedRoleResult.getDisplayName());
        assertEquals("___Role B___", updatedRole.getDisplayName());
        assertEquals("description", updatedRoleResult.getDescription());
        assertEquals("description", updatedRole.getDescription());
    });
}
Also used : CreateRoleParams(com.enonic.xp.security.CreateRoleParams) Role(com.enonic.xp.security.Role) UpdateRoleParams(com.enonic.xp.security.UpdateRoleParams) AbstractElasticsearchIntegrationTest(com.enonic.xp.repo.impl.elasticsearch.AbstractElasticsearchIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AbstractElasticsearchIntegrationTest (com.enonic.xp.repo.impl.elasticsearch.AbstractElasticsearchIntegrationTest)1 CreateRoleParams (com.enonic.xp.security.CreateRoleParams)1 Role (com.enonic.xp.security.Role)1 UpdateRoleParams (com.enonic.xp.security.UpdateRoleParams)1 Test (org.junit.jupiter.api.Test)1