use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class AclDAO method getSanitizedSecretsFor.
public ImmutableSet<SanitizedSecret> getSanitizedSecretsFor(Group group) {
checkNotNull(group);
ImmutableSet.Builder<SanitizedSecret> set = ImmutableSet.builder();
return dslContext.transactionResult(configuration -> {
SecretContentDAO secretContentDAO = secretContentDAOFactory.using(configuration);
for (SecretSeries series : getSecretSeriesFor(configuration, group)) {
SecretContent content = secretContentDAO.getSecretContentById(series.currentVersion().get()).get();
SecretSeriesAndContent seriesAndContent = SecretSeriesAndContent.of(series, content);
set.add(SanitizedSecret.fromSecretSeriesAndContent(seriesAndContent));
}
return set.build();
});
}
use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretsResourceIntegrationTest method partialUpdateSecretOverwritesNonNullOwnerWithNullValue.
@Test
public void partialUpdateSecretOverwritesNonNullOwnerWithNullValue() {
String groupName = createGroup();
String secretName = createSecretWithOwner(groupName);
SecretSeriesAndContent originalSecret = getSecret(secretName);
assertEquals(groupName, originalSecret.series().owner());
updateOwner(secretName, null);
SecretSeriesAndContent updatedSecret = getSecret(secretName);
assertNull(updatedSecret.series().owner());
}
use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretsResourceIntegrationTest method partialUpdateSecretIgnoresOwnerIfNotPresent.
@Test
public void partialUpdateSecretIgnoresOwnerIfNotPresent() {
String secretName = createSecretWithOwner(null);
SecretSeriesAndContent originalSecret = getSecret(secretName);
assertNull(originalSecret.series().owner());
String groupName = createGroup();
PartialUpdateSecretRequestV2 request = PartialUpdateSecretRequestV2.builder().ownerPresent(false).owner(groupName).build();
resource.partialUpdateSecret(User.named("nobody"), secretName, request);
SecretSeriesAndContent updatedSecret = getSecret(secretName);
assertNull(updatedSecret.series().owner());
}
use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretsResourceIntegrationTest method partialUpdateSecretOverwritesNonNullOwnerWithNonNullValue.
@Test
public void partialUpdateSecretOverwritesNonNullOwnerWithNonNullValue() {
String group1 = createGroup();
String group2 = createGroup();
String secretName = createSecretWithOwner(group1);
SecretSeriesAndContent originalSecret = getSecret(secretName);
assertEquals(group1, originalSecret.series().owner());
updateOwner(secretName, group2);
SecretSeriesAndContent updatedSecret = getSecret(secretName);
assertEquals(group2, updatedSecret.series().owner());
}
use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretResource method renameSecret.
@Timed
@ExceptionMetered
@Path("{oldName}/rename/{newName}")
@POST
@Consumes(APPLICATION_JSON)
public Response renameSecret(@Auth AutomationClient automationClient, @PathParam("oldName") String oldName, @PathParam("newName") String newName) {
SecretSeriesAndContent secret = secretDAO.getSecretByName(oldName).orElseThrow(NotFoundException::new);
secretDAO.renameSecretById(secret.series().id(), newName, automationClient.getName());
UriBuilder uriBuilder = UriBuilder.fromResource(SecretResource.class).path(newName);
return Response.created(uriBuilder.build()).build();
}
Aggregations