Skip to content

Migrate KcOidcFirstBrokerLoginDetectExistingUserTest to tests/base - #52787

Merged
shawkins merged 3 commits into
keycloak:mainfrom
edewit:issue-50755-migrate-broker-first-login
Oct 2, 2026
Merged

shawkins merged 3 commits into
keycloak:mainfrom
edewit:issue-50755-migrate-broker-first-login

Conversation

@edewit

@edewit edewit commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • migrate KcOidcFirstBrokerLoginDetectExistingUserTest from arquillian to tests/base as the first focused batch of broker package migration for Migrate broker package to the new test framework #50755
  • reuse the existing AbstractKcOidcBrokerTest / ManagedRealm broker infrastructure instead of a parallel BrokerConfiguration hierarchy

This supersedes the monolithic #51881 approach, which conflicted with the incremental broker migrations already merged to main (#51859, #52372, #52379, #52376, #52382, #52387, etc.).

Test plan

  • ./mvnw -pl tests/base -Dtest=KcOidcFirstBrokerLoginDetectExistingUserTest test

Part of #50755

Copilot AI balanced review requested due to automatic review settings September 15, 2026 14:34
@edewit
edewit requested review from a team as code owners September 15, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Migrates the first-broker-login “detect existing user” test to the tests/base infrastructure and introduces reusable broker test scaffolding for programmatic realm/flow setup.

Changes:

  • Migrated KcOidcFirstBrokerLoginDetectExistingUserTest from the Arquillian-style setup to the new tests/base broker infrastructure.
  • Added BrokerConfiguration-driven base test classes and first-broker-login flow mutators for broker scenarios.
  • Added LoginPage.login() helpers to simplify broker UI login flows.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcOidcFirstBrokerLoginDetectExistingUserTest.java Migrates the existing test to JUnit 5 + new broker base classes and UI helpers
tests/base/src/test/java/org/keycloak/tests/broker/KcOidcBrokerConfiguration.java Adds OIDC broker realm/client/idp configuration for the new broker test base
tests/base/src/test/java/org/keycloak/tests/broker/BrokerTestTools.java Adds shared URL/config helpers and selenium wait utilities
tests/base/src/test/java/org/keycloak/tests/broker/BrokerTestConstants.java Adds shared constants for broker tests
tests/base/src/test/java/org/keycloak/tests/broker/BrokerServerConfig.java Adds server dependency config for running broker tests
tests/base/src/test/java/org/keycloak/tests/broker/BrokerFirstLoginFlowMutators.java Adds helpers to mutate first-broker-login flow behavior during tests
tests/base/src/test/java/org/keycloak/tests/broker/BrokerConfiguration.java Defines the configuration contract for broker test realm/client/idp setup
tests/base/src/test/java/org/keycloak/tests/broker/AbstractInitializedBaseBrokerTest.java Adds broker test base that initializes realms, user, idp, and endpoints
tests/base/src/test/java/org/keycloak/tests/broker/AbstractBaseBrokerTest.java Adds core broker test base utilities (realm import/cleanup, login flows)
test-framework/ui/src/main/java/org/keycloak/testframework/ui/page/LoginPage.java Adds login() convenience methods for username+password and password-only flows

Note

Copilot is running an experiment and ran this review at Lite.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Provider endpoint initialization ignores the configured provider client ID, breaking reusable configurations with non-default client IDs.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

tests/base/src/test/java/org/keycloak/tests/broker/AbstractInitializedBaseBrokerTest.java:105

  • This hard-codes brokerapp even though BrokerConfiguration#getIDPClientIdInProviderRealm() defines the provider-side client ID and createProviderClients() uses it. Any configuration with a custom provider client ID will fail setup here before the broker flow runs; resolve and report the configured ID instead.
  • Files reviewed: 10/10 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.

@michalvavrik michalvavrik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Copilot AI review requested due to automatic review settings September 24, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The migration is complete and no unresolved issues were identified.

Review effort: Balanced
Findings: None

Add BrokerConfiguration-based broker test infrastructure for first-broker-login
scenarios that still need programmatic realm setup, and migrate the detect-existing-
user OIDC broker tests as the first batch of the broker package migration for keycloak#50755.

Supersedes the monolithic keycloak#51881 approach with a focused follow-up aligned to the
incremental broker migrations already on main.

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Initialize identity-provider and protocol-mapper config maps before use,
fail fast when the provider broker client is missing, use ThreadLocal for
broker server-root state, and tidy BrokerTestConstants modifier order.

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Copilot AI review requested due to automatic review settings September 24, 2026 13:59
@edewit
edewit force-pushed the issue-50755-migrate-broker-first-login branch from 0710b3e to 9d701f7 Compare September 24, 2026 13:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The migration preserves the covered scenarios, and no unresolved issues were identified.

Review effort: Balanced
Findings: None

Drop the parallel BrokerConfiguration-based test hierarchy and unused
helpers, addressing review feedback about duplication and dead code.

Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Copilot AI review requested due to automatic review settings September 24, 2026 14:28
@edewit
edewit force-pushed the issue-50755-migrate-broker-first-login branch from 9d701f7 to 7895c8c Compare September 24, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The migration preserves the covered scenarios, and no unresolved issues were identified.

Review effort: Balanced
Findings: None

@michalvavrik michalvavrik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@edewit
edewit force-pushed the issue-50755-migrate-broker-first-login branch from 7895c8c to d5291b8 Compare October 1, 2026 14:20

@shawkins shawkins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shawkins
shawkins merged commit 349648b into keycloak:main Oct 2, 2026
157 of 159 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants