Skip to content

Follow-up to #52391: fix stale provider client lookup in KcSamlSignedDocumentOnlyBrokerTest - #52457

Merged
pedroigor merged 1 commit into
keycloak:mainfrom
sguilhen:fix-saml-signed-document-clientid
Sep 4, 2026
Merged

pedroigor merged 1 commit into
keycloak:mainfrom
sguilhen:fix-saml-signed-document-clientid

Conversation

@sguilhen

@sguilhen sguilhen commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up fix for #52391 (already merged), found while auditing the broker test migration epic (#51955) for the same class of bug Copilot flagged in #52376.

  • KcSamlSignedDocumentOnlyBrokerTest.configureSignedDocumentOnly() (added by Migrate KcSamlSignedDocumentOnlyBrokerTest and SAML package reorg #52391) looks up the provider-side client by a hardcoded http://localhost:8080/realms/<consumer> literal.
  • AbstractKcSamlBrokerTest.configureSamlBrokerEndpoints() (superclass @BeforeEach, which JUnit 5 runs before this subclass's own @BeforeEach) already renames that same client from its seeded placeholder entity id to the consumer realm's real base URL.
  • So the lookup only ever found the client because the test framework's current default happens to bind to http://localhost:8080 - under any other base URL it would return an empty list and throw IndexOutOfBoundsException.
  • Fix: look the client up by consumerRealm.getBaseUrl(), the value it was actually renamed to.

Not caught during #52391's review because it currently passes CI by coincidence (default base URL matches the hardcoded literal); this closes that gap.

Test plan

  • KcSamlSignedDocumentOnlyBrokerTest passes locally

Copilot AI balanced review requested due to automatic review settings September 4, 2026 16:01
@sguilhen
sguilhen requested a review from a team as a code owner September 4, 2026 16:01

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.

🟢 Approval recommended

The focused change correctly aligns the lookup with the client ID assigned by superclass setup.

Pull request overview

Updates the SAML broker test to resolve the provider client using the consumer realm’s runtime base URL.

Changes:

  • Replaces the hardcoded localhost client ID with consumerRealm.getBaseUrl().
  • Documents the superclass setup ordering and client rename.
File summaries
File Description
tests/base/src/test/java/org/keycloak/tests/broker/saml/KcSamlSignedDocumentOnlyBrokerTest.java Uses the runtime SAML entity ID for provider-client lookup.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

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

@sguilhen
sguilhen requested a review from pedroigor September 4, 2026 16:03
configureSamlBrokerEndpoints() (AbstractKcSamlBrokerTest's @beforeeach,
which runs before this subclass's own @beforeeach) already renames the
provider-side client from its seeded placeholder entity id to the
consumer realm's actual base URL. This test's @beforeeach was still
looking the client up by the old placeholder literal, which only
worked because the test framework currently always binds to
http://localhost:8080 by default. Look it up by the same value
configureSamlBrokerEndpoints() renamed it to instead.

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
Copilot AI review requested due to automatic review settings September 4, 2026 18:22
@pedroigor
pedroigor force-pushed the fix-saml-signed-document-clientid branch from f4e0243 to f0b1385 Compare September 4, 2026 18:22

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.

🟢 Approval recommended

The focused change matches the client ID assigned by superclass setup and introduces no unresolved issues.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@pedroigor
pedroigor merged commit f5a00e4 into keycloak:main Sep 4, 2026
94 checks passed
@sguilhen
sguilhen deleted the fix-saml-signed-document-clientid branch September 21, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants