Search in sources :

Example 11 with BatchSecretRequest

use of keywhiz.api.BatchSecretRequest in project keywhiz by square.

the class BatchSecretDeliveryResourceTest method returnsNotFoundWhenOneOfSecretsDoesNotExistAndOneForbiddenReverse.

// One of the secrets doesn't exist AND one of the secrets not allowed => not found - to preserve compatibility
// This test builds a request in reverse of the previous one to test determinism
@Test(expected = NotFoundException.class)
public void returnsNotFoundWhenOneOfSecretsDoesNotExistAndOneForbiddenReverse() throws Exception {
    ImmutableList<String> secretnames = ImmutableList.of(secret.getName(), "secretthatdoesnotexist");
    BatchSecretRequest req = BatchSecretRequest.create(secretnames);
    when(aclDAO.getBatchSanitizedSecretsFor(client, secretnames)).thenReturn(List.of());
    when(clientDAO.getClientByName(client.getName())).thenReturn(Optional.of(client));
    when(secretController.getSecretsByName(secretnames)).thenReturn(List.of(secret));
    batchSecretDeliveryResource.getBatchSecret(client, req);
}
Also used : BatchSecretRequest(keywhiz.api.BatchSecretRequest) Test(org.junit.Test)

Aggregations

BatchSecretRequest (keywhiz.api.BatchSecretRequest)11 Test (org.junit.Test)11 SecretDeliveryResponse (keywhiz.api.SecretDeliveryResponse)7 Request (okhttp3.Request)5 Response (okhttp3.Response)5 SanitizedSecret (keywhiz.api.model.SanitizedSecret)4