Ejemplo n.º 1
0
  @Test
  public void test3destroy() {
    String token = store.getSessions().get(0).getToken();

    store.destroyToken(token);

    assertThat(store.getSessions().isEmpty(), is(true));
  }
Ejemplo n.º 2
0
  @Test
  public void test10expire() throws NotFoundException {
    String token = store.newToken("*****@*****.**", "domain.com");

    assertThat(token, is(notNullValue()));
    assertThat(token.length(), is(not(0)));
    assertThat(store.getSessions().size(), is(1));

    Session s = store.getSessions().get(0);

    store.expireSession(s.getId());

    assertThat(store.getSessions().isEmpty(), is(true));
  }
Ejemplo n.º 3
0
  @Test
  public void test2ping() throws InterruptedException {
    long lastActive = store.getSessions().get(0).getLastActive();

    assertThat(store.isValidToken(store.getSessions().get(0).getToken(), false), is(true));

    assertThat(store.getSessions().get(0).getLastActive(), is(lastActive));

    TimeUnit.MILLISECONDS.sleep(100);

    assertThat(store.isValidToken(store.getSessions().get(0).getToken(), true), is(true));

    assertThat(store.getSessions().get(0).getLastActive(), is(greaterThan(lastActive)));
  }
Ejemplo n.º 4
0
  @Test
  public void test0init() {
    assertThat(store.getSessions().isEmpty(), is(true));
    assertThat(store.isValidToken("asdf", true), is(false));
    assertThat(store.getIdentityForToken("asdf"), is(nullValue()));

    // These shouldn't throw anything
    store.destroyToken("asdf");
  }
Ejemplo n.º 5
0
  @Test
  public void test1create() throws InterruptedException {
    long now = System.currentTimeMillis();

    Thread.sleep(20);

    String token = store.newToken("*****@*****.**", "domain.com");

    assertThat(token, is(notNullValue()));
    assertThat(token.length(), is(not(0)));
    assertThat(store.getSessions().size(), is(1));

    Session s = store.getSessions().get(0);

    assertThat(s.getId(), is(notNullValue()));
    assertThat(s.getDomain(), is("domain.com"));
    assertThat(s.getToken(), is(token));
    assertThat(s.getUser(), is("*****@*****.**"));
    assertThat(s.getSessionStart(), is(greaterThan(now)));
    assertThat(s.getSessionExpiration(), is(greaterThan(s.getSessionStart())));
  }