From 9a9560fa6cc0056410dadf73c16e183ef544ecfc Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Tue, 21 Jul 2015 05:30:53 +0000 Subject: [PATCH] Fixes to classification enforcement: * only process services that start with an upper case character. We were being over zealous in our checking which was causing problems, we only care about public services. * add enable/disable/isenabled methods to pre-processor * switch off pre-processing when post-processing * remove method black list * unit tests, integration tests and UI tests run locally +review RM @taksoy git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@108613 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../classified-content-context.xml | 3 +- ...icationMethodInterceptorPostProcessor.java | 3 +- .../BasePostMethodInvocationProcessor.java | 18 +++- .../PreMethodInvocationProcessor.java | 45 ++++++--- ...owseClassificationEnforcementTestBase.java | 2 +- .../EnforceClassificationTest.java | 99 ------------------- ...PostMethodInvocationProcessorUnitTest.java | 1 + 7 files changed, 51 insertions(+), 120 deletions(-) delete mode 100644 rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/EnforceClassificationTest.java diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml index 0d9fea42db..c1ec943eb9 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml @@ -43,8 +43,7 @@ + class="org.alfresco.module.org_alfresco_module_rm.classification.interceptor.processor.PreMethodInvocationProcessor"> . - */ -package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor; - -import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService; -import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; - -/** - * Enforce classification integration test - * - * @author Roy Wetherall - * @since 3.0 - */ -public class EnforceClassificationTest extends BaseRMTestCase -{ - /** test data */ -// private static final String CLASSIFICATION_LEVEL1 = "level1"; -// private static final String CLASSIFICATION_LEVEL2 = "level2"; -// private static final String CLASSIFICATION_LEVEL3 = "level3"; -// private static final String CLASSIFICATION_LEVEL4 = "level4"; -// -// private static final String CLASSIFICATION_REASON = "Test Reason 1"; -// private static final String CLASSIFICATION_AUTHORITY = "classification.authority"; -// private static final String RECORD_NAME = "recordname.txt"; -// -// private ContentClassificationService contentClassificationService; - - @Override - protected void initServices() - { - super.initServices(); - contentClassificationService = (ContentClassificationService)applicationContext.getBean("contentClassificationService"); - } - - @Override - protected boolean isCollaborationSiteTest() - { - return true; - } - - /** - * - */ - public void testUserNotClearedDocument() throws Exception - { -// doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) -// { -// private String userName; -// -// public void given() throws Exception -// { -// // create test person and assign read permission to document -// userName = GUID.generate(); -// createPerson(userName, true); -// permissionService.setPermission(dmDocument, userName , PermissionService.READ, true); -// -// // assign security clearance -// securityClearanceService.setUserSecurityClearance(userName, CLASSIFICATION_LEVEL3); -// -// // classify document -// contentClassificationService.classifyContent( -// CLASSIFICATION_LEVEL1, -// CLASSIFICATION_AUTHORITY, -// Collections.singleton(CLASSIFICATION_REASON), -// dmDocument); -// -// } -// -// public void when() throws Exception -// { -// AuthenticationUtil.runAs(new RunAsWork() -// { -// public Void doWork() throws Exception -// { -// nodeService.getAspects(dmDocument); -// -// return null; -// } -// }, userName); -// } -// }); - } -} diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/NodeRefPostMethodInvocationProcessorUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/NodeRefPostMethodInvocationProcessorUnitTest.java index c8ddc99bd7..733aae3fe9 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/NodeRefPostMethodInvocationProcessorUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/interceptor/processor/NodeRefPostMethodInvocationProcessorUnitTest.java @@ -39,6 +39,7 @@ public class NodeRefPostMethodInvocationProcessorUnitTest extends BaseUnitTest { @InjectMocks private NodeRefPostMethodInvocationProcessor nodeRefPostMethodInvocationProcessor; @Mock private ContentClassificationService mockedContentClassificationService; + @Mock private PreMethodInvocationProcessor mockedPreMethodInvocationProcessor; @Test public void testProcessingNonExistingNode()