Beispiel #1
0
  @Test
  public void test3destroy() {
    String token = store.getSessions().get(0).getToken();

    store.destroyToken(token);

    assertThat(store.getSessions().isEmpty(), is(true));
  }
Beispiel #2
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");
  }
Beispiel #3
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));
  }
Beispiel #4
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())));
  }
Beispiel #5
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)));
  }
Beispiel #6
0
 @Test(expected = NotFoundException.class)
 public void test0notFound() throws NotFoundException {
   store.expireSession("asdf");
 }
Beispiel #7
0
 public JWTStoreTest() {
   System.setProperty("jwt.hmacSharedSecret", "qrllxoyy2x2bnsp84yjoi5wujrnqun6y0lspeu28");
   this.store = JWTStore.getInstance();
 }