Search in sources :

Example 6 with SecretDetailResponse

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();
}
Also used : SecretDetailResponse(keywhiz.api.SecretDetailResponse) LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 7 with SecretDetailResponse

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);
}
Also used : Group(keywhiz.api.model.Group) SecretDetailResponse(keywhiz.api.SecretDetailResponse) LongParam(io.dropwizard.jersey.params.LongParam) Client(keywhiz.api.model.Client) KeywhizClient(keywhiz.client.KeywhizClient) Test(org.junit.Test)

Aggregations

SecretDetailResponse (keywhiz.api.SecretDetailResponse)7 Test (org.junit.Test)5 LongParam (io.dropwizard.jersey.params.LongParam)3 IOException (java.io.IOException)2 Client (keywhiz.api.model.Client)2 Group (keywhiz.api.model.Group)2 KeywhizClient (keywhiz.client.KeywhizClient)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Date (java.util.Date)1