use of keywhiz.client.KeywhizClient.NotFoundException in project keywhiz by square.
the class AddActionTest method addSecretCanAssignGroup.
@Test
public void addSecretCanAssignGroup() throws Exception {
addActionConfig.addType = Arrays.asList("secret");
addActionConfig.name = secret.getDisplayName();
addActionConfig.group = group.getName();
byte[] content = base64Decoder.decode(secret.getSecret());
addAction.stream = new ByteArrayInputStream(content);
when(keywhizClient.getGroupByName(group.getName())).thenReturn(group);
when(keywhizClient.getSanitizedSecretByName(secret.getName())).thenThrow(// Call checks for existence.
new NotFoundException());
when(keywhizClient.createSecret(secret.getName(), "", content, secret.getMetadata(), 0)).thenReturn(secretDetailResponse);
addAction.run();
verify(keywhizClient).grantSecretToGroupByIds(secret.getId(), group.getId());
}
use of keywhiz.client.KeywhizClient.NotFoundException in project keywhiz by square.
the class AddActionTest method addThrowsIfMetadataHasBadKeys.
@Test(expected = IllegalArgumentException.class)
public void addThrowsIfMetadataHasBadKeys() throws Exception {
addActionConfig.addType = Arrays.asList("secret");
addActionConfig.name = secret.getDisplayName();
addActionConfig.json = "{\"ThisIsABadKey\":\"doh\"}";
addAction.stream = new ByteArrayInputStream(base64Decoder.decode(secret.getSecret()));
when(keywhizClient.getSanitizedSecretByName(secret.getName())).thenThrow(// Call checks for existence.
new NotFoundException());
addAction.run();
}
use of keywhiz.client.KeywhizClient.NotFoundException in project keywhiz by square.
the class AddActionTest method addCreatesWithoutVersionByDefault.
@Test
public void addCreatesWithoutVersionByDefault() throws Exception {
addActionConfig.addType = Arrays.asList("secret");
// Name without version
addActionConfig.name = secret.getName();
byte[] content = base64Decoder.decode(secret.getSecret());
addAction.stream = new ByteArrayInputStream(content);
when(keywhizClient.getSanitizedSecretByName(secret.getName())).thenThrow(// Call checks for existence.
new NotFoundException());
when(keywhizClient.createSecret(secret.getName(), "", content, secret.getMetadata(), 0)).thenReturn(secretDetailResponse);
addAction.run();
verify(keywhizClient, times(1)).createSecret(secret.getName(), "", content, secret.getMetadata(), 0);
}
use of keywhiz.client.KeywhizClient.NotFoundException in project keywhiz by square.
the class DeleteActionTest method deleteThrowsIfDeleteSecretFails.
@Test(expected = AssertionError.class)
public void deleteThrowsIfDeleteSecretFails() throws Exception {
deleteActionConfig.deleteType = Arrays.asList("secret");
deleteActionConfig.name = secret.getDisplayName();
when(keywhizClient.getSanitizedSecretByName(secret.getName())).thenThrow(new NotFoundException());
deleteAction.run();
}
use of keywhiz.client.KeywhizClient.NotFoundException in project keywhiz by square.
the class DescribeActionTest method describeThrowsIfGroupDoesNotExist.
@Test(expected = AssertionError.class)
public void describeThrowsIfGroupDoesNotExist() throws Exception {
describeActionConfig.describeType = Arrays.asList("group");
describeActionConfig.name = "nonexistent-group-name";
when(keywhizClient.getGroupByName(anyString())).thenThrow(new NotFoundException());
describeAction.run();
}
Aggregations