Search in sources :

Example 6 with LongParam

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

the class ClientsResourceTest method deleteCallsDelete.

@Test
public void deleteCallsDelete() {
    when(clientDAO.getClientById(12)).thenReturn(Optional.of(client));
    Response blah = resource.deleteClient(user, new LongParam("12"));
    verify(clientDAO).deleteClient(client);
    assertThat(blah.getStatus()).isEqualTo(204);
}
Also used : ClientDetailResponse(keywhiz.api.ClientDetailResponse) Response(javax.ws.rs.core.Response) LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 7 with LongParam

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

the class ClientsResourceTest method handlesNoAssociations.

@Test
public void handlesNoAssociations() {
    when(clientDAO.getClientById(1)).thenReturn(Optional.of(client));
    when(aclDAO.getGroupsFor(client)).thenReturn(Collections.emptySet());
    when(aclDAO.getSanitizedSecretsFor(client)).thenReturn(ImmutableSet.of());
    ClientDetailResponse response = resource.getClient(user, new LongParam("1"));
    assertThat(response.groups).isEmpty();
    assertThat(response.secrets).isEmpty();
}
Also used : LongParam(io.dropwizard.jersey.params.LongParam) ClientDetailResponse(keywhiz.api.ClientDetailResponse) Test(org.junit.Test)

Example 8 with LongParam

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

the class ClientsResourceTest method includesAssociations.

@Test
public void includesAssociations() {
    Group group1 = new Group(0, "group1", null, null, null, null, null, null);
    Group group2 = new Group(0, "group2", null, null, null, null, null, null);
    Secret secret = new Secret(15, "secret", null, () -> "supersecretdata", "checksum", now, "creator", now, "updater", null, null, null, 0, 1L);
    when(clientDAO.getClientById(1)).thenReturn(Optional.of(client));
    when(aclDAO.getGroupsFor(client)).thenReturn(Sets.newHashSet(group1, group2));
    when(aclDAO.getSanitizedSecretsFor(client)).thenReturn(ImmutableSet.of(SanitizedSecret.fromSecret(secret)));
    ClientDetailResponse response = resource.getClient(user, new LongParam("1"));
    assertThat(response.groups).containsOnly(group1, group2);
    assertThat(response.secrets).containsOnly(SanitizedSecret.fromSecret(secret));
}
Also used : Secret(keywhiz.api.model.Secret) SanitizedSecret(keywhiz.api.model.SanitizedSecret) Group(keywhiz.api.model.Group) LongParam(io.dropwizard.jersey.params.LongParam) ClientDetailResponse(keywhiz.api.ClientDetailResponse) Test(org.junit.Test)

Example 9 with LongParam

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

the class GroupsResourceTest method canDelete.

@Test
public void canDelete() {
    when(groupDAO.getGroupById(0xdeadbeef)).thenReturn(Optional.of(group));
    Response response = resource.deleteGroup(user, new LongParam(Long.toString(0xdeadbeef)));
    verify(groupDAO).deleteGroup(group);
    assertThat(response.getStatus()).isEqualTo(204);
}
Also used : Response(javax.ws.rs.core.Response) GroupDetailResponse(keywhiz.api.GroupDetailResponse) LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 10 with LongParam

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

the class GroupsResourceTest method notFoundWhenRetrievingBadId.

@Test(expected = NotFoundException.class)
public void notFoundWhenRetrievingBadId() {
    when(groupDAO.getGroupById(0x1bad1dea)).thenReturn(Optional.empty());
    resource.getGroup(user, new LongParam(Long.toString(0x1bad1dea)));
}
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