Search in sources :

Example 1 with Encryptor

use of org.cloudfoundry.credhub.domain.Encryptor in project credhub by cloudfoundry-incubator.

the class CredentialsHandlerTest method beforeEach.

@Before
public void beforeEach() {
    Encryptor encryptor = mock(Encryptor.class);
    permissionedCredentialService = mock(PermissionedCredentialService.class);
    permissionCheckingService = mock(PermissionCheckingService.class);
    subject = new CredentialsHandler(permissionedCredentialService);
    userContext = mock(UserContext.class);
    when(userContext.getActor()).thenReturn(USER);
    version1 = new SshCredentialVersion(CREDENTIAL_NAME);
    version1.setVersionCreatedAt(VERSION1_CREATED_AT);
    version1.setEncryptor(encryptor);
    version2 = new SshCredentialVersion(CREDENTIAL_NAME);
    version2.setVersionCreatedAt(VERSION2_CREATED_AT);
    version2.setEncryptor(encryptor);
}
Also used : PermissionCheckingService(org.cloudfoundry.credhub.service.PermissionCheckingService) PermissionedCredentialService(org.cloudfoundry.credhub.service.PermissionedCredentialService) UserContext(org.cloudfoundry.credhub.auth.UserContext) Encryptor(org.cloudfoundry.credhub.domain.Encryptor) SshCredentialVersion(org.cloudfoundry.credhub.domain.SshCredentialVersion) Before(org.junit.Before)

Example 2 with Encryptor

use of org.cloudfoundry.credhub.domain.Encryptor in project credhub by cloudfoundry-incubator.

the class JsonViewTest method beforeEach.

@Before
public void beforeEach() {
    value = new HashMap<>();
    value.put("string", "something");
    value.put("num", 10);
    value.put("camelCase", "blabla");
    serializedValue = serializeToString(value);
    encryptor = mock(Encryptor.class);
    uuid = UUID.randomUUID();
    entity = new JsonCredentialVersion("/foo").setEncryptor(encryptor).setUuid(uuid);
    when(encryptor.decrypt(any())).thenReturn(serializedValue);
}
Also used : JsonCredentialVersion(org.cloudfoundry.credhub.domain.JsonCredentialVersion) Encryptor(org.cloudfoundry.credhub.domain.Encryptor) Before(org.junit.Before)

Example 3 with Encryptor

use of org.cloudfoundry.credhub.domain.Encryptor in project credhub by cloudfoundry-incubator.

the class PasswordViewTest method beforeEach.

@Before
public void beforeEach() {
    encryptor = mock(Encryptor.class);
    uuid = UUID.randomUUID();
    entity = new PasswordCredentialVersion("/foo").setEncryptor(encryptor).setUuid(uuid);
    when(encryptor.decrypt(any())).thenReturn("fake-plaintext-value");
}
Also used : Encryptor(org.cloudfoundry.credhub.domain.Encryptor) PasswordCredentialVersion(org.cloudfoundry.credhub.domain.PasswordCredentialVersion) Before(org.junit.Before)

Example 4 with Encryptor

use of org.cloudfoundry.credhub.domain.Encryptor in project credhub by cloudfoundry-incubator.

the class ValueViewTest method beforeEach.

@Before
public void beforeEach() {
    uuid = UUID.randomUUID();
    encryptor = mock(Encryptor.class);
    when(encryptor.decrypt(any())).thenReturn("fake-plaintext-value");
    entity = new ValueCredentialVersion("/foo").setEncryptor(encryptor).setUuid(uuid);
}
Also used : ValueCredentialVersion(org.cloudfoundry.credhub.domain.ValueCredentialVersion) Encryptor(org.cloudfoundry.credhub.domain.Encryptor) Before(org.junit.Before)

Example 5 with Encryptor

use of org.cloudfoundry.credhub.domain.Encryptor in project credhub by cloudfoundry-incubator.

the class SshViewTest method beforeEach.

@Before
public void beforeEach() {
    Encryptor encryptor = mock(Encryptor.class);
    final EncryptedValue encryption = new EncryptedValue(UUID.randomUUID(), "encrypted".getBytes(), "nonce".getBytes());
    when(encryptor.encrypt(TestConstants.PRIVATE_KEY_4096)).thenReturn(encryption);
    when(encryptor.decrypt(encryption)).thenReturn(TestConstants.PRIVATE_KEY_4096);
    entity = new SshCredentialVersion(CREDENTIAL_NAME).setEncryptor(encryptor).setPublicKey(TestConstants.SSH_PUBLIC_KEY_4096_WITH_COMMENT).setPrivateKey(TestConstants.PRIVATE_KEY_4096);
    entity.setUuid(CREDENTIAL_UUID);
}
Also used : Encryptor(org.cloudfoundry.credhub.domain.Encryptor) EncryptedValue(org.cloudfoundry.credhub.entity.EncryptedValue) SshCredentialVersion(org.cloudfoundry.credhub.domain.SshCredentialVersion) Before(org.junit.Before)

Aggregations

Encryptor (org.cloudfoundry.credhub.domain.Encryptor)9 Before (org.junit.Before)7 SshCredentialVersion (org.cloudfoundry.credhub.domain.SshCredentialVersion)4 CertificateCredentialVersion (org.cloudfoundry.credhub.domain.CertificateCredentialVersion)3 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 UserContext (org.cloudfoundry.credhub.auth.UserContext)2 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)2 JsonCredentialVersion (org.cloudfoundry.credhub.domain.JsonCredentialVersion)2 RsaCredentialVersion (org.cloudfoundry.credhub.domain.RsaCredentialVersion)2 UserCredentialVersion (org.cloudfoundry.credhub.domain.UserCredentialVersion)2 ValueCredentialVersion (org.cloudfoundry.credhub.domain.ValueCredentialVersion)2 EncryptedValue (org.cloudfoundry.credhub.entity.EncryptedValue)2 PermissionCheckingService (org.cloudfoundry.credhub.service.PermissionCheckingService)2 JSONObject (net.minidev.json.JSONObject)1 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)1 CertificateService (org.cloudfoundry.credhub.service.CertificateService)1 PermissionedCertificateService (org.cloudfoundry.credhub.service.PermissionedCertificateService)1