use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerUserSuccessWithEmailVerificationWithResend.
@Test
// GreenMailRule is not working atm
@AuthServerContainerExclude(AuthServer.REMOTE)
public void registerUserSuccessWithEmailVerificationWithResend() throws Exception {
try (RealmAttributeUpdater rau = setVerifyEmail(true).update()) {
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
}
}
use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerUserNotUsernamePasswordPolicy.
// KEYCLOAK-3266
@Test
public void registerUserNotUsernamePasswordPolicy() throws IOException {
try (RealmAttributeUpdater rau = getRealmAttributeUpdater().setPasswordPolicy("notUsername").update()) {
loginPage.open();
assertTrue(loginPage.isCurrent());
loginPage.clickRegister();
registerPage.assertCurrent();
registerPage.register("firstName", "lastName", "registerUserNotUsername@email", "registerUserNotUsername", "registerUserNotUsername", "registerUserNotUsername");
assertTrue(registerPage.isCurrent());
assertEquals("Invalid password: must not be equal to the username.", registerPage.getInputPasswordErrors().getPasswordError());
adminClient.realm("test").users().create(UserBuilder.create().username("registerUserNotUsername").build());
registerPage.register("firstName", "lastName", "registerUserNotUsername@email", "registerUserNotUsername", "registerUserNotUsername", "registerUserNotUsername");
assertTrue(registerPage.isCurrent());
assertEquals("Username already exists.", registerPage.getInputAccountErrors().getUsernameError());
registerPage.register("firstName", "lastName", "registerUserNotUsername@email", null, "password", "password");
assertTrue(registerPage.isCurrent());
assertEquals("Please specify username.", registerPage.getInputAccountErrors().getUsernameError());
}
}
use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerUserSuccessWithEmailVerification.
@Test
// GreenMailRule is not working atm
@AuthServerContainerExclude(AuthServer.REMOTE)
public void registerUserSuccessWithEmailVerification() throws Exception {
try (RealmAttributeUpdater rau = setVerifyEmail(true).update()) {
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
}
}
use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerWithLoginHint_emailAsUsername.
@Test
public void registerWithLoginHint_emailAsUsername() throws IOException {
try (RealmAttributeUpdater rau = configureRealmRegistrationEmailAsUsername(true).update()) {
registerPage.openWithLoginHint("test@test.com");
assertEquals("test@test.com", registerPage.getEmail());
}
}
use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class LoginTest method loginRememberMeExpiredIdle.
@Test
// TODO remove this (KEYCLOAK-16228)
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true)
public void loginRememberMeExpiredIdle() throws Exception {
try (Closeable c = new RealmAttributeUpdater(adminClient.realm("test")).setSsoSessionIdleTimeoutRememberMe(1).setRememberMe(true).update()) {
// login form shown after redirect from app
oauth.clientId("test-app");
oauth.redirectUri(OAuthClient.APP_ROOT + "/auth");
oauth.openLoginForm();
assertTrue(loginPage.isCurrent());
loginPage.setRememberMe(true);
loginPage.login("test-user@localhost", "password");
// sucessful login - app page should be on display.
events.expectLogin().detail(Details.USERNAME, "test-user@localhost").assertEvent();
appPage.assertCurrent();
// expire idle timeout using the timeout window.
setTimeOffset(2 + SessionTimeoutHelper.IDLE_TIMEOUT_WINDOW_SECONDS);
// trying to open the account page with an expired idle timeout should redirect back to the login page.
appPage.openAccount();
loginPage.assertCurrent();
}
}
Aggregations