Esempio n. 1
0
  @Test
  @Ignore // this test has issues
  public void addSameApprovalDifferentStatusRepeatedlyOnlyUpdatesStatus() {
    assertTrue(
        dao.addApproval(
            new Approval()
                .setUserId("u2")
                .setClientId("c2")
                .setScope("dash.user")
                .setExpiresAt(Approval.timeFromNow(6000))
                .setStatus(APPROVED)));
    Approval app = dao.getApprovals("u2", "c2").iterator().next();
    assertEquals(
        Math.round(app.getExpiresAt().getTime() / 1000),
        Math.round((new Date().getTime() + 6000) / 1000));

    assertTrue(
        dao.addApproval(
            new Approval()
                .setUserId("u2")
                .setClientId("c2")
                .setScope("dash.user")
                .setExpiresAt(Approval.timeFromNow(8000))
                .setStatus(DENIED)));
    app = dao.getApprovals("u2", "c2").iterator().next();
    assertEquals(
        Math.round(app.getExpiresAt().getTime() / 1000),
        Math.round((new Date().getTime() + 6000) / 1000));
    assertEquals(DENIED, app.getStatus());
  }
Esempio n. 2
0
 @Test
 public void canAddApproval() {
   assertTrue(
       dao.addApproval(
           new Approval()
               .setUserId("u2")
               .setClientId("c2")
               .setScope("dash.user")
               .setExpiresAt(Approval.timeFromNow(12000))
               .setStatus(APPROVED)));
   List<Approval> apps = dao.getApprovals("u2", "c2");
   assertEquals(1, apps.size());
   Approval app = apps.iterator().next();
   assertEquals("dash.user", app.getScope());
   assertTrue(app.getExpiresAt().after(new Date()));
   assertEquals(APPROVED, app.getStatus());
 }
Esempio n. 3
0
 public ApprovalModifiedEventData(Approval approval) {
   scope = approval.getScope();
   status = approval.getStatus();
 }