mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1947 Restrict the classification levels shown to a user.
Currently we don't check what classification level the user has, and instead assume that they have the highest security clearance. The work to assign a security clearance to a user will be in RM-2112. +review RM git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@101413 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.classification;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
@@ -33,6 +34,7 @@ import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.MissingConfiguration;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||
@@ -201,7 +203,7 @@ public class ClassificationServiceImplUnitTest
|
||||
String expectedMessage = "Classification reasons configured in classpath do not match those stored in Alfresco. Alfresco will use the unchanged values stored in the database.";
|
||||
assertTrue("Warning message not found in log.", messages.anyMatch(message -> message == expectedMessage));
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = MissingConfiguration.class)
|
||||
public void noReasonsFoundCausesException()
|
||||
{
|
||||
@@ -211,4 +213,34 @@ public class ClassificationServiceImplUnitTest
|
||||
|
||||
classificationServiceImpl.initConfiguredClassificationReasons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that restrictList returns the three lower security levels when supplied with "secret" (i.e. that it doesn't
|
||||
* return "top secret").
|
||||
*/
|
||||
@Test public void restrictList_filter()
|
||||
{
|
||||
ClassificationLevel targetLevel = new ClassificationLevel("Secret", "rm.classification.secret");
|
||||
|
||||
List<ClassificationLevel> actual = classificationServiceImpl.restrictList(DEFAULT_CLASSIFICATION_LEVELS, targetLevel);
|
||||
|
||||
List<ClassificationLevel> expected = asLevelList("Secret", "rm.classification.secret",
|
||||
"Confidential", "rm.classification.confidential",
|
||||
"No Clearance", "rm.classification.noClearance");
|
||||
assertEquals(expected, actual);
|
||||
// Check that the returned list can't be modified.
|
||||
ExceptionUtils.expectedException(UnsupportedOperationException.class, () -> actual.remove(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that restrictList returns an empty list when the target is not contained in the list.
|
||||
*/
|
||||
@Test public void restrictList_targetNotFound()
|
||||
{
|
||||
ClassificationLevel targetLevel = new ClassificationLevel("UnrecognisedLevel", "rm.classification.IMadeThisUp");
|
||||
|
||||
List<ClassificationLevel> actual = classificationServiceImpl.restrictList(DEFAULT_CLASSIFICATION_LEVELS, targetLevel);
|
||||
|
||||
assertEquals("Expected an empty list when the target level is not found.", 0, actual.size());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user