Search in sources :

Example 26 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class MembershipResourceTest method missingGroupAllow.

@Test(expected = NotFoundException.class)
public void missingGroupAllow() {
    doThrow(IllegalStateException.class).when(aclDAO).findAndAllowAccess(secret.getId(), 98, auditLog, "user", new HashMap<>());
    resource.allowAccess(user, new LongParam(Long.toString(secret.getId())), new LongParam("98"));
}
Also used : LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 27 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class MembershipResourceTest method missingGroupDisallow.

@Test(expected = NotFoundException.class)
public void missingGroupDisallow() {
    doThrow(IllegalStateException.class).when(aclDAO).findAndRevokeAccess(secret.getId(), 3543, auditLog, "user", new HashMap<>());
    resource.disallowAccess(user, new LongParam(Long.toString(secret.getId())), new LongParam("3543"));
}
Also used : LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 28 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class MembershipResourceTest method evictThrowsWhenGroupIdNotFound.

@Test(expected = NotFoundException.class)
public void evictThrowsWhenGroupIdNotFound() {
    doThrow(IllegalStateException.class).when(aclDAO).findAndEvictClient(client.getId(), 0xbad2, auditLog, "user", new HashMap<>());
    resource.evictClient(user, new LongParam(Long.toString(client.getId())), new LongParam(Long.toString(0xbad2)));
}
Also used : LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 29 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class MembershipResourceTest method canDisallowAccess.

@Test
public void canDisallowAccess() {
    Response response = resource.disallowAccess(user, new LongParam(Long.toString(secret.getId())), new LongParam(Long.toString(group.getId())));
    assertThat(response.getStatus()).isEqualTo(200);
    verify(aclDAO).findAndRevokeAccess(secret.getId(), group.getId(), auditLog, "user", new HashMap<>());
}
Also used : Response(javax.ws.rs.core.Response) LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 30 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class MembershipResourceTest method canEnroll.

@Test
public void canEnroll() {
    resource.enrollClient(user, new LongParam(Long.toString(client.getId())), new LongParam(Long.toString(group.getId())));
    verify(aclDAO).findAndEnrollClient(client.getId(), group.getId(), auditLog, "user", new HashMap<>());
}
Also used : LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Aggregations

LongParam (io.dropwizard.jersey.params.LongParam)30 Test (org.junit.Test)30 Response (javax.ws.rs.core.Response)6 SecretDetailResponse (keywhiz.api.SecretDetailResponse)5 ClientDetailResponse (keywhiz.api.ClientDetailResponse)4 Group (keywhiz.api.model.Group)4 GroupDetailResponse (keywhiz.api.GroupDetailResponse)3 SanitizedSecret (keywhiz.api.model.SanitizedSecret)3 Client (keywhiz.api.model.Client)2 Secret (keywhiz.api.model.Secret)2 HashSet (java.util.HashSet)1 NotFoundException (javax.ws.rs.NotFoundException)1 KeywhizClient (keywhiz.client.KeywhizClient)1