Search in sources :

Example 46 with Credential

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

the class CredentialDataServiceTest method find_whenTheCredentialExists_returnsTheCredential.

@Test
public void find_whenTheCredentialExists_returnsTheCredential() {
    final Credential credential = new Credential(CREDENTIAL_NAME);
    credentialRepository.save(credential);
    assertThat(subject.find(CREDENTIAL_NAME), equalTo(credential));
}
Also used : Credential(org.cloudfoundry.credhub.entity.Credential) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 47 with Credential

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

the class CredentialDataServiceTest method save_savesTheCredential.

@Test
public void save_savesTheCredential() {
    final Credential credential = new Credential(CREDENTIAL_NAME);
    assertThat(credentialRepository.count(), equalTo(0L));
    credentialRepository.save(credential);
    assertThat(credentialRepository.count(), equalTo(1L));
    assertThat(credentialRepository.findOneByNameIgnoreCase(CREDENTIAL_NAME).getName(), equalTo(CREDENTIAL_NAME));
}
Also used : Credential(org.cloudfoundry.credhub.entity.Credential) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 48 with Credential

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

the class CredentialDataServiceTest method findByUUID_whenTheCredentialExists_returnsTheCredential.

@Test
public void findByUUID_whenTheCredentialExists_returnsTheCredential() {
    final Credential credential = new Credential(CREDENTIAL_NAME);
    credentialRepository.save(credential);
    assertThat(subject.findByUUID(credential.getUuid()), equalTo(credential));
}
Also used : Credential(org.cloudfoundry.credhub.entity.Credential) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 49 with Credential

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

the class CredentialDataServiceTest method findAll_whenThereAreCredentials_returnsTheListOfNames.

@Test
public void findAll_whenThereAreCredentials_returnsTheListOfNames() {
    credentialRepository.save(new Credential(CREDENTIAL_NAME));
    credentialRepository.save(new Credential(CREDENTIAL_NAME2));
    List<Credential> credentials = subject.findAll();
    List<String> names = credentials.stream().map(Credential::getName).collect(Collectors.toList());
    assertThat(names, hasSize(2));
    assertThat(names, containsInAnyOrder(CREDENTIAL_NAME, CREDENTIAL_NAME2));
}
Also used : Credential(org.cloudfoundry.credhub.entity.Credential) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Credential (org.cloudfoundry.credhub.entity.Credential)49 Test (org.junit.Test)30 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 UUID (java.util.UUID)13 UserContext (org.cloudfoundry.credhub.auth.UserContext)13 CertificateCredentialVersion (org.cloudfoundry.credhub.domain.CertificateCredentialVersion)13 EventAuditRecordParameters (org.cloudfoundry.credhub.audit.EventAuditRecordParameters)9 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)9 EntryNotFoundException (org.cloudfoundry.credhub.exceptions.EntryNotFoundException)9 EncryptedValue (org.cloudfoundry.credhub.entity.EncryptedValue)7 CertificateCredentialVersionData (org.cloudfoundry.credhub.entity.CertificateCredentialVersionData)5 PasswordCredentialVersionData (org.cloudfoundry.credhub.entity.PasswordCredentialVersionData)5 CertificateCredentialValue (org.cloudfoundry.credhub.credential.CertificateCredentialValue)4 CredentialVersionData (org.cloudfoundry.credhub.entity.CredentialVersionData)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 AuditingOperationCode (org.cloudfoundry.credhub.audit.AuditingOperationCode)3 UserContextHolder (org.cloudfoundry.credhub.auth.UserContextHolder)3 ValueCredentialVersionData (org.cloudfoundry.credhub.entity.ValueCredentialVersionData)3 ParameterizedValidationException (org.cloudfoundry.credhub.exceptions.ParameterizedValidationException)3