use of keywhiz.api.SecretDetailResponse in project keywhiz by square.
the class SecretsResourceTest method handlesNoAssociations.
@Test
public void handlesNoAssociations() {
when(secretController.getSecretById(22)).thenReturn(Optional.of(secret));
when(aclDAO.getGroupsFor(secret)).thenReturn(Collections.emptySet());
when(aclDAO.getClientsFor(secret)).thenReturn(Collections.emptySet());
SecretDetailResponse response = resource.retrieveSecret(user, new LongParam("22"));
assertThat(response.groups).isEmpty();
assertThat(response.clients).isEmpty();
}
use of keywhiz.api.SecretDetailResponse in project keywhiz by square.
the class SecretsResourceTest method includesAssociations.
@Test
public void includesAssociations() {
Client client = new Client(0, "client", null, null, null, null, null, null, false, false);
Group group1 = new Group(0, "group1", null, null, null, null, null, null);
Group group2 = new Group(0, "group2", null, null, null, null, null, null);
when(secretController.getSecretById(22)).thenReturn(Optional.of(secret));
when(aclDAO.getGroupsFor(secret)).thenReturn(Sets.newHashSet(group1, group2));
when(aclDAO.getClientsFor(secret)).thenReturn(Sets.newHashSet(client));
SecretDetailResponse response = resource.retrieveSecret(user, new LongParam("22"));
assertThat(response.groups).containsOnly(group1, group2);
assertThat(response.clients).containsOnly(client);
}
Aggregations