mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-2130 (Check classification after method execution, filtering results where appropriate)
+review RM-94 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/ENFORCE@107163 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.repo.site.SiteModel.SITE_MANAGER;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Tests for enforcement of classification when browsing documents in the document library
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 3.0
|
||||
*/
|
||||
public class DocumentClassificationEnforcementTest extends BaseRMTestCase
|
||||
{
|
||||
private static final String LEVEL1 = "level1";
|
||||
private static final String LEVEL2 = "level2";
|
||||
private static final String REASON = "Test Reason 1";
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase#isCollaborationSiteTest()
|
||||
*/
|
||||
@Override
|
||||
protected boolean isCollaborationSiteTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void testUserWithNoSecurityClearance()
|
||||
{
|
||||
/**
|
||||
* Given that a test user without security clearance exists
|
||||
* and two documents are created in the document library
|
||||
*
|
||||
* When one of the documents is classified with the highest security level
|
||||
*
|
||||
* Then as the admin user I will see both documents
|
||||
* and as the test user I will only see the unclassified document
|
||||
*/
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private String myUser;
|
||||
private NodeRef folder;
|
||||
private NodeRef doc1;
|
||||
private NodeRef doc2;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given()
|
||||
*/
|
||||
@Override
|
||||
public void given() throws Exception
|
||||
{
|
||||
myUser = generate();
|
||||
createPerson(myUser);
|
||||
siteService.setMembership(collabSiteId, myUser, SITE_MANAGER);
|
||||
|
||||
folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef();
|
||||
doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when()
|
||||
*/
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then()
|
||||
*/
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(2, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(doc1, doc2);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(1, childAssociationRefs.size());
|
||||
assertEquals(doc2, childAssociationRefs.get(0).getChildRef());
|
||||
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testUserWithMidlevelSecurityClearance()
|
||||
{
|
||||
/**
|
||||
* Given that a test user with mid-level security clearance exists
|
||||
* and three documents are created in the document library
|
||||
*
|
||||
* When one of the documents is classified with the highest security level
|
||||
* and another document is classified with the mid-level security level
|
||||
*
|
||||
* Then as the admin user I will see all three documents
|
||||
* and as the test user I will see the unclassified document
|
||||
* and the document with the mid-level classification
|
||||
* and I won't be able to see the document with the classification greater than my clearance level
|
||||
*/
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private String myUser;
|
||||
private NodeRef folder;
|
||||
private NodeRef doc1;
|
||||
private NodeRef doc2;
|
||||
private NodeRef doc3;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given()
|
||||
*/
|
||||
@Override
|
||||
public void given() throws Exception
|
||||
{
|
||||
myUser = generate();
|
||||
createPerson(myUser);
|
||||
siteService.setMembership(collabSiteId, myUser, SITE_MANAGER);
|
||||
securityClearanceService.setUserSecurityClearance(myUser, LEVEL2);
|
||||
|
||||
folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef();
|
||||
doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when()
|
||||
*/
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then()
|
||||
*/
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(3, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(doc1, doc2, doc3);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(2).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(2, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(doc2, doc3);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testUseWithHighestLevelSecurityClearance()
|
||||
{
|
||||
/**
|
||||
* Given that a test user with highest level security clearance exists
|
||||
* and three documents are created in the document library
|
||||
*
|
||||
* When one of the documents is classified with the highest security level
|
||||
* and another document is classified with the mid-level security level
|
||||
*
|
||||
* Then as the admin user I will see all three documents
|
||||
* and as the test user I will see all three documents
|
||||
*/
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private String myUser;
|
||||
private NodeRef folder;
|
||||
private NodeRef doc1;
|
||||
private NodeRef doc2;
|
||||
private NodeRef doc3;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given()
|
||||
*/
|
||||
@Override
|
||||
public void given() throws Exception
|
||||
{
|
||||
myUser = generate();
|
||||
createPerson(myUser);
|
||||
siteService.setMembership(collabSiteId, myUser, SITE_MANAGER);
|
||||
securityClearanceService.setUserSecurityClearance(myUser, LEVEL1);
|
||||
|
||||
folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef();
|
||||
doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when()
|
||||
*/
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then()
|
||||
*/
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(3, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(doc1, doc2, doc3);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(2).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(3, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(doc1, doc2, doc3);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(2).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification;
|
||||
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;
|
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService.ROLE_USER;
|
||||
import static org.alfresco.util.GUID.generate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Enforcement of classification when browsing records in the file plan
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 3.0
|
||||
*/
|
||||
public class RecordClassificationEnforcementTest extends BaseRMTestCase
|
||||
{
|
||||
private static final String LEVEL1 = "level1";
|
||||
private static final String LEVEL2 = "level2";
|
||||
private static final String REASON = "Test Reason 1";
|
||||
|
||||
public void testUserWithNoSecurityClearance()
|
||||
{
|
||||
/**
|
||||
* Given that a test user without security clearance exists
|
||||
* and the test user is added to the RM Users role
|
||||
* and a category, a folder and two records are created in the file plan
|
||||
*
|
||||
* When the test user is given read permissions on the category
|
||||
* and one of the records is classified with the highest security level
|
||||
*
|
||||
*
|
||||
* Then as the admin user I will see both records
|
||||
* and as the test user I will only see the unclassified record
|
||||
*/
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private String myUser;
|
||||
private NodeRef category;
|
||||
private NodeRef folder;
|
||||
private NodeRef record1;
|
||||
private NodeRef record2;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given()
|
||||
*/
|
||||
@Override
|
||||
public void given() throws Exception
|
||||
{
|
||||
myUser = generate();
|
||||
createPerson(myUser);
|
||||
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_USER, myUser);
|
||||
|
||||
category = filePlanService.createRecordCategory(filePlan, generate());
|
||||
folder = recordFolderService.createRecordFolder(category, generate());
|
||||
record1 = utils.createRecord(folder, generate());
|
||||
record2 = utils.createRecord(folder, generate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when()
|
||||
*/
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
filePlanPermissionService.setPermission(category, myUser, READ_RECORDS);
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then()
|
||||
*/
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(folder);
|
||||
assertEquals(2, childAssocs.size());
|
||||
|
||||
List<NodeRef> recordList = newArrayList(record1, record2);
|
||||
assertTrue(recordList.contains(childAssocs.get(0).getChildRef()));
|
||||
assertTrue(recordList.contains(childAssocs.get(1).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(folder);
|
||||
assertEquals(1, childAssocs.size());
|
||||
assertEquals(record2, childAssocs.get(0).getChildRef());
|
||||
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testUserWithMidlevelSecurityClearance()
|
||||
{
|
||||
/**
|
||||
* Given that a test user with mid-level security clearance exists
|
||||
* and the test user is added to the RM Users role
|
||||
* and a category, a folder and three records are created in the file plan
|
||||
*
|
||||
* When the test user is given read permissions on the category
|
||||
* and one of the records is classified with the highest security level
|
||||
* and another record is classified with the mid-level security level
|
||||
*
|
||||
* Then as the admin user I will see all three records
|
||||
* and as the test user I will see the unclassified record
|
||||
* and the record with the mid-level classification
|
||||
* and I won't be able to see the record with the classification greater than my clearance level
|
||||
*/
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private String myUser;
|
||||
private NodeRef category;
|
||||
private NodeRef folder;
|
||||
private NodeRef record1;
|
||||
private NodeRef record2;
|
||||
private NodeRef record3;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given()
|
||||
*/
|
||||
@Override
|
||||
public void given() throws Exception
|
||||
{
|
||||
myUser = generate();
|
||||
createPerson(myUser);
|
||||
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_USER, myUser);
|
||||
securityClearanceService.setUserSecurityClearance(myUser, LEVEL2);
|
||||
|
||||
category = filePlanService.createRecordCategory(filePlan, generate());
|
||||
folder = recordFolderService.createRecordFolder(category, generate());
|
||||
record1 = utils.createRecord(folder, generate());
|
||||
record2 = utils.createRecord(folder, generate());
|
||||
record3 = utils.createRecord(folder, generate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when()
|
||||
*/
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
filePlanPermissionService.setPermission(category, myUser, READ_RECORDS);
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then()
|
||||
*/
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(3, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(record1, record2, record3);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(2).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(2, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(record2, record3);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testUseWithHighestLevelSecurityClearance()
|
||||
{
|
||||
/**
|
||||
* Given that a test user with highest level security clearance exists
|
||||
* and the test user is added to the RM Users role
|
||||
* and a category, a folder and three records are created in the file plan
|
||||
*
|
||||
* When the test user is given read permissions on the category
|
||||
* and one of the records is classified with the highest security level
|
||||
* and another record is classified with the mid-level security level
|
||||
*
|
||||
* Then as the admin user I will see all three records
|
||||
* and as the test user I will see all three records
|
||||
*/
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private String myUser;
|
||||
private NodeRef category;
|
||||
private NodeRef folder;
|
||||
private NodeRef record1;
|
||||
private NodeRef record2;
|
||||
private NodeRef record3;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#given()
|
||||
*/
|
||||
@Override
|
||||
public void given() throws Exception
|
||||
{
|
||||
myUser = generate();
|
||||
createPerson(myUser);
|
||||
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_USER, myUser);
|
||||
securityClearanceService.setUserSecurityClearance(myUser, LEVEL1);
|
||||
|
||||
category = filePlanService.createRecordCategory(filePlan, generate());
|
||||
folder = recordFolderService.createRecordFolder(category, generate());
|
||||
record1 = utils.createRecord(folder, generate());
|
||||
record2 = utils.createRecord(folder, generate());
|
||||
record3 = utils.createRecord(folder, generate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#when()
|
||||
*/
|
||||
@Override
|
||||
public void when() throws Exception
|
||||
{
|
||||
filePlanPermissionService.setPermission(category, myUser, READ_RECORDS);
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1);
|
||||
contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase.BehaviourDrivenTest#then()
|
||||
*/
|
||||
@Override
|
||||
public void then() throws Exception
|
||||
{
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(3, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(record1, record2, record3);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(2).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new Test<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
List<ChildAssociationRef> childAssociationRefs = nodeService.getChildAssocs(folder);
|
||||
assertNotNull(childAssociationRefs);
|
||||
assertEquals(3, childAssociationRefs.size());
|
||||
|
||||
ArrayList<NodeRef> docs = newArrayList(record1, record2, record3);
|
||||
assertTrue(docs.contains(childAssociationRefs.get(0).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(1).getChildRef()));
|
||||
assertTrue(docs.contains(childAssociationRefs.get(2).getChildRef()));
|
||||
|
||||
return null;
|
||||
}
|
||||
}, myUser);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
@@ -32,18 +32,18 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Classification Post Method Invocation Test
|
||||
* Enforcement of classification for records with relationship
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ClassificationPostMethodInvocationTest extends BaseRMTestCase
|
||||
public class RelationshipClassificationEnforcementTest extends BaseRMTestCase
|
||||
{
|
||||
private static final String LEVEL1 = "level1";
|
||||
private static final String LEVEL3 = "level3";
|
||||
private static final String REASON = "Test Reason 1";
|
||||
|
||||
public void testClassificationPostMethodInvocation()
|
||||
public void testRelationshipClassification()
|
||||
{
|
||||
/**
|
||||
* Given a test user has been created
|
||||
@@ -56,9 +56,9 @@ public class ClassificationPostMethodInvocationTest extends BaseRMTestCase
|
||||
* and a relationship between those two records has been created
|
||||
*
|
||||
* Then the admin user should see both records in the folder
|
||||
* and the admin user should see in the relationship table
|
||||
* and the admin user should see in the relationship table
|
||||
* (in the details page of the record) the other record
|
||||
*
|
||||
*
|
||||
* and the test user should see only the unclassified record in the same folder
|
||||
* and the relationship table should be empty.
|
||||
*/
|
@@ -16,8 +16,9 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification;
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.classification.interceptor;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static org.alfresco.repo.site.SiteModel.SITE_MANAGER;
|
||||
import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
|
||||
@@ -87,7 +88,7 @@ public class ResultSetPostMethodInvocationProcessorTest extends BaseRMTestCase
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
//contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
|
||||
contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1);
|
||||
|
||||
return null;
|
||||
}
|
Reference in New Issue
Block a user