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;
}
}
}
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());
}
}
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'.");
}
}
}
}
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);
}
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);
}
Aggregations