Search in sources :

Example 36 with UserContext

use of org.cloudfoundry.credhub.auth.UserContext in project credhub by cloudfoundry-incubator.

the class CertificatesHandlerTest method beforeEach.

@Before
public void beforeEach() {
    Encryptor encryptor = mock(Encryptor.class);
    permissionedCertificateService = mock(PermissionedCertificateService.class);
    permissionCheckingService = mock(PermissionCheckingService.class);
    certificateService = mock(CertificateService.class);
    universalCredentialGenerator = mock(UniversalCredentialGenerator.class);
    generationRequestGenerator = mock(GenerationRequestGenerator.class);
    subject = new CertificatesHandler(permissionedCertificateService, certificateService, universalCredentialGenerator, generationRequestGenerator);
    userContext = mock(UserContext.class);
    when(userContext.getActor()).thenReturn(USER);
}
Also used : PermissionCheckingService(org.cloudfoundry.credhub.service.PermissionCheckingService) PermissionedCertificateService(org.cloudfoundry.credhub.service.PermissionedCertificateService) UserContext(org.cloudfoundry.credhub.auth.UserContext) PermissionedCertificateService(org.cloudfoundry.credhub.service.PermissionedCertificateService) CertificateService(org.cloudfoundry.credhub.service.CertificateService) Encryptor(org.cloudfoundry.credhub.domain.Encryptor) Before(org.junit.Before)

Example 37 with UserContext

use of org.cloudfoundry.credhub.auth.UserContext in project credhub by cloudfoundry-incubator.

the class SetHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    TestHelper.getBouncyCastleProvider();
    credentialService = mock(PermissionedCredentialService.class);
    certificateAuthorityService = mock(CertificateAuthorityService.class);
    permissionService = mock(PermissionService.class);
    userContext = new UserContext();
    UserContextHolder userContextHolder = new UserContextHolder();
    userContextHolder.setUserContext(userContext);
    subject = new SetHandler(credentialService, permissionService, certificateAuthorityService, userContextHolder);
    generationParameters = new StringGenerationParameters();
    accessControlEntries = new ArrayList<>();
    credentialVersion = mock(PasswordCredentialVersion.class);
    when(credentialService.save(anyObject(), anyObject(), anyObject(), anyList())).thenReturn(credentialVersion);
}
Also used : PermissionService(org.cloudfoundry.credhub.service.PermissionService) PermissionedCredentialService(org.cloudfoundry.credhub.service.PermissionedCredentialService) UserContext(org.cloudfoundry.credhub.auth.UserContext) UserContextHolder(org.cloudfoundry.credhub.auth.UserContextHolder) CertificateAuthorityService(org.cloudfoundry.credhub.data.CertificateAuthorityService) PasswordCredentialVersion(org.cloudfoundry.credhub.domain.PasswordCredentialVersion) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Before(org.junit.Before)

Aggregations

UserContext (org.cloudfoundry.credhub.auth.UserContext)37 Test (org.junit.Test)21 UUID (java.util.UUID)16 Before (org.junit.Before)14 Credential (org.cloudfoundry.credhub.entity.Credential)13 CertificateCredentialVersion (org.cloudfoundry.credhub.domain.CertificateCredentialVersion)9 UserContextHolder (org.cloudfoundry.credhub.auth.UserContextHolder)7 EventAuditRecord (org.cloudfoundry.credhub.entity.EventAuditRecord)6 CertificateCredentialValue (org.cloudfoundry.credhub.credential.CertificateCredentialValue)4 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)4 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)4 PermissionCheckingService (org.cloudfoundry.credhub.service.PermissionCheckingService)4 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)3 PermissionedCredentialService (org.cloudfoundry.credhub.service.PermissionedCredentialService)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 UserContextFactory (org.cloudfoundry.credhub.auth.UserContextFactory)2 CertificateAuthorityService (org.cloudfoundry.credhub.data.CertificateAuthorityService)2 PermissionDataService (org.cloudfoundry.credhub.data.PermissionDataService)2 CertificateGenerationParameters (org.cloudfoundry.credhub.domain.CertificateGenerationParameters)2 Encryptor (org.cloudfoundry.credhub.domain.Encryptor)2