Search in sources :

Example 41 with ScopePermissionRepresentation

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

the class ScopePermissionManagementTest method testDelete.

@Test
public void testDelete() {
    authorizationPage.navigateTo();
    ScopePermissionRepresentation expected = new ScopePermissionRepresentation();
    expected.setName("testDelete Permission");
    expected.setDescription("description");
    expected.addScope("Scope C");
    expected.addPolicy("Policy C");
    expected = createPermission(expected);
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().permissions().delete(expected.getName());
    assertAlertSuccess();
    authorizationPage.navigateTo();
    assertNull(authorizationPage.authorizationTabs().permissions().permissions().findByName(expected.getName()));
}
Also used : ScopePermissionRepresentation(org.keycloak.representations.idm.authorization.ScopePermissionRepresentation) Test(org.junit.Test)

Example 42 with ScopePermissionRepresentation

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

the class ScopePermissionManagementTest method testCreateWithoutPolicies.

@Test
public void testCreateWithoutPolicies() {
    authorizationPage.navigateTo();
    ScopePermissionRepresentation expected = new ScopePermissionRepresentation();
    expected.setName("testCreateWithoutPolicies Permission");
    expected.setDescription("description");
    expected.addResource("Resource A");
    expected.addScope("Scope A");
    expected = createPermission(expected);
    authorizationPage.navigateTo();
    ScopePermission actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
    assertPolicy(expected, actual);
}
Also used : ScopePermission(org.keycloak.testsuite.console.page.clients.authorization.permission.ScopePermission) ScopePermissionRepresentation(org.keycloak.representations.idm.authorization.ScopePermissionRepresentation) Test(org.junit.Test)

Example 43 with ScopePermissionRepresentation

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

the class ScopePermissionManagementTest method testUpdateWithoutResource.

@Test
public void testUpdateWithoutResource() {
    authorizationPage.navigateTo();
    ScopePermissionRepresentation expected = new ScopePermissionRepresentation();
    expected.setName("testUpdateWithoutResource Permission");
    expected.setDescription("description");
    expected.addResource("Resource A");
    expected.addScope("Scope A");
    expected.addPolicy("Policy C");
    expected = createPermission(expected);
    expected.getResources().clear();
    expected.addScope("Scope B");
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().permissions().update(expected.getName(), expected);
    assertAlertSuccess();
    authorizationPage.navigateTo();
    ScopePermission actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
    assertPolicy(expected, actual);
}
Also used : ScopePermission(org.keycloak.testsuite.console.page.clients.authorization.permission.ScopePermission) ScopePermissionRepresentation(org.keycloak.representations.idm.authorization.ScopePermissionRepresentation) Test(org.junit.Test)

Aggregations

ScopePermissionRepresentation (org.keycloak.representations.idm.authorization.ScopePermissionRepresentation)43 Test (org.junit.Test)32 AuthorizationResource (org.keycloak.admin.client.resource.AuthorizationResource)23 AuthorizationResponse (org.keycloak.representations.idm.authorization.AuthorizationResponse)17 AuthzClient (org.keycloak.authorization.client.AuthzClient)16 JSPolicyRepresentation (org.keycloak.representations.idm.authorization.JSPolicyRepresentation)16 ResourceRepresentation (org.keycloak.representations.idm.authorization.ResourceRepresentation)16 ClientResource (org.keycloak.admin.client.resource.ClientResource)15 AuthorizationRequest (org.keycloak.representations.idm.authorization.AuthorizationRequest)15 Permission (org.keycloak.representations.idm.authorization.Permission)14 Response (javax.ws.rs.core.Response)13 OAuthClient (org.keycloak.testsuite.util.OAuthClient)13 PermissionResponse (org.keycloak.representations.idm.authorization.PermissionResponse)11 TokenIntrospectionResponse (org.keycloak.authorization.client.representation.TokenIntrospectionResponse)10 AccessTokenResponse (org.keycloak.representations.AccessTokenResponse)10 HttpResponseException (org.keycloak.authorization.client.util.HttpResponseException)7 ResourcePermissionRepresentation (org.keycloak.representations.idm.authorization.ResourcePermissionRepresentation)7 ScopePermissionsResource (org.keycloak.admin.client.resource.ScopePermissionsResource)6 ScopePermission (org.keycloak.testsuite.console.page.clients.authorization.permission.ScopePermission)5 ArrayList (java.util.ArrayList)4