Search in sources :

Example 1 with Creator

use of org.keycloak.testsuite.updaters.Creator in project keycloak by keycloak.

the class AdminConsolePermissionsCalculatedTest method changeRealmTokenAlgorithm.

@Test
public void changeRealmTokenAlgorithm() throws Exception {
    try (Keycloak adminClient = AdminClientUtil.createAdminClient(suiteContext.isAdapterCompatTesting(), suiteContext.getAuthServerInfo().getContextRoot().toString());
        Creator c = Creator.create(adminClient, RealmBuilder.create().name(REALM_NAME).build())) {
        AccessTokenResponse accessToken = adminClient.tokenManager().getAccessToken();
        assertNotNull(adminClient.realms().findAll());
        String whoAmiUrl = suiteContext.getAuthServerInfo().getContextRoot().toString() + "/auth/admin/master/console/whoami";
        JsonNode jsonNode = SimpleHttp.doGet(whoAmiUrl, client).auth(accessToken.getToken()).asJson();
        assertTrue("Permissions for " + Config.getAdminRealm() + " realm.", jsonNode.at("/realm_access/" + Config.getAdminRealm()).isArray());
        assertTrue("Permissions for " + REALM_NAME + " realm.", jsonNode.at("/realm_access/" + REALM_NAME).isArray());
    }
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Creator(org.keycloak.testsuite.updaters.Creator) Keycloak(org.keycloak.admin.client.Keycloak) AccessTokenResponse(org.keycloak.representations.AccessTokenResponse) Test(org.junit.Test) AbstractKeycloakTest(org.keycloak.testsuite.AbstractKeycloakTest)

Example 2 with Creator

use of org.keycloak.testsuite.updaters.Creator in project keycloak by keycloak.

the class LDAPSamlIdPInitiatedVaryingLetterCaseTest method setupIdentityProvider.

@Before
public void setupIdentityProvider() {
    // Configure autolink flow
    AuthenticationFlowRepresentation newFlow = new AuthenticationFlowRepresentation();
    newFlow.setAlias(FLOW_AUTO_LINK);
    newFlow.setDescription("Auto-link flow");
    newFlow.setProviderId("basic-flow");
    newFlow.setBuiltIn(false);
    newFlow.setTopLevel(true);
    Creator.Flow amr = Creator.create(testRealm(), newFlow);
    AuthenticationExecutionInfoRepresentation exCreateUser = amr.addExecution(IdpCreateUserIfUniqueAuthenticatorFactory.PROVIDER_ID);
    exCreateUser.setRequirement(Requirement.ALTERNATIVE.name());
    testRealm().flows().updateExecutions(FLOW_AUTO_LINK, exCreateUser);
    AuthenticationExecutionInfoRepresentation exAutoLink = amr.addExecution(IdpAutoLinkAuthenticatorFactory.PROVIDER_ID);
    exAutoLink.setRequirement(Requirement.ALTERNATIVE.name());
    testRealm().flows().updateExecutions(FLOW_AUTO_LINK, exAutoLink);
    getCleanup().addCleanup(amr);
    // Configure identity provider
    IdentityProviderRepresentation idp = KcSamlBrokerConfiguration.INSTANCE.setUpIdentityProvider();
    idp.getConfig().put(SAMLIdentityProviderConfig.NAME_ID_POLICY_FORMAT, JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.get());
    idp.setFirstBrokerLoginFlowAlias(FLOW_AUTO_LINK);
    final Creator<IdentityProviderResource> idpCreator = Creator.create(testRealm(), idp);
    IdentityProviderMapperRepresentation samlNameIdMapper = new IdentityProviderMapperRepresentation();
    samlNameIdMapper.setName("username-nameid-mapper");
    idpAlias = idp.getAlias();
    samlNameIdMapper.setIdentityProviderAlias(idpAlias);
    samlNameIdMapper.setIdentityProviderMapper(UsernameTemplateMapper.PROVIDER_ID);
    samlNameIdMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, "IMPORT").put(UsernameTemplateMapper.TEMPLATE, "${NAMEID | lowercase}").put(UsernameTemplateMapper.TARGET, Target.BROKER_ID.name()).build());
    idpCreator.resource().addMapper(samlNameIdMapper);
    getCleanup().addCleanup(idpCreator);
}
Also used : IdentityProviderMapperRepresentation(org.keycloak.representations.idm.IdentityProviderMapperRepresentation) IdentityProviderResource(org.keycloak.admin.client.resource.IdentityProviderResource) AuthenticationFlowRepresentation(org.keycloak.representations.idm.AuthenticationFlowRepresentation) AuthenticationExecutionInfoRepresentation(org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation) IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation) Creator(org.keycloak.testsuite.updaters.Creator) Before(org.junit.Before)

Aggregations

Creator (org.keycloak.testsuite.updaters.Creator)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Keycloak (org.keycloak.admin.client.Keycloak)1 IdentityProviderResource (org.keycloak.admin.client.resource.IdentityProviderResource)1 AccessTokenResponse (org.keycloak.representations.AccessTokenResponse)1 AuthenticationExecutionInfoRepresentation (org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation)1 AuthenticationFlowRepresentation (org.keycloak.representations.idm.AuthenticationFlowRepresentation)1 IdentityProviderMapperRepresentation (org.keycloak.representations.idm.IdentityProviderMapperRepresentation)1 IdentityProviderRepresentation (org.keycloak.representations.idm.IdentityProviderRepresentation)1 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)1