use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerUpperCaseEmailWithChangedEmailAsUsername.
@Test
public void registerUpperCaseEmailWithChangedEmailAsUsername() throws IOException {
String userId = registerUpperCaseAndGetUserId(false);
assertThat(userId, notNullValue());
oauth.openLogout();
events.clear();
try (RealmAttributeUpdater rau = configureRealmRegistrationEmailAsUsername(true).update()) {
loginPage.open();
loginPage.assertCurrent();
final String EMAIL = "TEST@localhost";
loginPage.login(EMAIL, "password");
assertThat(RequestType.AUTH_RESPONSE, is(appPage.getRequestType()));
events.expectLogin().detail("username", EMAIL).user(userId).assertEvent();
} finally {
assertThat(userId, notNullValue());
testRealm().users().get(userId).remove();
}
}
use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerUserMissingOrInvalidEmail_emailAsUsername.
@Test
public void registerUserMissingOrInvalidEmail_emailAsUsername() throws IOException {
try (RealmAttributeUpdater rau = configureRealmRegistrationEmailAsUsername(true).update()) {
loginPage.open();
loginPage.clickRegister();
registerPage.assertCurrent();
registerPage.registerWithEmailAsUsername("firstName", "lastName", null, "password", "password");
registerPage.assertCurrent();
assertEquals("Please specify email.", registerPage.getInputAccountErrors().getEmailError());
events.expectRegister(null, null).removeDetail("username").removeDetail("email").error("invalid_registration").assertEvent();
registerPage.registerWithEmailAsUsername("firstName", "lastName", "registerUserInvalidEmailemail", "password", "password");
registerPage.assertCurrent();
assertEquals("Invalid email address.", registerPage.getInputAccountErrors().getEmailError());
events.expectRegister("registerUserInvalidEmailemail", "registerUserInvalidEmailemail").error("invalid_registration").assertEvent();
}
}
use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerUpperCaseEmailAsUsername.
@Test
public void registerUpperCaseEmailAsUsername() throws IOException {
try (RealmAttributeUpdater rau = configureRealmRegistrationEmailAsUsername(true).update()) {
String userId = registerUpperCaseAndGetUserId(true);
assertThat(userId, notNullValue());
testRealm().users().get(userId).remove();
}
}
use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerUserSuccess_emailAsUsername.
@Test
public void registerUserSuccess_emailAsUsername() throws IOException {
try (RealmAttributeUpdater rau = configureRealmRegistrationEmailAsUsername(true).update()) {
loginPage.open();
loginPage.clickRegister();
registerPage.assertCurrent();
registerPage.registerWithEmailAsUsername("firstName", "lastName", "registerUserSuccessE@email", "password", "password");
assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
String userId = events.expectRegister("registerUserSuccessE@email", "registerUserSuccessE@email").assertEvent().getUserId();
events.expectLogin().detail("username", "registerusersuccesse@email").user(userId).assertEvent();
UserRepresentation user = getUser(userId);
Assert.assertNotNull(user);
Assert.assertNotNull(user.getCreatedTimestamp());
// test that timestamp is current with 10s tollerance
Assert.assertTrue((System.currentTimeMillis() - user.getCreatedTimestamp()) < 10000);
}
}
use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.
the class RegisterTest method registerUserNotEmailPasswordPolicy.
// KEYCLOAK-12729
@Test
public void registerUserNotEmailPasswordPolicy() throws IOException {
try (RealmAttributeUpdater rau = configureRealmRegistrationEmailAsUsername(true).setPasswordPolicy("notEmail").update()) {
loginPage.open();
assertTrue(loginPage.isCurrent());
loginPage.clickRegister();
registerPage.assertCurrent();
registerPage.registerWithEmailAsUsername("firstName", "lastName", "registerUserNotEmail@email", "registerUserNotEmail@email", "registerUserNotEmail@email");
assertTrue(registerPage.isCurrent());
assertEquals("Invalid password: must not be equal to the email.", registerPage.getInputPasswordErrors().getPasswordError());
}
}
Aggregations