8000 Migrate KcOidcBrokerVaultTest by sguilhen · Pull Request #52388 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
10BC8
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,34 +196,6 @@ protected void logoutFromConsumerRealm() {
AccountHelper.logout(getConsumerRealm().admin(), getUserLogin());
}

// Turns off the first-broker-login review-profile step for flows that want to test something else
// without the review-profile page interrupting the redirect back to the consumer. Disabling the flow
// execution alone isn't enough: the new-testsuite consumer realm enables the VERIFY_PROFILE required
// action by default, which would still intercept the incomplete imported user (the provider user has
// no first/last name on purpose), so that is disabled too, mirroring the legacy suite (which never
// enabled VERIFY_PROFILE at all).
protected void disableUpdateProfileOnFirstLogin() {
var flows = getConsumerRealm().admin().flows();
for (AuthenticationExecutionInfoRepresentation execution :
flows.getExecutions(DefaultAuthenticationFlows.FIRST_BROKER_LOGIN_FLOW)) {
if (IdpCreateUserIfUniqueAuthenticatorFactory.PROVIDER_ID.equals(execution.getProviderId())) {
execution.setRequirement(AuthenticationExecutionModel.Requirement.ALTERNATIVE.name());
flows.updateExecutions(DefaultAuthenticationFlows.FIRST_BROKER_LOGIN_FLOW, execution);
} else if (execution.getAlias() != null
&& execution.getAlias().equals(DefaultAuthenticationFlows.IDP_REVIEW_PROFILE_CONFIG_ALIAS)) {
AuthenticatorConfigRepresentation config = flows.getAuthenticatorConfig(execution.getAuthenticationConfig());
config.getConfig().put("update.profile.on.first.login", IdentityProviderRepresentation.UPFLM_OFF);
flows.updateAuthenticatorConfig(config.getId(), config);
}
}
for (RequiredActionProviderRepresentation action : getConsumerRealm().admin().flows().getRequiredActions()) {
if (UserModel.RequiredAction.VERIFY_PROFILE.name().equals(action.getAlias())) {
action.setEnabled(false);
getConsumerRealm().admin().flows().updateRequiredAction(action.getAlias(), action);
}
}
}

protected void assertNumFederatedIdentities(String username, int expected) {
ManagedRealm consumerRealm = getConsumerRealm();
List<UserRepresentation> users = consumerRealm.admin().users().search(username, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.keycloak.tests.broker.oidc;

import java.net.URL;

import org.keycloak.representations.idm.IdentityProviderRepresentation;
import org.keycloak.testframework.annotations.KeycloakIntegrationTest;
import org.keycloak.testframework.server.KeycloakServerConfig;
import org.keycloak.testframework.server.KeycloakServerConfigBuilder;
import org.keycloak.tests.broker.AbstractKcOidcBrokerTest;

import org.junit.jupiter.api.BeforeEach;

@KeycloakIntegrationTest(config = KcOidcBrokerVaultTest.VaultBrokerServerConfig.class)
public class KcOidcBrokerVaultTest extends AbstractKcOidcBrokerTest {

static final String VAULT_CLIENT_SECRET = "${vault.oidc_idp}";

@BeforeEach
void configureVaultClientSecret() {
IdentityProviderRepresentation idp = consumerRealm.admin()
.identityProviders().get(getIdpAlias()).toRepresentation();
idp.getConfig().put("clientSecret", VAULT_CLIENT_SECRET);
consumerRealm.admin().identityProviders().get(getIdpAlias()).update(idp);
}

static class VaultBrokerServerConfig implements KeycloakServerConfig {
@Override
public KeycloakServerConfigBuilder configure(KeycloakServerConfigBuilder config) {
return config.option("vault", "file")
.option("vault-dir", vaultResourcePath());
}

private static String vaultResourcePath() {
URL url = KcOidcBrokerVaultTest.class.getResource("vault");
if (url == null) {
throw new RuntimeException("Unable to find vault resource directory");
}
return url.getPath();
}
Comment thread
sguilhen marked this conversation as resolved.
Resolved
}
}

This file was deleted.

This file was deleted.

Loading
0