Search in sources :

Example 51 with AuthenticatorConfigRepresentation

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

the class AuthenticatorConfigTest method testUpdateConfig.

@Test
public void testUpdateConfig() {
    AuthenticatorConfigRepresentation cfg = newConfig("foo", IdpCreateUserIfUniqueAuthenticatorFactory.REQUIRE_PASSWORD_UPDATE_AFTER_REGISTRATION, "true");
    String cfgId = createConfig(executionId, cfg);
    AuthenticatorConfigRepresentation cfgRep = authMgmtResource.getAuthenticatorConfig(cfgId);
    // Try to update not existent config
    try {
        authMgmtResource.updateAuthenticatorConfig("not-existent", cfgRep);
        Assert.fail("Config didn't found");
    } catch (NotFoundException nfe) {
    // Expected
    }
    // Assert nothing changed
    cfgRep = authMgmtResource.getAuthenticatorConfig(cfgId);
    assertConfig(cfgRep, cfgId, "foo", IdpCreateUserIfUniqueAuthenticatorFactory.REQUIRE_PASSWORD_UPDATE_AFTER_REGISTRATION, "true");
    // Update success
    cfgRep.setAlias("foo2");
    cfgRep.getConfig().put("configKey2", "configValue2");
    authMgmtResource.updateAuthenticatorConfig(cfgRep.getId(), cfgRep);
    assertAdminEvents.assertEvent(REALM_NAME, OperationType.UPDATE, AdminEventPaths.authExecutionConfigPath(cfgId), cfgRep, ResourceType.AUTHENTICATOR_CONFIG);
    // Assert updated
    cfgRep = authMgmtResource.getAuthenticatorConfig(cfgRep.getId());
    assertConfig(cfgRep, cfgId, "foo2", IdpCreateUserIfUniqueAuthenticatorFactory.REQUIRE_PASSWORD_UPDATE_AFTER_REGISTRATION, "true", "configKey2", "configValue2");
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) AuthenticatorConfigRepresentation(org.keycloak.representations.idm.AuthenticatorConfigRepresentation) Test(org.junit.Test)

Example 52 with AuthenticatorConfigRepresentation

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

the class AuthenticatorConfigTest method newConfig.

private AuthenticatorConfigRepresentation newConfig(String alias, String cfgKey, String cfgValue) {
    AuthenticatorConfigRepresentation cfg = new AuthenticatorConfigRepresentation();
    cfg.setAlias(alias);
    Map<String, String> cfgMap = new HashMap<>();
    cfgMap.put(cfgKey, cfgValue);
    cfg.setConfig(cfgMap);
    return cfg;
}
Also used : HashMap(java.util.HashMap) AuthenticatorConfigRepresentation(org.keycloak.representations.idm.AuthenticatorConfigRepresentation)

Example 53 with AuthenticatorConfigRepresentation

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

the class ScriptAuthenticatorTest method createScriptAuthConfig.

private AuthenticatorConfigRepresentation createScriptAuthConfig(String alias, String scriptName, String script, String scriptDescription) {
    AuthenticatorConfigRepresentation configRep = new AuthenticatorConfigRepresentation();
    configRep.setAlias(alias);
    configRep.getConfig().put("scriptCode", script);
    configRep.getConfig().put("scriptName", scriptName);
    configRep.getConfig().put("scriptDescription", scriptDescription);
    return configRep;
}
Also used : AuthenticatorConfigRepresentation(org.keycloak.representations.idm.AuthenticatorConfigRepresentation)

Aggregations

AuthenticatorConfigRepresentation (org.keycloak.representations.idm.AuthenticatorConfigRepresentation)53 Test (org.junit.Test)43 Matchers.containsString (org.hamcrest.Matchers.containsString)36 X509AuthenticatorConfigModel (org.keycloak.authentication.authenticators.x509.X509AuthenticatorConfigModel)24 OAuthClient (org.keycloak.testsuite.util.OAuthClient)18 Response (javax.ws.rs.core.Response)7 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)6 HashMap (java.util.HashMap)5 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)4 AuthenticationExecutionInfoRepresentation (org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation)4 AuthenticationFlowRepresentation (org.keycloak.representations.idm.AuthenticationFlowRepresentation)4 AssertEvents (org.keycloak.testsuite.AssertEvents)4 NotFoundException (javax.ws.rs.NotFoundException)2 LinkedHashMap (java.util.LinkedHashMap)1 Ignore (org.junit.Ignore)1 AuthenticationManagementResource (org.keycloak.admin.client.resource.AuthenticationManagementResource)1 RealmResource (org.keycloak.admin.client.resource.RealmResource)1 MultivaluedHashMap (org.keycloak.common.util.MultivaluedHashMap)1 AuthenticationExecutionModel (org.keycloak.models.AuthenticationExecutionModel)1 AuthenticationFlowModel (org.keycloak.models.AuthenticationFlowModel)1