示例#1
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));
            }
          });
    }
  }
示例#2
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());
  }
示例#3
0
  @Test
  public void returnToAppFromQueryParam() {
    driver.navigate().to(AccountUpdateProfilePage.PATH + "?referrer=test-app");
    loginPage.login("test-user@localhost", "password");
    Assert.assertTrue(profilePage.isCurrent());
    profilePage.backToApplication();

    Assert.assertTrue(appPage.isCurrent());
  }
示例#4
0
  @Test
  public void returnToAppFromHeader() {
    appPage.open();
    appPage.openAccount();
    loginPage.login("test-user@localhost", "password");

    Assert.assertTrue(profilePage.isCurrent());
    profilePage.backToApplication();

    Assert.assertTrue(appPage.isCurrent());
  }
示例#5
0
  @Test
  public void changeProfileNoAccess() throws Exception {
    profilePage.open();
    loginPage.login("test-user-no-access@localhost", "password");

    Assert.assertTrue(errorPage.isCurrent());
    Assert.assertEquals("No access", errorPage.getError());
  }
示例#6
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"));
  }
示例#7
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());
  }