8000 migration test RequiredActionUpdateProfileTest by gaoyikeshuer · Pull Request #48648 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

migration test RequiredActionUpdateProfileTest - #48648

Merged
rmartinc merged 1 commit into
keycloak:mainfrom
gaoyikeshuer:48149-migration-test
May 19, 2026
Merged

rmartinc merged 1 commit into
keycloak:mainfrom
gaoyikeshuer:48149-migration-test

Conversation

@gaoyikeshuer
@gaoyikeshuer gaoyikeshuer commented May 1, 2026 •
Copy link
Copy Markdown
Contributor

Closes #48149

@gaoyikeshuer
gaoyikeshuer force-pushed the 48149-migration-test branch 8 times, most recently from 8fdb9ed to 7843fca Compare May 5, 2026 08:04
@gaoyikeshuer
gaoyikeshuer marked this pull request as ready for review May 5, 2026 08:57
@gaoyikeshuer
gaoyikeshuer requested review from a team as code owners May 5, 2026 08:57
@rmartinc rmartinc 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.

Thanks @gaoyikeshuer! LGTM, just we need to add to the database and forms suite. I'm addiing @vaceksimon for the review too.

@rmartinc
rmartinc requested a review from vaceksimon May 5, 2026 13:26
@gaoyikeshuer
gaoyikeshuer force-pushed the 48149-migration-test branch 2 times, most recently from 282e64f to 4912c47 Compare May 6, 2026 13:24
@vaceksimon
Copy link
Copy Markdown
Contributor

Hi Yike, thanks for the contribution! I am swamped this week, I can take a look on Tuesday.

@gaoyikeshuer
gaoyikeshuer force-pushed the 48149-migration-test branch 2 times, most recently from ed93004 to fd7a3aa Compare May 6, 2026 14:40
@rmartinc rmartinc 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.

Thanks @gaoyikeshuer! It's almost OK, I don'r understand why you are removing the other class RequiredActionUpdateProfileWithUserProfileTest. Is this done on purpose? I think that this class should not be touched for the moment.

The other comment is just because I think you can just create the users with the same generated password and do not need to the resetPassword method anymore. It's much clearer this way. WDYT?

@gaoyikeshuer
gaoyikeshuer force-pushed the 48149-migration-test branch 3 times, most recently from 7ed1145 to f6e4ed4 Compare May 7, 2026 13:38
@@ -493,12 +532,12 @@ public void testMultivaluedAttributes() {
updateProfilePage.clickAddAttributeValue(elementId);
}
updateProfilePage.update("f", "l", "e@keycloak.org");
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.

@gaoyikeshuer I think you need to wait here for the page, my feeling is that you are reading the user before the browser has submitted the page.

                driver.waiting().waitForOAuthCallback();

In the four updateProfilePage.update in this method.

@gaoyikeshuer gaoyikeshuer May 11, 2026 •
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @rmartinc , thanks for pointing that out! Your suggestion fixed testMultivaluedAttributes and I added driver.waiting().waitForOAuthCallback(); after each of the four updateProfilePage.update(...) calls in that method.

But that alone wasn't enough for the rest of the class. The other tests that submit invalid input (updateProfileInvalidEmail, updateProfileMissingLastName, updateProfileMissingUsername, updateProfileDuplicateUsername) were failing with StaleElementReferenceException: after the server re-renders the form with the error, the cached WebElement is gone, so reading its value throws. I updated LoginUpdateProfilePage.readValue to catch SERE and retry with a fresh findElement.

With both fixes the suite is green on firefox-headless now. The whole build is red only because of a flaky unrelated test, but I don't have permission to re-run a single job. Moving the PR to ready for review.

@gaoyikeshuer
gaoyikeshuer force-pushed the 48149-migration-test branch 7 times, most recently from 2b1c1b2 to e5c0fb0 Compare May 11, 2026 09:49
@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If 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.forms.BrowserFlowTest#testUserWithoutAdditionalFactorConnection

Keycloak CI - Forms IT (chrome)

org.opentest4j.AssertionFailedError: Expected LoginPage but was localhost (https://localhost:8543/auth/realms/test/protocol/openid-connect/auth?scope=openid&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A8543%2Fauth%2Frealms%2Fmaster%2Fapp%2Fauth&client_id=test-app) ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...

Report flaky test

@gaoyikeshuer
gaoyikeshuer marked this pull request as ready for review May 11, 2026 10:49
@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If 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.forms.BrowserFlowTest#testUserWithoutAdditionalFactorConnection

Keycloak CI - Forms IT (chrome)

org.opentest4j.AssertionFailedError: Expected LoginPage but was localhost (https://localhost:8543/auth/realms/test/protocol/openid-connect/auth?scope=openid&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A8543%2Fauth%2Frealms%2Fmaster%2Fapp%2Fauth&client_id=test-app) ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...

Report flaky test

rmartinc
rmartinc previously approved these changes May 11, 2026
@rmartinc rmartinc 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.

Thanks @gaoyikeshuer! LGTM! Good job!

@vaceksimon Do you want to review this one tomorrow? Please let me know because for me it's OK now.

@vaceksimon vaceksimon 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.

Good work @gaoyikeshuer! I have a suggestion to use ManagedUser instances, which will reduce boilerplate code and the number of admin API requests.


@Page
protected AppPage appPage;
@InjectOAuthClient(config = RequiredActionUpdateProfileClientConfig.class)
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.

This config class is not needed and can be removed.

Comment on lines +649 to +658
realm.users(UserBuilder.create("test-user@localhost")
.email("test-user@localhost")
.name("Tom", "Brady")
.password(PASSWORD)
.emailVerified(true));
realm.users(UserBuilder.create("john-doh@localhost")
.email("john-doh@localhost")
.name("John", "Doh")
.password(PASSWORD)
.emailVerified(true));
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.

These two users can be moved to their own configuration classes instead:

    private static class TestUserConfig implements UserConfig {

        @Override
        public UserBuilder configure(UserBuilder user) {
            return user.username("test-user@localhost")
                    .email("test-user@localhost")
                    .name("Tom", "Brady")
                    .password(PASSWORD)
                    .emailVerified(true);
        }
    }

    private static class JohnDohUserConfig implements UserConfig {
        @Override
        public UserBuilder configure(UserBuilder user) {
            return user.username("john-doh@localhost")
                    .email("john-doh@localhost")
                    .name("John", "Doh")
                    .password(PASSWORD)
                    .emailVerified(true);
        }
    }

This brings the benefit that it can be passed to @InjectUser and you get access to a ManagedUser instance. Something like:

    @InjectUser(ref="testUser", config = RequiredActionUpdateProfileTest.TestUserConfig.class, lifecycle = LifeCycle.METHOD)
    ManagedUser testUser;

    @InjectUser(ref="johnDoh", config = RequiredActionUpdateProfileTest.JohnDohUserConfig.class, lifecycle = LifeCycle.METHOD)
    ManagedUser johnDohUser;

With these, you can now get rid of the whole @BeforeEach method.

It also gives access to this entities UserResource. So basically instead of looking fot the user with:

AdminApiUtil.findUserByUsername(realm.admin(), "test-user@localhost")

you can use directly:

testUser.admin().toRepresentation();

Assertions.assertEquals("New first", user.getFirstName());
Assertions.assertEquals("New last", user.getLastName());
Assertions.assertEquals("john-doh@localhost", user.getEmail());
Assertions.assertEquals("new", user.getUsername());
// email not changed so verify that emailVerified flag is NOT reset
Assertions.assertEquals(true, user.isEmailVerified());
getCleanup().addUserId(user.getId());
realm.cleanup().add(r -> r.users().get(user.getId()).remove());
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.

Once you have a ManagedUser with a lifecycle method, this should be redundant

@rmartinc rmartinc 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.

@gaoyikeshuer The tests seems to be failing now! Take a look when you have time. Thanks!

@gaoyikeshuer
gaoyikeshuer force-pushed the 48149-migration-test branch from 0ee253e to 2ffd553 Compare May 15, 2026 12:42
Signed-off-by: Yike Gao <yikegao8@gmail.com>
@gaoyikeshuer
gaoyikeshuer force-pushed the 48149-migration-test branch from 2ffd553 to 57c8400 Compare May 15, 2026 13:46
@rmartinc rmartinc 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.

Thanks @gaoyikeshuer! Please @vaceksimon check if it is OK now for you.

@vaceksimon vaceksimon 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. 10BC8 Learn more.

Perfect @gaoyikeshuer !

@rmartinc
Copy link
Copy Markdown
Contributor

Thanks @gaoyikeshuer and @vaceksimon!

@rmartinc
rmartinc merged commit 4aff9a4 into keycloak:main May 19, 2026
87 checks passed
@stianst stianst mentioned this pull request Jun 1, 2026
sashyo pushed a commit to tide-foundation/keycloak-IGA that referenced this pull request Jul 20, 2026
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.

Migrate the RequiredActionUpdateProfileTest

3 participants

0