use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class ValueCredentialVersionTest method setValue_encryptsValue.
@Test
public void setValue_encryptsValue() {
valueCredentialData = new ValueCredentialVersionData("foo");
subject = new ValueCredentialVersion(valueCredentialData).setEncryptor(encryptor);
subject.setValue("my-value");
assertThat(valueCredentialData.getEncryptedValueData().getEncryptedValue(), notNullValue());
assertThat(valueCredentialData.getEncryptedValueData().getNonce(), notNullValue());
}
use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class ValueCredentialVersionTest method getValue_decryptsValue.
@Test
public void getValue_decryptsValue() {
valueCredentialData = new ValueCredentialVersionData("foo");
subject = new ValueCredentialVersion(valueCredentialData).setEncryptor(encryptor);
subject.setValue("my-value");
assertThat(subject.getValue(), equalTo("my-value"));
}
use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class EventAuditLogServiceTest method beforeEach.
@Before
public void beforeEach() {
canaries = encryptionKeyCanaryRepository.findAll();
mockOutCurrentTimeProvider(currentTimeProvider).accept(now.toEpochMilli());
userContext = mockUserContext(true);
userContextHolder.setUserContext(userContext);
entity = new ValueCredentialVersionData("keyName");
entity.setEncryptedValueData(new EncryptedValue(canaries.get(0).getUuid(), "value", "nonce"));
}
use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class CredentialVersionDataRepositoryTest method canSaveStringsOfLength7000WhichMeans7016ForGCM.
@Test
public void canSaveStringsOfLength7000WhichMeans7016ForGCM() {
byte[] encryptedValue = new byte[7016];
Arrays.fill(encryptedValue, (byte) 'A');
final StringBuilder stringBuilder = new StringBuilder(7000);
Stream.generate(() -> "a").limit(stringBuilder.capacity()).forEach(stringBuilder::append);
ValueCredentialVersionData entity = new ValueCredentialVersionData();
Credential credential = credentialRepository.save(new Credential(name));
entity.setCredential(credential);
entity.setEncryptedValueData(new EncryptedValue().setEncryptedValue(encryptedValue).setEncryptionKeyUuid(canaryUuid).setNonce("nonce".getBytes()));
subject.save(entity);
assertThat(subject.findFirstByCredentialUuidOrderByVersionCreatedAtDesc(credential.getUuid()).getEncryptedValueData().getEncryptedValue().length, equalTo(7016));
}
use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class CredentialVersionDataServiceTest method setupTestFixturesForFindContainingName.
private void setupTestFixturesForFindContainingName(String valueName, String passwordName, String certificateName) {
fakeTimeSetter.accept(2000000000123L);
valueCredentialData = new ValueCredentialVersionData(valueName);
valueCredentialData.setEncryptedValueData(new EncryptedValue().setEncryptionKeyUuid(activeCanaryUuid).setEncryptedValue("value".getBytes()).setNonce(new byte[] {}));
ValueCredentialVersion namedValueCredential = new ValueCredentialVersion(valueCredentialData);
namedValueCredential.setEncryptor(encryptor);
subject.save(namedValueCredential);
PasswordCredentialVersionData passwordCredentialData = new PasswordCredentialVersionData("/mySe.cret");
passwordCredentialData.setEncryptedValueData(new EncryptedValue(activeCanaryUuid, "", ""));
new PasswordCredentialVersion(passwordCredentialData);
PasswordCredentialVersion namedPasswordCredential;
subject.save(namedValueCredential);
fakeTimeSetter.accept(1000000000123L);
passwordCredentialData = new PasswordCredentialVersionData(passwordName);
passwordCredentialData.setEncryptedValueData(new EncryptedValue().setEncryptionKeyUuid(activeCanaryUuid).setEncryptedValue("password".getBytes()).setNonce(new byte[] {}));
namedPasswordCredential = new PasswordCredentialVersion(passwordCredentialData);
subject.save(namedPasswordCredential);
CertificateCredentialVersionData certificateCredentialData = new CertificateCredentialVersionData("/myseecret");
CertificateCredentialVersion certificateCredential = new CertificateCredentialVersion(certificateCredentialData);
subject.save(certificateCredential);
fakeTimeSetter.accept(3000000000123L);
certificateCredentialData = new CertificateCredentialVersionData(certificateName);
certificateCredential = new CertificateCredentialVersion(certificateCredentialData);
subject.save(certificateCredential);
}
Aggregations