use of org.keycloak.representations.idm.authorization.ScopePermissionRepresentation in project keycloak by keycloak.
the class ScopePermissionManagementTest method testUpdateScopeOnly.
@Test
public void testUpdateScopeOnly() {
authorizationPage.navigateTo();
ScopePermissionRepresentation expected = new ScopePermissionRepresentation();
expected.setName("testUpdateScopeOnly Permission");
expected.setDescription("description");
expected.addScope("Scope C", "Scope A", "Scope B");
expected.addPolicy("Policy C", "Policy A", "Policy B");
expected = createPermission(expected);
String previousName = expected.getName();
expected.setName(previousName + "Changed");
expected.setDescription("changed");
expected.setDecisionStrategy(DecisionStrategy.CONSENSUS);
expected.getScopes().clear();
expected.addScope("Scope B");
expected.getPolicies().clear();
expected.addPolicy("Policy C");
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().permissions().update(previousName, expected);
assertAlertSuccess();
authorizationPage.navigateTo();
ScopePermission actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
}
use of org.keycloak.representations.idm.authorization.ScopePermissionRepresentation in project keycloak by keycloak.
the class ScopePermissionManagementTest method testCreateUpdateWithChild.
@Test
public void testCreateUpdateWithChild() {
ScopePermissionRepresentation expected = new ScopePermissionRepresentation();
expected.setName(UUID.randomUUID().toString());
expected.setDescription("description");
expected.addScope("Scope C");
expected.addPolicy("Policy C");
ScopePermission policy = authorizationPage.authorizationTabs().permissions().create(expected, false);
RolePolicyRepresentation childPolicy = new RolePolicyRepresentation();
childPolicy.setName(UUID.randomUUID().toString());
childPolicy.addRole("Role A");
policy.createPolicy(childPolicy);
policy.form().save();
assertAlertSuccess();
expected.addPolicy(childPolicy.getName());
authorizationPage.navigateTo();
ScopePermission actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
RolePolicyRepresentation childPolicy2 = new RolePolicyRepresentation();
childPolicy2.setName(UUID.randomUUID().toString());
childPolicy2.addRole("Role A");
policy.createPolicy(childPolicy2);
policy.form().save();
assertAlertSuccess();
expected.addPolicy(childPolicy2.getName());
authorizationPage.navigateTo();
actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
expected.addResource("Resource B");
expected.getScopes().clear();
expected.addScope("Scope B", "Scope C");
expected.getScopes().remove("Policy C");
RolePolicyRepresentation childPolicy3 = new RolePolicyRepresentation();
childPolicy3.setName(UUID.randomUUID().toString());
childPolicy3.addRole("Role A");
policy.update(expected, false);
policy.createPolicy(childPolicy3);
policy.form().save();
assertAlertSuccess();
expected.addPolicy(childPolicy3.getName());
authorizationPage.navigateTo();
actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
}
use of org.keycloak.representations.idm.authorization.ScopePermissionRepresentation in project keycloak by keycloak.
the class ScopePermissionManagementTest method testDeleteFromList.
@Test
public void testDeleteFromList() {
authorizationPage.navigateTo();
ScopePermissionRepresentation expected = new ScopePermissionRepresentation();
expected.setName("testDeleteFromList Permission");
expected.setDescription("description");
expected.addScope("Scope C");
expected.addPolicy("Policy C");
expected = createPermission(expected);
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().permissions().deleteFromList(expected.getName());
authorizationPage.navigateTo();
assertNull(authorizationPage.authorizationTabs().permissions().permissions().findByName(expected.getName()));
}
use of org.keycloak.representations.idm.authorization.ScopePermissionRepresentation in project keycloak by keycloak.
the class ScopePermissionForm method toRepresentation.
public ScopePermissionRepresentation toRepresentation() {
ScopePermissionRepresentation representation = new ScopePermissionRepresentation();
representation.setName(UIUtils.getTextInputValue(name));
representation.setDescription(UIUtils.getTextInputValue(description));
representation.setDecisionStrategy(DecisionStrategy.valueOf(UIUtils.getTextFromElement(decisionStrategy.getFirstSelectedOption()).toUpperCase()));
representation.setPolicies(policySelect.getSelected());
representation.setResources(resourceSelect.getSelected());
representation.setScopes(scopeSelect.getSelected());
representation.getScopes().addAll(resourceScopeSelect.getSelected());
return representation;
}
use of org.keycloak.representations.idm.authorization.ScopePermissionRepresentation in project keycloak by keycloak.
the class ScopePolicyProviderFactory method toRepresentation.
@Override
public ScopePermissionRepresentation toRepresentation(Policy policy, AuthorizationProvider authorization) {
ScopePermissionRepresentation representation = new ScopePermissionRepresentation();
representation.setResourceType(policy.getConfig().get("defaultResourceType"));
return representation;
}
Aggregations