Search in sources :

Example 1 with ValueCredentialVersionData

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();
}
Also used : ValueCredentialVersion(org.cloudfoundry.credhub.domain.ValueCredentialVersion) ValueCredentialVersionData(org.cloudfoundry.credhub.entity.ValueCredentialVersionData) Before(org.junit.Before)

Example 2 with ValueCredentialVersionData

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);
}
Also used : ValueCredentialVersion(org.cloudfoundry.credhub.domain.ValueCredentialVersion) PasswordCredentialVersionData(org.cloudfoundry.credhub.entity.PasswordCredentialVersionData) EncryptedValue(org.cloudfoundry.credhub.entity.EncryptedValue) PasswordCredentialVersion(org.cloudfoundry.credhub.domain.PasswordCredentialVersion) ValueCredentialVersionData(org.cloudfoundry.credhub.entity.ValueCredentialVersionData) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 3 with ValueCredentialVersionData

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/")));
}
Also used : ValueCredentialVersion(org.cloudfoundry.credhub.domain.ValueCredentialVersion) CertificateCredentialVersionData(org.cloudfoundry.credhub.entity.CertificateCredentialVersionData) PasswordCredentialVersionData(org.cloudfoundry.credhub.entity.PasswordCredentialVersionData) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PasswordCredentialVersion(org.cloudfoundry.credhub.domain.PasswordCredentialVersion) ValueCredentialVersionData(org.cloudfoundry.credhub.entity.ValueCredentialVersionData) CertificateCredentialVersion(org.cloudfoundry.credhub.domain.CertificateCredentialVersion) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 4 with ValueCredentialVersionData

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))));
}
Also used : Credential(org.cloudfoundry.credhub.entity.Credential) PermissionEntry(org.cloudfoundry.credhub.request.PermissionEntry) ValueCredentialVersionData(org.cloudfoundry.credhub.entity.ValueCredentialVersionData)

Example 5 with ValueCredentialVersionData

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);
}
Also used : ValueCredentialVersionData(org.cloudfoundry.credhub.entity.ValueCredentialVersionData) Test(org.junit.Test)

Aggregations

ValueCredentialVersionData (org.cloudfoundry.credhub.entity.ValueCredentialVersionData)12 Test (org.junit.Test)8 ValueCredentialVersion (org.cloudfoundry.credhub.domain.ValueCredentialVersion)4 EncryptedValue (org.cloudfoundry.credhub.entity.EncryptedValue)4 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)3 Credential (org.cloudfoundry.credhub.entity.Credential)3 PasswordCredentialVersionData (org.cloudfoundry.credhub.entity.PasswordCredentialVersionData)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 CertificateCredentialVersion (org.cloudfoundry.credhub.domain.CertificateCredentialVersion)2 CertificateCredentialVersionData (org.cloudfoundry.credhub.entity.CertificateCredentialVersionData)2 PermissionEntry (org.cloudfoundry.credhub.request.PermissionEntry)2 Before (org.junit.Before)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)1