Search in sources :

Example 66 with RealmResource

use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.

the class AbstractMigrationTest method testRequiredActionsPriority.

private void testRequiredActionsPriority(RealmResource... realms) {
    log.info("testing required action's priority");
    for (RealmResource realm : realms) {
        log.info("Taking required actions from realm: " + realm.toRepresentation().getRealm());
        List<RequiredActionProviderRepresentation> actions = realm.flows().getRequiredActions();
        // Checking the priority
        int priority = 10;
        for (RequiredActionProviderRepresentation action : actions) {
            if (action.getAlias().equals("update_user_locale")) {
                assertEquals(1000, action.getPriority());
            } else {
                assertEquals(priority, action.getPriority());
            }
            priority += 10;
        }
    }
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation) RealmResource(org.keycloak.admin.client.resource.RealmResource)

Example 67 with RealmResource

use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.

the class AbstractMigrationTest method testDuplicateEmailSupport.

protected void testDuplicateEmailSupport(RealmResource... realms) {
    log.info("testing duplicate email");
    for (RealmResource realm : realms) {
        RealmRepresentation rep = realm.toRepresentation();
        assertTrue("LoginWithEmailAllowed should be enabled.", rep.isLoginWithEmailAllowed());
        assertFalse("DuplicateEmailsAllowed should be disabled.", rep.isDuplicateEmailsAllowed());
    }
}
Also used : RealmResource(org.keycloak.admin.client.resource.RealmResource) RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation)

Example 68 with RealmResource

use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.

the class AbstractMigrationTest method testRoleManageAccountLinks.

protected void testRoleManageAccountLinks(RealmResource... realms) {
    log.info("testing role manage account links");
    for (RealmResource realm : realms) {
        List<ClientRepresentation> clients = realm.clients().findByClientId(ACCOUNT_MANAGEMENT_CLIENT_ID);
        if (!clients.isEmpty()) {
            String accountClientId = clients.get(0).getId();
            ClientResource accountClient = realm.clients().get(accountClientId);
            // the role should be presented, it'll throw javax.ws.rs.NotFoundException in case the role is not found
            accountClient.roles().get(MANAGE_ACCOUNT_LINKS).toRepresentation();
            Set<RoleRepresentation> roleComposites = accountClient.roles().get(MANAGE_ACCOUNT).getRoleComposites();
            boolean success = false;
            for (RoleRepresentation roleComposite : roleComposites) {
                if (roleComposite.getName().equals(MANAGE_ACCOUNT_LINKS)) {
                    success = true;
                }
            }
            if (!success) {
                fail("'manage-account' role of client 'account' should have composite role 'manage-account-links'.");
            }
        }
    }
}
Also used : RoleRepresentation(org.keycloak.representations.idm.RoleRepresentation) RealmResource(org.keycloak.admin.client.resource.RealmResource) ClientResource(org.keycloak.admin.client.resource.ClientResource) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation)

Example 69 with RealmResource

use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.

the class Creator method create.

public static Creator<RealmResource> create(Keycloak adminClient, RealmRepresentation rep) {
    adminClient.realms().create(rep);
    final RealmResource r = adminClient.realm(rep.getRealm());
    LOG.debugf("Created realm %s", rep.getRealm());
    return new Creator(rep.getRealm(), r, r::remove);
}
Also used : Logger(org.jboss.logging.Logger) RealmResource(org.keycloak.admin.client.resource.RealmResource)

Example 70 with RealmResource

use of org.keycloak.admin.client.resource.RealmResource in project keycloak by keycloak.

the class ClientAttributeUpdater method forClient.

/**
 * Creates a {@ClientAttributeUpdater} for the given client. The client must exist.
 * @param adminClient
 * @param realm
 * @param clientId
 * @return
 */
public static ClientAttributeUpdater forClient(Keycloak adminClient, String realm, String clientId) {
    RealmResource realmRes = adminClient.realm(realm);
    ClientsResource clients = realmRes.clients();
    List<ClientRepresentation> foundClients = clients.findByClientId(clientId);
    assertThat(foundClients, hasSize(1));
    ClientResource clientRes = clients.get(foundClients.get(0).getId());
    return new ClientAttributeUpdater(clientRes, realmRes);
}
Also used : RealmResource(org.keycloak.admin.client.resource.RealmResource) ClientsResource(org.keycloak.admin.client.resource.ClientsResource) ClientResource(org.keycloak.admin.client.resource.ClientResource) ClientRepresentation(org.keycloak.representations.idm.ClientRepresentation)

Aggregations

RealmResource (org.keycloak.admin.client.resource.RealmResource)263 Test (org.junit.Test)190 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)67 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)61 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)58 Response (javax.ws.rs.core.Response)55 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)48 ClientResource (org.keycloak.admin.client.resource.ClientResource)39 OAuthClient (org.keycloak.testsuite.util.OAuthClient)37 GroupRepresentation (org.keycloak.representations.idm.GroupRepresentation)36 RoleRepresentation (org.keycloak.representations.idm.RoleRepresentation)34 Before (org.junit.Before)31 UserResource (org.keycloak.admin.client.resource.UserResource)30 IdentityProviderRepresentation (org.keycloak.representations.idm.IdentityProviderRepresentation)25 List (java.util.List)19 LinkedList (java.util.LinkedList)16 ClientScopeRepresentation (org.keycloak.representations.idm.ClientScopeRepresentation)16 VerifyProfileTest (org.keycloak.testsuite.forms.VerifyProfileTest)14 ProtocolMapperRepresentation (org.keycloak.representations.idm.ProtocolMapperRepresentation)13 AccessToken (org.keycloak.representations.AccessToken)12