use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.
the class SecretsResourceTest method canDelete.
@Test
public void canDelete() {
when(secretController.getSecretById(0xdeadbeef)).thenReturn(Optional.of(secret));
HashSet<Group> groups = new HashSet<>();
groups.add(new Group(0, "group1", "", NOW, null, NOW, null, null));
groups.add(new Group(0, "group2", "", NOW, null, NOW, null, null));
when(aclDAO.getGroupsFor(secret)).thenReturn(groups);
Response response = resource.deleteSecret(user, new LongParam(Long.toString(0xdeadbeef)));
verify(secretDAO).deleteSecretsByName("name");
assertThat(response.getStatus()).isEqualTo(204);
}
use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.
the class GroupsResourceTest method getSpecificIncludesAllTheThings.
@Test
public void getSpecificIncludesAllTheThings() {
when(groupDAO.getGroupById(4444)).thenReturn(Optional.of(group));
SanitizedSecret secret = SanitizedSecret.of(1, "name", "checksum", null, now, "creator", now, "creator", null, null, null, 1136214245, 125L);
when(aclDAO.getSanitizedSecretsFor(group)).thenReturn(ImmutableSet.of(secret));
Client client = new Client(1, "client", "desc", now, "creator", now, "creator", null, true, false);
when(aclDAO.getClientsFor(group)).thenReturn(ImmutableSet.of(client));
GroupDetailResponse response = resource.getGroup(user, new LongParam("4444"));
assertThat(response.getId()).isEqualTo(group.getId());
assertThat(response.getName()).isEqualTo(group.getName());
assertThat(response.getDescription()).isEqualTo(group.getDescription());
assertThat(response.getCreationDate()).isEqualTo(group.getCreatedAt());
assertThat(response.getCreatedBy()).isEqualTo(group.getCreatedBy());
assertThat(response.getUpdateDate()).isEqualTo(group.getUpdatedAt());
assertThat(response.getUpdatedBy()).isEqualTo(group.getUpdatedBy());
assertThat(response.getSecrets()).containsExactly(secret);
assertThat(response.getClients()).containsExactly(client);
}
use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.
the class MembershipResourceTest method missingSecretAllow.
@Test(expected = NotFoundException.class)
public void missingSecretAllow() {
doThrow(IllegalStateException.class).when(aclDAO).findAndAllowAccess(3, group.getId(), auditLog, "user", new HashMap<>());
resource.allowAccess(user, new LongParam("3"), new LongParam(Long.toString(group.getId())));
}
use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.
the class MembershipResourceTest method canEvict.
@Test
public void canEvict() {
resource.evictClient(user, new LongParam(Long.toString(client.getId())), new LongParam(Long.toString(group.getId())));
verify(aclDAO).findAndEvictClient(client.getId(), group.getId(), auditLog, "user", new HashMap<>());
}
use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.
the class MembershipResourceTest method canAllowAccess.
@Test
public void canAllowAccess() {
Response response = resource.allowAccess(user, new LongParam("66"), new LongParam("55"));
assertThat(response.getStatus()).isEqualTo(200);
verify(aclDAO).findAndAllowAccess(66, 55, auditLog, "user", new HashMap<>());
}
Aggregations