コード例 #1
0
  public void testSetPassword() throws Exception {

    gov.nih.nci.security.authorization.domainobjects.User csmUser =
        new gov.nih.nci.security.authorization.domainobjects.User();
    String userName = "******";
    String password = "******";
    csmUser.setLoginName(userName);
    user = new LocalPersonUser();
    user.setLoginId(userName);

    expect(csmUserRepositoryImpl.getUserByName(userName)).andReturn(user).anyTimes();
    expect(csmUserRepositoryImpl.userHasPassword(user, password)).andReturn(false).anyTimes();
    expect(csmUserRepositoryImpl.userHadPassword(user, password)).andReturn(false).anyTimes();
    expect(csmUserRepositoryImpl.getUsernameById(userName)).andReturn(userName).anyTimes();
    expect(passwordPolicyDao.getById(1)).andReturn(passwordPolicy).anyTimes();
    csmUserRepositoryImpl.userChangePassword(user, password, 3);
    userDao.save(user);

    replayMocks();
    try {
      passwordManagerService.addUserToken(userName);
      passwordManagerService.setPassword(userName, password, user.getToken());
    } catch (Exception e) {
      e.printStackTrace();
      fail("Not expecting any exception");
    }
    verifyMocks();
  }
コード例 #2
0
  public void testAddToken() throws Exception {

    String userName = "******";
    user = new LocalPersonUser();
    user.setLoginId(userName);

    expect(csmUserRepositoryImpl.getUserByName(userName)).andReturn(user).anyTimes();
    userDao.save(user);

    replayMocks();
    assertNull(user.getToken());
    passwordManagerService.addUserToken(userName);
    assertNotNull(user.getToken());
  }