Java Code Examples for org.keycloak.representations.idm.RealmRepresentation#setVerifyEmail()
The following examples show how to use
org.keycloak.representations.idm.RealmRepresentation#setVerifyEmail() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrustStoreEmailTest.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void configureTestRealm(RealmRepresentation testRealm) { log.info("enable verify email and configure smtp server to run with ssl in test realm"); testRealm.setSmtpServer(SslMailServer.getServerConfiguration()); testRealm.setVerifyEmail(true); }
Example 2
Source File: AbstractFirstBrokerLoginTest.java From keycloak with Apache License 2.0 | 5 votes |
/** * Refers to in old test suite: org.keycloak.testsuite.broker.AbstractKeycloakIdentityProviderTest#testSuccessfulAuthenticationWithoutUpdateProfile_emailNotProvided_emailVerifyEnabled * */ @Test public void testSuccessfulAuthenticationWithoutUpdateProfile_emailNotProvided_emailVerifyEnabled() { RealmResource realm = adminClient.realm(bc.consumerRealmName()); RealmRepresentation realmRep = realm.toRepresentation(); realmRep.setVerifyEmail(true); realm.update(realmRep); updateExecutions(AbstractBrokerTest::disableUpdateProfileOnFirstLogin); createUser(bc.providerRealmName(), "no-email", "password", "FirstName", "LastName", null); driver.navigate().to(getAccountUrl(getConsumerRoot(), bc.consumerRealmName())); log.debug("Clicking social " + bc.getIDPAlias()); loginPage.clickSocial(bc.getIDPAlias()); waitForPage(driver, "log in to", true); Assert.assertTrue("Driver should be on the provider realm page right now", driver.getCurrentUrl().contains("/auth/realms/" + bc.providerRealmName() + "/")); log.debug("Logging in"); loginPage.login("no-email", "password"); waitForAccountManagementTitle(); accountUpdateProfilePage.assertCurrent(); List<UserRepresentation> users = realm.users().search("no-email"); assertEquals(1, users.size()); List<String> requiredActions = users.get(0).getRequiredActions(); assertEquals(1, requiredActions.size()); assertEquals(UserModel.RequiredAction.VERIFY_EMAIL.name(), requiredActions.get(0)); }
Example 3
Source File: AbstractFirstBrokerLoginTest.java From keycloak with Apache License 2.0 | 5 votes |
/** * Refers to in old test suite: org.keycloak.testsuite.broker.AbstractKeycloakIdentityProviderTest#testSuccessfulAuthenticationWithoutUpdateProfile_emailProvided_emailVerifyEnabled_emailTrustEnabled */ @Test public void testVerifyEmailNotRequiredActionWhenEmailIsTrustedByProvider() { RealmResource realm = adminClient.realm(bc.consumerRealmName()); RealmRepresentation realmRep = realm.toRepresentation(); realmRep.setVerifyEmail(true); realm.update(realmRep); IdentityProviderRepresentation idpRep = identityProviderResource.toRepresentation(); idpRep.setTrustEmail(true); identityProviderResource.update(idpRep); driver.navigate().to(getAccountUrl(getConsumerRoot(), bc.consumerRealmName())); logInWithBroker(bc); waitForPage(driver, "update account information", false); updateAccountInformationPage.assertCurrent(); updateAccountInformationPage.updateAccountInformation("FirstName", "LastName"); waitForAccountManagementTitle(); accountUpdateProfilePage.assertCurrent(); List<UserRepresentation> users = realm.users().search(bc.getUserLogin()); assertEquals(1, users.size()); List<String> requiredActions = users.get(0).getRequiredActions(); assertEquals(0, requiredActions.size()); }
Example 4
Source File: AbstractFirstBrokerLoginTest.java From keycloak with Apache License 2.0 | 5 votes |
/** * Refers to in old test suite: org.keycloak.testsuite.broker.AbstractKeycloakIdentityProviderTest#testSuccessfulAuthentication_emailTrustEnabled_emailVerifyEnabled_emailUpdatedOnFirstLogin */ @Test public void testVerifyEmailRequiredActionWhenChangingEmailDuringFirstLogin() { RealmResource realm = adminClient.realm(bc.consumerRealmName()); RealmRepresentation realmRep = realm.toRepresentation(); realmRep.setVerifyEmail(true); realm.update(realmRep); IdentityProviderRepresentation idpRep = identityProviderResource.toRepresentation(); idpRep.setTrustEmail(true); identityProviderResource.update(idpRep); configureSMTPServer(); driver.navigate().to(getAccountUrl(getConsumerRoot(), bc.consumerRealmName())); logInWithBroker(bc); waitForPage(driver, "update account information", false); updateAccountInformationPage.assertCurrent(); updateAccountInformationPage.updateAccountInformation("[email protected]", "FirstName", "LastName"); verifyEmailPage.assertCurrent(); String verificationUrl = assertEmailAndGetUrl(MailServerConfiguration.FROM, "[email protected]", "verify your email address", false); driver.navigate().to(verificationUrl.trim()); waitForAccountManagementTitle(); accountUpdateProfilePage.assertCurrent(); List<UserRepresentation> users = realm.users().search(bc.getUserLogin()); assertEquals(1, users.size()); List<String> requiredActions = users.get(0).getRequiredActions(); assertEquals(0, requiredActions.size()); }
Example 5
Source File: RegisterTest.java From keycloak with Apache License 2.0 | 4 votes |
@Test @AuthServerContainerExclude(AuthServer.REMOTE) // GreenMailRule is not working atm public void registerUserSuccessWithEmailVerification() throws Exception { RealmRepresentation realm = testRealm().toRepresentation(); boolean origVerifyEmail = realm.isVerifyEmail(); try { realm.setVerifyEmail(true); testRealm().update(realm); loginPage.open(); loginPage.clickRegister(); registerPage.assertCurrent(); registerPage.register("firstName", "lastName", "registerUserSuccessWithEmailVerification@email", "registerUserSuccessWithEmailVerification", "password", "password"); verifyEmailPage.assertCurrent(); String userId = events.expectRegister("registerUserSuccessWithEmailVerification", "registerUserSuccessWithEmailVerification@email").assertEvent().getUserId(); { assertTrue("Expecting verify email", greenMail.waitForIncomingEmail(1000, 1)); events.expect(EventType.SEND_VERIFY_EMAIL) .detail(Details.EMAIL, "registerUserSuccessWithEmailVerification@email".toLowerCase()) .user(userId) .assertEvent(); MimeMessage message = greenMail.getLastReceivedMessage(); String link = MailUtils.getPasswordResetEmailLink(message); driver.navigate().to(link); } events.expectRequiredAction(EventType.VERIFY_EMAIL) .detail(Details.EMAIL, "registerUserSuccessWithEmailVerification@email".toLowerCase()) .user(userId) .assertEvent(); assertUserRegistered(userId, "registerUserSuccessWithEmailVerification", "registerUserSuccessWithEmailVerification@email"); appPage.assertCurrent(); assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); // test that timestamp is current with 10s tollerance // test user info is set from form } finally { realm.setVerifyEmail(origVerifyEmail); testRealm().update(realm); } }
Example 6
Source File: RegisterTest.java From keycloak with Apache License 2.0 | 4 votes |
@Test @AuthServerContainerExclude(AuthServer.REMOTE) // GreenMailRule is not working atm public void registerUserSuccessWithEmailVerificationWithResend() throws Exception { RealmRepresentation realm = testRealm().toRepresentation(); boolean origVerifyEmail = realm.isVerifyEmail(); try { realm.setVerifyEmail(true); testRealm().update(realm); loginPage.open(); loginPage.clickRegister(); registerPage.assertCurrent(); registerPage.register("firstName", "lastName", "registerUserSuccessWithEmailVerificationWithResend@email", "registerUserSuccessWithEmailVerificationWithResend", "password", "password"); verifyEmailPage.assertCurrent(); String userId = events.expectRegister("registerUserSuccessWithEmailVerificationWithResend", "registerUserSuccessWithEmailVerificationWithResend@email").assertEvent().getUserId(); { assertTrue("Expecting verify email", greenMail.waitForIncomingEmail(1000, 1)); events.expect(EventType.SEND_VERIFY_EMAIL) .detail(Details.EMAIL, "registerUserSuccessWithEmailVerificationWithResend@email".toLowerCase()) .user(userId) .assertEvent(); verifyEmailPage.clickResendEmail(); verifyEmailPage.assertCurrent(); assertTrue("Expecting second verify email", greenMail.waitForIncomingEmail(1000, 1)); events.expect(EventType.SEND_VERIFY_EMAIL) .detail(Details.EMAIL, "registerUserSuccessWithEmailVerificationWithResend@email".toLowerCase()) .user(userId) .assertEvent(); MimeMessage message = greenMail.getLastReceivedMessage(); String link = MailUtils.getPasswordResetEmailLink(message); driver.navigate().to(link); } events.expectRequiredAction(EventType.VERIFY_EMAIL) .detail(Details.EMAIL, "registerUserSuccessWithEmailVerificationWithResend@email".toLowerCase()) .user(userId) .assertEvent(); assertUserRegistered(userId, "registerUserSuccessWithEmailVerificationWithResend", "registerUserSuccessWithEmailVerificationWithResend@email"); appPage.assertCurrent(); assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType()); // test that timestamp is current with 10s tollerance // test user info is set from form } finally { realm.setVerifyEmail(origVerifyEmail); testRealm().update(realm); } }
Example 7
Source File: RequiredActionEmailVerificationTest.java From keycloak with Apache License 2.0 | 4 votes |
@Override public void configureTestRealm(RealmRepresentation testRealm) { testRealm.setVerifyEmail(Boolean.TRUE); ActionUtil.findUserInRealmRep(testRealm, "test-user@localhost").setEmailVerified(Boolean.FALSE); }
Example 8
Source File: RealmManager.java From keycloak with Apache License 2.0 | 4 votes |
public RealmManager verifyEmail(Boolean enabled) { RealmRepresentation rep = realm.toRepresentation(); rep.setVerifyEmail(enabled); realm.update(rep); return this; }
Example 9
Source File: AbstractFirstBrokerLoginTest.java From keycloak with Apache License 2.0 | 3 votes |
/** * Refers to in old test suite: org.keycloak.testsuite.broker.AbstractKeycloakIdentityProviderTest#testSuccessfulAuthenticationWithoutUpdateProfile_emailProvided_emailVerifyEnabled */ @Test public void testLinkAccountWithUntrustedEmailVerified() { RealmResource realm = adminClient.realm(bc.consumerRealmName()); RealmRepresentation realmRep = realm.toRepresentation(); realmRep.setVerifyEmail(true); realm.update(realmRep); IdentityProviderRepresentation idpRep = identityProviderResource.toRepresentation(); idpRep.setTrustEmail(false); identityProviderResource.update(idpRep); configureSMTPServer(); driver.navigate().to(getAccountUrl(getConsumerRoot(), bc.consumerRealmName())); logInWithBroker(bc); waitForPage(driver, "update account information", false); updateAccountInformationPage.assertCurrent(); updateAccountInformationPage.updateAccountInformation("FirstName", "LastName"); verifyEmailPage.assertCurrent(); String verificationUrl = assertEmailAndGetUrl(MailServerConfiguration.FROM, USER_EMAIL, "verify your email address", false); driver.navigate().to(verificationUrl.trim()); waitForAccountManagementTitle(); accountUpdateProfilePage.assertCurrent(); }