Java Code Examples for org.keycloak.representations.idm.RealmRepresentation#setResetCredentialsFlow()

The following examples show how to use org.keycloak.representations.idm.RealmRepresentation#setResetCredentialsFlow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AltSubflowForCredentialResetTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void alternativeSubflowStaySignedOutTest() {
    configureAlternativeResetCredentialsFlow();
    try {
        loginPage.open();
        loginPage.resetPassword();
        Assert.assertTrue(loginPasswordResetPage.isCurrent());
        loginPasswordResetPage.changePassword("[email protected]");
        Assert.assertTrue(loginPage.isCurrent());
        assertEquals("You should receive an email shortly with further instructions.", loginUsernameOnlyPage.getSuccessMessage());
        loginPage.open();
        Assert.assertTrue(loginPage.isCurrent());
    } finally {
        testRealm().flows().getFlows().clear();
        RealmRepresentation realm = testRealm().toRepresentation();
        realm.setResetCredentialsFlow(DefaultAuthenticationFlows.RESET_CREDENTIALS_FLOW);
        testRealm().update(realm);
    }
}
 
Example 2
Source File: ResetCredentialsAlternativeFlowsTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void revertFlows() {
    List<AuthenticationFlowRepresentation> flows = testRealm().flows().getFlows();

    // Set default flows
    RealmRepresentation realm = testRealm().toRepresentation();
    realm.setBrowserFlow(DefaultAuthenticationFlows.BROWSER_FLOW);
    realm.setResetCredentialsFlow(DefaultAuthenticationFlows.RESET_CREDENTIALS_FLOW);
    testRealm().update(realm);

    // Delete flows previously created within various tests
    final List<String> aliasesOfExistingFlows = Arrays.asList(
            "browser - alternative",
            "resetcred - alternative",
            "resetcred - KEYCLOAK-11753 - test"
    );

    for(String existingFlowAlias : aliasesOfExistingFlows) {
        AuthenticationFlowRepresentation flowRepresentation = AbstractAuthenticationTest.findFlowByAlias(existingFlowAlias, flows);
        if (flowRepresentation != null) {
            testRealm().flows().deleteFlow(flowRepresentation.getId());
        }
    }
}
 
Example 3
Source File: UsedAuthenticationFlowWorkaroundFactory.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
private void disableResetCredentialsFlow(RealmRepresentation existingRealm) {
    String otherFlowAlias = searchTemporaryCreatedTopLevelFlowForReplacement();

    resetCredentialsFlow = existingRealm.getResetCredentialsFlow();

    existingRealm.setResetCredentialsFlow(otherFlowAlias);
    realmRepository.update(existingRealm);
}
 
Example 4
Source File: UsedAuthenticationFlowWorkaroundFactory.java    From keycloak-config-cli with Apache License 2.0 5 votes vote down vote up
private void resetCredentialsFlowIfNeeded(RealmRepresentation existingRealm) {
    if (Strings.isNotBlank(resetCredentialsFlow)) {
        logger.debug("Reset reset-credentials-flow in realm '{}' to '{}'", realmImport.getRealm(), resetCredentialsFlow);

        existingRealm.setResetCredentialsFlow(resetCredentialsFlow);
    }
}
 
Example 5
Source File: AltSubflowForCredentialResetTest.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private RealmRepresentation loadTestRealm() {
    RealmRepresentation res = loadJson(getClass().getResourceAsStream("/testrealm.json"), RealmRepresentation.class);
    res.setResetCredentialsFlow(DefaultAuthenticationFlows.RESET_CREDENTIALS_FLOW);
    return res;
}