use of org.cloudfoundry.credhub.entity.Credential 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));
}
use of org.cloudfoundry.credhub.entity.Credential in project credhub by cloudfoundry-incubator.
the class CertificateVersionDataServiceTest method findActiveWithTransitional_findsMostRecentNonTransitionalAndTransitionalCredentialVersions.
@Test
public void findActiveWithTransitional_findsMostRecentNonTransitionalAndTransitionalCredentialVersions() throws Exception {
Credential certificate = mock(Credential.class);
when(dataService.find("/some-cert-name")).thenReturn(certificate);
CredentialVersionData activeCert = mock(CredentialVersionData.class);
when(versionRepository.findLatestNonTransitionalCertificateVersion(any())).thenReturn(activeCert);
CredentialVersionData transitionalCert = mock(CredentialVersionData.class);
when(versionRepository.findTransitionalCertificateVersion(any())).thenReturn(transitionalCert);
CredentialVersion expectedActive = mock(CredentialVersion.class);
when(factory.makeCredentialFromEntity(activeCert)).thenReturn(expectedActive);
CredentialVersion expectedTransitional = mock(CredentialVersion.class);
when(factory.makeCredentialFromEntity(transitionalCert)).thenReturn(expectedTransitional);
List<CredentialVersion> credentialVersions = subject.findActiveWithTransitional("/some-cert-name");
assertThat(credentialVersions, hasSize(2));
assertThat(credentialVersions, containsInAnyOrder(expectedActive, expectedTransitional));
}
use of org.cloudfoundry.credhub.entity.Credential in project credhub by cloudfoundry-incubator.
the class CredentialDataServiceTest method save_setsTheUuidOnTheCredential.
@Test
public void save_setsTheUuidOnTheCredential() {
final Credential credential = credentialRepository.save(new Credential(CREDENTIAL_NAME));
assertThat(credential.getUuid(), instanceOf(UUID.class));
}
use of org.cloudfoundry.credhub.entity.Credential in project credhub by cloudfoundry-incubator.
the class CredentialDataServiceTest method delete_whenTheCredentialExists_deletesTheCredential_andReturnsTrue.
@Test
public void delete_whenTheCredentialExists_deletesTheCredential_andReturnsTrue() {
credentialRepository.save(new Credential(CREDENTIAL_NAME));
assertThat(subject.delete(CREDENTIAL_NAME), equalTo(true));
assertThat(credentialRepository.count(), equalTo(0L));
}
use of org.cloudfoundry.credhub.entity.Credential in project credhub by cloudfoundry-incubator.
the class CredentialDataServiceTest method delete_isCaseInsensitive.
@Test
public void delete_isCaseInsensitive() {
credentialRepository.save(new Credential(CREDENTIAL_NAME.toUpperCase()));
assertThat(subject.delete(CREDENTIAL_NAME.toLowerCase()), equalTo(true));
assertThat(credentialRepository.count(), equalTo(0L));
}
Aggregations