Search in sources :

Example 11 with AuthenticationExecutionRepresentation

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

the class ScriptAuthenticatorTest method configureFlows.

@Before
public void configureFlows() throws Exception {
    if (testContext.isInitialized()) {
        return;
    }
    String scriptFlow = "scriptBrowser";
    AuthenticationFlowRepresentation scriptBrowserFlow = FlowBuilder.create().alias(scriptFlow).description("dummy pass through registration").providerId("basic-flow").topLevel(true).builtIn(false).build();
    Response createFlowResponse = testRealm().flows().createFlow(scriptBrowserFlow);
    Assert.assertEquals(201, createFlowResponse.getStatus());
    RealmRepresentation realm = testRealm().toRepresentation();
    realm.setBrowserFlow(scriptFlow);
    realm.setDirectGrantFlow(scriptFlow);
    testRealm().update(realm);
    this.flow = findFlowByAlias(scriptFlow);
    AuthenticationExecutionRepresentation usernamePasswordFormExecution = ExecutionBuilder.create().id("username password form").parentFlow(this.flow.getId()).requirement(AuthenticationExecutionModel.Requirement.REQUIRED.name()).authenticator(UsernamePasswordFormFactory.PROVIDER_ID).build();
    AuthenticationExecutionRepresentation authScriptExecution = ExecutionBuilder.create().id(EXECUTION_ID).parentFlow(this.flow.getId()).requirement(AuthenticationExecutionModel.Requirement.REQUIRED.name()).authenticator(ScriptBasedAuthenticatorFactory.PROVIDER_ID).build();
    Response addExecutionResponse = testRealm().flows().addExecution(usernamePasswordFormExecution);
    Assert.assertEquals(201, addExecutionResponse.getStatus());
    addExecutionResponse.close();
    addExecutionResponse = testRealm().flows().addExecution(authScriptExecution);
    Assert.assertEquals(201, addExecutionResponse.getStatus());
    addExecutionResponse.close();
    testContext.setInitialized(true);
}
Also used : Response(javax.ws.rs.core.Response) RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation) AuthenticationExecutionRepresentation(org.keycloak.representations.idm.AuthenticationExecutionRepresentation) AuthenticationFlowRepresentation(org.keycloak.representations.idm.AuthenticationFlowRepresentation) Before(org.junit.Before)

Aggregations

AuthenticationExecutionRepresentation (org.keycloak.representations.idm.AuthenticationExecutionRepresentation)11 AuthenticationFlowRepresentation (org.keycloak.representations.idm.AuthenticationFlowRepresentation)8 Response (javax.ws.rs.core.Response)7 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)4 HashMap (java.util.HashMap)3 Before (org.junit.Before)3 Test (org.junit.Test)3 AuthenticationExecutionInfoRepresentation (org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation)3 RequiredActionProviderSimpleRepresentation (org.keycloak.representations.idm.RequiredActionProviderSimpleRepresentation)2 BadRequestException (javax.ws.rs.BadRequestException)1 AuthenticationManagementResource (org.keycloak.admin.client.resource.AuthenticationManagementResource)1 RealmResource (org.keycloak.admin.client.resource.RealmResource)1 AuthenticatorConfigRepresentation (org.keycloak.representations.idm.AuthenticatorConfigRepresentation)1 RequiredActionProviderRepresentation (org.keycloak.representations.idm.RequiredActionProviderRepresentation)1 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)1