Search in sources :

Example 6 with UserContextHolder

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

the class CertificateAuthorityServiceTest method beforeEach.

@Before
public void beforeEach() {
    certificate = new CertificateCredentialValue(null, CertificateStringConstants.SELF_SIGNED_CA_CERT, "my-key", null);
    certificateCredential = mock(CertificateCredentialVersion.class);
    permissionCheckingService = mock(PermissionCheckingService.class);
    userContext = mock(UserContext.class);
    when(userContext.getActor()).thenReturn(USER_NAME);
    when(certificateCredential.getName()).thenReturn(CREDENTIAL_NAME);
    when(permissionCheckingService.hasPermission(USER_NAME, CREDENTIAL_NAME, PermissionOperation.READ)).thenReturn(true);
    certificateVersionDataService = mock(CertificateVersionDataService.class);
    UserContextHolder userContextHolder = new UserContextHolder();
    userContextHolder.setUserContext(userContext);
    certificateAuthorityService = new CertificateAuthorityService(certificateVersionDataService, permissionCheckingService, userContextHolder);
}
Also used : PermissionCheckingService(org.cloudfoundry.credhub.service.PermissionCheckingService) CertificateCredentialValue(org.cloudfoundry.credhub.credential.CertificateCredentialValue) UserContext(org.cloudfoundry.credhub.auth.UserContext) UserContextHolder(org.cloudfoundry.credhub.auth.UserContextHolder) CertificateCredentialVersion(org.cloudfoundry.credhub.domain.CertificateCredentialVersion) Before(org.junit.Before)

Example 7 with UserContextHolder

use of org.cloudfoundry.credhub.auth.UserContextHolder 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)7 UserContextHolder (org.cloudfoundry.credhub.auth.UserContextHolder)7 Before (org.junit.Before)7 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)3 PermissionDataService (org.cloudfoundry.credhub.data.PermissionDataService)2 Credential (org.cloudfoundry.credhub.entity.Credential)2 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 UserContextFactory (org.cloudfoundry.credhub.auth.UserContextFactory)1 CertificateCredentialValue (org.cloudfoundry.credhub.credential.CertificateCredentialValue)1 CredentialValue (org.cloudfoundry.credhub.credential.CredentialValue)1 CertificateAuthorityService (org.cloudfoundry.credhub.data.CertificateAuthorityService)1 CertificateCredentialVersion (org.cloudfoundry.credhub.domain.CertificateCredentialVersion)1 PermissionOperation (org.cloudfoundry.credhub.request.PermissionOperation)1 PermissionCheckingService (org.cloudfoundry.credhub.service.PermissionCheckingService)1 PermissionService (org.cloudfoundry.credhub.service.PermissionService)1 PermissionedCredentialService (org.cloudfoundry.credhub.service.PermissionedCredentialService)1