コード例 #1
0
  private void doLoginAndAssert(Subject subject, LoginReply expectedReply, int expectedCount) {
    LoginReply reply;

    try {
      reply = _cache.login(subject);
    } catch (CacheException e) {
      throw new RuntimeException("Didn't expect that!", e);
    }
    assertEquals("check queries", expectedCount, _backEnd.getCount());

    assertEquals(
        "login attributes", expectedReply.getLoginAttributes(), reply.getLoginAttributes());
    assertEquals("login subject", expectedReply.getSubject(), reply.getSubject());
  }
コード例 #2
0
  @Before
  public void setUp() {
    _backEnd = new CountingLoginStrategy();
    _cache = new CachingLoginStrategy(_backEnd);

    _subject = new Subject();
    _subject.getPrincipals().add(new UserNamePrincipal("andrew"));

    _reply = new LoginReply();
    _reply.getSubject().getPrincipals().add(new UidPrincipal(1000));
    _reply.getLoginAttributes().add(new HomeDirectory("/home/andrew"));
    _backEnd.setLoginReply(_reply);
  }
コード例 #3
0
  @Test
  public void testWithTwoQueriesWithDiffSubjectsBothTriggerQuery() {
    doLoginAndAssert(1);

    Subject newSubject = new Subject();
    newSubject.getPrincipals().add(new UserNamePrincipal("fred"));

    LoginReply newReply = new LoginReply();
    newReply.getSubject().getPrincipals().add(new UidPrincipal(1010));
    newReply.getLoginAttributes().add(new HomeDirectory("/home/fred"));

    _backEnd.setLoginReply(newReply);

    doLoginAndAssert(newSubject, newReply, 2);
  }