forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add verify email required action for IdP email verification
Closes keycloak#26418 Signed-off-by: Lex Cao <[email protected]>
- Loading branch information
Showing
2 changed files
with
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -953,6 +953,44 @@ public void testLinkAccountByEmailVerificationTwice() { | |
waitForPage(driver, "your email address has been verified already.", false); | ||
} | ||
|
||
@Test | ||
public void testLinkAccountByEmailVerificationToEmailVerifiedUser() { | ||
// set up a user with verified email | ||
RealmResource realm = adminClient.realm(bc.consumerRealmName()); | ||
|
||
UserResource userResource = realm.users().get(createUser("consumer")); | ||
UserRepresentation consumerUser = userResource.toRepresentation(); | ||
|
||
consumerUser.setEmail(bc.getUserEmail()); | ||
consumerUser.setEmailVerified(true); | ||
userResource.update(consumerUser); | ||
configureSMTPServer(); | ||
|
||
// begin login with idp | ||
oauth.clientId("broker-app"); | ||
loginPage.open(bc.consumerRealmName()); | ||
logInWithBroker(bc); | ||
|
||
// update account profile | ||
waitForPage(driver, "update account information", false); | ||
updateAccountInformationPage.assertCurrent(); | ||
updateAccountInformationPage.updateAccountInformation("FirstName", "LastName"); | ||
|
||
// idp confirm link | ||
waitForPage(driver, "account already exists", false); | ||
idpConfirmLinkPage.assertCurrent(); | ||
assertEquals("User with email [email protected] already exists. How do you want to continue?", idpConfirmLinkPage.getMessage()); | ||
idpConfirmLinkPage.clickLinkAccount(); | ||
|
||
String url = assertEmailAndGetUrl(MailServerConfiguration.FROM, USER_EMAIL, | ||
"Someone wants to link your ", false); | ||
driver.navigate().to(url); | ||
|
||
assertTrue(driver.getCurrentUrl().startsWith(getConsumerRoot() + "/auth/realms/master/app/")); | ||
assertTrue(adminClient.realm(bc.consumerRealmName()).users().get(consumerUser.getId()).toRepresentation().isEmailVerified()); | ||
assertNumFederatedIdentities(consumerUser.getId(), 1); | ||
} | ||
|
||
|
||
/** | ||
* Refers to in old test suite: org.keycloak.testsuite.broker.AbstractFirstBrokerLoginTest#testLinkAccountByEmailVerificationResendEmail | ||
|