Search in sources :

Example 6 with JsonCredentialVersion

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

the class InterpolationControllerTest method POST_logsTheCredentialAccess.

@Test
public void POST_logsTheCredentialAccess() throws Exception {
    JsonCredentialVersion jsonCredential = mock(JsonCredentialVersion.class);
    doReturn(Maps.newHashMap("secret1", "secret1-value")).when(jsonCredential).getValue();
    when(jsonCredential.getName()).thenReturn("/cred1");
    JsonCredentialVersion jsonCredential1 = mock(JsonCredentialVersion.class);
    doReturn(Maps.newHashMap("secret2", "secret2-value")).when(jsonCredential1).getValue();
    when(jsonCredential1.getName()).thenReturn("/cred2");
    doReturn(Arrays.asList(jsonCredential)).when(mockCredentialVersionDataService).findNByName("/cred1", 1);
    doReturn(Arrays.asList(jsonCredential1)).when(mockCredentialVersionDataService).findNByName("/cred2", 1);
    mockMvc.perform(makeValidPostRequest()).andExpect(status().isOk());
    auditingHelper.verifyAuditing(UAA_OAUTH2_PASSWORD_GRANT_ACTOR_ID, "/api/v1/interpolate", 200, Lists.newArrayList(new EventAuditRecordParameters(CREDENTIAL_ACCESS, "/cred1"), new EventAuditRecordParameters(CREDENTIAL_ACCESS, "/cred2")));
}
Also used : JsonCredentialVersion(org.cloudfoundry.credhub.domain.JsonCredentialVersion) EventAuditRecordParameters(org.cloudfoundry.credhub.audit.EventAuditRecordParameters) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

JsonCredentialVersion (org.cloudfoundry.credhub.domain.JsonCredentialVersion)6 ArrayList (java.util.ArrayList)2 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)2 Encryptor (org.cloudfoundry.credhub.domain.Encryptor)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Map (java.util.Map)1 UUID (java.util.UUID)1 JSONObject (net.minidev.json.JSONObject)1 EventAuditRecordParameters (org.cloudfoundry.credhub.audit.EventAuditRecordParameters)1 CertificateCredentialVersion (org.cloudfoundry.credhub.domain.CertificateCredentialVersion)1 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)1 RsaCredentialVersion (org.cloudfoundry.credhub.domain.RsaCredentialVersion)1 SshCredentialVersion (org.cloudfoundry.credhub.domain.SshCredentialVersion)1 UserCredentialVersion (org.cloudfoundry.credhub.domain.UserCredentialVersion)1 ValueCredentialVersion (org.cloudfoundry.credhub.domain.ValueCredentialVersion)1 EntryNotFoundException (org.cloudfoundry.credhub.exceptions.EntryNotFoundException)1 ParameterizedValidationException (org.cloudfoundry.credhub.exceptions.ParameterizedValidationException)1 Before (org.junit.Before)1