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);
}
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();
}
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));
}
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);
}
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)));
}
Aggregations