Search in sources :

Example 1 with ManagementPermissionRepresentation

use of org.keycloak.representations.idm.ManagementPermissionRepresentation in project keycloak by keycloak.

the class UsersTest method createGroupWithPermissions.

private GroupRepresentation createGroupWithPermissions(String name) {
    GroupRepresentation grp = new GroupRepresentation();
    grp.setName(name);
    realm.groups().add(grp);
    Optional<GroupRepresentation> optional = realm.groups().groups().stream().filter(g -> g.getName().equals(name)).findFirst();
    assertThat(optional.isPresent(), is(true));
    grp = optional.get();
    String id = grp.getId();
    // enable the permissions
    realm.groups().group(id).setPermissions(new ManagementPermissionRepresentation(true));
    assertThat(realm.groups().group(id).getPermissions().isEnabled(), is(true));
    return grp;
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Profile(org.keycloak.common.Profile) Matchers.not(org.hamcrest.Matchers.not) AuthorizationResource(org.keycloak.admin.client.resource.AuthorizationResource) GroupRepresentation(org.keycloak.representations.idm.GroupRepresentation) KeyStoreException(java.security.KeyStoreException) PolicyRepresentation(org.keycloak.representations.idm.authorization.PolicyRepresentation) ArrayList(java.util.ArrayList) ManagementPermissionRepresentation(org.keycloak.representations.idm.ManagementPermissionRepresentation) AdminClientUtil(org.keycloak.testsuite.util.AdminClientUtil) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) RoleRepresentation(org.keycloak.representations.idm.RoleRepresentation) ProfileAssume(org.keycloak.testsuite.ProfileAssume) Before(org.junit.Before) Matchers.empty(org.hamcrest.Matchers.empty) UserRepresentation(org.keycloak.representations.idm.UserRepresentation) RealmResource(org.keycloak.admin.client.resource.RealmResource) ScopePermissionRepresentation(org.keycloak.representations.idm.authorization.ScopePermissionRepresentation) Test(org.junit.Test) IOException(java.io.IOException) DecisionStrategy(org.keycloak.representations.idm.authorization.DecisionStrategy) KeyManagementException(java.security.KeyManagementException) CertificateException(java.security.cert.CertificateException) Keycloak(org.keycloak.admin.client.Keycloak) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation) UserPolicyRepresentation(org.keycloak.representations.idm.authorization.UserPolicyRepresentation) List(java.util.List) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Optional(java.util.Optional) Collections(java.util.Collections) GroupRepresentation(org.keycloak.representations.idm.GroupRepresentation) ManagementPermissionRepresentation(org.keycloak.representations.idm.ManagementPermissionRepresentation)

Aggregations

IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.empty (org.hamcrest.Matchers.empty)1 Matchers.not (org.hamcrest.Matchers.not)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Keycloak (org.keycloak.admin.client.Keycloak)1 AuthorizationResource (org.keycloak.admin.client.resource.AuthorizationResource)1 RealmResource (org.keycloak.admin.client.resource.RealmResource)1 Profile (org.keycloak.common.Profile)1 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)1