Search in sources :

Example 1 with UserContextFactory

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

the class UserContextInterceptorTest method setup.

@Before
public void setup() {
    userContextFactory = mock(UserContextFactory.class);
    userContext = mock(UserContext.class);
    userContextHolder = new UserContextHolder();
    subject = new UserContextInterceptor(userContextFactory, userContextHolder);
    when(userContextFactory.createUserContext(any())).thenReturn(userContext);
    request = mock(HttpServletRequest.class);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) UserContext(org.cloudfoundry.credhub.auth.UserContext) UserContextFactory(org.cloudfoundry.credhub.auth.UserContextFactory) UserContextHolder(org.cloudfoundry.credhub.auth.UserContextHolder) Before(org.junit.Before)

Example 2 with UserContextFactory

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

the class AuditInterceptorTest method setup.

@Before
public void setup() {
    requestAuditRecordDataService = mock(RequestAuditRecordDataService.class);
    securityEventsLogService = mock(SecurityEventsLogService.class);
    auditLogFactory = mock(AuditLogFactory.class);
    userContextFactory = mock(UserContextFactory.class);
    userContext = mock(UserContext.class);
    requestUuid = new RequestUuid();
    subject = new AuditInterceptor(requestAuditRecordDataService, securityEventsLogService, auditLogFactory, userContextFactory);
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    final Authentication authentication = mock(Authentication.class);
    when(request.getUserPrincipal()).thenReturn(authentication);
    userContext = mock(UserContext.class);
    when(userContextFactory.createUserContext(any())).thenReturn(userContext);
    when(userContext.getActor()).thenReturn("user");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) UserContext(org.cloudfoundry.credhub.auth.UserContext) Authentication(org.springframework.security.core.Authentication) AuditLogFactory(org.cloudfoundry.credhub.audit.AuditLogFactory) HttpServletResponse(javax.servlet.http.HttpServletResponse) UserContextFactory(org.cloudfoundry.credhub.auth.UserContextFactory) RequestAuditRecordDataService(org.cloudfoundry.credhub.data.RequestAuditRecordDataService) RequestUuid(org.cloudfoundry.credhub.audit.RequestUuid) SecurityEventsLogService(org.cloudfoundry.credhub.service.SecurityEventsLogService) Before(org.junit.Before)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)2 UserContext (org.cloudfoundry.credhub.auth.UserContext)2 UserContextFactory (org.cloudfoundry.credhub.auth.UserContextFactory)2 Before (org.junit.Before)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 AuditLogFactory (org.cloudfoundry.credhub.audit.AuditLogFactory)1 RequestUuid (org.cloudfoundry.credhub.audit.RequestUuid)1 UserContextHolder (org.cloudfoundry.credhub.auth.UserContextHolder)1 RequestAuditRecordDataService (org.cloudfoundry.credhub.data.RequestAuditRecordDataService)1 SecurityEventsLogService (org.cloudfoundry.credhub.service.SecurityEventsLogService)1 Authentication (org.springframework.security.core.Authentication)1