Пример #1
0
  @Test
  public void testCreateOrganizationAndAdminWithConfirmationAndActivation() throws Exception {
    setup.set(PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "true");
    setup.set(PROPERTIES_NOTIFY_ADMIN_OF_ACTIVATION, "true");
    setup.set(PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false");
    setup.set(PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "true");

    final String orgName = uniqueOrg();
    final String userName = uniqueUsername();
    final String email = uniqueEmail();

    OrganizationOwnerInfo org_owner =
        createOwnerAndOrganization(
            orgName, userName, "Test User", email, "testpassword", false, false);

    assertNotNull(org_owner);

    List<Message> user_inbox = Mailbox.get(email);

    assertFalse(user_inbox.isEmpty());

    Message confirmation = user_inbox.get(0);
    assertEquals("User Account Confirmation: " + email, confirmation.getSubject());

    String token = getTokenFromMessage(confirmation);
    logger.info(token);

    ActivationState state =
        setup.getMgmtSvc().handleConfirmationTokenForAdminUser(org_owner.owner.getUuid(), token);
    assertEquals(ActivationState.CONFIRMED_AWAITING_ACTIVATION, state);

    confirmation = user_inbox.get(1);
    String body =
        ((MimeMultipart) confirmation.getContent()).getBodyPart(0).getContent().toString();
    Boolean subbedEmailed = StringUtils.contains(body, "$");

    assertFalse(subbedEmailed);

    assertEquals("User Account Confirmed", confirmation.getSubject());

    List<Message> sysadmin_inbox = Mailbox.get("*****@*****.**");
    assertFalse(sysadmin_inbox.isEmpty());

    Message activation = sysadmin_inbox.get(0);
    assertEquals("Request For Admin User Account Activation " + email, activation.getSubject());

    token = getTokenFromMessage(activation);
    logger.info(token);

    state = setup.getMgmtSvc().handleActivationTokenForAdminUser(org_owner.owner.getUuid(), token);
    assertEquals(ActivationState.ACTIVATED, state);

    Message activated = user_inbox.get(2);
    assertEquals("User Account Activated", activated.getSubject());

    MockImapClient client = new MockImapClient("mockserver.com", "test-user-2", "somepassword");
    client.processMail();
  }
Пример #2
0
  @Test
  public void testCreateOrganizationAndAdminWithConfirmationOnly() throws Exception {
    setup.set(PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false");
    setup.set(PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false");
    setup.set(PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "true");
    setup.set(PROPERTIES_NOTIFY_ADMIN_OF_ACTIVATION, "true");

    final String orgName = uniqueOrg();
    final String userName = uniqueUsername();
    final String email = uniqueEmail();

    OrganizationOwnerInfo org_owner =
        createOwnerAndOrganization(
            orgName, userName, "Test User", email, "testpassword", false, false);

    assertNotNull(org_owner);

    List<Message> inbox = Mailbox.get(email);

    assertFalse(inbox.isEmpty());

    MockImapClient client = new MockImapClient("mockserver.com", "test-user-1", "somepassword");
    client.processMail();

    Message confirmation = inbox.get(0);
    assertEquals("User Account Confirmation: " + email, confirmation.getSubject());

    String token = getTokenFromMessage(confirmation);
    logger.info(token);

    assertEquals(
        ActivationState.ACTIVATED,
        setup.getMgmtSvc().handleConfirmationTokenForAdminUser(org_owner.owner.getUuid(), token));

    Message activation = inbox.get(1);
    assertEquals("User Account Activated", activation.getSubject());

    client = new MockImapClient("mockserver.com", "test-user-1", "somepassword");
    client.processMail();
  }
Пример #3
0
  @Test
  public void skipAllEmailConfiguration() throws Exception {
    setup.set(PROPERTIES_SYSADMIN_APPROVES_ORGANIZATIONS, "false");
    setup.set(PROPERTIES_ORGANIZATIONS_REQUIRE_CONFIRMATION, "false");
    setup.set(PROPERTIES_SYSADMIN_APPROVES_ADMIN_USERS, "false");
    setup.set(PROPERTIES_ADMIN_USERS_REQUIRE_CONFIRMATION, "false");

    final String orgName = uniqueOrg();
    final String userName = uniqueUsername();
    final String email = uniqueEmail();

    OrganizationOwnerInfo ooi =
        setup
            .getMgmtSvc()
            .createOwnerAndOrganization(orgName, userName, "Test User", email, "testpassword");

    EntityManager em = setup.getEmf().getEntityManager(setup.getEmf().getManagementAppId());
    User user = em.get(ooi.getOwner().getUuid(), User.class);
    assertTrue(user.activated());
    assertFalse(user.disabled());
    assertTrue(user.confirmed());
  }