use of org.alfresco.repo.audit.AuditServiceImpl in project alfresco-remote-api by Alfresco.
the class AuditWebScriptTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
ctx = getServer().getApplicationContext();
// MNT-10807 : Auditing does not take into account audit.filter.alfresco-access.transaction.user
UserAuditFilter userAuditFilter = new UserAuditFilter();
userAuditFilter.setUserFilterPattern("System;.*");
userAuditFilter.afterPropertiesSet();
AuditComponent auditComponent = (AuditComponent) ctx.getBean("auditComponent");
auditComponent.setUserAuditFilter(userAuditFilter);
AuditServiceImpl auditServiceImpl = (AuditServiceImpl) ctx.getBean("auditService");
auditServiceImpl.setAuditComponent(auditComponent);
authenticationService = (AuthenticationService) ctx.getBean("AuthenticationService");
auditService = (AuditService) ctx.getBean("AuditService");
searchService = (SearchService) ctx.getBean("SearchService");
repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper");
fileFolderService = (FileFolderService) getServer().getApplicationContext().getBean("FileFolderService");
admin = AuthenticationUtil.getAdminUserName();
// Register the test models
AuditModelRegistryImpl auditModelRegistry = (AuditModelRegistryImpl) ctx.getBean("auditModel.modelRegistry");
URL testModelUrl = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test-repository.xml");
URL testModelUrl1 = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test-mnt-16748.xml");
auditModelRegistry.registerModel(testModelUrl);
auditModelRegistry.registerModel(testModelUrl1);
auditModelRegistry.loadAuditModels();
AuthenticationUtil.setFullyAuthenticatedUser(admin);
wasGloballyEnabled = auditService.isAuditEnabled();
wasRepoEnabled = auditService.isAuditEnabled(APP_REPOTEST_NAME, APP_REPOTEST_PATH);
wasSearchEnabled = auditService.isAuditEnabled(APP_SEARCHTEST_NAME, APP_SEARCHTEST_PATH);
// Only enable if required
if (!wasGloballyEnabled) {
auditService.setAuditEnabled(true);
wasGloballyEnabled = auditService.isAuditEnabled();
if (!wasGloballyEnabled) {
fail("Failed to enable global audit for test");
}
}
if (!wasRepoEnabled) {
auditService.enableAudit(APP_REPOTEST_NAME, APP_REPOTEST_PATH);
wasRepoEnabled = auditService.isAuditEnabled(APP_REPOTEST_NAME, APP_REPOTEST_PATH);
if (!wasRepoEnabled) {
fail("Failed to enable repo audit for test");
}
}
if (!wasSearchEnabled) {
auditService.enableAudit(APP_SEARCHTEST_NAME, APP_SEARCHTEST_PATH);
wasSearchEnabled = auditService.isAuditEnabled(APP_SEARCHTEST_NAME, APP_SEARCHTEST_PATH);
if (!wasSearchEnabled) {
fail("Failed to enable search audit for test");
}
}
}
Aggregations