use of org.keycloak.admin.client.resource.ResourceScopeResource in project keycloak by keycloak.
the class ScopeManagementTest method testUpdate.
@Test
public void testUpdate() {
ResourceScopeResource scopeResource = createDefaultScope();
ScopeRepresentation scope = scopeResource.toRepresentation();
scope.setName("changed");
scope.setIconUri("changed");
scopeResource.update(scope);
scope = scopeResource.toRepresentation();
assertEquals("changed", scope.getName());
assertEquals("changed", scope.getIconUri());
}
use of org.keycloak.admin.client.resource.ResourceScopeResource in project keycloak by keycloak.
the class ScopeManagementTest method testDeleteAndPolicyUpdate.
@Test(expected = NotFoundException.class)
public void testDeleteAndPolicyUpdate() {
ResourceScopeResource scopeResource = createDefaultScope();
ScopeRepresentation scopeRepresentation = scopeResource.toRepresentation();
ScopePermissionRepresentation representation = new ScopePermissionRepresentation();
representation.setName(scopeRepresentation.getName());
representation.addScope(scopeRepresentation.getId());
getClientResource().authorization().permissions().scope().create(representation);
ScopePermissionRepresentation permissionRepresentation = getClientResource().authorization().permissions().scope().findByName(scopeRepresentation.getName());
List<ScopeRepresentation> scopes = getClientResource().authorization().policies().policy(permissionRepresentation.getId()).scopes();
assertEquals(1, scopes.size());
scopeResource.remove();
assertTrue(getClientResource().authorization().policies().policy(permissionRepresentation.getId()).scopes().isEmpty());
}
use of org.keycloak.admin.client.resource.ResourceScopeResource in project keycloak by keycloak.
the class ScopeManagementTest method testDelete.
@Test(expected = NotFoundException.class)
public void testDelete() {
ResourceScopeResource scopeResource = createDefaultScope();
scopeResource.remove();
scopeResource.toRepresentation();
}
use of org.keycloak.admin.client.resource.ResourceScopeResource in project keycloak by keycloak.
the class ScopeManagementTest method testNotUpdateOnResourceUpdate.
@Test
public void testNotUpdateOnResourceUpdate() {
ResourceScopeResource scopeResource = createDefaultScope();
ScopeRepresentation scope = scopeResource.toRepresentation();
scope.setName("changed");
scope.setDisplayName("changed");
scope.setIconUri("changed");
scopeResource.update(scope);
scope = scopeResource.toRepresentation();
assertEquals("changed", scope.getName());
assertEquals("changed", scope.getDisplayName());
assertEquals("changed", scope.getIconUri());
ResourcesResource resources = getClientResource().authorization().resources();
ResourceRepresentation resource;
try (Response response = resources.create(new ResourceRepresentation(UUID.randomUUID().toString(), scope.getName()))) {
resource = response.readEntity(ResourceRepresentation.class);
}
resource.getScopes().iterator().next().setDisplayName(null);
resources.resource(resource.getId()).update(resource);
scope = scopeResource.toRepresentation();
assertEquals("changed", scope.getName());
assertEquals("changed", scope.getDisplayName());
assertEquals("changed", scope.getIconUri());
}
Aggregations