Search in sources :

Example 11 with ValueCredentialVersionData

use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.

the class PermissionDataServiceTest method setAccessControlEntries_whenGivenANewAce_returnsTheAcl.

@Test
public void setAccessControlEntries_whenGivenANewAce_returnsTheAcl() {
    final ValueCredentialVersionData valueCredentialData2 = new ValueCredentialVersionData("lightsaber2");
    final Credential credential2 = valueCredentialData2.getCredential();
    credentialDataService.save(credential2);
    aces = singletonList(new PermissionEntry(LUKE, singletonList(READ)));
    subject.savePermissions(credential2, aces);
    List<PermissionEntry> response = subject.getPermissions(credential2);
    final PermissionEntry permissionEntry = response.get(0);
    assertThat(response, hasSize(1));
    assertThat(permissionEntry.getActor(), equalTo(LUKE));
    assertThat(permissionEntry.getAllowedOperations(), hasSize(1));
    assertThat(permissionEntry.getAllowedOperations(), hasItem(READ));
}
Also used : Credential(org.cloudfoundry.credhub.entity.Credential) PermissionEntry(org.cloudfoundry.credhub.request.PermissionEntry) ValueCredentialVersionData(org.cloudfoundry.credhub.entity.ValueCredentialVersionData) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with ValueCredentialVersionData

use of org.cloudfoundry.credhub.entity.ValueCredentialVersionData in project credhub by cloudfoundry-incubator.

the class ValueCredentialVersionTest method setValue_whenValueIsNull_throwsException.

@Test(expected = IllegalArgumentException.class)
public void setValue_whenValueIsNull_throwsException() {
    valueCredentialData = new ValueCredentialVersionData("foo");
    subject = new ValueCredentialVersion(valueCredentialData).setEncryptor(encryptor);
    subject.setValue(null);
}
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