use of org.cloudfoundry.credhub.entity.EncryptionKeyCanary in project credhub by cloudfoundry-incubator.
the class EncryptionKeyCanaryDataServiceTest method save_savesTheEncryptionCanary.
@Test
public void save_savesTheEncryptionCanary() {
EncryptionKeyCanary encryptionKeyCanary = new EncryptionKeyCanary();
encryptionKeyCanary.setNonce("test-nonce".getBytes());
encryptionKeyCanary.setEncryptedCanaryValue("test-value".getBytes());
subject.save(encryptionKeyCanary);
List<EncryptionKeyCanary> canaries = subject.findAll();
assertThat(canaries, hasSize(1));
EncryptionKeyCanary actual = canaries.get(0);
assertNotNull(actual.getUuid());
assertThat(actual.getUuid(), equalTo(encryptionKeyCanary.getUuid()));
assertThat(actual.getNonce(), equalTo("test-nonce".getBytes()));
assertThat(actual.getEncryptedCanaryValue(), equalTo("test-value".getBytes()));
}
use of org.cloudfoundry.credhub.entity.EncryptionKeyCanary in project credhub by cloudfoundry-incubator.
the class EncryptionKeyCanaryDataServiceTest method delete_whenThereAreCanaries_deletesTheRequestedCanaries.
@Test
public void delete_whenThereAreCanaries_deletesTheRequestedCanaries() {
EncryptionKeyCanary firstCanary = new EncryptionKeyCanary();
EncryptionKeyCanary secondCanary = new EncryptionKeyCanary();
EncryptionKeyCanary thirdCanary = new EncryptionKeyCanary();
firstCanary = subject.save(firstCanary);
secondCanary = subject.save(secondCanary);
thirdCanary = subject.save(thirdCanary);
List<EncryptionKeyCanary> canaries = subject.findAll();
List<UUID> uuids = canaries.stream().map(canary -> canary.getUuid()).collect(Collectors.toList());
assertThat(canaries, hasSize(3));
assertThat(uuids, containsInAnyOrder(firstCanary.getUuid(), secondCanary.getUuid(), thirdCanary.getUuid()));
subject.delete(newArrayList(firstCanary.getUuid(), thirdCanary.getUuid()));
canaries = subject.findAll();
uuids = canaries.stream().map(canary -> canary.getUuid()).collect(Collectors.toList());
assertThat(canaries, hasSize(1));
assertThat(uuids, containsInAnyOrder(secondCanary.getUuid()));
}
Aggregations