Ejemplo n.º 1
0
  @Test
  public void resetPasswordCancel() throws IOException, MessagingException {
    loginPage.open();
    loginPage.resetPassword();

    resetPasswordPage.assertCurrent();

    resetPasswordPage.changePassword("login-test");

    resetPasswordPage.assertCurrent();

    events
        .expectRequiredAction(EventType.SEND_RESET_PASSWORD)
        .user(userId)
        .detail(Details.USERNAME, "login-test")
        .detail(Details.EMAIL, "*****@*****.**")
        .assertEvent()
        .getSessionId();

    resetPasswordPage.backToLogin();

    Assert.assertTrue(loginPage.isCurrent());

    loginPage.login("login-test", "password");

    events.expectLogin().user(userId).detail(Details.USERNAME, "login-test").assertEvent();

    Assert.assertEquals(1, greenMail.getReceivedMessages().length);

    MimeMessage message = greenMail.getReceivedMessages()[0];

    String body = (String) message.getContent();
    String changePasswordUrl = MailUtil.getLink(body);

    driver.navigate().to(changePasswordUrl.trim());

    events
        .expect(EventType.RESET_PASSWORD_ERROR)
        .client((String) null)
        .user((String) null)
        .error("invalid_code")
        .clearDetails()
        .assertEvent();

    Assert.assertTrue(errorPage.isCurrent());
    Assert.assertEquals(
        "Unknown code, please login again through your application.", errorPage.getError());
  }
Ejemplo n.º 2
0
  protected void testSuccessfulImpersonation(String admin, String adminRealm) {
    Client client = createClient(admin, adminRealm);
    WebTarget impersonate = createImpersonateTarget(client);
    Map data = impersonate.request().post(null, Map.class);
    Assert.assertNotNull(data);
    Assert.assertNotNull(data.get("redirect"));

    events
        .expect(EventType.IMPERSONATE)
        .session(AssertEvents.isUUID())
        .user(impersonatedUserId)
        .detail(Details.IMPERSONATOR, admin)
        .detail(Details.IMPERSONATOR_REALM, adminRealm)
        .client((String) null)
        .assertEvent();

    client.close();
  }