use of org.cloudfoundry.credhub.auth.UserContext 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);
}
use of org.cloudfoundry.credhub.auth.UserContext in project credhub by cloudfoundry-incubator.
the class GenerateHandlerTest method setUp.
@Before
public void setUp() throws Exception {
credentialService = mock(PermissionedCredentialService.class);
universalCredentialGenerator = mock(UniversalCredentialGenerator.class);
permissionService = mock(PermissionService.class);
subject = new GenerateHandler(credentialService, permissionService, universalCredentialGenerator);
generationParameters = new StringGenerationParameters();
accessControlEntries = new ArrayList<>();
userContext = new UserContext();
credentialVersion = mock(PasswordCredentialVersion.class);
when(credentialService.save(anyObject(), anyObject(), anyObject(), anyList())).thenReturn(credentialVersion);
}
use of org.cloudfoundry.credhub.auth.UserContext 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);
}
use of org.cloudfoundry.credhub.auth.UserContext in project credhub by cloudfoundry-incubator.
the class CertificateServiceTest method setup.
@Before
public void setup() {
initMocks(this);
auditRecordParameters = new ArrayList<>();
userContext = mock(UserContext.class);
userContextHolder = new UserContextHolder();
userContextHolder.setUserContext(userContext);
subject = new CertificateService(certificateVersionDataService, permissionCheckingService, userContextHolder);
credentialVersion.createName(credentialName);
when(userContext.getActor()).thenReturn(actor);
when(certificateVersionDataService.findByCredentialUUID(credentialUuid)).thenReturn(credentialVersion);
}
use of org.cloudfoundry.credhub.auth.UserContext in project credhub by cloudfoundry-incubator.
the class AuditInterceptor method afterCompletion.
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) throws Exception {
Principal userAuth = request.getUserPrincipal();
if (userAuth == null) {
return;
}
UserContext userContext = userContextFactory.createUserContext((Authentication) userAuth);
RequestAuditRecord requestAuditRecord = auditLogFactory.createRequestAuditRecord(request, userContext, response.getStatus());
try {
requestAuditRecordDataService.save(requestAuditRecord);
} finally {
securityEventsLogService.log(new SecurityEventAuditRecord(requestAuditRecord, userContext.getActor()));
}
}
Aggregations