예제 #1
0
  @Test
  public void changePassword() {
    changePasswordPage.open();
    loginPage.login("test-user@localhost", "password");

    changePasswordPage.changePassword("", "new-password", "new-password");

    Assert.assertTrue(profilePage.isError());

    changePasswordPage.changePassword("password", "new-password", "new-password2");

    Assert.assertTrue(profilePage.isError());

    changePasswordPage.changePassword("password", "new-password", "new-password");

    Assert.assertTrue(profilePage.isSuccess());

    changePasswordPage.logout();

    loginPage.open();
    loginPage.login("test-user@localhost", "password");

    Assert.assertEquals("Invalid username or password.", loginPage.getError());

    loginPage.open();
    loginPage.login("test-user@localhost", "new-password");

    Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
  }
예제 #2
0
  @Test
  public void changePasswordWithPasswordPolicy() {
    keycloakRule.configure(
        new KeycloakRule.KeycloakSetup() {
          @Override
          public void config(
              RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
            appRealm.setPasswordPolicy(new PasswordPolicy("length"));
          }
        });

    try {
      changePasswordPage.open();
      loginPage.login("test-user@localhost", "password");

      changePasswordPage.changePassword("", "new", "new");

      Assert.assertTrue(profilePage.isError());

      changePasswordPage.changePassword("password", "new-password", "new-password");

      Assert.assertTrue(profilePage.isSuccess());
    } finally {
      keycloakRule.configure(
          new KeycloakRule.KeycloakSetup() {
            @Override
            public void config(
                RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
              appRealm.setPasswordPolicy(new PasswordPolicy(null));
            }
          });
    }
  }
예제 #3
0
  @Test
  public void changeProfile() {
    profilePage.open();
    loginPage.login("test-user@localhost", "password");

    Assert.assertEquals("", profilePage.getFirstName());
    Assert.assertEquals("", profilePage.getLastName());
    Assert.assertEquals("test-user@localhost", profilePage.getEmail());

    // All fields are required, so there should be an error when something is missing.
    profilePage.updateProfile("", "New last", "*****@*****.**");

    Assert.assertTrue(profilePage.isError());
    Assert.assertEquals("", profilePage.getFirstName());
    Assert.assertEquals("", profilePage.getLastName());
    Assert.assertEquals("test-user@localhost", profilePage.getEmail());

    profilePage.updateProfile("New first", "", "*****@*****.**");

    Assert.assertTrue(profilePage.isError());
    Assert.assertEquals("", profilePage.getFirstName());
    Assert.assertEquals("", profilePage.getLastName());
    Assert.assertEquals("test-user@localhost", profilePage.getEmail());

    profilePage.updateProfile("New first", "New last", "");

    Assert.assertTrue(profilePage.isError());
    Assert.assertEquals("", profilePage.getFirstName());
    Assert.assertEquals("", profilePage.getLastName());
    Assert.assertEquals("test-user@localhost", profilePage.getEmail());

    profilePage.updateProfile("New first", "New last", "*****@*****.**");

    Assert.assertTrue(profilePage.isSuccess());
    Assert.assertEquals("New first", profilePage.getFirstName());
    Assert.assertEquals("New last", profilePage.getLastName());
    Assert.assertEquals("*****@*****.**", profilePage.getEmail());
  }
예제 #4
0
  @Test
  public void setupTotp() {
    totpPage.open();
    loginPage.login("test-user@localhost", "password");

    Assert.assertTrue(totpPage.isCurrent());

    Assert.assertFalse(driver.getPageSource().contains("Remove Google"));

    // Error with false code
    totpPage.configure(totp.generate(totpPage.getTotpSecret() + "123"));

    Assert.assertTrue(profilePage.isError());

    totpPage.configure(totp.generate(totpPage.getTotpSecret()));

    Assert.assertTrue(profilePage.isSuccess());

    Assert.assertTrue(driver.getPageSource().contains("Remove Google"));
  }