use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class AbstractRoleMapperTest method loginAsUserTwiceWithMapper.
protected UserRepresentation loginAsUserTwiceWithMapper(IdentityProviderMapperSyncMode syncMode, boolean createAfterFirstLogin, Map<String, List<String>> userConfig) {
final IdentityProviderRepresentation idp = setupIdentityProvider();
if (!createAfterFirstLogin) {
createMapperInIdp(idp, syncMode);
}
createUserInProviderRealm(userConfig);
createUserRoleAndGrantToUserInProviderRealm();
logInAsUserInIDPForFirstTime();
UserRepresentation user = findUser(bc.consumerRealmName(), bc.getUserLogin(), bc.getUserEmail());
if (!createAfterFirstLogin) {
assertThatRoleHasBeenAssignedInConsumerRealmTo(user);
} else {
assertThatRoleHasNotBeenAssignedInConsumerRealmTo(user);
}
if (createAfterFirstLogin) {
createMapperInIdp(idp, syncMode);
}
logoutFromRealm(getConsumerRoot(), bc.consumerRealmName());
updateUser();
logInAsUserInIDP();
user = findUser(bc.consumerRealmName(), bc.getUserLogin(), bc.getUserEmail());
return user;
}
use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class BrokerWithLegacyIdTest method getBrokerConfiguration.
@Override
protected BrokerConfiguration getBrokerConfiguration() {
return new KcOidcBrokerConfiguration() {
@Override
public IdentityProviderRepresentation setUpIdentityProvider(IdentityProviderSyncMode syncMode) {
IdentityProviderRepresentation idp = super.setUpIdentityProvider(syncMode);
idp.setProviderId(LegacyIdIdentityProviderFactory.PROVIDER_ID);
return idp;
}
};
}
use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class JsonUserAttributeMapperTest method loginAsUserTwiceWithMapper.
private UserRepresentation loginAsUserTwiceWithMapper(IdentityProviderMapperSyncMode syncMode, boolean createAfterFirstLogin, String claim, String updatedValue) {
final IdentityProviderRepresentation idp = setupIdentityProvider();
if (!createAfterFirstLogin) {
createGithubProviderMapper(idp, syncMode);
}
createUserInProviderRealm(new HashMap<>());
logInAsUserInIDPForFirstTime();
UserRepresentation user = findUser(bc.consumerRealmName(), bc.getUserLogin(), bc.getUserEmail());
if (!createAfterFirstLogin) {
assertUserAttribute(HARDOCDED_VALUE, user);
} else {
assertAbsentUserAttribute(user);
}
if (createAfterFirstLogin) {
createGithubProviderMapper(idp, syncMode);
}
logoutFromRealm(getConsumerRoot(), bc.consumerRealmName());
if (!createAfterFirstLogin) {
updateClaimSentToIDP(claim, updatedValue);
}
logInAsUserInIDP();
return findUser(bc.consumerRealmName(), bc.getUserLogin(), bc.getUserEmail());
}
use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class HardcodedUserAttributeMapperTest method loginAsUserTwiceWithMapper.
protected UserRepresentation loginAsUserTwiceWithMapper(IdentityProviderMapperSyncMode syncMode, boolean createAfterFirstLogin) {
final IdentityProviderRepresentation idp = setupIdentityProvider();
if (!createAfterFirstLogin) {
createMapperInIdp(idp, syncMode);
}
createUserInProviderRealm();
logInAsUserInIDPForFirstTime();
UserRepresentation user = findUser(bc.consumerRealmName(), bc.getUserLogin(), bc.getUserEmail());
if (!createAfterFirstLogin) {
assertThatAttributeHasBeenAssigned(user);
} else {
assertThatAttributeHasNotBeenAssigned(user);
}
if (createAfterFirstLogin) {
createMapperInIdp(idp, syncMode);
}
logoutFromRealm(getConsumerRoot(), bc.consumerRealmName());
if (user.getAttributes() != null) {
user.setAttributes(new HashMap<>());
}
adminClient.realm(bc.consumerRealmName()).users().get(user.getId()).update(user);
logInAsUserInIDP();
return findUser(bc.consumerRealmName(), bc.getUserLogin(), bc.getUserEmail());
}
use of org.keycloak.representations.idm.IdentityProviderRepresentation in project keycloak by keycloak.
the class KcOIDCBrokerWithSignatureTest method testClearKeysCache.
@Test
public void testClearKeysCache() throws Exception {
// Configure OIDC identity provider with JWKS URL
updateIdentityProviderWithJwksUrl();
// Check that user is able to login
logInAsUserInIDPForFirstTime();
assertLoggedInAccountManagement();
logoutFromRealm(getConsumerRoot(), bc.consumerRealmName());
// Check that key is cached
IdentityProviderRepresentation idpRep = getIdentityProvider();
String expectedCacheKey = PublicKeyStorageUtils.getIdpModelCacheKey(consumerRealm().toRepresentation().getId(), idpRep.getInternalId());
TestingCacheResource cache = testingClient.testing(bc.consumerRealmName()).cache(InfinispanConnectionProvider.KEYS_CACHE_NAME);
Assert.assertTrue(cache.contains(expectedCacheKey));
// Clear cache and check nothing cached
consumerRealm().clearKeysCache();
Assert.assertFalse(cache.contains(expectedCacheKey));
Assert.assertEquals(cache.size(), 0);
}
Aggregations