use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretsResourceIntegrationTest method partialUpdateSecretOverwritesNullOwnerWithNonNullValue.
@Test
public void partialUpdateSecretOverwritesNullOwnerWithNonNullValue() {
String secretName = createSecretWithOwner(null);
SecretSeriesAndContent originalSecret = getSecret(secretName);
assertNull(originalSecret.series().owner());
String groupName = createGroup();
updateOwner(secretName, groupName);
SecretSeriesAndContent updatedSecret = getSecret(secretName);
assertEquals(groupName, updatedSecret.series().owner());
}
use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretDAOTest method createOrUpdateNonExistingSecretWithOwner.
@Test
public void createOrUpdateNonExistingSecretWithOwner() {
String ownerName = createGroup();
long secretId = createOrUpdateSecretWithOwner(ownerName);
SecretSeriesAndContent secret = secretDAO.getSecretById(secretId).get();
assertEquals(ownerName, secret.series().owner());
}
use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretDAOTest method createsSecretWithOwner.
@Test
public void createsSecretWithOwner() {
String ownerName = createGroup();
long secretId = createSecretWithOwner(ownerName);
SecretSeriesAndContent secret = secretDAO.getSecretById(secretId).get();
assertEquals(ownerName, secret.series().owner());
}
use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretDetailResponseV2Test method formsCorrectlyFromSecretSeriesAndContent.
@Test
public void formsCorrectlyFromSecretSeriesAndContent() {
SecretSeries series = SecretSeries.of(1, "secret-name", "secret-owner", "secret-description", ApiDate.parse("2013-03-28T21:23:04.159Z"), "creator-user", ApiDate.parse("2014-03-28T21:23:04.159Z"), "updater-user", "text/plain", null, 1L);
SecretContent content = SecretContent.of(1, 1, "YXNkZGFz", "checksum", ApiDate.parse("2014-03-28T21:23:04.159Z"), "updater-user", ApiDate.parse("2014-03-28T21:23:04.159Z"), "updater-user", ImmutableMap.of("owner", "root"), 1136214245);
SecretSeriesAndContent seriesAndContent = SecretSeriesAndContent.of(series, content);
SecretDetailResponseV2 fromSeriesAndContent = SecretDetailResponseV2.builder().seriesAndContent(seriesAndContent).build();
assertThat(fromSeriesAndContent).isEqualTo(secretDetailResponse);
}
use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretDAO method getSecretsBatched.
/**
* @param idx the first index to select in a list of secrets sorted by creation time
* @param num the number of secrets after idx to select in the list of secrets
* @param newestFirst if true, order the secrets from newest creation time to oldest
* @return A list of secrets
*/
public ImmutableList<SecretSeriesAndContent> getSecretsBatched(int idx, int num, boolean newestFirst) {
return dslContext.transactionResult(configuration -> {
SecretContentDAO secretContentDAO = secretContentDAOFactory.using(configuration);
SecretSeriesDAO secretSeriesDAO = secretSeriesDAOFactory.using(configuration);
ImmutableList.Builder<SecretSeriesAndContent> secretsBuilder = ImmutableList.builder();
for (SecretSeries series : secretSeriesDAO.getSecretSeriesBatched(idx, num, newestFirst)) {
SecretContent content = secretContentDAO.getSecretContentById(series.currentVersion().get()).get();
SecretSeriesAndContent seriesAndContent = SecretSeriesAndContent.of(series, content);
secretsBuilder.add(seriesAndContent);
}
return secretsBuilder.build();
});
}
Aggregations