Search in sources :

Example 41 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation 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());
}
Also used : ResourceScopeResource(org.keycloak.admin.client.resource.ResourceScopeResource) Response(javax.ws.rs.core.Response) ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation) ResourcesResource(org.keycloak.admin.client.resource.ResourcesResource) ResourceRepresentation(org.keycloak.representations.idm.authorization.ResourceRepresentation) Test(org.junit.Test)

Example 42 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class ScopeManagementTest method testDeleteFromList.

@Test
public void testDeleteFromList() {
    ScopeRepresentation expected = createScope();
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().scopes().deleteFromList(expected.getName());
    authorizationPage.navigateTo();
    assertNull(authorizationPage.authorizationTabs().scopes().scopes().findByName(expected.getName()));
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation) Test(org.junit.Test)

Example 43 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class ScopeManagementTest method assertScope.

private void assertScope(ScopeRepresentation expected) {
    authorizationPage.navigateTo();
    ScopeRepresentation actual = authorizationPage.authorizationTabs().scopes().scopes().findByName(expected.getName());
    assertEquals(expected.getName(), actual.getName());
    assertEquals(expected.getIconUri(), actual.getIconUri());
    ScopeRepresentation scope = authorizationPage.authorizationTabs().scopes().name(expected.getName()).toRepresentation();
    assertEquals(expected.getDisplayName(), scope.getDisplayName());
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation)

Example 44 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class ScopeManagementTest method testUpdate.

@Test
public void testUpdate() {
    ScopeRepresentation expected = createScope();
    String previousName = expected.getName();
    expected.setName("changed");
    expected.setDisplayName("changed");
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().scopes().update(previousName, expected);
    assertAlertSuccess();
    assertScope(expected);
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation) Test(org.junit.Test)

Example 45 with ScopeRepresentation

use of org.keycloak.representations.idm.authorization.ScopeRepresentation in project keycloak by keycloak.

the class ScopeManagementTest method testDelete.

@Test
public void testDelete() {
    ScopeRepresentation expected = createScope();
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().scopes().delete(expected.getName());
    authorizationPage.navigateTo();
    assertNull(authorizationPage.authorizationTabs().scopes().scopes().findByName(expected.getName()));
}
Also used : ScopeRepresentation(org.keycloak.representations.idm.authorization.ScopeRepresentation) Test(org.junit.Test)

Aggregations

ScopeRepresentation (org.keycloak.representations.idm.authorization.ScopeRepresentation)48 ResourceRepresentation (org.keycloak.representations.idm.authorization.ResourceRepresentation)27 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)14 List (java.util.List)12 Response (javax.ws.rs.core.Response)11 HashSet (java.util.HashSet)10 AuthorizationResource (org.keycloak.admin.client.resource.AuthorizationResource)10 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Set (java.util.Set)8 AuthzClient (org.keycloak.authorization.client.AuthzClient)8 Arrays (java.util.Arrays)7 AuthorizationRequest (org.keycloak.representations.idm.authorization.AuthorizationRequest)7 PolicyRepresentation (org.keycloak.representations.idm.authorization.PolicyRepresentation)7 Collection (java.util.Collection)6 Collectors (java.util.stream.Collectors)6 ResourceScopesResource (org.keycloak.admin.client.resource.ResourceScopesResource)5 HttpResponseException (org.keycloak.authorization.client.util.HttpResponseException)5 WebElement (org.openqa.selenium.WebElement)5