Repository navigation
Migrate basic broker infrastructure to new testsuite - #51859
Conversation
martin-kanis
left a comment
There was a problem hiding this comment.
@sguilhen thanks, I added few comments/questions. Probably someone from the new framework creators will need to eventually chime in.
729d613 to
c2bc943
Compare
938cdcc to
1917b99
Compare
ffd075c to
4f10e2b
Compare
There was a problem hiding this comment.
Pull request overview
Migrates foundational broker login testing from Arquillian to the JUnit 5 test framework for #51954.
Changes:
- Adds reusable OIDC/SAML broker configuration and login-test interfaces.
- Adds three basic broker integration tests.
- Adds broker-related UI page objects.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
BrokerConfigSupport.java |
Shared broker helpers and constants. |
BrokerLoginTest.java |
Reusable broker login/logout tests. |
OidcBrokerConfigSupport.java |
OIDC realm and broker configuration. |
SamlBrokerConfigSupport.java |
SAML realm and broker configuration. |
KcOidcBrokerTest.java |
Basic OIDC broker tests. |
KcOidcBrokerClientSecretBasicAuthTest.java |
OIDC basic-auth variant. |
KcSamlBrokerTest.java |
Basic SAML broker tests. |
IdpConfirmLinkPage.java |
IdP account-link confirmation page object. |
LoginTotpPage.java |
OTP login page object. |
Suppressed comments (2)
test-framework/ui/src/main/java/org/keycloak/testframework/ui/page/LoginTotpPage.java:26
- This regresses the existing page-object contract where
login(null)submits an empty OTP to test validation; Selenium rejectssendKeys(null)before the form is submitted. Preserve null as an empty input.
otpInput.sendKeys(totp);
test-framework/ui/src/main/java/org/keycloak/testframework/ui/page/LoginTotpPage.java:44
- The login template prefixes its
login-otppage ID withlogin-, so the rendered body ID islogin-login-otp. With the current value,assertCurrent()always times out on the OTP page.
return "login-otp";
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4f10e2b to
5fb6603
Compare
5fb6603 to
7b3578f
Compare
7b3578f to
b163149
Compare
| Map<String, String> config = mapper.getConfig(); | ||
| config.put(ProtocolMapperUtils.USER_ATTRIBUTE, userAttribute); | ||
| config.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, samlAttributeName); | ||
| config.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, nameFormat); | ||
| if (friendlyName != null) { | ||
| config.put(AttributeStatementHelper.FRIENDLY_NAME, friendlyName); | ||
| } |
| String consumerBrokerEndpoint = consumerBaseUrl + "/broker/" + IDP_SAML_ALIAS + "/endpoint"; | ||
| // ManagedRealm#getBaseUrl() is "<serverRoot>/realms/<realm>"; strip the realm suffix to get the | ||
| // server root that the consumer-side SP client URLs (sales-post) must point at. | ||
| String consumerServerRoot = consumerBaseUrl.substring(0, consumerBaseUrl.indexOf("/realms/")); |
| } | ||
|
|
||
| private boolean profilePageAppeared() { | ||
| Set<String> profilePageIds = Set.of("login-login-update-profile", "login-idp-review-user-profile"); |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.federation.ldap.LDAPGroupMapperTest#test06_addingUserToNewKeycloakGrouporg.keycloak.testsuite.forms.BruteForceTest#testGrantInvalidPasswordKeycloak CI - Forms IT (chrome) org.keycloak.testsuite.adapter.servlet.SAMLClockSkewAdapterTest#testTokenTimeIsValidKeycloak CI - Adapter IT Strict Cookies |
martin-kanis
left a comment
There was a problem hiding this comment.
@sguilhen Thanks for all of the iterations. Looks good to me.
a0d4f31 to
f858e3f
Compare
f858e3f to
408146b
Compare
Add shared test infrastructure (BrokerConfigSupport, KcOidcBrokerConfigSupport, SamlBrokerConfigSupport, BrokerLoginTest) and migrate KcOidcBrokerTest, KcOidcBrokerClientSecretBasicAuthTest, and KcSamlBrokerTest. The shared OIDC config brokers through the Keycloak-specific "keycloak-oidc" identity provider, matching the legacy KcOidcBrokerConfiguration baseline (with prompt=login and loginHint forwarding); a generic-provider variant can be added where a test actually needs it. The provider user is created without a first/last name, as the legacy suite did, so the imported consumer user is incomplete and the consumer's first-broker-login review-profile page is shown. The default helper asserts that page appears before updating it (mirroring the legacy assertCurrent()), and VERIFY_PROFILE is disabled on the provider realm since the new testsuite enables it by default and would otherwise stop the incomplete user at the provider. A tolerant updateAccountInformationIfPresent() variant remains for flows that intentionally skip profile review. The login flows run against the migrated broker-app client (via BrokerAppClientConfig) rather than the framework default test-app, and the OIDC provider-side client carries the legacy broker callback configuration (redirect/admin/backchannel-logout URLs, post-logout redirect URIs) rewritten from the consumer base URL, mirroring the SAML base. The legacy test classes are retained since they carry additional test methods not yet covered by this migration. Per Copilot review: the protocol bases (AbstractKcOidcBrokerTest / AbstractKcSamlBrokerTest) now inject the default provider/consumer realms and implement getProviderRealm()/getConsumerRealm() once, instead of leaving them abstract for every concrete test to implement. A concrete test using the default config needs no realm fields or getters at all; a test that needs a different config for one side shadows just that field (same name/type, different @InjectRealm#config) - the framework resolves the shadowed and inherited field to the same deployed realm, so no getter override is needed either way (same pattern already used by AccountRestServiceLightweightTokenTest#managedRealm). Closes keycloak#51954 Signed-off-by: Stefan Guilhen <sguilhen@redhat.com> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
408146b to
8639b57
Compare
This is the foundational PR of the broker test migration - moving the broker suite from the legacy Arquillian testsuite (
testsuite/integration-arquillian/.../broker) to the new JUnit 5 framework undertests/base/.../broker.Scope
Kept deliberately small so the shared infrastructure can be reviewed on its own:
AbstractBrokerTest,AbstractBrokerLoginTest, and the protocol basesAbstractKcOidcBrokerTest/AbstractKcSamlBrokerTest(abstract-class hierarchy; concrete tests inherit the injected clients/pages and the@Testlogin logic). The protocol bases also inject the default provider/consumer realms, so a concrete test using the default config needs no fields or getters at all; a test that needs a different config for one or both realms shadows just the field(s) it varies (same name/type, different@InjectRealm#config) - the framework resolves the shadowed and inherited field to the same deployed realm, so no getter override is needed either way.KcOidcBrokerTest,KcOidcBrokerClientSecretBasicAuthTest,KcSamlBrokerTest.The design uses abstract classes by default (the new framework injects into class fields, not interfaces, so this removes the getter boilerplate and matches the rest of
tests/base); interfaces are kept only for cases that must mix two independent@Testaxes (JWE variants, the token-store matrix). This is the pattern the rest of the migration follows, so that is the main thing to scrutinize.Closes #51954