forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate locale when using app initiated registration URL
Fixes keycloak#13505 Signed-off-by: Thomas Darimont <thomas.darimont@googlemail.com>
- Loading branch information
1 parent
7988f02
commit 6b83a45
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...tests/base/src/test/java/org/keycloak/testsuite/actions/AppInitiatedRegistrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.keycloak.testsuite.actions; | ||
|
||
import jakarta.ws.rs.core.UriBuilder; | ||
import org.jboss.arquillian.graphene.page.Page; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.keycloak.locale.LocaleSelectorProvider; | ||
import org.keycloak.representations.idm.RealmRepresentation; | ||
import org.keycloak.representations.idm.UserRepresentation; | ||
import org.keycloak.testsuite.AbstractTestRealmKeycloakTest; | ||
import org.keycloak.testsuite.Assert; | ||
import org.keycloak.testsuite.admin.ApiUtil; | ||
import org.keycloak.testsuite.pages.AppPage; | ||
import org.keycloak.testsuite.pages.RegisterPage; | ||
|
||
public class AppInitiatedRegistrationTest extends AbstractTestRealmKeycloakTest { | ||
|
||
@Page | ||
protected AppPage appPage; | ||
|
||
@Page | ||
protected RegisterPage registerPage; | ||
|
||
@Override | ||
public void configureTestRealm(RealmRepresentation testRealm) { | ||
} | ||
|
||
@Before | ||
public void before() { | ||
ApiUtil.removeUserByUsername(testRealm(), "test-user@localhost"); | ||
} | ||
|
||
@Test | ||
public void ensureLocaleParameterIsPropagatedDuringAppInitiatedRegistration() { | ||
|
||
var appInitiatedRegisterUrlBuilder = UriBuilder.fromUri(oauth.getRegisterationsUrl()); | ||
appInitiatedRegisterUrlBuilder.queryParam(LocaleSelectorProvider.KC_LOCALE_PARAM, "en"); | ||
var appInitiatedRegisterUrl = appInitiatedRegisterUrlBuilder.build().toString(); | ||
|
||
driver.navigate().to(appInitiatedRegisterUrl); | ||
|
||
registerPage.assertCurrent(); | ||
registerPage.register("first", "last", "test-user@localhost", "test-user", "test","test"); | ||
|
||
appPage.assertCurrent(); | ||
|
||
UserRepresentation user = testRealm().users().searchByEmail("test-user@localhost", true).get(0); | ||
// ensure that the locale was set on the user | ||
Assert.assertEquals("en", user.getAttributes().get("locale").get(0)); | ||
} | ||
} |