示例#1
0
  @Test
  public void testDescribeUserSetChanges() throws Exception {
    String changes = null;

    HttpSession httpSession = getSession();
    UserContext.newContext(getRequest(), m_user, m_customer);

    changes = DiffUtils.describeUserSetChanges(null, null, null);
    assertNull("DiffUtils.describeUserSetChanges(null, null, null) should return null", changes);

    SavedUserSet susOld = new SavedUserSet(m_customer.getCustID());
    SavedUserSet susNew = new SavedUserSet(m_customer.getCustID());

    changes = DiffUtils.describeUserSetChanges(getRequest(), susOld, susNew);
    assertNull("Expected no diffs for 2 identical user sets", changes);

    List<SearchConstraint> constraints;
    constraints = new ArrayList<SearchConstraint>();
    constraints.add(
        new SearchConstraint(
            IUserManager.PROP_USERID,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            m_user.getUserID()));

    susNew.addUsers(constraints);

    changes = DiffUtils.describeUserSetChanges(getRequest(), susOld, susNew);
    assertNotNull("Expected diffs on 2 different user sets", changes);
  }
示例#2
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException {
    ManagementContainer container = ManagementContainer.getInstance();
    IAuthenticationManager am = container.getAuthenticationManager();
    HttpSession session = request.getSession();
    Integer userIdObj = (Integer) session.getAttribute(REQUEST_ID);
    if (userIdObj == null) {
      reportSingleError(request, "login", "errors.login.invalid");
      return mapping.findForward(FAILURE);
    }

    int userID = userIdObj.intValue();
    UserLoginResult result = am.checkLoginStatus(userID);
    if (result.getStatus() == LoginStatus.AUTH_PENDING) {
      return mapping.findForward("logon.wait");
    }
    session.removeAttribute(REQUEST_ID);
    if (result.getStatus() == LoginStatus.AUTH_FAILED) {
      reportSingleError(request, "login", "errors.login.invalid");
      return mapping.findForward(FAILURE);
    }

    UserContext.newContext(request, result.getUser(), result.getCustomer());

    if (result.getStatus() == LoginStatus.AUTH_OK) {
      LogonUtils.configureBranding(request, response, result.getCustomer());
    }

    return successfulLoginForward(request, response, mapping, actionForm, result);
  }
示例#3
0
  @Test
  public void testDescribeReviewerGroupReviewerChanges() throws Exception {
    String changes = null;

    UserContext.newContext(getRequest(), m_user, m_customer);

    changes = DiffUtils.describeReviewerGroupReviewerChanges(null, null, null);
    assertNull(
        "DiffUtils.describeReviewerGroupReviewerChanges(null, null, null) should return null",
        changes);

    List<SearchConstraint> constraints;
    constraints = new ArrayList<SearchConstraint>();
    constraints.add(
        new SearchConstraint(
            IUserManager.PROP_USERID,
            SearchConstraintOperator.CONSTRAINT_EQUALS,
            m_user.getUserID()));

    SavedUserSet reviewers = new SavedUserSet(m_customer.getCustID());
    reviewers.addUsers(constraints);

    ReviewerGroup oldRG =
        new ReviewerGroup(m_customer.getCustID(), 1, "name", reviewers, null, "extra");
    ReviewerGroup newRG =
        new ReviewerGroup(m_customer.getCustID(), 1, "name", reviewers, null, "extra");

    changes = DiffUtils.describeReviewerGroupReviewerChanges(getRequest(), oldRG, newRG);
    assertNull("Expected no diffs for 2 identical user sets", changes);

    reviewers = new SavedUserSet(m_customer.getCustID());
    newRG.setReviewers(reviewers);

    changes = DiffUtils.describeReviewerGroupReviewerChanges(getRequest(), oldRG, newRG);
    assertNotNull("Expected diffs on 2 different reviewer groups", changes);

    SavedUserSet reviewers1 = new SavedUserSet(m_customer.getCustID());
    reviewers1.addConstraintSets(InternalUserSets.getAllUsersSet(m_customer.getCustID()));
    oldRG.setReviewers(reviewers1);

    SavedUserSet reviewers2 = new SavedUserSet(m_customer.getCustID());
    newRG.setReviewers(reviewers2);

    changes = DiffUtils.describeReviewerGroupReviewerChanges(getRequest(), oldRG, newRG);
    assertNotNull("Expected diffs on 2 different reviewer groups", changes);
  }