Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Migrates Keycloak authorization tests toward the newer test framework by switching to JUnit Jupiter and introducing testframework injections (realm/events/run-on-server/OAuth), along with a package rename from org.keycloak.testsuite.* to org.keycloak.tests.*.
Changes:
- Renamed test packages from
org.keycloak.testsuite.authz...toorg.keycloak.tests.authz.... - Switched many tests from JUnit 4 annotations (
@Test,@Before,@After) to JUnit Jupiter equivalents, and introduced@KeycloakIntegrationTest. - Replaced direct
testRealmResource()/testingClient.server().run(...)usage withManagedRealm/RunOnServerClientinjections in several tests.
Reviewed changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/UserPolicyManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/TimePolicyManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ScopePermissionManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ScopeManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/RolePolicyManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ResourceServerManagementTest.java | Package rename + ManagedRealm admin access |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ResourcePermissionManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ResourceManagementWithAuthzClientTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ResourceManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/JSPolicyManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ImportAuthorizationSettingsTest.java | JUnit Jupiter lifecycle + ManagedRealm usage |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/GroupPolicyManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/GenericPolicyManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/GenericPolicyManagementAdminEventTest.java | Package rename + ManagedRealm update usage |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ExportAuthorizationSettingsTest.java | ManagedRealm admin access for clients/roles |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/ClientPolicyManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/AuthorizationTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/AuthorizationDisabledInPreviewTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/AggregatePolicyManagementTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/AbstractPolicyManagementTest.java | Base class migration to testframework/JUnit Jupiter |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/admin/AbstractAuthorizationTest.java | Base class migration to testframework/JUnit Jupiter |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/UserManagedPermissionServiceTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/UserManagedAccessTest.java | Events/run-on-server migration + JUnit Jupiter |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/UmaResourceTypeRepresentationTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/UmaPermissionTicketPushedClaimsTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/UmaGrantTypeTest.java | OAuth/timeoffset injection + JUnit Jupiter |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/UmaDiscoveryDocumentTest.java | Migratio 8000 n off testsuite base + OAuth injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/ScriptCacheTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/RolePolicyTest.java | JUnit Jupiter lifecycle + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/RegexPolicyTest.java | JUnit Jupiter lifecycle + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/ProtectionResourceTest.java | JUnit Jupiter assertions/lifecycle migration |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/PolicyEvaluationTest.java | run-on-server migration + JUnit Jupiter |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/PolicyEvaluationCompositeRoleTest.java | run-on-server migration + JUnit Jupiter |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/PermissionManagementTest.java | run-on-server migration + JUnit Jupiter |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/PermissionEqualsTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/PermissionClaimTest.java | OAuth injection + JUnit Jupiter lifecycle |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/GroupPathWithoutGroupClaimPolicyTest.java | Package rename + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/GroupPathPolicyTest.java | JUnit Jupiter lifecycle + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/GroupNamePolicyTest.java | JUnit Jupiter lifecycle + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/EntitlementAPITest.java | Events/OAuth/timeoffset migration + Jupiter |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/ConflictingScopePermissionTest.java | JUnit Jupiter lifecycle + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/ClientScopePolicyTest.java | JUnit Jupiter lifecycle + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/AuthzClientTest.java | Package rename + Jupiter + env rule retained |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/AuthzClientCredentialsTest.java | JUnit Jupiter lifecycle + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/AuthorizationTest.java | JUnit Jupiter lifecycle + testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/AuthorizationAPITest.java | OAuth injection + JUnit Jupiter lifecycle |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/AttributeTest.java | Package rename + JUnit Jupiter/testframework injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/AbstractResourceServerTest.java | Base class annotation + injection |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/AbstractAuthzTest.java | Base class migration to testframework/JUnit Jupiter |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 51 out of 51 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/AbstractAuthzTest.java:1
- There are now two
AbstractAuthzTestbase classes (this one inorg.keycloak.testsuite.authzand a new one inorg.keycloak.tests.authz), and they are using different test engines (this one still imports JUnit 4@BeforeClass). This duplication + mixed lifecycle annotations increases the risk of divergence and confusion when migrating the remaining tests. Consider consolidating to a single base implementation and aligning lifecycle annotations with the chosen test engine (Jupiter) to reduce maintenance overhead.
e22a8f2 to
4626439
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 51 out of 51 changed files in this pull request and generated 1 comment.
Suppressed comments (15)
tests/base/src/test/java/org/keycloak/tests/authz/AbstractResourceServerTest.java:60
- A bare
@InjectRealmcreates an empty, generated-name realm, while these tests require theauthz-testrealm, users, roles, and clients built inaddTestRealms. The new framework never calls that legacy hook, so provide aRealmConfighere (or per subclass) that reproduces this setup.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractAuthorizationTest.java:55 - This class still relies on the Arquillian
AbstractClientTestlifecycle and itsadminClient/page resources, but Jupiter does not invoke the inherited JUnit 4 setup. The injected realm also uses the empty default configuration rather thancreateTestRealm(), leaving the admin authorization tests without their expected realm and client.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractPolicyManagementTest.java:17 - Moving this base into
tests/basedoes not migrate its setup:addTestRealms, JUnit 4@BeforeClass, and JUnit 4@Beforeare not invoked for the Jupiter subclasses. Consequently the policy fixtures are never imported or configured; convert this base to the new realm/configuration and Jupiter lifecycle APIs.
tests/base/src/test/java/org/keycloak/tests/authz/UmaDiscoveryDocumentTest.java:17 - This test was only repackaged and still uses the Arquillian base,
@ArquillianResource, and JUnit 4@Test; it has no new-framework integration or injected OAuth client/realm. It therefore remains on the old runner rather than being executable as a migratedtests/basetest.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ScopeManagementTest.java:45 - The methods in this class still use
org.junit.Test, so they run on the JUnit 4 engine and the Jupiter@KeycloakIntegrationTestextension does not initializemanagedRealm. Switch the test annotation import to Jupiter.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ResourceManagementTest.java:56 - The methods in this class still use
org.junit.Test, so they run on the JUnit 4 engine and the Jupiter@KeycloakIntegrationTestextension does not initializemanagedRealm. Switch the test annotation import to Jupiter.
tests/base/src/test/java/org/keycloak/tests/authz/AuthzClientTest.java:15 - After switching this class to Jupiter, the JUnit 4
@Ruleis ignored.envVars.set(...)still mutates the process environment, but the rule no longer restores it after the test, so later tests can observe these values; replace it with a Jupiter-compatible environment extension or explicit restoration.
tests/base/src/test/java/org/keycloak/tests/authz/EntitlementAPITest.java:106 - Jupiter does not apply the retained JUnit 4
ExpectedExceptionrule. The two tests that configureexpectedExceptionwill let their expectedAuthorizationDeniedExceptionescape and fail; migrate those assertions toassertThrowsand assert the cause/message explicitly.
tests/base/src/test/java/org/keycloak/tests/authz/EntitlementAPITest.java:124 - This Jupiter test still expects Arquillian to inject
ContainerController, which the new extension does not do.testServerRestartdereferences this field at lines 1969-1970, so it will fail with a null controller; migrate the restart scenario to a new-framework server control facility.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AuthorizationDisabledInPreviewTest.java:40 @KeycloakIntegrationTestruns this class with Jupiter, so the JUnit 4@BeforeClassmethod is ignored. The feature-disabled assumption is never applied, and the default server configuration does not disable authorization; use a customKeycloakServerConfigwithfeaturesDisabled(AUTHORIZATION)and a Jupiter lifecycle hook if the assumption is still needed.
tests/base/src/test/java/org/keycloak/tests/authz/UserManagedPermissionServiceTest.java:86- The new framework does not process the Arquillian
@EnableFeature, and its default server config does not enable the previewSCRIPTSfeature. Configure@KeycloakIntegrationTestwith a server config that callsfeatures(Feature.SCRIPTS)or script-policy creation will fail.
tests/base/src/test/java/org/keycloak/tests/authz/UmaPermissionTicketPushedClaimsTest.java:52 - The new framework does not process the Arquillian
@EnableFeature, and its default server config does not enable the previewSCRIPTSfeature. Configure@KeycloakIntegrationTestwith a server config that callsfeatures(Feature.SCRIPTS)or script-policy creation will fail.
tests/base/src/test/java/org/keycloak/tests/authz/PermissionClaimTest.java:74 - The new framework does not process the Arquillian
@EnableFeature, and its default server config does not enable the previewSCRIPTSfeature. Configure@KeycloakIntegrationTestwith a server config that callsfeatures(Feature.SCRIPTS)or script-policy creation will fail.
tests/base/src/test/java/org/keycloak/tests/authz/admin/JSPolicyManagementTest.java:45 - The new framework does not process the Arquillian
@EnableFeature, and its default server config does not enable the previewSCRIPTSfeature. Configure@KeycloakIntegrationTestwith a server config that callsfeatures(Feature.SCRIPTS)or script-policy creation will fail.
tests/base/src/test/java/org/keycloak/tests/authz/PolicyEvaluationTest.java:95 - The new framework does not process the Arquillian
@EnableFeature, and its default server config does not enable the previewSCRIPTSfeature. Configure@KeycloakIntegrationTestwith a server config that callsfeatures(Feature.SCRIPTS)or script-policy creation will fail.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 56 out of 56 changed files in this pull request and generated 6 comments.
Suppressed comments (16)
Previously missed (3) — in code that hasn't changed since the last review.
tests/base/src/test/java/org/keycloak/tests/authz/PermissionEqualsTest.java:41
- This is a pure value-object unit test and never uses the injected realm or server. Marking it as an integration test creates a realm and starts framework resources unnecessarily; keep only the Jupiter
@Testmethods and remove the integration annotation/injection.
tests/base/src/test/java/org/keycloak/tests/authz/AttributeTest.java:47 - This test only exercises an in-memory
Attributesobject and does not use Keycloak ormanagedRealm. Registering it as an integration test adds avoidable server/realm setup; migrate it as a plain Jupiter unit test instead.
tests/base/src/test/java/org/keycloak/tests/authz/ScriptCacheTest.java:45 - The test operates entirely on a local
ScriptCacheand never uses the injected realm. Running it through@KeycloakIntegrationTestadds unnecessary server and realm lifecycle overhead; leave it as a plain Jupiter test.
tests/base/src/test/java/org/keycloak/tests/authz/AbstractResourceServerTest.java:60
- This injection creates an empty generated realm, while the unchanged
addTestRealmsmethod is a legacy JUnit/Arquillian hook and is never called by the new extension. Every resource-server test therefore looks up the nonexistentauthz-testrealm andresource-server-testclient; provide an@InjectRealm(config = ...)configuration containing this setup.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractAuthorizationTest.java:52 - The new framework creates only the default empty managed realm here; the legacy
addTestRealmshook below is not executed. The admin tests immediately search this realm forresource-server-test, so they fail before exercising their assertions unlesscreateTestRealm()is supplied through an@InjectRealmRealmConfig.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractPolicyManagementTest.java:77 - Changing this lifecycle method to Jupiter does not provision the realm built by
addTestRealms; that legacy hook is no longer invoked. Concrete subclasses inject the default empty realm, while this setup accessesauthz-testandresource-server-test, so convertcreateTestRealm()into theRealmConfigused by their@InjectRealmfields.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ScopeManagementTest.java:45 - This class still uses JUnit 4
org.junit.Testmethods.tests/basehas no Vintage engine, so adding the Jupiter integration annotation does not make any of these tests discoverable; migrate all test annotations toorg.junit.jupiter.api.Test.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ResourceManagementTest.java:56 - This class still uses JUnit 4
org.junit.Testmethods.tests/basehas no Vintage engine, so the Jupiter suite will not discover them despite@KeycloakIntegrationTest; migrate every test annotation in this file to JUnit Jupiter.
tests/base/src/test/java/org/keycloak/tests/authz/UmaDiscoveryDocumentTest.java:18 - Only the package was moved: this test still uses JUnit 4 plus Arquillian injection and has no
@KeycloakIntegrationTest. Sincetests/basedoes not include the Vintage engine, the test is no longer discovered; migrate its runner resources and test annotations to the new framework.
tests/base/src/test/java/org/keycloak/tests/authz/EntitlementAPITest.java:1969 - Under the new framework these Arquillian fields are never injected, so this condition is always false and the server restart is silently skipped. That removes the core persistence check from
testOfflineRequestingPartyToken; use the new framework's server lifecycle support or explicitly disable the test until restart is supported.
tests/base/src/test/java/org/keycloak/tests/authz/PermissionClaimTest.java:74 - The legacy
@EnableFeatureannotation is not processed byKeycloakIntegrationTestExtension, and the default server config does not enableSCRIPTS. This class creates JavaScript policies, so configure the new framework with the existing script-enabled server config.
tests/base/src/test/java/org/keycloak/tests/authz/PolicyEvaluationTest.java:95 - The legacy
@EnableFeatureannotation is not processed by the new test extension, leavingSCRIPTSdisabled under the default server config. Configure this migrated test with the existing script-enabled server config.
tests/base/src/test/java/org/keycloak/tests/authz/UserManagedPermissionServiceTest.java:86 - The new test extension ignores the retained Arquillian
@EnableFeature, soSCRIPTSremains disabled and the script-policy scenarios cannot run. Use the existing script-enabled new-framework server config.
tests/base/src/test/java/org/keycloak/tests/authz/UmaPermissionTicketPushedClaimsTest.java:52 - The retained Arquillian
@EnableFeaturedoes not configure the new test server, whose default config leavesSCRIPTSdisabled. Point this class at the existing script-enabled server config.
tests/base/src/test/java/org/keycloak/tests/authz/admin/JSPolicyManagementTest.java:45 @EnableFeatureis an Arquillian annotation and is ignored by the new framework, so this test starts a server withoutSCRIPTSand cannot create JavaScript policies. Configure@KeycloakIntegrationTestwith the existing script-enabled server config.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AuthorizationDisabledInPreviewTest.java:37- This test no longer starts a server with
AUTHORIZATIONdisabled; the default new-framework config enables it, and the method merely aborts after making a successful request. Add aKeycloakServerConfigthat disablesProfile.Feature.AUTHORIZATIONso the disabled-feature behavior is actually exercised.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 54 out of 54 changed files in this pull request and generated 1 comment.
Suppressed comments (12)
Previously missed (1) — in code that hasn't changed since the last review.
tests/base/src/test/java/org/keycloak/tests/authz/admin/GenericPolicyManagementAdminEventTest.java:41
- This remains a legacy hook rather than a Jupiter lifecycle callback, and the migrated hierarchy never invokes it. As a result admin events are not enabled for this test class; make this setup an explicit
@BeforeEachcallback (after the managed realm migration).
tests/base/src/test/java/org/keycloak/tests/authz/admin/ScopeManagementTest.java:45
- This class still imports JUnit 4's
org.junit.Test; the Jupiter engine that applies@KeycloakIntegrationTestwill therefore not discover its test methods. Switch the import to JUnit Jupiter.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ResourceManagementTest.java:56 - This class still imports JUnit 4's
org.junit.Test; the Jupiter engine that applies@KeycloakIntegrationTestwill therefore omit these methods, including inherited coverage inResourceManagementWithAuthzClientTest. Switch the import to JUnit Jupiter.
tests/base/src/test/java/org/keycloak/tests/authz/UmaDiscoveryDocumentTest.java:17 - Only the package was moved here: the class still uses JUnit 4, Arquillian injection, and lacks
@KeycloakIntegrationTest. It will not run under the new test framework, so this test needs a full Jupiter/framework migration rather than just relocation.
tests/base/src/test/java/org/keycloak/tests/authz/EntitlementAPITest.java:1969 - In the new framework both Arquillian fields are null, so this guard always skips the server restart and
testOfflineRequestingPartyTokenmerely introspects against the same process. Use the new framework's restart mechanism so the test continues to verify token persistence across a restart.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AuthorizationDisabledInPreviewTest.java:53 Base2TestSuitenow always enables AUTHORIZATION, so this branch aborts the test on every suite run and the disabled-feature behavior is never exercised. Move this test to a server configuration with AUTHORIZATION disabled instead of converting success into an assumption failure.
tests/base/src/test/java/org/keycloak/tests/authz/AuthzClientTest.java:18- This replaces the process-wide crypto provider and never restores it. Because this test now runs in the shared Base2 JVM and
AuthzClientCryptoProviderleaves many operations unsupported, later tests become order-dependent; preserve and restore the prior provider in afinallyblock.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractAuthorizationTest.java:52 - This injection creates a separate default realm, while
addTestRealmsdescribesauthz-test; JUnit 5 does not executeAbstractKeycloakTest's JUnit 4 import lifecycle. ConsequentlyfindClientResourcesearches the default realm, whereresource-server-testdoes not exist, and the admin tests fail during setup. Configure the managed realm fromcreateTestRealm()and use it consistently instead of retaining the legacy import contract.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractPolicyManagementTest.java:76 - After changing this to
@BeforeEach, setup runs under Jupiter, but nothing invokesaddTestRealms; the inherited importer is a JUnit 4 lifecycle method. The injected realms in concrete subclasses use the default configuration, soauthz-testandresource-server-testare absent and this setup fails. MigratecreateTestRealm()into a RealmConfig-backed@InjectRealmand use that managed realm here.
tests/base/src/test/java/org/keycloak/tests/authz/AbstractAuthzTest.java:45 - This reimplements realm import instead of calling the polymorphic
importTestRealms(). As a resultAbstractResourceServerTest.importTestRealms()never initializeskoloId/martaId; additionally,AuthorizationAPITest.addTestRealms()dereferencestestingClientbefore it is initialized. Initialize the testing client and invoke the existing import method, then record the imported names for cleanup.
testRealmReps = new ArrayList<>();
addTestRealms(testRealmReps);
for (RealmRepresentation realmRepresentation : testRealmReps) {
importRealm(realmRepresentation);
importedRealmNames.add(realmRepresentation.getRealm());
}
tests/base/src/test/java/org/keycloak/tests/authz/UserManagedAccessTest.java:88
Eventsis bound to the injected defaultManagedRealm, but this test performs logins in the separately importedauthz-testrealm. Calls such asevents.poll()therefore query the wrong realm and cannot observe the asserted permission events. Makeauthz-testthe framework-managed realm (or otherwise bindInjectEventsto that managed instance).
tests/base/src/test/java/org/keycloak/tests/authz/EntitlementAPITest.java:146Eventsdepends on the default injectedManagedRealm, while all authorization requests in this class target the separately importedauthz-testrealm. The migrated event assertions will poll the wrong realm; configureauthz-testas the managed realm and bind Events to it.
5edfeb1 to
e341f11
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 54 out of 54 changed files in this pull request and generated 1 comment.
Suppressed comments (9)
tests/base/src/test/java/org/keycloak/tests/authz/AbstractAuthzTest.java:48
- Calling
importRealmdirectly bypasses overrides ofimportTestRealms; for example,AbstractResourceServerTest.importTestRealms()initializeskoloIdandmartaId, so the migrated event assertions currently compare against null. Invoke the lifecycle method and only record the imported names afterward.
addTestRealms(testRealmReps);
for (RealmRepresentation realmRepresentation : testRealmReps) {
importRealm(realmRepresentation);
importedRealmNames.add(realmRepresentation.getRealm());
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractAuthorizationTest.java:52
- This default
@InjectRealmcreates an empty, generated realm; the Jupiter extension does not invoke the legacyaddTestRealms, soresource-server-testis absent andgetClientResource()returns null. ProvisioncreateTestRealm()through a new-framework realm config (or explicitly import/remove it in Jupiter lifecycle methods).
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractPolicyManagementTest.java:57 - Injecting only the admin client does not create
authz-test; under Jupiter the legacybeforeAbstractKeycloakTestthat callsaddTestRealmsis not executed, soconfigureAuthorization()targets a nonexistent realm. Migrate this hierarchy's realm setup to@InjectRealm(config = ...)or an explicit Jupiter setup/cleanup bridge.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ScopeManagementTest.java:45 - The methods in this migrated class still use JUnit 4's
@Test, so they run through the inherited Arquillian runner (or are skipped) instead of the new Jupiter extension. Use the Jupiter annotation as in the other migrated classes.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ResourceManagementTest.java:56 - The methods in this migrated class still use JUnit 4's
@Test, so they run through the inherited Arquillian runner (or are skipped) instead of the new Jupiter extension. Use the Jupiter annotation as in the other migrated classes.
tests/base/src/test/java/org/keycloak/tests/authz/UmaDiscoveryDocumentTest.java:18 - Moving this class into the selected
org.keycloak.tests.authzpackage without converting it leaves it entirely on JUnit 4/Arquillian (@ArquillianResource, legacy OAuth client, and no@KeycloakIntegrationTest). It will not execute with the intended new-framework lifecycle; migrate those dependencies before including it in Base2.
tests/base/src/test/java/org/keycloak/tests/authz/EntitlementAPITest.java:1969 - In the Jupiter framework these Arquillian resources are not injected, so this condition is always false and the offline-token test no longer restarts the server—the behavior it is intended to cover. Replace the conditional with the new framework's server restart facility and reconnect any clients as required.
tests/base/src/test/java/org/keycloak/tests/authz/admin/GenericPolicyManagementAdminEventTest.java:41 - This override is only called from the legacy JUnit 4
beforeAbstractKeycloakTestlifecycle, which is not executed by@KeycloakIntegrationTest; consequently admin events are never enabled for this subclass. Move this setup to a Jupiter@BeforeEachmethod (after the managed realm has been provisioned).
tests/base/src/test/java/org/keycloak/tests/authz/AbstractResourceServerTest.java:59 - This injected realm is a separate default realm from the manually imported
authz-test. New-framework resources such as@InjectEventsbind to this managed realm, soUserManagedAccessTestandEntitlementAPITestpoll the wrong realm (and the events interceptor enables events on the wrong realm). Provisionauthz-testthrough this managed realm instead of maintaining two realm lifecycles.
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#test01_ldapOnlyGroupMappings |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 57 out of 57 changed files in this pull request and generated 2 comments.
Suppressed comments (12)
Previously missed (4) — in code that hasn't changed since the last review.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AuthorizationDisabledInPreviewTest.java:54
- The Base2 suite explicitly enables
AUTHORIZATION, so the new-framework path always reaches this assumption and aborts the test instead of testing the disabled-feature response. Give this class a server config that disablesProfile.Feature.AUTHORIZATIONand retain the failure assertion rather than converting success into a skipped test.
tests/base/src/test/java/org/keycloak/tests/authz/EntitlementAPITest.java:1969 - Under the new framework both Arquillian fields are null, so this guard permanently skips the server restart and the test no longer verifies that an offline RPT survives a restart. Migrate this step to a new-framework restart mechanism rather than silently omitting the core operation.
tests/base/src/test/java/org/keycloak/tests/authz/ProtectionResourceTest.java:47 - This cleanup is registered on the unrelated injected realm. Framework cleanup runs after user
@AfterEachmethods, butAbstractAuthzTest.afterAuthzTest()has already deletedauthz-test, so this callback attempts to update a removed authorization resource and can fail cleanup with 404. Restore this setting before the manual realm teardown (or makeauthz-testthe managed realm).
tests/base/src/test/java/org/keycloak/tests/authz/RolePolicyTest.java:181 - This callback is attached to the generated managed realm but closes over a client in the manually imported
authz-testrealm. It executes only afterAbstractAuthzTest.afterAuthzTest()deletes that realm, so cleanup can fail with 404; run it before realm removal or manageauthz-testthroughManagedRealm.
This issue also appears on line 211 of the same file.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractAuthorizationTest.java:52
@InjectRealmcreates an empty generated realm by default; the JUnit 5 extension does not invoke the legacyaddTestRealms/JUnit 4 setup that createsauthz-testandresource-server-test. ConsequentlygetClientResource()returns null for every subclass; configure the injected realm withcreateTestRealm()(or add an explicit Jupiter import lifecycle) and consistently use that realm.
tests/base/src/test/java/org/keycloak/tests/authz/admin/AbstractPolicyManagementTest.java:80- This Jupiter setup accesses
authz-test, but no Jupiter lifecycle imports the realm returned byaddTestRealms; the inherited importer is JUnit 4@Beforeand is not run by Jupiter. All policy-management tests therefore reach this method withoutresource-server-test; migrate realm creation into@InjectRealmor add a Jupiter import/cleanup lifecycle.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ScopeManagementTest.java:45 - The class enables the Jupiter extension, but its test methods still use JUnit 4
@Test; Jupiter will not execute those methods with the injected realm. Change this import to the Jupiter annotation.
tests/base/src/test/java/org/keycloak/tests/authz/admin/ResourceManagementTest.java:56 - The class enables the Jupiter extension, but its test methods still use JUnit 4
@Test; Jupiter will not execute those methods with the injected realm. Change this import to the Jupiter annotation.
tests/base/src/test/java/org/keycloak/tests/authz/UmaDiscoveryDocumentTest.java:17 - Moving this class into
org.keycloak.tests.authzmakes the new suite select it, but it remains a JUnit 4/Arquillian test using@ArquillianResourceand fixed legacy URLs, with no@KeycloakIntegrationTest. It therefore is not actually migrated to or executed by the Jupiter framework; migrate its annotations/resources and URLs before moving the package.
tests/base/src/test/java/org/keycloak/tests/authz/AuthzClientTest.java:18 - This overwrites the process-wide crypto provider and never restores it. Because the framework only installs
DefaultCryptoProviderwhenCryptoIntegrationis uninitialized, later integration tests can inheritAuthzClientCryptoProvider, whose algorithm/certificate methods throwUnsupportedOperationException; save the previous provider and restore it infinally/@AfterEach.
tests/base/src/test/java/org/keycloak/tests/authz/admin/GenericPolicyManagementAdminEventTest.java:41 - This update remains inside the legacy
afterAbstractKeycloakTestRealmImporthook, which the Jupiter extension does not invoke, so this subclass never enables admin events. Convert the override into a Jupiter lifecycle callback.
tests/base/src/test/java/org/keycloak/tests/authz/RolePolicyTest.java:214 - This managed-realm cleanup also targets the manually imported
authz-testclient and runs after that realm has been deleted by the superclass@AfterEach. Move this restoration ahead of manual realm teardown or use aManagedRealmrepresentingauthz-test.
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
AuthzClientCryptoProvider was leaking into later Base2TestSuite tests and breaking ManagedCertificates setup. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Admin policy and authorization tests still extended AbstractKeycloakTest without importing the authz-test realm. Extend AbstractAuthzTest so realm setup runs b 10BC8 efore configureAuthorization, and fix client lookup to use the imported realm. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Remove the private authzConfigurationStream helper now that admin tests extend AbstractAuthzTest, which already provides the protected method. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Load custom test providers in Base2, remove unavailable event-queue listener, add test policy provider to custom-providers, and migrate UmaDiscoveryDocumentTest to the new test framework. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Rewrite authz client config URLs, use test realm OIDC endpoints in UMA discovery test, deploy script policies, fix export test client realm, and replace Arquillian cleanup in policy evaluation test. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Decouple authz tests from the legacy Arquillian base, enable realm events for manual Events wrappers, use KeycloakServerConfig for SCRIPTS, and fix API drift in PolicyEvaluationTest and UmaDiscoveryDocumentTest. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Assign the injected admin client to the shared realm support field so authz tests can import realms during @beforeeach setup. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Use integration-arquillian-testsuite-providers instead of the empty deployment artifact so custom policy providers and test application endpoints are available to migrated authz tests. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Use dynamic auth server and sector identifier URLs for pairwise clients, invoke afterImportTestRealms for user ID setup, and resolve token endpoint from the injected OAuth client instead of legacy static URLs. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Poll events via the testsuite testing SPI like legacy AssertEvents, migrate remaining JUnit 4 admin tests to Jupiter, and isolate OAuth client config in the public client claims test. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Register TestEventsListenerProvider when importing authz test realms so pollEvent() works, and fix ScopeManagementTest policy scope assertion. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Copy deployed script policies into keycloak-tests-custom-scripts, wire that dependency into AuthzScriptsServerConfig/Base2ServerConfig, create alice in the authz-test realm for import settings, use InjectRunOnServer for UMA permission cleanup checks, and fix the public-client claims test. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
AUTHORIZATION is already a default feature; enabling it in the suite conflicted with AuthorizationDisabledInPreviewTest which disables it. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Clear leaked OAuth offline_access scope between EntitlementAPITest methods, disable ADMIN_FINE_GRAINED_AUTHZ_V2 with AUTHORIZATION so the preview-disabled server can start, and give migrated authz tests DefaultAuthzServerConfig with testsuite providers. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Drop arquillian and system-rules dependencies from tests/base, move authz policy test providers into custom-providers, and switch the migrated authz base to framework SectorIdentifier/events APIs. Also fix KEYCLOAK-4340 realm lookup, authz-client cleanup, AuthzClient HTTP client reuse, and restore env-var substitution coverage. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
PERMISSION_TOKEN_ERROR is not saveByDefault, so enable all EventTypes when configuring migrated authz test realms for admin-API event asserts. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Use the injected RunOnServerClient so the migrated PolicyEvaluation and UserManagedPermission tests compile under the new framework. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Also remove unused Assertions imports that failed Spotless check. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
| String authServerRoot = authServerRoot(); | ||
| String config = new String(input.readAllBytes(), StandardCharsets.UTF_8) | ||
| .replace("http://localhost:8180/auth", authServerRoot) | ||
| .replace("https://localhost:8543/auth", authServerRoot); | ||
| return new ByteArrayInputStream(config.getBytes(StandardCharsets.UTF_8)); |
| public void testFetchDiscoveryDocument() { | ||
| Client client = AdminClientUtil.createResteasyClient(); | ||
| UriBuilder builder = UriBuilder.fromUri(OAuthClient.AUTH_SERVER_ROOT); | ||
| Client client = ClientBuilder.newClient(); |

fixes: #50754