use of org.keycloak.admin.client.resource.ResourcesResource in project keycloak by keycloak.
the class ResourceManagementTest method doUpdateResource.
protected ResourceRepresentation doUpdateResource(ResourceRepresentation resource) {
ResourcesResource resources = getClientResource().authorization().resources();
ResourceResource existing = resources.resource(resource.getId());
existing.update(resource);
return resources.resource(resource.getId()).toRepresentation();
}
use of org.keycloak.admin.client.resource.ResourcesResource in project keycloak by keycloak.
the class AbstractServletAuthzAdapterTest method testCanNotAccessWhenEnforcing.
@Test
public void testCanNotAccessWhenEnforcing() throws Exception {
performTests(() -> {
importResourceServerSettings();
ResourcesResource resources = getAuthorizationResource().resources();
ResourceRepresentation resource = resources.findByName("Protected Resource").get(0);
resource.setUri("/index.jsp");
resources.resource(resource.getId()).update(resource);
}, () -> {
login("jdoe", "jdoe");
driver.navigate().to(getResourceServerUrl().toString() + "/enforcing/resource");
assertWasDenied();
});
}
use of org.keycloak.admin.client.resource.ResourcesResource in project keycloak by keycloak.
the class AuthorizationTest method onAfter.
@After
public void onAfter() {
ResourcesResource resources = getClient().authorization().resources();
List<ResourceRepresentation> existingResources = resources.resources();
for (ResourceRepresentation resource : existingResources) {
resources.resource(resource.getId()).remove();
}
}
use of org.keycloak.admin.client.resource.ResourcesResource in project keycloak by keycloak.
the class ScopePermissionManagementTest method configureTest.
@Before
public void configureTest() {
super.configureTest();
RolesResource realmRoles = testRealmResource().roles();
realmRoles.create(new RoleRepresentation("Role A", "", false));
realmRoles.create(new RoleRepresentation("Role B", "", false));
RolePolicyRepresentation policyA = new RolePolicyRepresentation();
policyA.setName("Policy A");
policyA.addRole("Role A");
AuthorizationResource authorization = testRealmResource().clients().get(newClient.getId()).authorization();
PoliciesResource policies = authorization.policies();
RolePoliciesResource roles = policies.role();
roles.create(policyA);
RolePolicyRepresentation policyB = new RolePolicyRepresentation();
policyB.setName("Policy B");
policyB.addRole("Role B");
roles.create(policyB);
UserPolicyRepresentation policyC = new UserPolicyRepresentation();
policyC.setName("Policy C");
policyC.addUser("test");
policies.user().create(policyC).close();
authorization.scopes().create(new ScopeRepresentation("Scope A"));
authorization.scopes().create(new ScopeRepresentation("Scope B"));
authorization.scopes().create(new ScopeRepresentation("Scope C"));
ResourcesResource resources = authorization.resources();
resources.create(new ResourceRepresentation("Resource A", "Scope A"));
resources.create(new ResourceRepresentation("Resource B", "Scope B", "Scope C"));
}
use of org.keycloak.admin.client.resource.ResourcesResource in project keycloak by keycloak.
the class ResourceManagementTest method doRemoveResource.
protected void doRemoveResource(ResourceRepresentation resource) {
ResourcesResource resources = getClientResource().authorization().resources();
resources.resource(resource.getId()).remove();
}
Aggregations