use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class LegacyCredentialTest method setup.
@Before
public void setup() throws Exception {
CREDENTIAL_NAME = "/bob";
ValueCredentialVersionData valueCredentialData = new ValueCredentialVersionData(CREDENTIAL_NAME);
ValueCredentialVersion noAclsSecret = new ValueCredentialVersion(valueCredentialData);
noAclsSecret.setEncryptor(encryptor);
noAclsSecret.setValue("bob's value");
credentialVersionDataService.save(noAclsSecret);
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).apply(springSecurity()).build();
}
use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class CredentialVersionDataServiceTest method save_givenAnExistingCredential_throwsExceptionIfTypeMismatch.
@Test(expected = ParameterizedValidationException.class)
public void save_givenAnExistingCredential_throwsExceptionIfTypeMismatch() {
PasswordCredentialVersionData passwordCredentialData = new PasswordCredentialVersionData("/my-credential-3");
passwordCredentialData.setEncryptedValueData(new EncryptedValue().setEncryptionKeyUuid(activeCanaryUuid).setEncryptedValue(new byte[] {}).setNonce(new byte[] {}));
PasswordCredentialVersion credential = new PasswordCredentialVersion(passwordCredentialData);
subject.save(credential);
ValueCredentialVersionData newCredentialData = new ValueCredentialVersionData();
newCredentialData.setEncryptedValueData(new EncryptedValue().setEncryptionKeyUuid(activeCanaryUuid).setEncryptedValue("some value".getBytes()));
newCredentialData.setCredential(passwordCredentialData.getCredential());
ValueCredentialVersion newCredential = new ValueCredentialVersion(newCredentialData);
subject.save(newCredential);
}
use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class CredentialVersionDataServiceTest method findAllPaths_returnsCompleteDirectoryStructure.
@Test
public void findAllPaths_returnsCompleteDirectoryStructure() {
String valueOther = "/fubario";
String valueName = "/value/Credential";
String passwordName = "/password/Credential";
String certificateName = "/certif/ic/ateCredential";
ValueCredentialVersionData valueCredentialData = new ValueCredentialVersionData(valueOther);
ValueCredentialVersion valueCredential = new ValueCredentialVersion(valueCredentialData);
subject.save(valueCredential);
valueCredentialData = new ValueCredentialVersionData(valueName);
valueCredential = new ValueCredentialVersion(valueCredentialData);
subject.save(valueCredential);
PasswordCredentialVersionData passwordCredentialData = new PasswordCredentialVersionData(passwordName);
PasswordCredentialVersion passwordCredential = new PasswordCredentialVersion(passwordCredentialData);
subject.save(passwordCredential);
CertificateCredentialVersionData certificateCredentialData = new CertificateCredentialVersionData(certificateName);
CertificateCredentialVersion certificateCredential = new CertificateCredentialVersion(certificateCredentialData);
subject.save(certificateCredential);
assertThat(subject.findAllPaths(), equalTo(newArrayList("/", "/certif/", "/certif/ic/", "/password/", "/value/")));
}
use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class PermissionDataServiceTest method seedDatabase.
private void seedDatabase() {
ValueCredentialVersionData valueCredentialData = new ValueCredentialVersionData(CREDENTIAL_NAME);
credential = valueCredentialData.getCredential();
ValueCredentialVersionData noAccessValueCredentialData = new ValueCredentialVersionData(NO_ACCESS_CREDENTIAL_NAME);
Credential noAccessValueCredential = noAccessValueCredentialData.getCredential();
Credential noAccessCredential = credentialDataService.save(noAccessValueCredential);
this.credential = credentialDataService.save(this.credential);
subject.savePermissions(this.credential, singletonList(new PermissionEntry(LUKE, newArrayList(WRITE, DELETE))));
subject.savePermissions(this.credential, singletonList(new PermissionEntry(LEIA, singletonList(READ))));
subject.savePermissions(this.credential, singletonList(new PermissionEntry(HAN_SOLO, newArrayList(READ_ACL, WRITE_ACL))));
}
use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.
the class CredentialRotationTest method rotate_givenValueCredential_reEncryptsWithActiveKey.
@Test
public void rotate_givenValueCredential_reEncryptsWithActiveKey() {
ValueCredentialVersionData valueCredentialData = new ValueCredentialVersionData("value key");
ValueCredentialVersion credential = new ValueCredentialVersion(valueCredentialData);
assertRotation(credential, valueCredentialData);
}
Aggregations