Exemplo n.º 1
0
  @Test
  public void canGetApprovals() {
    addApproval("marissa", "c1", "uaa.user", 6000, APPROVED);
    addApproval("marissa", "c1", "uaa.admin", 12000, DENIED);
    addApproval("marissa", "c1", "openid", 6000, APPROVED);

    assertEquals(3, endpoints.getApprovals("userName pr", 1, 100).size());
    assertEquals(2, endpoints.getApprovals("userName pr", 1, 2).size());
  }
Exemplo n.º 2
0
  @Test
  public void canRevokeApprovals() {
    addApproval("marissa", "c1", "uaa.user", 6000, APPROVED);
    addApproval("marissa", "c1", "uaa.admin", 12000, DENIED);
    addApproval("marissa", "c1", "openid", 6000, APPROVED);

    assertEquals(3, endpoints.getApprovals("userName pr", 1, 100).size());
    assertEquals("ok", endpoints.revokeApprovals("c1").getStatus());
    assertEquals(0, endpoints.getApprovals("userName pr", 1, 100).size());
  }
Exemplo n.º 3
0
  @Test
  public void canGetApprovalsWithAutoApproveTrue() {
    // Only get scopes that need approval
    addApproval("marissa", "c1", "uaa.user", 6000, APPROVED);
    addApproval("marissa", "c1", "uaa.admin", 12000, DENIED);
    addApproval("marissa", "c1", "openid", 6000, APPROVED);

    assertEquals(3, endpoints.getApprovals("userName eq 'marissa'", 1, 100).size());

    addApproval("marissa", "c1", "read", 12000, DENIED);
    addApproval("marissa", "c1", "write", 6000, APPROVED);

    assertEquals(3, endpoints.getApprovals("userName eq 'marissa'", 1, 100).size());
  }
Exemplo n.º 4
0
  @Test
  public void canUpdateApprovals() {
    addApproval("marissa", "c1", "uaa.user", 6000, APPROVED);
    addApproval("marissa", "c1", "uaa.admin", 12000, DENIED);
    addApproval("marissa", "c1", "openid", 6000, APPROVED);

    Approval[] app =
        new Approval[] {
          new Approval("marissa", "c1", "uaa.user", 2000, APPROVED),
          new Approval("marissa", "c1", "dash.user", 2000, APPROVED),
          new Approval("marissa", "c1", "openid", 2000, DENIED),
          new Approval("marissa", "c1", "cloud_controller.read", 2000, APPROVED)
        };
    List<Approval> response = endpoints.updateApprovals(app);
    assertEquals(4, response.size());
    assertTrue(response.contains(new Approval("marissa", "c1", "uaa.user", 2000, APPROVED)));
    assertTrue(response.contains(new Approval("marissa", "c1", "dash.user", 2000, APPROVED)));
    assertTrue(response.contains(new Approval("marissa", "c1", "openid", 2000, DENIED)));
    assertTrue(
        response.contains(new Approval("marissa", "c1", "cloud_controller.read", 2000, APPROVED)));

    List<Approval> updatedApprovals = endpoints.getApprovals("userName eq 'marissa'", 1, 100);
    assertEquals(4, updatedApprovals.size());
    assertTrue(
        updatedApprovals.contains(new Approval("marissa", "c1", "dash.user", 2000, APPROVED)));
    assertTrue(updatedApprovals.contains(new Approval("marissa", "c1", "openid", 2000, DENIED)));
    assertTrue(
        updatedApprovals.contains(
            new Approval("marissa", "c1", "cloud_controller.read", 2000, APPROVED)));
    assertTrue(
        updatedApprovals.contains(new Approval("marissa", "c1", "uaa.user", 2000, APPROVED)));
  }
Exemplo n.º 5
0
  public void attemptingToCreateAnApprovalWithADifferentStatusUpdatesApproval() {
    addApproval("marissa", "c1", "uaa.user", 6000, APPROVED);
    addApproval("marissa", "c1", "uaa.admin", 12000, DENIED);
    addApproval("marissa", "c1", "openid", 6000, APPROVED);

    addApproval("marissa", "c1", "openid", 18000, DENIED);

    List<Approval> updatedApprovals = endpoints.getApprovals("userName eq 'marissa'", 1, 100);
    assertEquals(4, updatedApprovals.size());
    assertTrue(
        updatedApprovals.contains(new Approval("marissa", "c1", "uaa.user", 6000, APPROVED)));
    assertTrue(
        updatedApprovals.contains(new Approval("marissa", "c1", "uaa.admin", 12000, DENIED)));
    assertTrue(updatedApprovals.contains(new Approval("marissa", "c1", "openid", 18000, DENIED)));
  }
Exemplo n.º 6
0
  public void attemptingToCreateDuplicateApprovalsExtendsValidity() {
    addApproval("marissa", "c1", "uaa.user", 6000, APPROVED);
    addApproval("marissa", "c1", "uaa.admin", 12000, DENIED);
    addApproval("marissa", "c1", "openid", 6000, APPROVED);

    addApproval("marissa", "c1", "openid", 10000, APPROVED);

    List<Approval> updatedApprovals = endpoints.getApprovals("userName eq 'marissa'", 1, 100);
    assertEquals(3, updatedApprovals.size());
    assertTrue(
        updatedApprovals.contains(new Approval("marissa", "c1", "uaa.user", 6000, APPROVED)));
    assertTrue(
        updatedApprovals.contains(new Approval("marissa", "c1", "uaa.admin", 12000, DENIED)));
    assertTrue(updatedApprovals.contains(new Approval("marissa", "c1", "openid", 10000, APPROVED)));
  }