Merge branch 'feature/Search-1835-GSCompatibility' into 'master'

Feature/search 1835 gs compatibility

See merge request search_discovery/insightengine!168
This commit is contained in:
Meenal Bhave
2019-10-02 12:18:27 +01:00
9 changed files with 431 additions and 63 deletions
+4 -4
View File
@@ -14,9 +14,9 @@
<tas.rest.api.version>6.0.1.2</tas.rest.api.version>
<tas.cmis.api.version>6.0.0.4</tas.cmis.api.version>
<tas.utility.version>3.0.11</tas.utility.version>
<!-- GS V3.1-0 is not compatible with IE, but GS automation Artifacts V3.1-0 have been suggested to be used for GS-IE automation tests
This version needs to be later updated with IE compatible GS version based on Alfresco 6.1.x -->
<rm.version>3.1.0</rm.version>
<!-- GS V3.2-0-SNAPSHOT will have to be used for GS-IE automation tests due to the dependencies in TAS Rest API project
This version needs to be later updated when GS V3.2-0 is released -->
<rm.version>3.2.0-SNAPSHOT</rm.version>
<suiteXmlFile>src/test/resources/SearchSuite.xml</suiteXmlFile>
<test.exclude></test.exclude>
<test.include></test.include>
@@ -120,4 +120,4 @@
<version>12-ea+10</version>
</dependency>
</dependencies>
</project>
</project>
@@ -39,5 +39,7 @@ public class TestGroup
public static final String ACS_611n = "ACS_611n"; // Alfresco Content Services 6.1.1 or above
public static final String ACS_62n = "ACS_62n"; // Alfresco Content Services 6.2 or above
public static final String AGS_302 = "AGS_302"; // Alfresco governance Services 3.0.2 or above
public static final String NOT_BAMBOO = "Not_Bamboo"; // The does not run on bamboo
}
@@ -18,7 +18,6 @@ import org.alfresco.rest.search.SearchResponse;
import org.alfresco.utility.LogFactory;
import org.alfresco.utility.TasProperties;
import org.alfresco.utility.Utility;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataContent;
import org.alfresco.utility.data.DataSite;
import org.alfresco.utility.data.DataUser;
@@ -109,8 +108,6 @@ public abstract class AbstractE2EFunctionalTest extends AbstractTestNGSpringCont
testSite = dataSite.usingUser(testUser).createSite(testSite);
unique_searchString = testSite.getTitle().replace("SiteSearch", "Unique");
dataUser.addUserToSite(testUser, testSite, UserRole.SiteContributor);
}
public boolean deployCustomModel(String path)
@@ -5,11 +5,11 @@
* agreement is prohibited.
*/
package org.alfresco.test.search.functional.searchServices.search.rm;
package org.alfresco.test.search.functional.gs;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import java.util.List;
import org.alfresco.dataprep.SiteService.RMSiteCompliance;
@@ -20,8 +20,11 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
import org.alfresco.test.search.functional.AbstractE2EFunctionalTest;
import org.alfresco.rest.rm.enterprise.service.ClassificationService;
import org.alfresco.test.search.functional.insightEngine.AbstractInsightEngineE2ETest;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,11 +33,12 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass;
/**
* Base test class for RM tests.
* Base test class for GS tests.
*
* @author Cristina Diaconu
* @author Meenal Bhave
*/
public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
public abstract class AbstractGSE2ETest extends AbstractInsightEngineE2ETest
{
protected static final String FILE_PLAN_ALIAS = "-filePlan-";
protected static final String RECORD_TYPE = "rma:record";
@@ -52,20 +56,27 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
protected static final String FOLDER2 = RandomData.getRandomName("RM_folder2");
protected static final String ELECTRONIC_FILE = RandomData.getRandomName("RM_electonic_file");
protected static final String NON_ELECTRONIC_FILE = RandomData.getRandomName("RM_nonelectonic_file");
protected static final String SEARCH_LANGUAGE = "cmis";
protected static final String SEARCH_LANGUAGE_CMIS = "cmis";
protected RecordCategory rootCategory;
protected Record electronicRecord, nonElectronicRecord;
@Autowired
protected RestAPIFactory restAPIFactory;
@Autowired
private ClassificationService classificationService;
@BeforeClass(alwaysRun = true)
public void rmDataPreparation() throws Exception
public void rmDataPreparation()
{
serverHealth.assertServerIsOnline();
testSite = createRMSite();
// create the Root category
RecordCategory rootCategory = createRootCategory(ROOT_CATEGORY_NAME);
rootCategory = createRootCategory(ROOT_CATEGORY_NAME);
Assert.assertNotNull(rootCategory, "Root category was not created!");
// Add two children (categories) on Root category
@@ -84,18 +95,24 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
createRecordFolder(childCategory2.getId(), FOLDER2);
// Complete a file
Record electronicRecord = createElectronicRecord(folder1.getId(), ELECTRONIC_FILE);
electronicRecord = createElectronicRecord(folder1.getId(), ELECTRONIC_FILE);
completeRecord(electronicRecord.getId());
createNonElectronicRecord(folder1.getId(), NON_ELECTRONIC_FILE);
nonElectronicRecord = createNonElectronicRecord(folder1.getId(), NON_ELECTRONIC_FILE);
// Add an electronic record on folder2
createElectronicRecord(folder2.getId(), ELECTRONIC_FILE);
}
public ClassificationService getClassificationService()
{
return classificationService;
}
/**
* Create a new RM Site. If the site already exists then remove it and create a new one.
*/
public SiteModel createRMSite() throws Exception
public SiteModel createRMSite()
{
RMSiteAPI rmSiteAPI = restAPIFactory.getRMSiteAPI();
@@ -107,16 +124,19 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
return dataSite.createRMSite(RMSiteCompliance.STANDARD);
}
protected RestAPIFactory getRestAPIFactory()
{
return restAPIFactory;
}
/**
* Helper method to create root category as the admin user
*
* @param categoryName The name of the category
* @return The created category
* @throws Exception on unsuccessful component creation
*/
public RecordCategory createRootCategory(String categoryName) throws Exception
public RecordCategory createRootCategory(String categoryName)
{
return createRootCategory(dataUser.getAdminUser(), categoryName, RECORD_CATEGORY_TITLE);
return createRootCategory(adminUserModel, categoryName, RECORD_CATEGORY_TITLE);
}
/**
@@ -126,10 +146,8 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
* @param categoryName The name of the category
* @param categoryTitle The title of the category
* @return The created category
* @throws Exception on unsuccessful component creation
*/
public RecordCategory createRootCategory(UserModel userModel, String categoryName, String categoryTitle)
throws Exception
{
RecordCategory recordCategoryModel = createRecordCategoryModel(categoryName, categoryTitle);
return restAPIFactory.getFilePlansAPI(userModel).createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS);
@@ -141,11 +159,10 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
* @param recordCategoryId The id of the record category
* @param name The name of the record category child
* @return The created child category
* @throws Exception on unsuccessful component creation
*/
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name) throws Exception
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name)
{
return createRecordCategoryChild(dataUser.getAdminUser(), recordCategoryId, name, RECORD_CATEGORY_TYPE);
return createRecordCategoryChild(adminUserModel, recordCategoryId, name, RECORD_CATEGORY_TYPE);
}
/**
@@ -156,10 +173,9 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
* @param name The name of the record category child
* @param type The type of the record category child
* @return The created child category
* @throws Exception on unsuccessful component creation
*/
public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name,
String type) throws Exception
String type)
{
RecordCategoryChild recordCategoryChildModel = createRecordCategoryChildModel(name, type);
return restAPIFactory.getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel,
@@ -172,11 +188,10 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
* @param recordCategoryId The id of the record category
* @param name The name of the record category child
* @return The created record folder.
* @throws Exception on unsuccessful component creation
*/
public RecordCategoryChild createRecordFolder(String recordCategoryId, String name) throws Exception
public RecordCategoryChild createRecordFolder(String recordCategoryId, String name)
{
return createRecordCategoryChild(dataUser.getAdminUser(), recordCategoryId, name, RECORD_FOLDER_TYPE);
return createRecordCategoryChild(adminUserModel, recordCategoryId, name, RECORD_FOLDER_TYPE);
}
/**
@@ -185,9 +200,8 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
* @param parentId The id of the parent
* @param name The name of the record
* @return The created record
* @throws Exception on unsuccessful component creation
*/
public Record createElectronicRecord(String parentId, String name) throws Exception
public Record createElectronicRecord(String parentId, String name)
{
return createElectronicRecord(parentId, name, null);
}
@@ -198,9 +212,8 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
* @param parentId The id of the parent
* @param name The name of the record
* @return The created electronic record
* @throws Exception on unsuccessful component creation
*/
public Record createElectronicRecord(String parentId, String name, UserModel user) throws Exception
public Record createElectronicRecord(String parentId, String name, UserModel user)
{
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI(user);
Record recordModel = Record.builder().name(name).nodeType(CONTENT_TYPE).build();
@@ -213,9 +226,8 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
* @param parentId The id of the parent
* @param name The name of the record
* @return The created non electronic record
* @throws Exception on unsuccessful component creation
*/
public Record createNonElectronicRecord(String parentId, String name) throws Exception
public Record createNonElectronicRecord(String parentId, String name)
{
return createNonElectronicRecord(parentId, name, null);
}
@@ -227,9 +239,8 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
* @param name The name of the record
* @param user The user who creates the non-electronic record
* @return The created non electronic record
* @throws Exception on unsuccessful component creation
*/
public Record createNonElectronicRecord(String parentId, String name, UserModel user) throws Exception
public Record createNonElectronicRecord(String parentId, String name, UserModel user)
{
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI(user);
Record recordModel = Record.builder().name(name).nodeType(NON_ELECTRONIC_RECORD_TYPE).build();
@@ -241,9 +252,8 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
*
* @param recordId The id of the record to complete
* @return The completed record
* @throws Exception on unsuccessful component creation
*/
public Record completeRecord(String recordId) throws Exception
public Record completeRecord(String recordId)
{
RecordsAPI recordsAPI = restAPIFactory.getRecordsAPI();
List<String> aspects = recordsAPI.getRecord(recordId).getAspectNames();
@@ -260,4 +270,45 @@ public abstract class AbstractRmE2ETest extends AbstractE2EFunctionalTest
return updateRecord;
}
/**
* Helper method to create root category
*
* @return The created category
*/
public RecordCategoryChild createCategoryFolderInFilePlan()
{
// create root category
RecordCategory recordCategory = createRootCategory("Category " + getRandomAlphanumeric());
return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric());
}
/**
* Helper method to create record folder
*
* @param recordCategoryId The id of the record category
* @param name The name of the folder
* @return The created folder
*/
public RecordCategoryChild createFolder(String recordCategoryId, String name)
{
UserModel asUser = dataContent.getAdminUser();
RecordCategoryChild recordFolderModel = createRecordCategoryChildModel(name, RECORD_FOLDER_TYPE);
return getRestAPIFactory().getRecordCategoryAPI(asUser).createRecordCategoryChild(recordFolderModel, recordCategoryId);
}
/**
* Helper method to create a test user with rm role
*
* @param user to which the rm role is to be assigned
* @param userRole the rm role
* @return the created user model
*/
protected UserModel createUserWithRMRole(UserModel user, String userRole)
{
getRestAPIFactory().getRMUserAPI().assignRoleToUser(user.getUsername(), userRole);
return user;
}
}
@@ -5,11 +5,12 @@
* agreement is prohibited.
*/
package org.alfresco.test.search.functional.searchServices.search.rm;
package org.alfresco.test.search.functional.gs.search;
import org.alfresco.rest.search.RestRequestQueryModel;
import org.alfresco.rest.search.SearchResponse;
import org.alfresco.search.TestGroup;
import org.alfresco.test.search.functional.gs.AbstractGSE2ETest;
import org.alfresco.utility.model.FolderModel;
import org.springframework.http.HttpStatus;
import org.testng.Assert;
@@ -19,39 +20,44 @@ import org.testng.annotations.Test;
* The purpose of this test is to create basic queries using a RM site and a basic file plan.
*
* @author Cristina Diaconu
* @author Meenal Bhave
*/
public class SearchServicesRME2ETest extends AbstractRmE2ETest
public class SearchServicesGSE2ETest extends AbstractGSE2ETest
{
@Test(priority = 1)
public void testBasicSearch() throws Exception
@Test(priority = 1, groups = {TestGroup.AGS_302})
public void testBasicSearch()
{
// Create a new folder
FolderModel testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
// Search for a folder name
String query = "select * from cmis:folder where cmis:name='" + testFolder + "'";
// Search for the new folder using folder name
boolean indexingInProgress = isContentInSearchResults(testFolder.getName(), testFolder.getName(), true);
Assert.assertTrue(indexingInProgress, "Expected folder is not found: " + testFolder.getName());
// Search for a folder name using cmis query
String query = "select * from cmis:folder where cmis:name='" + testFolder.getName() + "'";
RestRequestQueryModel queryModel = new RestRequestQueryModel();
queryModel.setQuery(query);
queryModel.setLanguage(SEARCH_LANGUAGE);
queryModel.setLanguage(SEARCH_LANGUAGE_CMIS);
SearchResponse response = queryAsUser(dataUser.getAdminUser(), queryModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
Assert.assertEquals(response.getPagination().getCount(), 2,
"Wrong number of search elements, expected two folders.");
Assert.assertEquals(response.getPagination().getCount(), 1, "Expected folder is not found: " + testFolder.getName());
// Search for a file name
query = "select * from cmis:document where cmis:name like '" + NON_ELECTRONIC_FILE + "%'";
queryModel = new RestRequestQueryModel();
queryModel.setQuery(query);
queryModel.setLanguage(SEARCH_LANGUAGE);
queryModel.setLanguage(SEARCH_LANGUAGE_CMIS);
response = queryAsUser(dataUser.getAdminUser(), queryModel);
restClient.assertStatusCodeIs(HttpStatus.OK);
Assert.assertEquals(response.getPagination().getCount(), 1,
"Wrong number of search elements, expected 1 non electronic file");
Assert.assertEquals(response.getPagination().getCount(), 1, "Expected file is not found: " + NON_ELECTRONIC_FILE);
}
}
@@ -0,0 +1,298 @@
/*
* Copyright 2019 Alfresco Software, Ltd. All rights reserved.
* License rights for this program may be obtained from Alfresco Software, Ltd.
* pursuant to a written agreement and any use of this program without such an
* agreement is prohibited.
*/
package org.alfresco.test.search.functional.gs.sql;
import static java.util.Arrays.asList;
import static org.apache.commons.collections4.CollectionUtils.isEqualCollection;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER;
import static org.testng.Assert.assertTrue;
import java.util.List;
import org.alfresco.rest.core.RestResponse;
import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.rm.community.model.user.UserPermissions;
import org.alfresco.rest.rm.enterprise.core.ClassificationData;
import org.alfresco.rest.search.SearchResponse;
import org.alfresco.rest.search.SearchSqlRequest;
import org.alfresco.search.TestGroup;
import org.alfresco.test.search.functional.gs.AbstractGSE2ETest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.UserModel;
import org.hamcrest.Matchers;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* The purpose of this test is to create basic queries using a RM site and a basic file plan.
*
* @author Meenal Bhave
*/
public class SearchSqlGSE2ETest extends AbstractGSE2ETest
{
private UserModel testUserGSTopSecret, testUserSecret, testUserConfidential, testUserNoAccess;
private FolderModel testFolder;
private FileModel fileRecord, fileRecordElectronic, fileUnclassified, fileClassifiedAsTopSecret,
fileClassifiedAsSecret, fileClassifiedAsConfidential;
private String TOPSECRET_FILE, SECRET_FILE, CONFIDENTIAL_FILE, UNCLASSIFIED_FILE;
private final String RECORD_IDENTIFIER = "rma:identifier:'*'";
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
super.setup();
// Create other users to check access permissions
testUser = createUserWithRMRole(testUser, ROLE_RM_USER.roleId);
testUserGSTopSecret = dataUser.createRandomTestUser("UserTopSecret");
testUserSecret = dataUser.createRandomTestUser("UserSecret");
testUserConfidential = dataUser.createRandomTestUser("UserConfidential");
testUserNoAccess = dataUser.createRandomTestUser("UserSearchNoAccess");
// Add users to testSite
getDataUser().addUserToSite(testUserGSTopSecret, testSite, UserRole.SiteCollaborator);
getDataUser().addUserToSite(testUserSecret, testSite, UserRole.SiteContributor);
getDataUser().addUserToSite(testUserConfidential, testSite, UserRole.SiteConsumer);
// Assign classification levels
getClassificationService().assignClearance(adminUserModel, testUser, ClassificationData.TOP_SECRET_CLASSIFICATION_LEVEL_ID);
getClassificationService().assignClearance(adminUserModel, testUserGSTopSecret, ClassificationData.TOP_SECRET_CLASSIFICATION_LEVEL_ID);
getClassificationService().assignClearance(adminUserModel, testUserSecret, ClassificationData.SECRET_CLASSIFICATION_LEVEL_ID);
getClassificationService().assignClearance(adminUserModel, testUserConfidential, ClassificationData.CONFIDENTIAL_CLASSIFICATION_LEVEL_ID);
getClassificationService().assignClearance(adminUserModel, testUserNoAccess, ClassificationData.UNCLASSIFIED_CLASSIFICATION_LEVEL_ID);
// Create a folder and files
testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
fileRecord = new FileModel(unique_searchString + "record-1.txt", "record1", "record1", FileType.TEXT_PLAIN, "record1");
dataContent.usingUser(testUser).usingSite(testSite).createContent(fileRecord);
fileRecordElectronic = new FileModel(unique_searchString + "e-record-1.txt", "e-record1", "e-record1", FileType.TEXT_PLAIN, "e-record1");
dataContent.usingUser(testUser).usingSite(testSite).createContent(fileRecordElectronic);
// Create Files to be classified later
fileClassifiedAsTopSecret = new FileModel(unique_searchString + "TopS-1.txt", "top", "top", FileType.TEXT_PLAIN, "top");
dataContent.usingUser(testUser).usingSite(testSite).createContent(fileClassifiedAsTopSecret);
fileClassifiedAsSecret = new FileModel(unique_searchString + "Secret-1.txt", "secret", "secret", FileType.TEXT_PLAIN, "secret");
dataContent.usingUser(testUser).usingSite(testSite).createContent(fileClassifiedAsSecret);
fileClassifiedAsConfidential = new FileModel(unique_searchString + "conf-1.txt", "conf", "conf", FileType.TEXT_PLAIN, "conf");
dataContent.usingUser(testUser).usingSite(testSite).createContent(fileClassifiedAsConfidential);
fileUnclassified = new FileModel(unique_searchString + "Unclassified-1.txt", "Unclassified1", "Unclassified1", FileType.TEXT_PLAIN, "Unclassified1");
dataContent.usingUser(testUser).usingSite(testSite).createContent(fileUnclassified);
// Classify files
getClassificationService().classifyNode(adminUserModel, fileClassifiedAsTopSecret.getNodeRefWithoutVersion(), ClassificationData.TOP_SECRET_CLASSIFICATION_LEVEL_ID);
getClassificationService().classifyNode(testUser, fileClassifiedAsSecret.getNodeRefWithoutVersion(), ClassificationData.SECRET_CLASSIFICATION_LEVEL_ID);
getClassificationService().classifyNode(testUser, fileClassifiedAsConfidential.getNodeRefWithoutVersion(), ClassificationData.CONFIDENTIAL_CLASSIFICATION_LEVEL_ID);
getClassificationService().classifyNode(testUser, fileUnclassified.getNodeRefWithoutVersion(), ClassificationData.UNCLASSIFIED_CLASSIFICATION_LEVEL_ID);
TOPSECRET_FILE = fileClassifiedAsTopSecret.getName();
SECRET_FILE = fileClassifiedAsSecret.getName();
CONFIDENTIAL_FILE = fileClassifiedAsConfidential.getName();
UNCLASSIFIED_FILE = fileUnclassified.getName();
}
@Test(priority = 1, groups = { TestGroup.AGS_302 })
public void testSQLRespectsSitePermissions()
{
// Search for a file name to ensure content is indexed
boolean indexingInProgress = isContentInSearchResults(fileRecord.getName(), fileRecord.getName(), true);
assertTrue(indexingInProgress, "Expected record file, not found");
indexingInProgress = isContentInSearchResults(testFolder.getName(), testFolder.getName(), true);
assertTrue(indexingInProgress, "Expected folder, not found");
// Search using sql: userNoAccess is not expected to find the record
SearchSqlRequest sqlRequest = new SearchSqlRequest();
sqlRequest.setSql("select * from alfresco where cm_name = '" + fileRecord.getName() + "'");
// Verify that testUserNoAccess can't see content of the Private site that he is not a member of
RestResponse response = searchSql(sqlRequest, testUserNoAccess);
response.assertThat().body("list.pagination.count", Matchers.equalTo(0));
// Verify that the site member can see the content: Collaborator
response = searchSql(sqlRequest, testUserSecret);
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
// Verify that the site member can see the content: Consumer
response = searchSql(sqlRequest, testUserConfidential);
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
}
@Test(priority = 2, groups = { TestGroup.AGS_302 })
public void testSQLFiltersClassifiedFiles()
{
// Wait for the files to be indexed
boolean fileFound = isContentInSearchResults("sc_classification:c", CONFIDENTIAL_FILE, true);
assertTrue(fileFound, "Expected confidential file, not found");
// Check Aggregate query response doesn't bring up classification levels the user should not see
SearchSqlRequest sqlRequest = new SearchSqlRequest();
sqlRequest.setSql("select sc_classification, count(*) from alfresco group by sc_classification");
// User should only see aggregate results for security level he can access
RestResponse response = searchSql(sqlRequest, testUserGSTopSecret);
response.assertThat().body("list.pagination.count", Matchers.equalTo(4));
response = searchSql(sqlRequest, testUserSecret);
response.assertThat().body("list.pagination.count", Matchers.equalTo(3));
response = searchSql(sqlRequest, testUserConfidential);
response.assertThat().body("list.pagination.count", Matchers.equalTo(2));
sqlRequest = new SearchSqlRequest();
sqlRequest.setSql("select sc_classification, count(*) from alfresco where SITE = '" + testSite.getId() + "' group by sc_classification");
response = searchSql(sqlRequest, testUserGSTopSecret);
response.assertThat().body("list.pagination.count", Matchers.equalTo(4));
response = searchSql(sqlRequest, testUserSecret);
response.assertThat().body("list.pagination.count", Matchers.equalTo(3));
response = searchSql(sqlRequest, testUserConfidential);
response.assertThat().body("list.pagination.count", Matchers.equalTo(2));
response = searchSql(sqlRequest, testUserNoAccess);
response.assertThat().body("list.pagination.count", Matchers.equalTo(0));
// Check Query results include content based on classification level, starting with unclassified file
sqlRequest = new SearchSqlRequest();
sqlRequest.setSql("select cm_name from alfresco where sc_classification = '*' and SITE = '" + testSite.getId() + "'");
List<String> expectedResult = asList(TOPSECRET_FILE, SECRET_FILE, CONFIDENTIAL_FILE, UNCLASSIFIED_FILE);
List<String> results = getContentListForSolrRequest(sqlRequest, testUserGSTopSecret);
assertTrue(isEqualCollection(expectedResult, results), "Unexpected files in the response: " + results.toString());
expectedResult = asList(SECRET_FILE, CONFIDENTIAL_FILE, UNCLASSIFIED_FILE);
results = getContentListForSolrRequest(sqlRequest, testUserSecret);
assertTrue(isEqualCollection(expectedResult, results), "Unexpected files in the response: " + results.toString());
expectedResult = asList(CONFIDENTIAL_FILE, UNCLASSIFIED_FILE);
results = getContentListForSolrRequest(sqlRequest, testUserConfidential);
assertTrue(isEqualCollection(expectedResult, results), "Unexpected files in the response: " + results.toString());
results = getContentListForSolrRequest(sqlRequest, testUserNoAccess);
assertTrue(results.isEmpty(), "Unexpected files in the response: " + results.toString());
}
@Test(priority = 3, groups = { TestGroup.AGS_302 })
public void testSQLFiltersElectronicRecords()
{
// File a Electronic Record
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
Record elecRecord = createElectronicRecord(recordFolder.getId(), fileRecord.getName());
// Add permission for the GS user to Read Records
getRestAPIFactory().getRMUserAPI().addUserPermission(recordFolder.getParentId(), testUser, UserPermissions.PERMISSION_READ_RECORDS);
// Wait for the record to be indexed and check that it can be found
boolean fileFound = isContentInSearchResults(RECORD_IDENTIFIER, elecRecord.getName(), true);
assertTrue(fileFound, "Expected record file, not found");
SearchResponse result = queryAsUser(testUserGSTopSecret, RECORD_IDENTIFIER);
Assert.assertEquals(result.getPagination().getCount(), 0, "Expected count of entries 0, found more");
SearchSqlRequest sqlRequest = new SearchSqlRequest();
sqlRequest.setSql("select cm_name, PATH from alfresco where rma_identifier = '*' and type = 'cm:content'");
// Verify that user can see the electronic record with minimum read records permissions
RestResponse response = searchSql(sqlRequest, testUser);
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
// Verify that users can not see the electronic record without read record permissions
response = searchSql(sqlRequest, testUserGSTopSecret);
response.assertThat().body("list.pagination.count", Matchers.equalTo(0));
}
@Test(priority = 4, groups = { TestGroup.AGS_302 })
public void testSQLFiltersInPlaceRecords()
{
// Declare a file as Record
Record inPlaceRecord = getRestAPIFactory().getFilesAPI().declareAsRecord(fileRecord.getNodeRefWithoutVersion());
// Wait for the record to be indexed
boolean fileFound = isContentInSearchResults(RECORD_IDENTIFIER, inPlaceRecord.getName(), true);
assertTrue(fileFound, "Expected in place record file, not found");
// Verify that user can see the in place record without any additional permissions
SearchSqlRequest sqlRequest = new SearchSqlRequest();
sqlRequest.setSql("select cm_name from alfresco where rma_identifier = '*' and Site = '" + testSite.getId() + "'");
RestResponse response = searchSql(sqlRequest, testUser);
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
response.assertThat().body("list.entries.entry[0].value", Matchers.contains(inPlaceRecord.getName()));
// Verify that other site members can see the in place record with no additional permissions
response = searchSql(sqlRequest, testUserGSTopSecret);
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
response.assertThat().body("list.entries.entry[0].value", Matchers.contains(inPlaceRecord.getName()));
response = searchSql(sqlRequest, testUserConfidential);
response.assertThat().body("list.pagination.count", Matchers.equalTo(1));
response.assertThat().body("list.entries.entry[0].value", Matchers.contains(inPlaceRecord.getName()));
response = searchSql(sqlRequest, testUserNoAccess);
response.assertThat().body("list.pagination.count", Matchers.equalTo(0));
}
@Test(priority = 5, groups = { TestGroup.AGS_302 })
public void testSQLFiltersRecordsCascadedPermissions()
{
// Search for records when user does not have read permission
boolean fileFound = isContentInSearchResults(NON_ELECTRONIC_FILE, nonElectronicRecord.getName(), false);
assertTrue(fileFound, "Non electronic record file found in the results, when user doesn't have read permissions");
// Search for records when user does not have read permission
fileFound = isContentInSearchResults(ELECTRONIC_FILE, electronicRecord.getName(), false);
assertTrue(fileFound, "Electronic record file found in the results, when user doesn't have read permissions");
// Assign Read permissions to the user at rootCategory level
getRestAPIFactory().getRMUserAPI().addUserPermission(rootCategory.getId(), testUser, UserPermissions.PERMISSION_READ_RECORDS);
getRestAPIFactory().getRMUserAPI().addUserPermission(rootCategory.getId(), testUserGSTopSecret, UserPermissions.PERMISSION_READ_RECORDS);
// Check that the non electronic record can now be found
isContentInSearchResults(NON_ELECTRONIC_FILE, nonElectronicRecord.getName(), true);
assertTrue(fileFound, "Expected non electronic record file, not found");
// Check that the electronic record can now be found
fileFound = isContentInSearchResults(ELECTRONIC_FILE, electronicRecord.getName(), true);
assertTrue(fileFound, "Expected electronic record file, not found");
// Check that the electronic record and non electronic record both can be found with cascaded permissions
String recordFiles = String.format("('%s' , '%s')", nonElectronicRecord.getName(), electronicRecord.getName());
SearchSqlRequest sqlRequest = new SearchSqlRequest();
sqlRequest.setSql("select cm_name from alfresco where rma_identifier = '*' and cm_name in " + recordFiles + " order by cm_name");
RestResponse response = searchSql(sqlRequest, testUser);
response.assertThat().body("list.pagination.count", Matchers.equalTo(2));
response.assertThat().body("list.entries.entry[0].value", Matchers.contains(electronicRecord.getName()));
response.assertThat().body("list.entries.entry[1].value", Matchers.contains(nonElectronicRecord.getName()));
response = searchSql(sqlRequest, testUserGSTopSecret);
response.assertThat().body("list.pagination.count", Matchers.equalTo(2));
response.assertThat().body("list.entries.entry[0].value", Matchers.contains(electronicRecord.getName()));
response.assertThat().body("list.entries.entry[1].value", Matchers.contains(nonElectronicRecord.getName()));
}
}
@@ -24,7 +24,7 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.asserts.SoftAssert;
import com.jayway.restassured.RestAssured;
import io.restassured.RestAssured;
@Configuration
@ContextConfiguration("classpath:alfresco-search-e2e-context.xml")
@@ -0,0 +1,22 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="IEGSCompatibilitySuite" verbose="6" preserve-order="true">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"/>
<listener class-name="org.alfresco.utility.report.log.LogsListener"/>
</listeners>
<test name="SS-With-GS">
<packages>
<package name="org.alfresco.test.search.functional.gs.search.*"/>
</packages>
</test>
<test name="IE-With-GS">
<packages>
<package name="org.alfresco.test.search.functional.gs.sql.*"/>
</packages>
</test>
<suite-files>
<suite-file path="src/test/resources/InsightSuite.xml"></suite-file>
</suite-files>
</suite>
@@ -1,8 +0,0 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="CompatibilitySuite" verbose="6" preserve-order="true">
<test name="SS-With-RM">
<packages>
<package name="org.alfresco.test.search.functional.searchServices.search.rm"/>
</packages>
</test>
</suite>