mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
adding tests for Prevent Classified Items Being Moved/Copied/Linked into Folders with Lower Classification
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<maven.build.sourceVersion>1.8</maven.build.sourceVersion>
|
||||
<alfresco.rm.share>alfresco-rm-community-share</alfresco.rm.share>
|
||||
<alfresco.rm.repo>alfresco-rm-community-repo</alfresco.rm.repo>
|
||||
<tas.restapi.version>5.2.0-9</tas.restapi.version>
|
||||
<tas.restapi.version>5.2.0-10</tas.restapi.version>
|
||||
<fluent.json.version>2.0.0</fluent.json.version>
|
||||
</properties>
|
||||
|
||||
|
@@ -26,11 +26,12 @@
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.model.common;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* POJO for owner parameter
|
||||
@@ -43,6 +44,7 @@ import lombok.EqualsAndHashCode;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
//@NoArgsConstructor
|
||||
//@AllArgsConstructor
|
||||
@JsonIgnoreProperties (ignoreUnknown = true)
|
||||
public class Owner extends TestModel
|
||||
{
|
||||
|
||||
|
@@ -30,7 +30,10 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.rest.model.RestByUserModel;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.rm.community.model.common.Path;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
@@ -51,7 +54,7 @@ import lombok.NoArgsConstructor;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Record extends TestModel
|
||||
public class Record extends TestModel implements IRestModel<RestNodeModel>
|
||||
{
|
||||
/*************************/
|
||||
/** Mandatory parameters */
|
||||
@@ -100,4 +103,25 @@ public class Record extends TestModel
|
||||
|
||||
@JsonProperty
|
||||
private Path path;
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNodeModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty (value = "entry")
|
||||
RestNodeModel model;
|
||||
|
||||
@Override
|
||||
public RestNodeModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
@@ -114,6 +114,35 @@ public class RecordsAPI extends BaseAPI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reject the record given as parameter
|
||||
*
|
||||
* @param user the user declaring the document as record
|
||||
* @param password the user's password
|
||||
* @param recordName the record name
|
||||
* @param reason reject reason
|
||||
* @return true if the action completed successfully
|
||||
*/
|
||||
public boolean rejectRecord(String user, String password, String recordName, String reason)
|
||||
{
|
||||
String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName);
|
||||
|
||||
try
|
||||
{
|
||||
JSONObject requestParams = new JSONObject();
|
||||
requestParams.put("name", "reject");
|
||||
requestParams.put("nodeRef", recNodeRef);
|
||||
requestParams.put("params",new JSONObject()
|
||||
.put("reason",reason));
|
||||
|
||||
return doPostJsonRequest(user, password, requestParams, RM_ACTIONS_API);
|
||||
}
|
||||
catch (JSONException error)
|
||||
{
|
||||
LOGGER.error("Unable to extract response parameter", error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Declare document version as record
|
||||
*
|
||||
|
@@ -27,7 +27,6 @@
|
||||
package org.alfresco.rest.rm.community.base;
|
||||
|
||||
import static lombok.AccessLevel.PROTECTED;
|
||||
|
||||
import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME;
|
||||
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||
@@ -39,8 +38,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
||||
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
|
||||
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
|
||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
||||
@@ -54,10 +51,12 @@ import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.dataprep.ContentService;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestAPIFactory;
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
|
||||
import org.alfresco.rest.rm.community.model.record.Record;
|
||||
@@ -77,6 +76,7 @@ import org.alfresco.rest.search.SearchNodeModel;
|
||||
import org.alfresco.rest.search.SearchRequest;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.model.ContentModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
@@ -615,4 +615,39 @@ public class BaseRMRestTest extends RestTest
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to return site document library content model
|
||||
*
|
||||
* @return ContentModel
|
||||
* @throws Exception
|
||||
*/
|
||||
public ContentModel getDocumentLibrary(UserModel usermodel, SiteModel testSite) throws Exception
|
||||
{
|
||||
ContentModel siteModel = new ContentModel();
|
||||
siteModel.setNodeRef(testSite.getGuid());
|
||||
|
||||
restClient.authenticateUser(usermodel);
|
||||
|
||||
List<RestNodeModel> nodes = restClient.withCoreAPI().usingNode(siteModel)
|
||||
.listChildren().getEntries().stream().collect(Collectors.toList());
|
||||
ContentModel documentLibrary = new ContentModel();
|
||||
documentLibrary.setName(nodes.get(0).onModel().getName());
|
||||
documentLibrary.setNodeRef(nodes.get(0).onModel().getId());
|
||||
return documentLibrary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create a Content Model
|
||||
*
|
||||
* @return ContentModel
|
||||
* @throws Exception
|
||||
*/
|
||||
public ContentModel toContentModel(String nodeId)
|
||||
{
|
||||
ContentModel node = new ContentModel();
|
||||
node.setNodeRef(nodeId);
|
||||
return node;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user