use of keywhiz.api.model.SecretSeriesAndContent in project keywhiz by square.
the class SecretDAOTest method createOrUpdateSecretWhenSecretExists.
@Test
public void createOrUpdateSecretWhenSecretExists() {
String name = "newSecret";
long firstId = secretDAO.createSecret(name, null, "content1", cryptographer.computeHmac("content1".getBytes(UTF_8), "hmackey"), "creator1", ImmutableMap.of("foo", "bar"), 1000, "description1", "type1", ImmutableMap.of());
long secondId = secretDAO.createOrUpdateSecret(name, null, "content2", cryptographer.computeHmac("content2".getBytes(UTF_8), "hmackey"), "creator2", ImmutableMap.of("foo2", "bar2"), 2000, "description2", "type2", ImmutableMap.of());
assertThat(secondId).isEqualTo(firstId);
SecretSeriesAndContent newSecret = secretDAO.getSecretById(firstId).get();
assertThat(newSecret.series().createdBy()).isEqualTo("creator1");
assertThat(newSecret.series().updatedBy()).isEqualTo("creator2");
assertThat(newSecret.series().description()).isEqualTo("description2");
assertThat(newSecret.series().type().get()).isEqualTo("type2");
assertThat(newSecret.content().createdBy()).isEqualTo("creator2");
assertThat(newSecret.content().encryptedContent()).isEqualTo("content2");
assertThat(newSecret.content().metadata()).isEqualTo(ImmutableMap.of("foo2", "bar2"));
}
Aggregations