use of org.keycloak.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.
the class ShiftRequiredActionTest method testShiftRequiredAction.
@Test
public void testShiftRequiredAction() {
// get action
List<RequiredActionProviderRepresentation> actions = authMgmtResource.getRequiredActions();
RequiredActionProviderRepresentation last = actions.get(actions.size() - 1);
RequiredActionProviderRepresentation oneButLast = actions.get(actions.size() - 2);
// Not possible to raisePriority of not-existent required action
try {
authMgmtResource.raisePriority("not-existent");
Assert.fail("Not expected to raise priority of not existent required action");
} catch (NotFoundException nfe) {
// Expected
}
// shift last required action up
authMgmtResource.raiseRequiredActionPriority(last.getAlias());
assertAdminEvents.assertEvent(REALM_NAME, OperationType.UPDATE, AdminEventPaths.authRaiseRequiredActionPath(last.getAlias()), ResourceType.REQUIRED_ACTION);
List<RequiredActionProviderRepresentation> actions2 = authMgmtResource.getRequiredActions();
RequiredActionProviderRepresentation last2 = actions2.get(actions.size() - 1);
RequiredActionProviderRepresentation oneButLast2 = actions2.get(actions.size() - 2);
Assert.assertEquals("Required action shifted up - N", last.getAlias(), oneButLast2.getAlias());
Assert.assertEquals("Required action up - N-1", oneButLast.getAlias(), last2.getAlias());
// Not possible to lowerPriority of not-existent required action
try {
authMgmtResource.lowerRequiredActionPriority("not-existent");
Assert.fail("Not expected to raise priority of not existent required action");
} catch (NotFoundException nfe) {
// Expected
}
// shift one before last down
authMgmtResource.lowerRequiredActionPriority(oneButLast2.getAlias());
assertAdminEvents.assertEvent(REALM_NAME, OperationType.UPDATE, AdminEventPaths.authLowerRequiredActionPath(oneButLast2.getAlias()), ResourceType.REQUIRED_ACTION);
actions2 = authMgmtResource.getRequiredActions();
last2 = actions2.get(actions.size() - 1);
oneButLast2 = actions2.get(actions.size() - 2);
Assert.assertEquals("Required action shifted down - N", last.getAlias(), last2.getAlias());
Assert.assertEquals("Required action shifted down - N-1", oneButLast.getAlias(), oneButLast2.getAlias());
}
use of org.keycloak.representations.idm.RequiredActionProviderRepresentation 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.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.
the class AbstractMigrationTest method testUserLocaleActionAdded.
protected void testUserLocaleActionAdded(RealmResource realm) {
RequiredActionProviderRepresentation rep = realm.flows().getRequiredAction("update_user_locale");
assertNotNull(rep);
assertEquals("update_user_locale", rep.getAlias());
assertEquals("update_user_locale", rep.getProviderId());
assertEquals("Update User Locale", rep.getName());
assertEquals(1000, rep.getPriority());
assertTrue(rep.isEnabled());
assertFalse(rep.isDefaultAction());
}
use of org.keycloak.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.
the class DeleteAccountActionTest method setUpAction.
@Before
public void setUpAction() {
UserRepresentation user = ActionUtil.findUserWithAdminClient(adminClient, "test-user@localhost");
UserBuilder.edit(user).requiredAction(DeleteAccount.PROVIDER_ID);
testRealm().users().get(user.getId()).update(user);
addDeleteAccountRoleToUserClientRoles();
RequiredActionProviderRepresentation rep = testRealm().flows().getRequiredAction(DeleteAccount.PROVIDER_ID);
rep.setEnabled(true);
adminClient.realm("test").flows().updateRequiredAction(DeleteAccount.PROVIDER_ID, rep);
}
use of org.keycloak.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.
the class TermsAndConditionsTest method addTermsAndConditionRequiredAction.
@Before
public void addTermsAndConditionRequiredAction() {
UserRepresentation user = ActionUtil.findUserWithAdminClient(adminClient, "test-user@localhost");
UserBuilder.edit(user).requiredAction(TermsAndConditions.PROVIDER_ID);
adminClient.realm("test").users().get(user.getId()).update(user);
RequiredActionProviderRepresentation rep = adminClient.realm("test").flows().getRequiredAction("terms_and_conditions");
rep.setEnabled(true);
adminClient.realm("test").flows().updateRequiredAction("terms_and_conditions", rep);
}
Aggregations