Search in sources :

Example 6 with IdentityProviderRepresentation

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

the class AbstractAdvancedBrokerTest method testLogoutWorksWithTokenTimeout.

/**
 * Refers to in old testsuite: org.keycloak.testsuite.broker.OIDCKeyCloakServerBrokerBasicTest#testLogoutWorksWithTokenTimeout()
 */
@Test
public void testLogoutWorksWithTokenTimeout() {
    try {
        updateExecutions(AbstractBrokerTest::enableUpdateProfileOnFirstLogin);
        RealmRepresentation realm = adminClient.realm(bc.providerRealmName()).toRepresentation();
        assertNotNull(realm);
        realm.setAccessTokenLifespan(1);
        adminClient.realm(bc.providerRealmName()).update(realm);
        IdentityProviderRepresentation idp = adminClient.realm(bc.consumerRealmName()).identityProviders().get(bc.getIDPAlias()).toRepresentation();
        idp.getConfig().put("backchannelSupported", "false");
        adminClient.realm(bc.consumerRealmName()).identityProviders().get(bc.getIDPAlias()).update(idp);
        Time.setOffset(2);
        driver.navigate().to(getAccountUrl(getConsumerRoot(), bc.consumerRealmName()));
        logInWithBroker(bc);
        waitForPage(driver, "update account information", false);
        updateAccountInformationPage.assertCurrent();
        updateAccountInformationPage.updateAccountInformation("FirstName", "LastName");
        accountPage.logOut();
        waitForPage(driver, "sign in to", true);
        log.debug("Logging in");
        assertTrue(this.driver.getCurrentUrl().contains("/auth/realms/" + bc.consumerRealmName() + "/protocol/openid-connect/auth"));
    } finally {
        Time.setOffset(0);
    }
}
Also used : RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation) IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation) Test(org.junit.Test)

Example 7 with IdentityProviderRepresentation

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

the class AbstractIdentityProviderMapperTest method setupIdentityProviderDisableUserInfo.

protected IdentityProviderRepresentation setupIdentityProviderDisableUserInfo() {
    log.debug("adding identity provider to realm " + bc.consumerRealmName());
    final IdentityProviderRepresentation idp = bc.setUpIdentityProvider();
    idp.getConfig().put("disableUserInfo", "true");
    realm.identityProviders().create(idp).close();
    return idp;
}
Also used : IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation)

Example 8 with IdentityProviderRepresentation

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

the class AbstractAdvancedGroupMapperTest method createAdvancedGroupMapper.

protected void createAdvancedGroupMapper(String claimsOrAttributeRepresentation, boolean areClaimsOrAttributeValuesRegexes) {
    IdentityProviderRepresentation idp = setupIdentityProvider();
    createMapperInIdp(idp, claimsOrAttributeRepresentation, areClaimsOrAttributeValuesRegexes, IMPORT);
}
Also used : IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation)

Example 9 with IdentityProviderRepresentation

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

the class HardcodedUserAttributeMapperTest method addHardcodedAttributeOnFirstLogin.

@Test
public void addHardcodedAttributeOnFirstLogin() {
    final IdentityProviderRepresentation idp = setupIdentityProvider();
    createMapperInIdp(idp, IMPORT);
    createUserInProviderRealm();
    logInAsUserInIDPForFirstTime();
    UserRepresentation user = findUser(bc.consumerRealmName(), bc.getUserLogin(), bc.getUserEmail());
    assertThatAttributeHasBeenAssigned(user);
}
Also used : IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation) UserRepresentation(org.keycloak.representations.idm.UserRepresentation) Test(org.junit.Test)

Example 10 with IdentityProviderRepresentation

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

the class KcOIDCBrokerWithSignatureTest method testSignatureVerificationHardcodedPublicKey.

@Test
public void testSignatureVerificationHardcodedPublicKey() throws Exception {
    // Configure OIDC identity provider with JWKS URL
    IdentityProviderRepresentation idpRep = getIdentityProvider();
    OIDCIdentityProviderConfigRep cfg = new OIDCIdentityProviderConfigRep(idpRep);
    cfg.setValidateSignature(true);
    cfg.setUseJwksUrl(false);
    KeysMetadataRepresentation.KeyMetadataRepresentation key = ApiUtil.findActiveSigningKey(providerRealm());
    cfg.setPublicKeySignatureVerifier(key.getPublicKey());
    updateIdentityProvider(idpRep);
    // Check that user is able to login
    logInAsUserInIDPForFirstTime();
    assertLoggedInAccountManagement();
    logoutFromRealm(getConsumerRoot(), bc.consumerRealmName());
    // Rotate public keys on the parent broker
    rotateKeys();
    // User not able to login now as new keys can't be yet downloaded (10s timeout)
    logInAsUserInIDP();
    assertErrorPage("Unexpected error when authenticating with identity provider");
    logoutFromRealm(getConsumerRoot(), bc.consumerRealmName());
    // Even after time offset is user not able to login, because it uses old key hardcoded in identityProvider config
    setTimeOffset(20);
    logInAsUserInIDPWithReAuthenticate();
    assertErrorPage("Unexpected error when authenticating with identity provider");
}
Also used : KeysMetadataRepresentation(org.keycloak.representations.idm.KeysMetadataRepresentation) IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation) Test(org.junit.Test)

Aggregations

IdentityProviderRepresentation (org.keycloak.representations.idm.IdentityProviderRepresentation)91 Test (org.junit.Test)45 IdentityProviderResource (org.keycloak.admin.client.resource.IdentityProviderResource)23 RealmResource (org.keycloak.admin.client.resource.RealmResource)22 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)17 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)16 Response (javax.ws.rs.core.Response)15 Matchers.containsString (org.hamcrest.Matchers.containsString)10 List (java.util.List)9 MultipartFormDataOutput (org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput)8 URL (java.net.URL)7 IdentityProviderMapperRepresentation (org.keycloak.representations.idm.IdentityProviderMapperRepresentation)7 OAuthClient (org.keycloak.testsuite.util.OAuthClient)7 IOException (java.io.IOException)6 URI (java.net.URI)6 Map (java.util.Map)6 Matchers.hasSize (org.hamcrest.Matchers.hasSize)6 Matchers.is (org.hamcrest.Matchers.is)6 SAMLIdentityProviderConfig (org.keycloak.broker.saml.SAMLIdentityProviderConfig)6 AttributeType (org.keycloak.dom.saml.v2.assertion.AttributeType)6