mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ACS-4005: Removing duplicate RestTest class.
This commit is contained in:
@@ -1,89 +0,0 @@
|
|||||||
package org.alfresco.rest;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.alfresco.dataprep.WorkflowService;
|
|
||||||
import org.alfresco.rest.core.RestProperties;
|
|
||||||
import org.alfresco.rest.core.RestWrapper;
|
|
||||||
import org.alfresco.rest.rules.RulesTestsUtils;
|
|
||||||
import org.alfresco.utility.LogFactory;
|
|
||||||
import org.alfresco.utility.TasProperties;
|
|
||||||
import org.alfresco.utility.data.DataContent;
|
|
||||||
import org.alfresco.utility.data.DataGroup;
|
|
||||||
import org.alfresco.utility.data.DataLink;
|
|
||||||
import org.alfresco.utility.data.DataSite;
|
|
||||||
import org.alfresco.utility.data.DataUserAIS;
|
|
||||||
import org.alfresco.utility.data.DataWorkflow;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.alfresco.utility.network.ServerHealth;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
|
||||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
|
||||||
import org.testng.annotations.AfterMethod;
|
|
||||||
import org.testng.annotations.BeforeMethod;
|
|
||||||
import org.testng.annotations.BeforeSuite;
|
|
||||||
|
|
||||||
@ContextConfiguration("classpath:alfresco-restapi-context.xml")
|
|
||||||
public abstract class RestTest extends AbstractTestNGSpringContextTests
|
|
||||||
{
|
|
||||||
private static Logger LOG = LogFactory.getLogger();
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected RestProperties restProperties;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected TasProperties properties;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected ServerHealth serverHealth;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected RestWrapper restClient;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected DataUserAIS dataUser;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected DataSite dataSite;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected DataContent dataContent;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected DataGroup dataGroup;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected DataWorkflow dataWorkflow;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected DataLink dataLink;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected WorkflowService workflow;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
protected RulesTestsUtils rulesUtils;
|
|
||||||
|
|
||||||
protected SiteModel testSite;
|
|
||||||
|
|
||||||
@BeforeSuite(alwaysRun = true)
|
|
||||||
public void checkServerHealth() throws Exception
|
|
||||||
{
|
|
||||||
super.springTestContextPrepareTestInstance();
|
|
||||||
serverHealth.assertServerIsOnline();
|
|
||||||
testSite = dataSite.createPublicRandomSite();
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeMethod(alwaysRun=true)
|
|
||||||
public void showStartTestInfo(Method method)
|
|
||||||
{
|
|
||||||
LOG.info(String.format("*** STARTING Test: [%s] ***",method.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterMethod(alwaysRun=true)
|
|
||||||
public void showEndTestInfo(Method method)
|
|
||||||
{
|
|
||||||
LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
@@ -26,7 +26,6 @@
|
|||||||
package org.alfresco.rest.rules;
|
package org.alfresco.rest.rules;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED;
|
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED;
|
||||||
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION;
|
import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION;
|
||||||
import static org.alfresco.rest.rules.RulesTestsUtils.CHECKIN_ACTION;
|
import static org.alfresco.rest.rules.RulesTestsUtils.CHECKIN_ACTION;
|
||||||
@@ -58,11 +57,9 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import javax.json.Json;
|
import javax.json.Json;
|
||||||
import javax.json.JsonObject;
|
import javax.json.JsonObject;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
||||||
import org.alfresco.rest.model.RestActionConstraintModel;
|
import org.alfresco.rest.model.RestActionConstraintModel;
|
||||||
import org.alfresco.rest.model.RestCompositeConditionDefinitionModel;
|
import org.alfresco.rest.model.RestCompositeConditionDefinitionModel;
|
||||||
@@ -83,7 +80,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for POST /nodes/{nodeId}/rule-sets/{ruleSetId}/rules.
|
* Tests for POST /nodes/{nodeId}/rule-sets/{ruleSetId}/rules.
|
||||||
*/
|
*/
|
||||||
@Test(groups = {TestGroup.RULES})
|
@Test(groups = {TestGroup.RULES})
|
||||||
public class CreateRulesTests extends RestTest
|
public class CreateRulesTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
private UserModel user;
|
private UserModel user;
|
||||||
private SiteModel site;
|
private SiteModel site;
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
package org.alfresco.rest.rules;
|
package org.alfresco.rest.rules;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import static org.alfresco.utility.constants.UserRole.SiteCollaborator;
|
import static org.alfresco.utility.constants.UserRole.SiteCollaborator;
|
||||||
import static org.alfresco.utility.constants.UserRole.SiteContributor;
|
import static org.alfresco.utility.constants.UserRole.SiteContributor;
|
||||||
import static org.alfresco.utility.constants.UserRole.SiteManager;
|
import static org.alfresco.utility.constants.UserRole.SiteManager;
|
||||||
@@ -41,7 +40,6 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestRuleModel;
|
import org.alfresco.rest.model.RestRuleModel;
|
||||||
import org.alfresco.rest.model.RestRuleModelsCollection;
|
import org.alfresco.rest.model.RestRuleModelsCollection;
|
||||||
import org.alfresco.utility.model.FolderModel;
|
import org.alfresco.utility.model.FolderModel;
|
||||||
@@ -56,7 +54,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for DELETE /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}.
|
* Tests for DELETE /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}.
|
||||||
*/
|
*/
|
||||||
@Test(groups = {TestGroup.RULES})
|
@Test(groups = {TestGroup.RULES})
|
||||||
public class DeleteRulesTests extends RestTest
|
public class DeleteRulesTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
private static final String FAKE_NODE_REF = "fake-node-id";
|
private static final String FAKE_NODE_REF = "fake-node-id";
|
||||||
|
|
||||||
|
@@ -36,7 +36,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
import org.alfresco.dataprep.CMISUtil;
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
||||||
import org.alfresco.rest.model.RestNodeModel;
|
import org.alfresco.rest.model.RestNodeModel;
|
||||||
import org.alfresco.rest.model.RestRuleExecutionModel;
|
import org.alfresco.rest.model.RestRuleExecutionModel;
|
||||||
@@ -56,7 +55,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for POST /nodes/{nodeId}/rule-executions.
|
* Tests for POST /nodes/{nodeId}/rule-executions.
|
||||||
*/
|
*/
|
||||||
@Test(groups = { TestGroup.RULES})
|
@Test(groups = { TestGroup.RULES})
|
||||||
public class ExecuteRulesTests extends RestTest
|
public class ExecuteRulesTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
|
|
||||||
private UserModel user;
|
private UserModel user;
|
||||||
|
@@ -32,7 +32,6 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestRuleModel;
|
import org.alfresco.rest.model.RestRuleModel;
|
||||||
import org.alfresco.rest.model.RestRuleModelsCollection;
|
import org.alfresco.rest.model.RestRuleModelsCollection;
|
||||||
import org.alfresco.rest.model.RestRuleSetLinkModel;
|
import org.alfresco.rest.model.RestRuleSetLinkModel;
|
||||||
@@ -49,7 +48,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules with rule inheritance.
|
* Tests for GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules with rule inheritance.
|
||||||
*/
|
*/
|
||||||
@Test(groups = {TestGroup.RULES})
|
@Test(groups = {TestGroup.RULES})
|
||||||
public class GetInheritedRulesTests extends RestTest
|
public class GetInheritedRulesTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
private UserModel user;
|
private UserModel user;
|
||||||
private SiteModel site;
|
private SiteModel site;
|
||||||
|
@@ -36,8 +36,6 @@ import static org.springframework.http.HttpStatus.OK;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestRuleModel;
|
import org.alfresco.rest.model.RestRuleModel;
|
||||||
import org.alfresco.rest.model.RestRuleSetLinkModel;
|
import org.alfresco.rest.model.RestRuleSetLinkModel;
|
||||||
import org.alfresco.rest.model.RestRuleSetModel;
|
import org.alfresco.rest.model.RestRuleSetModel;
|
||||||
@@ -57,7 +55,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for GET /nodes/{nodeId}/rule-sets and /nodes/{nodeId}/rule-sets/{ruleSetId}.
|
* Tests for GET /nodes/{nodeId}/rule-sets and /nodes/{nodeId}/rule-sets/{ruleSetId}.
|
||||||
*/
|
*/
|
||||||
@Test (groups = { TestGroup.RULES })
|
@Test (groups = { TestGroup.RULES })
|
||||||
public class GetRuleSetsTests extends RestTest
|
public class GetRuleSetsTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
private UserModel user;
|
private UserModel user;
|
||||||
private SiteModel site;
|
private SiteModel site;
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
package org.alfresco.rest.rules;
|
package org.alfresco.rest.rules;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import static org.alfresco.utility.constants.UserRole.SiteCollaborator;
|
import static org.alfresco.utility.constants.UserRole.SiteCollaborator;
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -39,7 +38,6 @@ import java.util.List;
|
|||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestRuleModel;
|
import org.alfresco.rest.model.RestRuleModel;
|
||||||
import org.alfresco.rest.model.RestRuleModelsCollection;
|
import org.alfresco.rest.model.RestRuleModelsCollection;
|
||||||
import org.alfresco.utility.model.FolderModel;
|
import org.alfresco.utility.model.FolderModel;
|
||||||
@@ -53,7 +51,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules and GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}.
|
* Tests for GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules and GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}.
|
||||||
*/
|
*/
|
||||||
@Test(groups = {TestGroup.RULES})
|
@Test(groups = {TestGroup.RULES})
|
||||||
public class GetRulesTests extends RestTest
|
public class GetRulesTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
private UserModel user;
|
private UserModel user;
|
||||||
private SiteModel site;
|
private SiteModel site;
|
||||||
|
@@ -1,203 +1,200 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.rules;
|
package org.alfresco.rest.rules;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.List;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Lists;
|
import org.alfresco.rest.model.RestRuleModel;
|
||||||
|
import org.alfresco.rest.model.RestRuleSetModel;
|
||||||
import org.alfresco.rest.RestTest;
|
import org.alfresco.utility.constants.UserRole;
|
||||||
import org.alfresco.rest.model.RestRuleModel;
|
import org.alfresco.utility.model.FolderModel;
|
||||||
import org.alfresco.rest.model.RestRuleSetModel;
|
import org.alfresco.utility.model.SiteModel;
|
||||||
import org.alfresco.utility.constants.UserRole;
|
import org.alfresco.utility.model.TestGroup;
|
||||||
import org.alfresco.utility.model.FolderModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.alfresco.utility.model.TestGroup;
|
import org.testng.annotations.Test;
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
@Test (groups = { TestGroup.RULES })
|
||||||
import org.testng.annotations.Test;
|
public class ReorderRulesTests extends RulesRestTest
|
||||||
|
{
|
||||||
@Test (groups = { TestGroup.RULES })
|
private UserModel user;
|
||||||
public class ReorderRules extends RestTest
|
private SiteModel site;
|
||||||
{
|
|
||||||
private UserModel user;
|
@BeforeClass (alwaysRun = true)
|
||||||
private SiteModel site;
|
public void dataPreparation()
|
||||||
|
{
|
||||||
@BeforeClass (alwaysRun = true)
|
STEP("Create a user and site.");
|
||||||
public void dataPreparation()
|
user = dataUser.createRandomTestUser();
|
||||||
{
|
site = dataSite.usingUser(user).createPublicRandomSite();
|
||||||
STEP("Create a user and site.");
|
}
|
||||||
user = dataUser.createRandomTestUser();
|
|
||||||
site = dataSite.usingUser(user).createPublicRandomSite();
|
/** Check we can get the ordered list of rules in a rule set. */
|
||||||
}
|
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||||
|
public void getOrderedRuleIds()
|
||||||
/** Check we can get the ordered list of rules in a rule set. */
|
{
|
||||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
STEP("Create a folder containing three rules in the existing site");
|
||||||
public void getOrderedRuleIds()
|
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||||
{
|
List<RestRuleModel> rules = createRulesInFolder(folder, user);
|
||||||
STEP("Create a folder containing three rules in the existing site");
|
|
||||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
STEP("Get the default rule set for the folder including the ordered rule ids");
|
||||||
List<RestRuleModel> rules = createRulesInFolder(folder, user);
|
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
||||||
|
.include("ruleIds").getDefaultRuleSet();
|
||||||
STEP("Get the default rule set for the folder including the ordered rule ids");
|
|
||||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
List<String> expectedRuleIds = rules.stream().map(RestRuleModel::getId).collect(toList());
|
||||||
.include("ruleIds").getDefaultRuleSet();
|
restClient.assertStatusCodeIs(OK);
|
||||||
|
ruleSet.assertThat().field("ruleIds").is(expectedRuleIds);
|
||||||
List<String> expectedRuleIds = rules.stream().map(RestRuleModel::getId).collect(toList());
|
}
|
||||||
restClient.assertStatusCodeIs(OK);
|
|
||||||
ruleSet.assertThat().field("ruleIds").is(expectedRuleIds);
|
/** Check that a user can view the order of the rules in a rule set if they only have read permission. */
|
||||||
}
|
@Test
|
||||||
|
public void getRuleSetAndRuleIdsWithReadOnlyPermission()
|
||||||
/** Check that a user can view the order of the rules in a rule set if they only have read permission. */
|
{
|
||||||
@Test
|
STEP("Create a site owned by admin and add user as a consumer");
|
||||||
public void getRuleSetAndRuleIdsWithReadOnlyPermission()
|
SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite();
|
||||||
{
|
dataUser.addUserToSite(user, siteModel, UserRole.SiteConsumer);
|
||||||
STEP("Create a site owned by admin and add user as a consumer");
|
|
||||||
SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite();
|
STEP("Use admin to create a folder with a rule set and three rules in it");
|
||||||
dataUser.addUserToSite(user, siteModel, UserRole.SiteConsumer);
|
FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
||||||
|
dataContent.usingAdmin().usingResource(ruleFolder).createFolder();
|
||||||
STEP("Use admin to create a folder with a rule set and three rules in it");
|
List<RestRuleModel> rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser());
|
||||||
FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
|
||||||
dataContent.usingAdmin().usingResource(ruleFolder).createFolder();
|
STEP("Get the rule set with the ordered list of rules");
|
||||||
List<RestRuleModel> rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser());
|
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||||
|
.include("ruleIds").getDefaultRuleSet();
|
||||||
STEP("Get the rule set with the ordered list of rules");
|
|
||||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
restClient.assertStatusCodeIs(OK);
|
||||||
.include("ruleIds").getDefaultRuleSet();
|
List<String> ruleIds = rules.stream().map(RestRuleModel::getId).collect(toList());
|
||||||
|
ruleSet.assertThat().field("ruleIds").is(ruleIds);
|
||||||
restClient.assertStatusCodeIs(OK);
|
}
|
||||||
List<String> ruleIds = rules.stream().map(RestRuleModel::getId).collect(toList());
|
|
||||||
ruleSet.assertThat().field("ruleIds").is(ruleIds);
|
/** Check we can reorder the rules in a rule set. */
|
||||||
}
|
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||||
|
public void reorderRules()
|
||||||
/** Check we can reorder the rules in a rule set. */
|
{
|
||||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
STEP("Create a folder containing three rules in the existing site");
|
||||||
public void reorderRules()
|
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||||
{
|
List<RestRuleModel> rules = createRulesInFolder(folder, user);
|
||||||
STEP("Create a folder containing three rules in the existing site");
|
|
||||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
STEP("Reverse the order of the rules within the rule set");
|
||||||
List<RestRuleModel> rules = createRulesInFolder(folder, user);
|
List<String> reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList()));
|
||||||
|
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
||||||
STEP("Reverse the order of the rules within the rule set");
|
ruleSetBody.setId("-default-");
|
||||||
List<String> reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList()));
|
ruleSetBody.setRuleIds(reversedRuleIds);
|
||||||
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
||||||
ruleSetBody.setId("-default-");
|
.include("ruleIds").updateRuleSet(ruleSetBody);
|
||||||
ruleSetBody.setRuleIds(reversedRuleIds);
|
|
||||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
restClient.assertStatusCodeIs(OK);
|
||||||
.include("ruleIds").updateRuleSet(ruleSetBody);
|
ruleSet.assertThat().field("ruleIds").is(reversedRuleIds);
|
||||||
|
}
|
||||||
restClient.assertStatusCodeIs(OK);
|
|
||||||
ruleSet.assertThat().field("ruleIds").is(reversedRuleIds);
|
/** Check we can reorder the rules in a rule set by editing the response from the GET. */
|
||||||
}
|
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||||
|
public void reorderRulesUsingResponseFromGET()
|
||||||
/** Check we can reorder the rules in a rule set by editing the response from the GET. */
|
{
|
||||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
STEP("Create a folder containing three rules in the existing site");
|
||||||
public void reorderRulesUsingResponseFromGET()
|
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||||
{
|
List<RestRuleModel> rules = createRulesInFolder(folder, user);
|
||||||
STEP("Create a folder containing three rules in the existing site");
|
|
||||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
STEP("Get the rule set with its id.");
|
||||||
List<RestRuleModel> rules = createRulesInFolder(folder, user);
|
RestRuleSetModel ruleSetResponse = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
||||||
|
.include("ruleIds").getDefaultRuleSet();
|
||||||
STEP("Get the rule set with its id.");
|
|
||||||
RestRuleSetModel ruleSetResponse = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
STEP("Reverse the order of the rules within the rule set");
|
||||||
.include("ruleIds").getDefaultRuleSet();
|
ruleSetResponse.setRuleIds(Lists.reverse(ruleSetResponse.getRuleIds()));
|
||||||
|
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
||||||
STEP("Reverse the order of the rules within the rule set");
|
.include("ruleIds").updateRuleSet(ruleSetResponse);
|
||||||
ruleSetResponse.setRuleIds(Lists.reverse(ruleSetResponse.getRuleIds()));
|
|
||||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
restClient.assertStatusCodeIs(OK);
|
||||||
.include("ruleIds").updateRuleSet(ruleSetResponse);
|
List<String> reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList()));
|
||||||
|
ruleSet.assertThat().field("ruleIds").is(reversedRuleIds);
|
||||||
restClient.assertStatusCodeIs(OK);
|
}
|
||||||
List<String> reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList()));
|
|
||||||
ruleSet.assertThat().field("ruleIds").is(reversedRuleIds);
|
/** Check that a user cannot reorder the rules in a rule set if they only have read permission. */
|
||||||
}
|
@Test
|
||||||
|
public void reorderRulesWithoutPermission()
|
||||||
/** Check that a user cannot reorder the rules in a rule set if they only have read permission. */
|
{
|
||||||
@Test
|
STEP("Create a site owned by admin and add user as a consumer");
|
||||||
public void reorderRulesWithoutPermission()
|
SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite();
|
||||||
{
|
dataUser.addUserToSite(user, siteModel, UserRole.SiteContributor);
|
||||||
STEP("Create a site owned by admin and add user as a consumer");
|
|
||||||
SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite();
|
STEP("Use admin to create a folder with a rule set and three rules in it");
|
||||||
dataUser.addUserToSite(user, siteModel, UserRole.SiteContributor);
|
FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
||||||
|
dataContent.usingAdmin().usingResource(ruleFolder).createFolder();
|
||||||
STEP("Use admin to create a folder with a rule set and three rules in it");
|
List<RestRuleModel> rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser());
|
||||||
FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
|
||||||
dataContent.usingAdmin().usingResource(ruleFolder).createFolder();
|
STEP("Try to reorder the rules as the contributor");
|
||||||
List<RestRuleModel> rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser());
|
List<String> reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList()));
|
||||||
|
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
||||||
STEP("Try to reorder the rules as the contributor");
|
ruleSetBody.setId("-default-");
|
||||||
List<String> reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList()));
|
ruleSetBody.setRuleIds(reversedRuleIds);
|
||||||
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||||
ruleSetBody.setId("-default-");
|
.include("ruleIds").updateRuleSet(ruleSetBody);
|
||||||
ruleSetBody.setRuleIds(reversedRuleIds);
|
|
||||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
restClient.assertStatusCodeIs(FORBIDDEN);
|
||||||
.include("ruleIds").updateRuleSet(ruleSetBody);
|
}
|
||||||
|
|
||||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
/** Check that a user can reorder the rules in a rule set if they have write permission. */
|
||||||
}
|
@Test
|
||||||
|
public void reorderRulesWithPermission()
|
||||||
/** Check that a user can reorder the rules in a rule set if they have write permission. */
|
{
|
||||||
@Test
|
STEP("Create a site owned by admin and add user as a collaborator");
|
||||||
public void reorderRulesWithPermission()
|
SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite();
|
||||||
{
|
dataUser.addUserToSite(user, siteModel, UserRole.SiteCollaborator);
|
||||||
STEP("Create a site owned by admin and add user as a collaborator");
|
|
||||||
SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite();
|
STEP("Use admin to create a folder with a rule set and three rules in it");
|
||||||
dataUser.addUserToSite(user, siteModel, UserRole.SiteCollaborator);
|
FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
||||||
|
dataContent.usingAdmin().usingResource(ruleFolder).createFolder();
|
||||||
STEP("Use admin to create a folder with a rule set and three rules in it");
|
List<RestRuleModel> rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser());
|
||||||
FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
|
||||||
dataContent.usingAdmin().usingResource(ruleFolder).createFolder();
|
STEP("Try to reorder the rules as the contributor");
|
||||||
List<RestRuleModel> rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser());
|
List<String> reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList()));
|
||||||
|
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
||||||
STEP("Try to reorder the rules as the contributor");
|
ruleSetBody.setId("-default-");
|
||||||
List<String> reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList()));
|
ruleSetBody.setRuleIds(reversedRuleIds);
|
||||||
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||||
ruleSetBody.setId("-default-");
|
.include("ruleIds").updateRuleSet(ruleSetBody);
|
||||||
ruleSetBody.setRuleIds(reversedRuleIds);
|
|
||||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
restClient.assertStatusCodeIs(OK);
|
||||||
.include("ruleIds").updateRuleSet(ruleSetBody);
|
ruleSet.assertThat().field("ruleIds").is(reversedRuleIds);
|
||||||
|
}
|
||||||
restClient.assertStatusCodeIs(OK);
|
|
||||||
ruleSet.assertThat().field("ruleIds").is(reversedRuleIds);
|
/** Create three rules in the given folder. */
|
||||||
}
|
private List<RestRuleModel> createRulesInFolder(FolderModel folder, UserModel user)
|
||||||
|
{
|
||||||
/** Create three rules in the given folder. */
|
return IntStream.range(0, 3).mapToObj(index ->
|
||||||
private List<RestRuleModel> createRulesInFolder(FolderModel folder, UserModel user)
|
{
|
||||||
{
|
RestRuleModel ruleModel = rulesUtils.createRuleModelWithDefaultValues();
|
||||||
return IntStream.range(0, 3).mapToObj(index ->
|
return restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||||
{
|
}).collect(toList());
|
||||||
RestRuleModel ruleModel = rulesUtils.createRuleModelWithDefaultValues();
|
}
|
||||||
return restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
}
|
||||||
}).collect(toList());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -35,7 +35,6 @@ import static org.springframework.http.HttpStatus.NO_CONTENT;
|
|||||||
import static org.springframework.http.HttpStatus.OK;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
import org.alfresco.dataprep.CMISUtil;
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestRuleModel;
|
import org.alfresco.rest.model.RestRuleModel;
|
||||||
import org.alfresco.rest.model.RestRuleModelsCollection;
|
import org.alfresco.rest.model.RestRuleModelsCollection;
|
||||||
import org.alfresco.rest.model.RestRuleSetLinkModel;
|
import org.alfresco.rest.model.RestRuleSetLinkModel;
|
||||||
@@ -53,7 +52,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for /nodes/{nodeId}/rule-set-links.
|
* Tests for /nodes/{nodeId}/rule-set-links.
|
||||||
*/
|
*/
|
||||||
@Test(groups = {TestGroup.RULES})
|
@Test(groups = {TestGroup.RULES})
|
||||||
public class RuleSetLinksTests extends RestTest
|
public class RuleSetLinksTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
private UserModel user;
|
private UserModel user;
|
||||||
private SiteModel site;
|
private SiteModel site;
|
||||||
|
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Remote API
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.alfresco.rest.rules;
|
||||||
|
|
||||||
|
import org.alfresco.rest.RestTest;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
public class RulesRestTest extends RestTest
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
protected RulesTestsUtils rulesUtils;
|
||||||
|
}
|
@@ -33,7 +33,6 @@ import static org.springframework.http.HttpStatus.FORBIDDEN;
|
|||||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestRuleSettingsModel;
|
import org.alfresco.rest.model.RestRuleSettingsModel;
|
||||||
import org.alfresco.utility.model.FolderModel;
|
import org.alfresco.utility.model.FolderModel;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
import org.alfresco.utility.model.SiteModel;
|
||||||
@@ -46,7 +45,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for GET and PUT /nodes/{nodeId}/rule-settings/{ruleSettingKey}.
|
* Tests for GET and PUT /nodes/{nodeId}/rule-settings/{ruleSettingKey}.
|
||||||
*/
|
*/
|
||||||
@Test (groups = { TestGroup.RULES })
|
@Test (groups = { TestGroup.RULES })
|
||||||
public class SetInheritanceTests extends RestTest
|
public class SetInheritanceTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
private UserModel siteOwner;
|
private UserModel siteOwner;
|
||||||
private SiteModel site;
|
private SiteModel site;
|
||||||
|
@@ -48,8 +48,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
|
||||||
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
import org.alfresco.rest.model.RestActionBodyExecTemplateModel;
|
||||||
import org.alfresco.rest.model.RestCompositeConditionDefinitionModel;
|
import org.alfresco.rest.model.RestCompositeConditionDefinitionModel;
|
||||||
import org.alfresco.rest.model.RestRuleModel;
|
import org.alfresco.rest.model.RestRuleModel;
|
||||||
@@ -64,7 +62,7 @@ import org.testng.annotations.Test;
|
|||||||
* Tests for PUT /nodes/{nodeId}/rule-sets/{ruleSetId}/rules.
|
* Tests for PUT /nodes/{nodeId}/rule-sets/{ruleSetId}/rules.
|
||||||
*/
|
*/
|
||||||
@Test (groups = { TestGroup.RULES })
|
@Test (groups = { TestGroup.RULES })
|
||||||
public class UpdateRulesTests extends RestTest
|
public class UpdateRulesTests extends RulesRestTest
|
||||||
{
|
{
|
||||||
private UserModel user;
|
private UserModel user;
|
||||||
private SiteModel site;
|
private SiteModel site;
|
||||||
|
Reference in New Issue
Block a user