mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-3723, ACS-3724, ACS-3725 move rules V1 API to private space (#1495)
* ACS-3723: Moving endpoints to private API path. * ACS-3723: Fixes to E2E tests and some other parts. * ACS-3723: Removing unnecessary imports.
This commit is contained in:
@@ -100,7 +100,7 @@ public class CreateRulesTests extends RestTest
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModelWithModifiedValues();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues();
|
||||
@@ -121,7 +121,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = new RestRuleModel();
|
||||
ruleModel.setName("ruleName");
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
restClient.assertLastError().containsSummary("Folder with id fake-id was not found");
|
||||
@@ -135,7 +135,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = new RestRuleModel();
|
||||
ruleModel.setName("ruleName");
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingRuleSet("fake-id").createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingRuleSet("fake-id").createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
restClient.assertLastError().containsSummary("Rule set with id fake-id was not found");
|
||||
@@ -147,7 +147,7 @@ public class CreateRulesTests extends RestTest
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModel("");
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
restClient.assertLastError().containsSummary("Rule name is a mandatory parameter");
|
||||
@@ -160,8 +160,8 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = createRuleModel("duplicateRuleName");
|
||||
|
||||
STEP("Create two identical rules");
|
||||
RestRuleModel ruleA = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
RestRuleModel ruleB = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
RestRuleModel ruleA = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
RestRuleModel ruleB = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
// Check that the names are the same but the ids are different.
|
||||
ruleA.assertThat().field("name").is(ruleB.getName());
|
||||
@@ -180,7 +180,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = new RestRuleModel();
|
||||
ruleModel.setName("ruleName");
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
||||
restClient.assertLastError().containsSummary("Insufficient permissions to manage rules");
|
||||
@@ -232,7 +232,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = new RestRuleModel();
|
||||
ruleModel.setName("ruleName");
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(fileModel).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(fileModel).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
restClient.assertLastError().containsSummary("folder is expected");
|
||||
@@ -246,7 +246,7 @@ public class CreateRulesTests extends RestTest
|
||||
List<String> ruleNames = List.of("ruleA", "ruleB", "ruleC");
|
||||
List<RestRuleModel> ruleModels = ruleNames.stream().map(RulesTestsUtils::createRuleModel).collect(toList());
|
||||
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createListOfRules(ruleModels);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -269,7 +269,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleC = createRuleModel("ruleC");
|
||||
List<RestRuleModel> ruleModels = List.of(ruleA, ruleB, ruleC);
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createListOfRules(ruleModels);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().createListOfRules(ruleModels);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
restClient.assertLastError().containsSummary("Rule name is a mandatory parameter");
|
||||
@@ -282,7 +282,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -298,7 +298,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -314,7 +314,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -331,7 +331,7 @@ public class CreateRulesTests extends RestTest
|
||||
ruleModel.setIsShared(true);
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -346,7 +346,7 @@ public class CreateRulesTests extends RestTest
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include("isShared")
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
@@ -365,7 +365,7 @@ public class CreateRulesTests extends RestTest
|
||||
dataUser.addUserToSite(userWithRole, privateSite, userRole);
|
||||
RestRuleModel ruleModel = createRuleModel("testRule", List.of(createAddAudioAspectAction()));
|
||||
|
||||
return restClient.authenticateUser(userWithRole).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
return restClient.authenticateUser(userWithRole).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,7 +376,7 @@ public class CreateRulesTests extends RestTest
|
||||
{
|
||||
final UserModel admin = dataUser.getAdminUser();
|
||||
|
||||
final RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
final RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createVariousActions());
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
|
||||
@@ -392,7 +392,7 @@ public class CreateRulesTests extends RestTest
|
||||
@Test
|
||||
public void createRuleWithActions_userCannotUsePrivateAction()
|
||||
{
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createRuleWithPrivateAction());
|
||||
|
||||
restClient.assertStatusCodeIs(FORBIDDEN)
|
||||
@@ -403,7 +403,7 @@ public class CreateRulesTests extends RestTest
|
||||
@Test
|
||||
public void createRuleWithActions_adminCanUsePrivateAction()
|
||||
{
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createRuleWithPrivateAction());
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -418,7 +418,7 @@ public class CreateRulesTests extends RestTest
|
||||
final RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setActions(null);
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -438,7 +438,7 @@ public class CreateRulesTests extends RestTest
|
||||
invalidAction.setParams(Map.of("dummy-key", "dummy-value"));
|
||||
ruleModel.setActions(List.of(invalidAction));
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -457,7 +457,7 @@ public class CreateRulesTests extends RestTest
|
||||
invalidAction.setActionDefinitionId(actionDefinitionId);
|
||||
ruleModel.setActions(List.of(invalidAction));
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -479,7 +479,7 @@ public class CreateRulesTests extends RestTest
|
||||
final RestActionBodyExecTemplateModel scriptAction = createCustomActionModel(actionDefinitionId, Map.of(scriptRef, scriptNodeId));
|
||||
ruleModel.setActions(List.of(scriptAction));
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -503,7 +503,7 @@ public class CreateRulesTests extends RestTest
|
||||
invalidAction.setParams(Map.of(invalidParameterKey,"dummyValue"));
|
||||
ruleModel.setActions(List.of(invalidAction));
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -524,7 +524,7 @@ public class CreateRulesTests extends RestTest
|
||||
invalidAction.setParams(Map.of("deep-copy",false));
|
||||
ruleModel.setActions(List.of(invalidAction));
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -540,7 +540,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setConditions(createVariousConditions());
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
|
||||
@@ -559,7 +559,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setConditions(createCompositeCondition(null));
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
|
||||
@@ -584,7 +584,7 @@ public class CreateRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
ruleModel.setConditions(conditions);
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
restClient.assertLastError().containsSummary("Category in condition is invalid");
|
||||
|
@@ -84,19 +84,19 @@ public class DeleteRulesTests extends RestTest
|
||||
final List<RestRuleModel> createdRules = Stream.of("ruleA", "ruleB", "ruleC")
|
||||
.map(ruleName -> {
|
||||
RestRuleModel ruleModel = createRuleModel(ruleName);
|
||||
return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
return restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
})
|
||||
.collect(toList());
|
||||
|
||||
STEP("Attempt delete one rule");
|
||||
final RestRuleModel ruleA = createdRules.get(0);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().deleteRule(ruleA.getId());
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().deleteRule(ruleA.getId());
|
||||
restClient.assertStatusCodeIs(NO_CONTENT);
|
||||
|
||||
STEP("Get and check the rules from the folder after deleting one of them");
|
||||
final RestRuleModelsCollection rulesAfterDeletion =
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().getListOfRules();
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().getListOfRules();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
rulesAfterDeletion.assertThat().entriesListCountIs(createdRules.size() - 1);
|
||||
Assert.assertTrue(rulesAfterDeletion.getEntries()
|
||||
@@ -127,7 +127,7 @@ public class DeleteRulesTests extends RestTest
|
||||
nonExistingFolder.setNodeRef(FAKE_NODE_REF);
|
||||
|
||||
STEP("Attempt delete the rule in non-existing folder");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistingFolder).usingDefaultRuleSet().deleteRule(testRule.getId());
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistingFolder).usingDefaultRuleSet().deleteRule(testRule.getId());
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class DeleteRulesTests extends RestTest
|
||||
final RestRuleModel testRule = createRule(ruleFolder);
|
||||
|
||||
STEP("Attempt delete the rule in non-existing rule set");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingRuleSet(FAKE_NODE_REF).deleteRule(testRule.getId());
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingRuleSet(FAKE_NODE_REF).deleteRule(testRule.getId());
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class DeleteRulesTests extends RestTest
|
||||
{
|
||||
final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
STEP("Attempt delete non-existing rule");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().deleteRule(FAKE_NODE_REF);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().deleteRule(FAKE_NODE_REF);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND);
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class DeleteRulesTests extends RestTest
|
||||
final FolderModel anotherFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Attempt delete an existing rule from a wrong but existing (second) folder");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(anotherFolder).usingDefaultRuleSet().deleteRule(testRule.getId());
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(anotherFolder).usingDefaultRuleSet().deleteRule(testRule.getId());
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND);
|
||||
}
|
||||
@@ -189,11 +189,11 @@ public class DeleteRulesTests extends RestTest
|
||||
final FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder();
|
||||
final RestRuleModel ruleModel = createRuleModel("Private site rule");
|
||||
final RestRuleModel createdRule =
|
||||
restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(privateUser).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Try to delete the rule with another user");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().deleteRule(createdRule.getId());
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().deleteRule(createdRule.getId());
|
||||
|
||||
restClient.assertLastError().statusCodeIs(FORBIDDEN);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public class DeleteRulesTests extends RestTest
|
||||
restClient.authenticateUser(user).withCoreAPI().usingSite(site).addPerson(siteCollaborator);
|
||||
|
||||
STEP("Check the manager can delete the rule");
|
||||
restClient.authenticateUser(siteCollaborator).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(siteCollaborator).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.deleteRule(testRule.getId());
|
||||
|
||||
restClient.assertLastError().statusCodeIs(FORBIDDEN);
|
||||
@@ -230,7 +230,7 @@ public class DeleteRulesTests extends RestTest
|
||||
final FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder();
|
||||
final RestRuleModel ruleModel = createRuleModel("Private site rule");
|
||||
final RestRuleModel createdRule =
|
||||
restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(privateUser).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Create a manager in the private site");
|
||||
@@ -239,7 +239,7 @@ public class DeleteRulesTests extends RestTest
|
||||
restClient.authenticateUser(privateUser).withCoreAPI().usingSite(privateSite).addPerson(siteManager);
|
||||
|
||||
STEP("Check the manager can delete the rule");
|
||||
restClient.authenticateUser(siteManager).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(siteManager).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
.deleteRule(createdRule.getId());
|
||||
|
||||
restClient.assertStatusCodeIs(NO_CONTENT);
|
||||
@@ -249,6 +249,6 @@ public class DeleteRulesTests extends RestTest
|
||||
{
|
||||
STEP("Create a rule in the folder");
|
||||
final RestRuleModel ruleModel = createRuleModel("Test rule");
|
||||
return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
return restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
}
|
||||
}
|
||||
|
@@ -94,8 +94,8 @@ public class ExecuteRulesTests extends RestTest
|
||||
RestActionBodyExecTemplateModel addLockableAspectAction = createAddAspectAction(LOCKABLE_ASPECT);
|
||||
RestRuleModel ruleModel = createRuleModel(RULE_NAME_DEFAULT, List.of(addLockableAspectAction));
|
||||
ruleModel.setIsInheritable(true);
|
||||
parentFolderRule = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
childFolderRule = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
parentFolderRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(parentFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
childFolderRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(childFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT);
|
||||
|
||||
STEP("Execute rule");
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withPrivateAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
|
||||
STEP("Execute rules including inherited rules");
|
||||
RestRuleExecutionModel ruleExecutionRequest = createRuleExecutionRequest();
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).executeRules(ruleExecutionRequest);
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withPrivateAPI().usingNode(childFolder).executeRules(ruleExecutionRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
|
||||
|
||||
@@ -162,7 +162,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
STEP("Execute rules on parent folder including sub-folders");
|
||||
RestRuleExecutionModel ruleExecutionRequest = createRuleExecutionRequest();
|
||||
ruleExecutionRequest.setIsEachSubFolderIncluded(true);
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).executeRules(ruleExecutionRequest);
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withPrivateAPI().usingNode(parentFolder).executeRules(ruleExecutionRequest);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(true);
|
||||
|
||||
@@ -189,7 +189,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
STEP("Disable child rules");
|
||||
RestRuleModel updatedChildRule = createRuleModelWithDefaultValues();
|
||||
updatedChildRule.setIsEnabled(false);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).usingDefaultRuleSet().updateRule(childFolderRule.getId(), updatedChildRule);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(childFolder).usingDefaultRuleSet().updateRule(childFolderRule.getId(), updatedChildRule);
|
||||
|
||||
STEP("Check if file aspects don't contain Audio one");
|
||||
RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolderFile).getNode();
|
||||
@@ -197,7 +197,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT);
|
||||
|
||||
STEP("Execute rule");
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withPrivateAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
|
||||
|
||||
@@ -216,7 +216,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
STEP("Set parent rule as not inheritable");
|
||||
RestRuleModel updatedParentRule = createRuleModelWithDefaultValues();
|
||||
updatedParentRule.setIsInheritable(false);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).usingDefaultRuleSet().updateRule(parentFolderRule.getId(), updatedParentRule);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(parentFolder).usingDefaultRuleSet().updateRule(parentFolderRule.getId(), updatedParentRule);
|
||||
|
||||
STEP("Check if file aspects don't contain Audio and Lockable ones");
|
||||
RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolderFile).getNode();
|
||||
@@ -224,7 +224,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT, LOCKABLE_ASPECT);
|
||||
|
||||
STEP("Execute child folder rules including inherited rules");
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
RestRuleExecutionModel executionResult = restClient.authenticateUser(user).withPrivateAPI().usingNode(childFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
|
||||
|
||||
@@ -246,10 +246,10 @@ public class ExecuteRulesTests extends RestTest
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
|
||||
dataContent.usingAdmin().usingResource(privateFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
|
||||
STEP("Try to execute private folder's rules by user");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(privateFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@@ -264,11 +264,11 @@ public class ExecuteRulesTests extends RestTest
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
|
||||
dataContent.usingAdmin().usingResource(privateFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
dataUser.usingAdmin().addUserToSite(contributor, privateSite, UserRole.SiteContributor);
|
||||
|
||||
STEP("Try to execute private folder's rules by contributor");
|
||||
restClient.authenticateUser(contributor).withCoreAPI().usingNode(privateFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.authenticateUser(contributor).withPrivateAPI().usingNode(privateFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
|
||||
FileModel privateFile = dataContent.usingAdmin().usingResource(privateFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
restClient.authenticateUser(admin).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
restClient.authenticateUser(admin).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
dataUser.usingAdmin().addUserToSite(collaborator, privateSite, UserRole.SiteCollaborator);
|
||||
|
||||
STEP("Check if file aspects don't contain Audio one");
|
||||
@@ -293,7 +293,7 @@ public class ExecuteRulesTests extends RestTest
|
||||
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT);
|
||||
|
||||
STEP("Execute private folder's rules by collaborator");
|
||||
restClient.authenticateUser(collaborator).withCoreAPI().usingNode(privateFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.authenticateUser(collaborator).withPrivateAPI().usingNode(privateFolder).executeRules(createRuleExecutionRequest());
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
STEP("Check if Audio aspect is present");
|
||||
|
@@ -73,21 +73,21 @@ public class GetInheritedRulesTests extends RestTest
|
||||
FolderModel parent = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
FolderModel child = dataContent.usingUser(user).usingResource(parent).createFolder();
|
||||
RestRuleModel parentRule = createRuleModelWithModifiedValues();
|
||||
parentRule = restClient.authenticateUser(user).withCoreAPI().usingNode(parent).usingDefaultRuleSet().createSingleRule(parentRule);
|
||||
parentRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(parent).usingDefaultRuleSet().createSingleRule(parentRule);
|
||||
RestRuleModel childRule = createRuleModelWithModifiedValues();
|
||||
childRule = restClient.authenticateUser(user).withCoreAPI().usingNode(child).usingDefaultRuleSet().createSingleRule(childRule);
|
||||
childRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(child).usingDefaultRuleSet().createSingleRule(childRule);
|
||||
|
||||
STEP("Get the rules in the default rule set for the child folder");
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(child).usingDefaultRuleSet().getListOfRules();
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withPrivateAPI().usingNode(child).usingDefaultRuleSet().getListOfRules();
|
||||
rules.assertThat().entriesListContains("id", childRule.getId())
|
||||
.and().entriesListCountIs(1);
|
||||
|
||||
STEP("Get the rules in the inherited rule set for the child folder");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(child).include("inclusionType").getListOfRuleSets();
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI().usingNode(child).include("inclusionType").getListOfRuleSets();
|
||||
String inheritedRuleSetId = ruleSets.getEntries().stream()
|
||||
.filter(ruleSet -> ruleSet.onModel().getInclusionType().equals("inherited"))
|
||||
.findFirst().get().onModel().getId();
|
||||
RestRuleModelsCollection inheritedRules = restClient.authenticateUser(user).withCoreAPI().usingNode(child).usingRuleSet(inheritedRuleSetId).getListOfRules();
|
||||
RestRuleModelsCollection inheritedRules = restClient.authenticateUser(user).withPrivateAPI().usingNode(child).usingRuleSet(inheritedRuleSetId).getListOfRules();
|
||||
inheritedRules.assertThat().entriesListContains("id", parentRule.getId())
|
||||
.and().entriesListCountIs(1);
|
||||
}
|
||||
@@ -111,23 +111,23 @@ public class GetInheritedRulesTests extends RestTest
|
||||
FolderModel folderB = dataContent.usingUser(user).usingResource(folderA).createFolder();
|
||||
FolderModel folderC = dataContent.usingUser(user).usingResource(folderB).createFolder();
|
||||
FolderModel folderD = dataContent.usingUser(user).usingResource(folderC).createFolder();
|
||||
RestRuleModel ruleB = restClient.authenticateUser(user).withCoreAPI().usingNode(folderB).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
|
||||
RestRuleModel ruleC = restClient.authenticateUser(user).withCoreAPI().usingNode(folderC).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
|
||||
RestRuleModel ruleD = restClient.authenticateUser(user).withCoreAPI().usingNode(folderD).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
|
||||
RestRuleModel ruleB = restClient.authenticateUser(user).withPrivateAPI().usingNode(folderB).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
|
||||
RestRuleModel ruleC = restClient.authenticateUser(user).withPrivateAPI().usingNode(folderC).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
|
||||
RestRuleModel ruleD = restClient.authenticateUser(user).withPrivateAPI().usingNode(folderD).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
|
||||
STEP("Link folderA to ruleSetD");
|
||||
RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel();
|
||||
linkModel.setId(folderD.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folderA).createRuleLink(linkModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folderA).createRuleLink(linkModel);
|
||||
|
||||
STEP("Get the rule sets for the folderD");
|
||||
List<RestRuleSetModel> ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(folderD).getListOfRuleSets().getEntries();
|
||||
List<RestRuleSetModel> ruleSets = restClient.authenticateUser(user).withPrivateAPI().usingNode(folderD).getListOfRuleSets().getEntries();
|
||||
|
||||
STEP("Check the rules for each rule set are as expected");
|
||||
List<RestRuleModel> expectedRuleIds = List.of(ruleD, ruleB, ruleC);
|
||||
IntStream.range(0, 2).forEach(index -> {
|
||||
String ruleSetId = ruleSets.get(index).onModel().getId();
|
||||
List<RestRuleModel> rules = restClient.authenticateUser(user)
|
||||
.withCoreAPI()
|
||||
.withPrivateAPI()
|
||||
.usingNode(folderD)
|
||||
.usingRuleSet(ruleSetId)
|
||||
.getListOfRules()
|
||||
|
@@ -46,6 +46,7 @@ import org.alfresco.rest.model.RestRuleSetModel;
|
||||
import org.alfresco.rest.model.RestRuleSetModelsCollection;
|
||||
import org.alfresco.rest.model.RestRuleSettingsModel;
|
||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||
import org.alfresco.rest.requests.privateAPI.RestPrivateAPI;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
@@ -83,16 +84,16 @@ public class GetRuleSetsTests extends RestTest
|
||||
notInheritingChildFolder = dataContent.usingUser(user).usingResource(ruleFolder).createFolder();
|
||||
RestRuleSettingsModel doesntInherit = new RestRuleSettingsModel();
|
||||
doesntInherit.setValue(false);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(notInheritingChildFolder)
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(notInheritingChildFolder)
|
||||
.usingIsInheritanceEnabledRuleSetting().updateSetting(doesntInherit);
|
||||
|
||||
STEP("Create a rule in the folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Get the rule sets for the folder and find the rule set id");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.getListOfRuleSets();
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
@@ -100,7 +101,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
STEP("Use admin to create a private site containing a rule in a rule set that can be inherited.");
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
|
||||
coreAPIForAdmin().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
|
||||
privateAPIForAdmin().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
|
||||
}
|
||||
|
||||
/** Check we can get an empty list of rule sets. */
|
||||
@@ -111,7 +112,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Get the rule sets for the folder");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(folder).getListOfRuleSets();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -123,7 +124,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getRuleSetsList()
|
||||
{
|
||||
STEP("Get the rule sets for the folder");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.getListOfRuleSets();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -139,7 +140,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
STEP("Try to load rule sets for a non-existent folder.");
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).getListOfRuleSets();
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).getListOfRuleSets();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -148,7 +149,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getRuleSetsWithoutPermission()
|
||||
{
|
||||
STEP("Check a user cannot list rule sets without read access.");
|
||||
coreAPIForUser().usingNode(privateFolder).getListOfRuleSets();
|
||||
privateAPIForUser().usingNode(privateFolder).getListOfRuleSets();
|
||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
||||
}
|
||||
|
||||
@@ -162,24 +163,24 @@ public class GetRuleSetsTests extends RestTest
|
||||
FolderModel childFolder = dataContent.usingUser(user).usingResource(parentFolder).createFolder();
|
||||
RestRuleSettingsModel enabled = new RestRuleSettingsModel();
|
||||
enabled.setValue(true);
|
||||
coreAPIForUser().usingNode(parentFolder).usingRuleSetting(IS_INHERITANCE_ENABLED).updateSetting(enabled);
|
||||
privateAPIForUser().usingNode(parentFolder).usingRuleSetting(IS_INHERITANCE_ENABLED).updateSetting(enabled);
|
||||
|
||||
STEP("Link the parent folder to a private rule set.");
|
||||
RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel();
|
||||
linkModel.setId(privateFolder.getNodeRef());
|
||||
coreAPIForAdmin().usingNode(parentFolder).createRuleLink(linkModel);
|
||||
privateAPIForAdmin().usingNode(parentFolder).createRuleLink(linkModel);
|
||||
|
||||
STEP("Create a rule on the child folder.");
|
||||
coreAPIForUser().usingNode(childFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
privateAPIForUser().usingNode(childFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
|
||||
STEP("Check admin can view both rule sets.");
|
||||
RestRuleSetModelsCollection adminViewOfRuleSets = coreAPIForAdmin().usingNode(childFolder).getListOfRuleSets();
|
||||
RestRuleSetModelsCollection adminViewOfRuleSets = privateAPIForAdmin().usingNode(childFolder).getListOfRuleSets();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
RestRuleSetModel parentRuleSet = adminViewOfRuleSets.getEntries().get(0).onModel();
|
||||
RestRuleSetModel childRuleSet = adminViewOfRuleSets.getEntries().get(1).onModel();
|
||||
|
||||
STEP("Check the normal user can only view the child rule set.");
|
||||
RestRuleSetModelsCollection userViewOfRuleSets = coreAPIForUser().usingNode(childFolder).getListOfRuleSets();
|
||||
RestRuleSetModelsCollection userViewOfRuleSets = privateAPIForUser().usingNode(childFolder).getListOfRuleSets();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
userViewOfRuleSets.assertThat().entriesListContains("id", childRuleSet.getId())
|
||||
.and().entriesListDoesNotContain("id", parentRuleSet.getId());
|
||||
@@ -190,7 +191,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getRuleSetsAndOwningFolders()
|
||||
{
|
||||
STEP("Get the rule sets and owning folders");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(ruleFolder)
|
||||
.include("owningFolder")
|
||||
.getListOfRuleSets();
|
||||
@@ -207,7 +208,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getRuleSetsAndOwnedInclusionType()
|
||||
{
|
||||
STEP("Get the rule sets and inclusion type");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(ruleFolder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
@@ -224,7 +225,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getRuleSetsAndInheritedInclusionType()
|
||||
{
|
||||
STEP("Get the rule sets and inclusion type");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(inheritingChildFolder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
@@ -241,7 +242,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getRuleSetsWithoutInheriting()
|
||||
{
|
||||
STEP("Get the rule sets and inclusion type");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(notInheritingChildFolder)
|
||||
.getListOfRuleSets();
|
||||
|
||||
@@ -254,7 +255,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getRuleSetById()
|
||||
{
|
||||
STEP("Get the rule set using its rule set id");
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.getRuleSet(ruleSetId);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -272,7 +273,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getDefaultRuleSetById()
|
||||
{
|
||||
STEP("Get the default rule set for the folder");
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.getDefaultRuleSet();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -286,7 +287,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
STEP("Try to load a rule set for a non-existent folder.");
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).getDefaultRuleSet();
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).getDefaultRuleSet();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -296,7 +297,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
{
|
||||
STEP("Get the rule set using fake rule set id");
|
||||
String fakeRuleSetId = "fake-rule-set-id";
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).getRuleSet(fakeRuleSetId);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).getRuleSet(fakeRuleSetId);
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -305,7 +306,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
public void getRuleSetAndOwningFolder()
|
||||
{
|
||||
STEP("Get the rule set and owning folder");
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI()
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(ruleFolder)
|
||||
.include("owningFolder")
|
||||
.getRuleSet(ruleSetId);
|
||||
@@ -349,27 +350,27 @@ public class GetRuleSetsTests extends RestTest
|
||||
RestRuleSettingsModel nonInheriting = new RestRuleSettingsModel();
|
||||
nonInheriting.setKey(IS_INHERITANCE_ENABLED);
|
||||
nonInheriting.setValue(false);
|
||||
coreAPIForUser().usingNode(nonInheritingFolder).usingIsInheritanceEnabledRuleSetting().updateSetting(nonInheriting);
|
||||
privateAPIForUser().usingNode(nonInheritingFolder).usingIsInheritanceEnabledRuleSetting().updateSetting(nonInheriting);
|
||||
// Create a child that will link to the rule and a child of that to inherit via the link.
|
||||
FolderModel linkingFolder = dataContent.usingUser(user).usingResource(nonInheritingFolder).createFolder();
|
||||
FolderModel descendantFolder = dataContent.usingUser(user).usingResource(linkingFolder).createFolder();
|
||||
|
||||
STEP("Create an inheritable rule in the folder and get the rule set id.");
|
||||
RestRuleModel ruleModel = createRuleModelWithModifiedValues();
|
||||
coreAPIForUser().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
RestRuleSetModelsCollection ruleSets = coreAPIForUser().usingNode(folder).getListOfRuleSets();
|
||||
privateAPIForUser().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
RestRuleSetModelsCollection ruleSets = privateAPIForUser().usingNode(folder).getListOfRuleSets();
|
||||
String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
|
||||
STEP("Create the link to the rule from the linking folder");
|
||||
RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel();
|
||||
ruleSetLink.setId(folder.getNodeRef());
|
||||
coreAPIForUser().usingNode(linkingFolder).createRuleLink(ruleSetLink);
|
||||
privateAPIForUser().usingNode(linkingFolder).createRuleLink(ruleSetLink);
|
||||
|
||||
STEP("Remove the user from the site");
|
||||
dataUser.removeUserFromSite(user, siteModel);
|
||||
|
||||
STEP("Get the rule set and inheriting folders");
|
||||
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(folder)
|
||||
RestRuleSetModel ruleSet = privateAPIForUser().usingNode(folder)
|
||||
.include("inheritedBy")
|
||||
.getRuleSet(ruleSetId);
|
||||
|
||||
@@ -398,16 +399,16 @@ public class GetRuleSetsTests extends RestTest
|
||||
|
||||
STEP("Create a rule in the folder and link to it from the other two.");
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
RestRuleSetModelsCollection ruleSets = coreAPIForAdmin().usingNode(ruleFolder).getListOfRuleSets();
|
||||
privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
RestRuleSetModelsCollection ruleSets = privateAPIForAdmin().usingNode(ruleFolder).getListOfRuleSets();
|
||||
String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel();
|
||||
ruleSetLink.setId(ruleFolder.getNodeRef());
|
||||
coreAPIForUser().usingNode(publicFolder).createRuleLink(ruleSetLink);
|
||||
coreAPIForAdmin().usingNode(privateFolder).createRuleLink(ruleSetLink);
|
||||
privateAPIForUser().usingNode(publicFolder).createRuleLink(ruleSetLink);
|
||||
privateAPIForAdmin().usingNode(privateFolder).createRuleLink(ruleSetLink);
|
||||
|
||||
STEP("Get the rule set and linkedToBy field");
|
||||
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
|
||||
.include("linkedToBy")
|
||||
.getRuleSet(ruleSetId);
|
||||
|
||||
@@ -428,13 +429,13 @@ public class GetRuleSetsTests extends RestTest
|
||||
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
|
||||
dataContent.usingAdmin().usingResource(ruleFolder).createFolder();
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
STEP("Remove the user from the site");
|
||||
dataUser.removeUserFromSite(user, siteModel);
|
||||
|
||||
STEP("Get the rule set and isInherited field");
|
||||
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
|
||||
.include("isInherited", "inheritedBy")
|
||||
.getDefaultRuleSet();
|
||||
|
||||
@@ -452,17 +453,17 @@ public class GetRuleSetsTests extends RestTest
|
||||
SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite();
|
||||
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
STEP("Create a second folder in the site that links to the rule set");
|
||||
FolderModel secondFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
|
||||
dataContent.usingUser(user).usingResource(secondFolder).createFolder();
|
||||
RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel();
|
||||
ruleSetLink.setId(ruleFolder.getNodeRef());
|
||||
coreAPIForUser().usingNode(secondFolder).createRuleLink(ruleSetLink);
|
||||
privateAPIForUser().usingNode(secondFolder).createRuleLink(ruleSetLink);
|
||||
|
||||
STEP("Get the rule set and isInherited field");
|
||||
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
|
||||
.include("isInherited")
|
||||
.getDefaultRuleSet();
|
||||
|
||||
@@ -480,16 +481,16 @@ public class GetRuleSetsTests extends RestTest
|
||||
SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite();
|
||||
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
STEP("Create a second folder in the site that links to the rule set");
|
||||
FolderModel secondFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
|
||||
RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel();
|
||||
ruleSetLink.setId(ruleFolder.getNodeRef());
|
||||
coreAPIForUser().usingNode(secondFolder).createRuleLink(ruleSetLink);
|
||||
privateAPIForUser().usingNode(secondFolder).createRuleLink(ruleSetLink);
|
||||
|
||||
STEP("Get the rule set and isInherited field");
|
||||
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
|
||||
.include("isInherited")
|
||||
.getDefaultRuleSet();
|
||||
|
||||
@@ -509,19 +510,19 @@ public class GetRuleSetsTests extends RestTest
|
||||
STEP("Create a folder with a rule set");
|
||||
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
STEP("Create a private folder linking to the rule set");
|
||||
FolderModel linkingFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
||||
RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel();
|
||||
linkModel.setId(ruleFolder.getNodeRef());
|
||||
coreAPIForAdmin().usingNode(linkingFolder).createRuleLink(linkModel);
|
||||
privateAPIForAdmin().usingNode(linkingFolder).createRuleLink(linkModel);
|
||||
|
||||
STEP("Remove the user from the site");
|
||||
dataUser.removeUserFromSite(user, siteModel);
|
||||
|
||||
STEP("Get the rule set and isLinkedTo field");
|
||||
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
|
||||
.include("isLinkedTo", "linkedToBy", "owningFolder")
|
||||
.getDefaultRuleSet();
|
||||
|
||||
@@ -541,11 +542,11 @@ public class GetRuleSetsTests extends RestTest
|
||||
SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite();
|
||||
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
dataContent.usingUser(user).usingResource(ruleFolder).createFolder();
|
||||
|
||||
STEP("Get the rule set and isLinkedTo field");
|
||||
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
|
||||
.include("isLinkedTo")
|
||||
.getDefaultRuleSet();
|
||||
|
||||
@@ -563,35 +564,40 @@ public class GetRuleSetsTests extends RestTest
|
||||
FolderModel childFolder = dataContent.usingUser(user).usingResource(parentFolder).createFolder();
|
||||
RestRuleSettingsModel enabled = new RestRuleSettingsModel();
|
||||
enabled.setValue(true);
|
||||
coreAPIForUser().usingNode(parentFolder).usingRuleSetting(IS_INHERITANCE_ENABLED).updateSetting(enabled);
|
||||
privateAPIForUser().usingNode(parentFolder).usingRuleSetting(IS_INHERITANCE_ENABLED).updateSetting(enabled);
|
||||
|
||||
STEP("Link the parent folder to a private rule set.");
|
||||
RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel();
|
||||
linkModel.setId(privateFolder.getNodeRef());
|
||||
coreAPIForAdmin().usingNode(parentFolder).createRuleLink(linkModel);
|
||||
privateAPIForAdmin().usingNode(parentFolder).createRuleLink(linkModel);
|
||||
|
||||
STEP("Create a rule on the child folder.");
|
||||
coreAPIForUser().usingNode(childFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
privateAPIForUser().usingNode(childFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
|
||||
|
||||
STEP("Use the admin user to get both rule sets.");
|
||||
RestRuleSetModelsCollection adminViewOfRuleSets = coreAPIForAdmin().usingNode(childFolder).getListOfRuleSets();
|
||||
RestRuleSetModelsCollection adminViewOfRuleSets = privateAPIForAdmin().usingNode(childFolder).getListOfRuleSets();
|
||||
RestRuleSetModel parentRuleSet = adminViewOfRuleSets.getEntries().get(0).onModel();
|
||||
RestRuleSetModel childRuleSet = adminViewOfRuleSets.getEntries().get(1).onModel();
|
||||
|
||||
STEP("Check the normal user can only view the child rule set.");
|
||||
coreAPIForUser().usingNode(childFolder).getRuleSet(parentRuleSet.getId());
|
||||
privateAPIForUser().usingNode(childFolder).getRuleSet(parentRuleSet.getId());
|
||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
||||
coreAPIForUser().usingNode(childFolder).getRuleSet(childRuleSet.getId());
|
||||
privateAPIForUser().usingNode(childFolder).getRuleSet(childRuleSet.getId());
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
}
|
||||
|
||||
private RestCoreAPI coreAPIForUser()
|
||||
{
|
||||
return restClient.authenticateUser(user).withCoreAPI();
|
||||
}
|
||||
|
||||
private RestCoreAPI coreAPIForAdmin()
|
||||
{
|
||||
return restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI();
|
||||
}
|
||||
|
||||
private RestPrivateAPI privateAPIForUser()
|
||||
{
|
||||
return restClient.authenticateUser(user).withPrivateAPI();
|
||||
}
|
||||
|
||||
private RestPrivateAPI privateAPIForAdmin()
|
||||
{
|
||||
return restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI();
|
||||
}
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ public class GetRulesTests extends RestTest
|
||||
STEP("Create rules in the folder");
|
||||
createdRules = Stream.of("ruleA", "ruleB").map(ruleName -> {
|
||||
RestRuleModel ruleModel = createRuleModel(ruleName);
|
||||
return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
return restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
}).collect(toList());
|
||||
createdRuleA = createdRules.get(0);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class GetRulesTests extends RestTest
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Get the rules that apply to the folder");
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getListOfRules();
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().getListOfRules();
|
||||
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
assertTrue("Expected no rules to be present.", rules.isEmpty());
|
||||
@@ -105,7 +105,7 @@ public class GetRulesTests extends RestTest
|
||||
public void getRulesList()
|
||||
{
|
||||
STEP("Get the rules that apply to the folder");
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().getListOfRules();
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().getListOfRules();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
rules.assertThat().entriesListCountIs(createdRules.size());
|
||||
@@ -123,7 +123,7 @@ public class GetRulesTests extends RestTest
|
||||
STEP("Try to load rules for a non-existent folder.");
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getListOfRules();
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getListOfRules();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class GetRulesTests extends RestTest
|
||||
STEP("Create a folder in existing site");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
STEP("Try to load rules for a non-existent rule set.");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingRuleSet("fake-id").getListOfRules();
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingRuleSet("fake-id").getListOfRules();
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class GetRulesTests extends RestTest
|
||||
public void getRulesListWithIncludedFields()
|
||||
{
|
||||
STEP("Get the rules that apply to the folder");
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include("isShared")
|
||||
.getListOfRules();
|
||||
|
||||
@@ -169,7 +169,7 @@ public class GetRulesTests extends RestTest
|
||||
public void getSingleRule()
|
||||
{
|
||||
STEP("Load a particular rule");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().getSingleRule(createdRuleA.getId());
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().getSingleRule(createdRuleA.getId());
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
|
||||
@@ -187,7 +187,7 @@ public class GetRulesTests extends RestTest
|
||||
ruleModel.setTriggers(List.of("update"));
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues();
|
||||
@@ -208,7 +208,7 @@ public class GetRulesTests extends RestTest
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
UserModel admin = dataUser.getAdminUser();
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
|
||||
@@ -229,7 +229,7 @@ public class GetRulesTests extends RestTest
|
||||
STEP("Try to load a rule from a non-existent folder.");
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getSingleRule("fake-rule-id");
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getSingleRule("fake-rule-id");
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class GetRulesTests extends RestTest
|
||||
STEP("Create a folder in existing site");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
STEP("Try to load rules for a non-existent rule set.");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingRuleSet("fake-id").getSingleRule("fake-rule-id");
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingRuleSet("fake-id").getSingleRule("fake-rule-id");
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ public class GetRulesTests extends RestTest
|
||||
STEP("Create a folder in existing site");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
STEP("Try to load a rule for a wrong but existing folder.");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(createdRuleA.getId());
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(createdRuleA.getId());
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ public class GetRulesTests extends RestTest
|
||||
public void getSingleRuleWithIncludedFields()
|
||||
{
|
||||
STEP("Load a particular rule");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include("isShared")
|
||||
.getSingleRule(createdRuleA.getId());
|
||||
|
||||
@@ -276,10 +276,10 @@ public class GetRulesTests extends RestTest
|
||||
FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder();
|
||||
RestRuleModel ruleModel = new RestRuleModel();
|
||||
ruleModel.setName("Private site rule");
|
||||
restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(privateUser).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
STEP("Try to get the rule with another user");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().getListOfRules();
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().getListOfRules();
|
||||
|
||||
restClient.assertLastError()
|
||||
.statusCodeIs(FORBIDDEN)
|
||||
@@ -294,7 +294,7 @@ public class GetRulesTests extends RestTest
|
||||
SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite();
|
||||
FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder();
|
||||
RestRuleModel ruleModel = createRuleModel("Private site rule");
|
||||
restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(privateUser).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
STEP("Create a collaborator in the private site");
|
||||
UserModel collaborator = dataUser.createRandomTestUser();
|
||||
@@ -302,7 +302,7 @@ public class GetRulesTests extends RestTest
|
||||
restClient.authenticateUser(privateUser).withCoreAPI().usingSite(privateSite).addPerson(collaborator);
|
||||
|
||||
STEP("Check the collaborator can view the rule");
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(collaborator).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().getListOfRules();
|
||||
RestRuleModelsCollection rules = restClient.authenticateUser(collaborator).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().getListOfRules();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
rules.assertThat().entriesListContains("name", "Private site rule");
|
||||
@@ -316,11 +316,11 @@ public class GetRulesTests extends RestTest
|
||||
{
|
||||
STEP("Create a rule with a few actions");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
final RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
final RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
.createSingleRule(createVariousActions());
|
||||
|
||||
STEP("Retrieve the created rule via the GET endpoint");
|
||||
final RestRuleModel getRuleBody = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(rule.getId());
|
||||
final RestRuleModel getRuleBody = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(rule.getId());
|
||||
|
||||
STEP("Assert that actions are returned as expected from the GET endpoint");
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -344,11 +344,11 @@ public class GetRulesTests extends RestTest
|
||||
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Retrieve the created rule via the GET endpoint");
|
||||
final RestRuleModel getRuleBody = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(rule.getId());
|
||||
final RestRuleModel getRuleBody = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().getSingleRule(rule.getId());
|
||||
|
||||
STEP("Assert that conditions are retrieved using the GET endpoint");
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
|
@@ -71,7 +71,7 @@ public class ReorderRules extends RestTest
|
||||
List<RestRuleModel> rules = createRulesInFolder(folder, user);
|
||||
|
||||
STEP("Get the default rule set for the folder including the ordered rule ids");
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(folder)
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
||||
.include("ruleIds").getDefaultRuleSet();
|
||||
|
||||
List<String> expectedRuleIds = rules.stream().map(RestRuleModel::getId).collect(toList());
|
||||
@@ -93,7 +93,7 @@ public class ReorderRules extends RestTest
|
||||
List<RestRuleModel> rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser());
|
||||
|
||||
STEP("Get the rule set with the ordered list of rules");
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.include("ruleIds").getDefaultRuleSet();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -114,7 +114,7 @@ public class ReorderRules extends RestTest
|
||||
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
||||
ruleSetBody.setId("-default-");
|
||||
ruleSetBody.setRuleIds(reversedRuleIds);
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(folder)
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
||||
.include("ruleIds").updateRuleSet(ruleSetBody);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -130,12 +130,12 @@ public class ReorderRules extends RestTest
|
||||
List<RestRuleModel> rules = createRulesInFolder(folder, user);
|
||||
|
||||
STEP("Get the rule set with its id.");
|
||||
RestRuleSetModel ruleSetResponse = restClient.authenticateUser(user).withCoreAPI().usingNode(folder)
|
||||
RestRuleSetModel ruleSetResponse = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
||||
.include("ruleIds").getDefaultRuleSet();
|
||||
|
||||
STEP("Reverse the order of the rules within the rule set");
|
||||
ruleSetResponse.setRuleIds(Lists.reverse(ruleSetResponse.getRuleIds()));
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(folder)
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
|
||||
.include("ruleIds").updateRuleSet(ruleSetResponse);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -161,7 +161,7 @@ public class ReorderRules extends RestTest
|
||||
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
||||
ruleSetBody.setId("-default-");
|
||||
ruleSetBody.setRuleIds(reversedRuleIds);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.include("ruleIds").updateRuleSet(ruleSetBody);
|
||||
|
||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
||||
@@ -185,7 +185,7 @@ public class ReorderRules extends RestTest
|
||||
RestRuleSetModel ruleSetBody = new RestRuleSetModel();
|
||||
ruleSetBody.setId("-default-");
|
||||
ruleSetBody.setRuleIds(reversedRuleIds);
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.include("ruleIds").updateRuleSet(ruleSetBody);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -198,7 +198,7 @@ public class ReorderRules extends RestTest
|
||||
return IntStream.range(0, 3).mapToObj(index ->
|
||||
{
|
||||
RestRuleModel ruleModel = createRuleModelWithDefaultValues();
|
||||
return restClient.authenticateUser(user).withCoreAPI().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
return restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
}).collect(toList());
|
||||
}
|
||||
}
|
||||
|
@@ -80,11 +80,11 @@ public class RuleSetLinksTests extends RestTest
|
||||
|
||||
STEP("Create a rule in the rule folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Get the rule sets for the folder and find the rule set id");
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.getListOfRuleSets();
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
@@ -92,7 +92,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Link to a rule folder");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(ruleFolder.getNodeRef());
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result");
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -101,7 +101,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
ruleLink.assertThat().isEqualTo(expectedLink);
|
||||
|
||||
STEP("Check if folder returns same rules");
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI()
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(folder)
|
||||
.usingDefaultRuleSet()
|
||||
.getListOfRules();
|
||||
@@ -109,7 +109,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
|
||||
|
||||
STEP("Check if folder returns rule set with linked inclusionType");
|
||||
final RestRuleSetModelsCollection linkedRuleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
final RestRuleSetModelsCollection linkedRuleSets = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(folder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
@@ -133,11 +133,11 @@ public class RuleSetLinksTests extends RestTest
|
||||
|
||||
STEP("Create a rule in the rule folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Get the rule sets for the folder and find the rule set id");
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.getListOfRuleSets();
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
@@ -145,7 +145,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Link to a rule set");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(ruleSetId);
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result");
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -154,7 +154,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
ruleLink.assertThat().isEqualTo(expectedLink);
|
||||
|
||||
STEP("Check if folder returns same rules");
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI()
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(folder)
|
||||
.usingDefaultRuleSet()
|
||||
.getListOfRules();
|
||||
@@ -162,7 +162,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
|
||||
|
||||
STEP("Check if folder returns rule set with linked inclusionType");
|
||||
final RestRuleSetModelsCollection likedRuleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
final RestRuleSetModelsCollection likedRuleSets = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(folder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
@@ -186,7 +186,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Link to non-existing rule set");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId("dummy-rule-set-id");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result is 404");
|
||||
restClient.assertStatusCodeIs(NOT_FOUND);
|
||||
@@ -205,7 +205,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Link to a folder without rules");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(folder2.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).createRuleLink(request);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder1).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result is 400");
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST)
|
||||
@@ -224,16 +224,16 @@ public class RuleSetLinksTests extends RestTest
|
||||
|
||||
STEP("Create rules in both folders.");
|
||||
RestRuleModel ruleModel1 = createRuleModel("ruleName1");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder1).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel1);
|
||||
RestRuleModel ruleModel2 = createRuleModel("ruleName2");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder2).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder2).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel2);
|
||||
|
||||
STEP("Link from a folder with rules");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(folder2.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).createRuleLink(request);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder1).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result is 400");
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST)
|
||||
@@ -254,7 +254,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Link to a file node");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(fileContent.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result is 400");
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST)
|
||||
@@ -273,11 +273,11 @@ public class RuleSetLinksTests extends RestTest
|
||||
|
||||
STEP("Create a rule in the parent folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(parentFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Get the rule sets for the folder and find the rule set id");
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder)
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI().usingNode(parentFolder)
|
||||
.getListOfRuleSets();
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
@@ -285,7 +285,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Link to the parent folder");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(parentFolder.getNodeRef());
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).createRuleLink(request);
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withPrivateAPI().usingNode(childFolder).createRuleLink(request);
|
||||
|
||||
STEP("Assert link result");
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -294,7 +294,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
ruleLink.assertThat().isEqualTo(expectedLink);
|
||||
|
||||
STEP("Check if child folder returns same rules");
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI()
|
||||
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(childFolder)
|
||||
.usingDefaultRuleSet()
|
||||
.getListOfRules();
|
||||
@@ -302,7 +302,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
|
||||
|
||||
STEP("Check if child folder returns rule set with linked inclusionType");
|
||||
final RestRuleSetModelsCollection linkedRuleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
final RestRuleSetModelsCollection linkedRuleSets = restClient.authenticateUser(user).withPrivateAPI()
|
||||
.usingNode(childFolder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
@@ -323,14 +323,14 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Use admin to create a private site with a folder containing a rule.");
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createRuleModelWithDefaultValues());
|
||||
|
||||
STEP("Use a normal user to try to link to the rule.");
|
||||
FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(privateFolder.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).createRuleLink(request);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).createRuleLink(request);
|
||||
|
||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
||||
}
|
||||
@@ -344,7 +344,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Use admin to create a private site with a folder containing a rule.");
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createRuleModelWithDefaultValues());
|
||||
|
||||
STEP("Add the normal user as a consumer.");
|
||||
@@ -354,7 +354,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(privateFolder.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).createRuleLink(request);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).createRuleLink(request);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
}
|
||||
@@ -373,11 +373,11 @@ public class RuleSetLinksTests extends RestTest
|
||||
|
||||
STEP("Create a rule in the rule folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
|
||||
STEP("Get the rule sets for the folder and find the rule set id");
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
final RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.getListOfRuleSets();
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
|
||||
@@ -385,23 +385,23 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Link to a rule folder");
|
||||
final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(ruleFolder.getNodeRef());
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withCoreAPI().usingNode(folder).createRuleLink(request);
|
||||
final RestRuleSetLinkModel ruleLink = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).createRuleLink(request);
|
||||
|
||||
STEP("Unlink the rule set");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).unlinkRuleSet(ruleSetId);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).unlinkRuleSet(ruleSetId);
|
||||
|
||||
STEP("Assert unlink result");
|
||||
restClient.assertStatusCodeIs(NO_CONTENT);
|
||||
|
||||
STEP("GET the rule set and isLinkedTo field.");
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder)
|
||||
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
|
||||
.include("isLinkedTo", "linkedToBy", "owningFolder")
|
||||
.getDefaultRuleSet();
|
||||
|
||||
STEP("Assert linkedTo is false.");
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
ruleSet.assertThat().field("isLinkedTo").is(false)
|
||||
.assertThat().field("linkedToBy").isEmpty();;
|
||||
.assertThat().field("linkedToBy").isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,7 +416,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Attempt to unlink the rule set");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).unlinkRuleSet(folder.getNodeRef());
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).unlinkRuleSet(folder.getNodeRef());
|
||||
|
||||
STEP("Assert unlink result");
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST)
|
||||
@@ -436,7 +436,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Attempt to unlink the rule set");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(folder).unlinkRuleSet("non-existent-id");
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).unlinkRuleSet("non-existent-id");
|
||||
|
||||
STEP("Assert unlink result");
|
||||
restClient.assertStatusCodeIs(NOT_FOUND)
|
||||
@@ -452,7 +452,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Use admin to create a private site with a folder containing a rule.");
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createRuleModelWithDefaultValues());
|
||||
|
||||
STEP("Add the user as a consumer.");
|
||||
@@ -462,14 +462,14 @@ public class RuleSetLinksTests extends RestTest
|
||||
FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(privateFolder.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).createRuleLink(request);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).createRuleLink(request);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
STEP("Remove the user from the private site.");
|
||||
dataUser.usingAdmin().removeUserFromSite(user, privateSite);
|
||||
|
||||
STEP("Use the user to try to unlink from the rule set.");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).unlinkRuleSet("-default-");
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).unlinkRuleSet("-default-");
|
||||
|
||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
||||
}
|
||||
@@ -483,7 +483,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Use admin to create a private site with a folder containing a rule.");
|
||||
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
|
||||
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createRuleModelWithDefaultValues());
|
||||
|
||||
STEP("Add the user as a consumer.");
|
||||
@@ -493,11 +493,11 @@ public class RuleSetLinksTests extends RestTest
|
||||
FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
RestRuleSetLinkModel request = new RestRuleSetLinkModel();
|
||||
request.setId(privateFolder.getNodeRef());
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).createRuleLink(request);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).createRuleLink(request);
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
|
||||
STEP("Use the consumer to try to unlink from the rule set.");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).unlinkRuleSet("-default-");
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).unlinkRuleSet("-default-");
|
||||
|
||||
restClient.assertStatusCodeIs(NO_CONTENT);
|
||||
}
|
||||
|
@@ -68,8 +68,8 @@ public class SetInheritanceTests extends RestTest
|
||||
|
||||
STEP("Get the -isInheritanceEnabled- rule settings for the folder.");
|
||||
RestRuleSettingsModel ruleSettingsModel = restClient.authenticateUser(siteOwner)
|
||||
.withCoreAPI()
|
||||
.usingResource(folder)
|
||||
.withPrivateAPI()
|
||||
.usingNode(folder)
|
||||
.usingIsInheritanceEnabledRuleSetting()
|
||||
.retrieveSetting();
|
||||
|
||||
@@ -88,8 +88,8 @@ public class SetInheritanceTests extends RestTest
|
||||
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
|
||||
nonExistentFolder.setNodeRef("fake-id");
|
||||
restClient.authenticateUser(siteOwner)
|
||||
.withCoreAPI()
|
||||
.usingResource(nonExistentFolder)
|
||||
.withPrivateAPI()
|
||||
.usingNode(nonExistentFolder)
|
||||
.usingIsInheritanceEnabledRuleSetting()
|
||||
.retrieveSetting();
|
||||
|
||||
@@ -105,7 +105,7 @@ public class SetInheritanceTests extends RestTest
|
||||
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
|
||||
|
||||
STEP("Try to get a fake setting from the folder.");
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(folder).usingRuleSetting("-fakeRuleSetting-")
|
||||
restClient.authenticateUser(siteOwner).withPrivateAPI().usingNode(folder).usingRuleSetting("-fakeRuleSetting-")
|
||||
.retrieveSetting();
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
@@ -122,8 +122,8 @@ public class SetInheritanceTests extends RestTest
|
||||
|
||||
STEP("Try to get the -isInheritanceEnabled- setting without permission.");
|
||||
restClient.authenticateUser(noPermissionUser)
|
||||
.withCoreAPI()
|
||||
.usingResource(folder)
|
||||
.withPrivateAPI()
|
||||
.usingNode(folder)
|
||||
.usingIsInheritanceEnabledRuleSetting()
|
||||
.retrieveSetting();
|
||||
|
||||
@@ -143,8 +143,8 @@ public class SetInheritanceTests extends RestTest
|
||||
updateBody.setValue(false);
|
||||
|
||||
RestRuleSettingsModel ruleSettingsModel = restClient.authenticateUser(siteOwner)
|
||||
.withCoreAPI()
|
||||
.usingResource(folder)
|
||||
.withPrivateAPI()
|
||||
.usingNode(folder)
|
||||
.usingIsInheritanceEnabledRuleSetting()
|
||||
.updateSetting(updateBody);
|
||||
|
||||
@@ -166,7 +166,7 @@ public class SetInheritanceTests extends RestTest
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue("banana");
|
||||
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(folder).usingIsInheritanceEnabledRuleSetting()
|
||||
restClient.authenticateUser(siteOwner).withPrivateAPI().usingNode(folder).usingIsInheritanceEnabledRuleSetting()
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(BAD_REQUEST)
|
||||
@@ -184,7 +184,7 @@ public class SetInheritanceTests extends RestTest
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue(true);
|
||||
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(nonExistentFolder).usingIsInheritanceEnabledRuleSetting()
|
||||
restClient.authenticateUser(siteOwner).withPrivateAPI().usingNode(nonExistentFolder).usingIsInheritanceEnabledRuleSetting()
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
@@ -202,7 +202,7 @@ public class SetInheritanceTests extends RestTest
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue(true);
|
||||
|
||||
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(folder).usingRuleSetting("-fakeRuleSetting-")
|
||||
restClient.authenticateUser(siteOwner).withPrivateAPI().usingNode(folder).usingRuleSetting("-fakeRuleSetting-")
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
@@ -223,7 +223,7 @@ public class SetInheritanceTests extends RestTest
|
||||
RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
|
||||
updateBody.setValue(true);
|
||||
|
||||
restClient.authenticateUser(collaborator).withCoreAPI().usingResource(folder).usingIsInheritanceEnabledRuleSetting()
|
||||
restClient.authenticateUser(collaborator).withPrivateAPI().usingNode(folder).usingIsInheritanceEnabledRuleSetting()
|
||||
.updateSetting(updateBody);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(FORBIDDEN)
|
||||
|
@@ -97,7 +97,7 @@ public class UpdateRulesTests extends RestTest
|
||||
|
||||
STEP("Try to update the rule.");
|
||||
RestRuleModel updatedRuleModel = createRuleModel("Updated rule name");
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), updatedRuleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -118,7 +118,7 @@ public class UpdateRulesTests extends RestTest
|
||||
|
||||
RestRuleModel updatedRuleModel = new RestRuleModel();
|
||||
updatedRuleModel.setName("Updated rule name");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), updatedRuleModel);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
@@ -134,7 +134,7 @@ public class UpdateRulesTests extends RestTest
|
||||
STEP("Try to update a rule in a non-existent rule set.");
|
||||
RestRuleModel updatedRuleModel = new RestRuleModel();
|
||||
updatedRuleModel.setName("Updated rule name");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingRuleSet("fake-id")
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingRuleSet("fake-id")
|
||||
.updateRule(rule.getId(), updatedRuleModel);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
@@ -148,7 +148,7 @@ public class UpdateRulesTests extends RestTest
|
||||
STEP("Try to update a rule that doesn't exist.");
|
||||
RestRuleModel updatedRuleModel = new RestRuleModel();
|
||||
updatedRuleModel.setName("Updated rule name");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule("fake-id", updatedRuleModel);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(NOT_FOUND)
|
||||
@@ -169,7 +169,7 @@ public class UpdateRulesTests extends RestTest
|
||||
dataUser.addUserToSite(collaborator, privateSite, SiteCollaborator);
|
||||
RestRuleModel ruleModel = new RestRuleModel();
|
||||
ruleModel.setName("ruleName");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
|
||||
|
||||
restClient.assertStatusCodeIs(FORBIDDEN);
|
||||
restClient.assertLastError().containsSummary("Insufficient permissions to manage rules");
|
||||
@@ -183,7 +183,7 @@ public class UpdateRulesTests extends RestTest
|
||||
|
||||
STEP("Try to update the rule to have no name.");
|
||||
RestRuleModel updatedRuleModel = createRuleModel("");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().updateRule(rule.getId(), updatedRuleModel);
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().updateRule(rule.getId(), updatedRuleModel);
|
||||
|
||||
restClient.assertLastError().statusCodeIs(BAD_REQUEST)
|
||||
.containsSummary("Rule name is a mandatory parameter");
|
||||
@@ -198,7 +198,7 @@ public class UpdateRulesTests extends RestTest
|
||||
STEP("Try to update the rule id and check it isn't changed.");
|
||||
RestRuleModel updatedRuleModel = createRuleModel("Rule name");
|
||||
updatedRuleModel.setId("new-rule-id");
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), updatedRuleModel);
|
||||
|
||||
updatedRule.assertThat().field(ID).is(rule.getId());
|
||||
@@ -212,7 +212,7 @@ public class UpdateRulesTests extends RestTest
|
||||
|
||||
STEP("Try to update the rule.");
|
||||
RestRuleModel updatedRuleModel = createRuleModel("Updated rule name");
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include(IS_SHARED)
|
||||
.updateRule(rule.getId(), updatedRuleModel);
|
||||
|
||||
@@ -229,7 +229,7 @@ public class UpdateRulesTests extends RestTest
|
||||
|
||||
STEP("Try to update the rule - set no actions.");
|
||||
rule.setActions(null);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include(IS_SHARED)
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
@@ -251,7 +251,7 @@ public class UpdateRulesTests extends RestTest
|
||||
invalidAction.setActionDefinitionId(actionDefinitionId);
|
||||
invalidAction.setParams(Map.of("dummy-key", "dummy-value"));
|
||||
rule.setActions(List.of(invalidAction));
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include(IS_SHARED)
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
@@ -272,7 +272,7 @@ public class UpdateRulesTests extends RestTest
|
||||
|
||||
STEP("Try to update the rule.");
|
||||
rule.setName("Updated rule name");
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.include(IS_SHARED)
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
@@ -298,7 +298,7 @@ public class UpdateRulesTests extends RestTest
|
||||
rule.setIsAsynchronous(!RULE_ASYNC_DEFAULT);
|
||||
final String updatedErrorScript = "updated-error-script";
|
||||
rule.setErrorScript(updatedErrorScript);
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -315,7 +315,7 @@ public class UpdateRulesTests extends RestTest
|
||||
STEP("Try to update the rule and add conditions.");
|
||||
rule.setConditions(createVariousConditions());
|
||||
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -332,7 +332,7 @@ public class UpdateRulesTests extends RestTest
|
||||
STEP("Try to update the rule and add null conditions.");
|
||||
rule.setConditions(null);
|
||||
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -353,7 +353,7 @@ public class UpdateRulesTests extends RestTest
|
||||
List.of(createCompositeCondition(false, List.of(createSimpleCondition("tag", "equals", "sample_tag")))));
|
||||
rule.setConditions(compositeCondition);
|
||||
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -372,7 +372,7 @@ public class UpdateRulesTests extends RestTest
|
||||
STEP("Try to update the rule and remove all conditions.");
|
||||
rule.setConditions(null);
|
||||
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -393,7 +393,7 @@ public class UpdateRulesTests extends RestTest
|
||||
List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("category", "equals", "fake-category-id")))));
|
||||
rule.setConditions(conditions);
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -413,7 +413,7 @@ public class UpdateRulesTests extends RestTest
|
||||
List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("size", null, "65500")))));
|
||||
rule.setConditions(conditions);
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -433,7 +433,7 @@ public class UpdateRulesTests extends RestTest
|
||||
List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition(null, "greater_than", "65500")))));
|
||||
rule.setConditions(conditions);
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -453,7 +453,7 @@ public class UpdateRulesTests extends RestTest
|
||||
List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("size", "greater_than", "")))));
|
||||
rule.setConditions(conditions);
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -476,7 +476,7 @@ public class UpdateRulesTests extends RestTest
|
||||
final RestActionBodyExecTemplateModel addAspectAction = createCustomActionModel("add-features", addAspectParams);
|
||||
rule.setActions(Arrays.asList(copyAction, addAspectAction));
|
||||
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
final RestRuleModel updatedRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -500,7 +500,7 @@ public class UpdateRulesTests extends RestTest
|
||||
final Map<String, Serializable> scriptParams = Map.of("script-ref", "dummy-script-node-id");
|
||||
rule.setActions(List.of(checkOutAction));
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -524,7 +524,7 @@ public class UpdateRulesTests extends RestTest
|
||||
action.setParams(Map.of(aspectNameParam, paramValue));
|
||||
rule.setActions(List.of(action));
|
||||
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
@@ -538,12 +538,12 @@ public class UpdateRulesTests extends RestTest
|
||||
public void updateRuleWithActions_userCannotUsePrivateAction()
|
||||
{
|
||||
STEP("Using admin create a rule with a private action.");
|
||||
RestRuleModel rule = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createRuleWithPrivateAction());
|
||||
|
||||
STEP("Try to update the rule with a normal user.");
|
||||
rule.setName("Updated name");
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(FORBIDDEN)
|
||||
@@ -555,12 +555,12 @@ public class UpdateRulesTests extends RestTest
|
||||
public void updateRuleWithActions_adminCanUsePrivateAction()
|
||||
{
|
||||
STEP("Using admin create a rule with a private action.");
|
||||
RestRuleModel rule = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel rule = restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(createRuleWithPrivateAction());
|
||||
|
||||
STEP("Try to update the rule with the admin user.");
|
||||
rule.setName("Updated name");
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
RestRuleModel updatedRule = restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.updateRule(rule.getId(), rule);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
@@ -583,7 +583,7 @@ public class UpdateRulesTests extends RestTest
|
||||
{
|
||||
STEP("Create a rule called " + name + ", containing actions: " + restActionModels);
|
||||
RestRuleModel ruleModel = createRuleModel(name, restActionModels);
|
||||
return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
return restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ public class UpdateRulesTests extends RestTest
|
||||
private RestRuleModel createAndSaveRule(final RestRuleModel ruleModel)
|
||||
{
|
||||
STEP("Create a rule: " + ruleModel);
|
||||
return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
return restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
.createSingleRule(ruleModel);
|
||||
}
|
||||
}
|
||||
|
2
pom.xml
2
pom.xml
@@ -122,7 +122,7 @@
|
||||
<dependency.mariadb.version>2.7.4</dependency.mariadb.version>
|
||||
<dependency.tas-utility.version>3.0.56</dependency.tas-utility.version>
|
||||
<dependency.rest-assured.version>5.2.0</dependency.rest-assured.version>
|
||||
<dependency.tas-restapi.version>1.134</dependency.tas-restapi.version>
|
||||
<dependency.tas-restapi.version>1.135</dependency.tas-restapi.version>
|
||||
<dependency.tas-email.version>1.9</dependency.tas-email.version>
|
||||
<dependency.tas-webdav.version>1.7</dependency.tas-webdav.version>
|
||||
<dependency.tas-ftp.version>1.7</dependency.tas-ftp.version>
|
||||
|
@@ -23,12 +23,13 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.api.nodes;
|
||||
package org.alfresco.rest.api.rules;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.api.Rules;
|
||||
import org.alfresco.rest.api.model.rules.RuleExecution;
|
||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
@@ -24,7 +24,7 @@
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.api.nodes;
|
||||
package org.alfresco.rest.api.rules;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.rest.api.RuleSets;
|
||||
import org.alfresco.rest.api.model.rules.RuleSetLink;
|
||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.WebApiParam;
|
||||
import org.alfresco.rest.framework.core.ResourceParameter;
|
@@ -24,12 +24,13 @@
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.api.nodes;
|
||||
package org.alfresco.rest.api.rules;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.rest.api.RuleSets;
|
||||
import org.alfresco.rest.api.model.rules.RuleSet;
|
||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
@@ -1,104 +1,105 @@
|
||||
/*
|
||||
* #%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.api.nodes;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.rest.api.RuleSettings;
|
||||
import org.alfresco.rest.api.model.rules.RuleSetting;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.Experimental;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Folder node rule settings (rule inheritance).
|
||||
*/
|
||||
@Experimental
|
||||
@RelationshipResource (name = "rule-settings", entityResource = NodesEntityResource.class, title = "Folder rule settings")
|
||||
public class NodeRuleSettingsRelation implements RelationshipResourceAction.ReadById<RuleSetting>,
|
||||
RelationshipResourceAction.Update<RuleSetting>,
|
||||
InitializingBean
|
||||
{
|
||||
private RuleSettings ruleSettings;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
PropertyCheck.mandatory(this, "ruleSettings", ruleSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the given configuration value for the specified folder.
|
||||
* <p>
|
||||
* - GET /nodes/{folderId}/rule-settings/{ruleSettingKey}
|
||||
*
|
||||
* @param folderId The id of the folder.
|
||||
* @param ruleSettingKey The setting to retrieve.
|
||||
* @param parameters Unused.
|
||||
* @return {@link RuleSetting} The current value of the setting.
|
||||
*/
|
||||
@WebApiDescription (
|
||||
title = "Get a folder node rule setting",
|
||||
description = "Returns the specified rule setting for the given folder",
|
||||
successStatus = HttpServletResponse.SC_OK
|
||||
)
|
||||
@Override
|
||||
public RuleSetting readById(String folderId, String ruleSettingKey, Parameters parameters) throws RelationshipResourceNotFoundException
|
||||
{
|
||||
return ruleSettings.getRuleSetting(folderId, ruleSettingKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of a rule setting for the specified folder.
|
||||
* <p>
|
||||
* PUT /nodes/{folderId}/rule-settings/{ruleSettingKey}
|
||||
*
|
||||
* @param folderId The id of the folder.
|
||||
* @param ruleSetting The new value of the rule setting.
|
||||
* @param parameters Unused.
|
||||
* @return The updated rule setting.
|
||||
*/
|
||||
@WebApiDescription (
|
||||
title = "Update folder node rule setting",
|
||||
description = "Update a rule setting for given node",
|
||||
successStatus = HttpServletResponse.SC_OK
|
||||
)
|
||||
@Override
|
||||
public RuleSetting update(String folderId, RuleSetting ruleSetting, Parameters parameters)
|
||||
{
|
||||
return ruleSettings.setRuleSetting(folderId, ruleSetting);
|
||||
}
|
||||
|
||||
public void setRuleSettings(RuleSettings ruleSettings)
|
||||
{
|
||||
this.ruleSettings = ruleSettings;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* #%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.api.rules;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.rest.api.RuleSettings;
|
||||
import org.alfresco.rest.api.model.rules.RuleSetting;
|
||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||
import org.alfresco.rest.framework.WebApiDescription;
|
||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
||||
import org.alfresco.rest.framework.resource.RelationshipResource;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.service.Experimental;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Folder node rule settings (rule inheritance).
|
||||
*/
|
||||
@Experimental
|
||||
@RelationshipResource (name = "rule-settings", entityResource = NodesEntityResource.class, title = "Folder rule settings")
|
||||
public class NodeRuleSettingsRelation implements RelationshipResourceAction.ReadById<RuleSetting>,
|
||||
RelationshipResourceAction.Update<RuleSetting>,
|
||||
InitializingBean
|
||||
{
|
||||
private RuleSettings ruleSettings;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
PropertyCheck.mandatory(this, "ruleSettings", ruleSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the given configuration value for the specified folder.
|
||||
* <p>
|
||||
* - GET /nodes/{folderId}/rule-settings/{ruleSettingKey}
|
||||
*
|
||||
* @param folderId The id of the folder.
|
||||
* @param ruleSettingKey The setting to retrieve.
|
||||
* @param parameters Unused.
|
||||
* @return {@link RuleSetting} The current value of the setting.
|
||||
*/
|
||||
@WebApiDescription (
|
||||
title = "Get a folder node rule setting",
|
||||
description = "Returns the specified rule setting for the given folder",
|
||||
successStatus = HttpServletResponse.SC_OK
|
||||
)
|
||||
@Override
|
||||
public RuleSetting readById(String folderId, String ruleSettingKey, Parameters parameters) throws RelationshipResourceNotFoundException
|
||||
{
|
||||
return ruleSettings.getRuleSetting(folderId, ruleSettingKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of a rule setting for the specified folder.
|
||||
* <p>
|
||||
* PUT /nodes/{folderId}/rule-settings/{ruleSettingKey}
|
||||
*
|
||||
* @param folderId The id of the folder.
|
||||
* @param ruleSetting The new value of the rule setting.
|
||||
* @param parameters Unused.
|
||||
* @return The updated rule setting.
|
||||
*/
|
||||
@WebApiDescription (
|
||||
title = "Update folder node rule setting",
|
||||
description = "Update a rule setting for given node",
|
||||
successStatus = HttpServletResponse.SC_OK
|
||||
)
|
||||
@Override
|
||||
public RuleSetting update(String folderId, RuleSetting ruleSetting, Parameters parameters)
|
||||
{
|
||||
return ruleSettings.setRuleSetting(folderId, ruleSetting);
|
||||
}
|
||||
|
||||
public void setRuleSettings(RuleSettings ruleSettings)
|
||||
{
|
||||
this.ruleSettings = ruleSettings;
|
||||
}
|
||||
}
|
@@ -24,7 +24,7 @@
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.api.nodes;
|
||||
package org.alfresco.rest.api.rules;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
@WebApi(name="alfresco", scope=Api.SCOPE.PRIVATE, version=1)
|
||||
package org.alfresco.rest.api.rules;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.WebApi;
|
@@ -869,7 +869,7 @@
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rest.api.nodes.NodeRulesRelation">
|
||||
<bean class="org.alfresco.rest.api.rules.NodeRulesRelation">
|
||||
<property name="rules" ref="Rules" />
|
||||
</bean>
|
||||
|
||||
@@ -902,7 +902,7 @@
|
||||
<property name="ruleMapper" ref="ruleMapper"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rest.api.nodes.NodeRuleSetsRelation">
|
||||
<bean class="org.alfresco.rest.api.rules.NodeRuleSetsRelation">
|
||||
<property name="ruleSets" ref="RuleSets" />
|
||||
</bean>
|
||||
|
||||
@@ -935,11 +935,11 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rest.api.nodes.NodeRuleSetLinksRelation">
|
||||
<bean class="org.alfresco.rest.api.rules.NodeRuleSetLinksRelation">
|
||||
<constructor-arg name="ruleSets" ref="RuleSets" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rest.api.nodes.NodeRuleExecutionsRelation">
|
||||
<bean class="org.alfresco.rest.api.rules.NodeRuleExecutionsRelation">
|
||||
<constructor-arg name="rules" ref="Rules" />
|
||||
</bean>
|
||||
|
||||
@@ -958,7 +958,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean class="org.alfresco.rest.api.nodes.NodeRuleSettingsRelation">
|
||||
<bean class="org.alfresco.rest.api.rules.NodeRuleSettingsRelation">
|
||||
<property name="ruleSettings" ref="RuleSettings" />
|
||||
</bean>
|
||||
|
||||
|
@@ -36,7 +36,8 @@ import org.alfresco.rest.api.impl.rules.NodeValidatorTest;
|
||||
import org.alfresco.rest.api.impl.rules.RuleLoaderTest;
|
||||
import org.alfresco.rest.api.impl.rules.RuleSetsImplTest;
|
||||
import org.alfresco.rest.api.impl.rules.RulesImplTest;
|
||||
import org.alfresco.rest.api.nodes.NodeRulesRelationTest;
|
||||
import org.alfresco.rest.api.rules.NodeRuleSetsRelationTest;
|
||||
import org.alfresco.rest.api.rules.NodeRulesRelationTest;
|
||||
import org.alfresco.service.Experimental;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
@@ -45,6 +46,7 @@ import org.junit.runners.Suite;
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
NodeRulesRelationTest.class,
|
||||
NodeRuleSetsRelationTest.class,
|
||||
RulesImplTest.class,
|
||||
RuleSetsImplTest.class,
|
||||
NodeValidatorTest.class,
|
||||
|
@@ -24,7 +24,7 @@
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.api.nodes;
|
||||
package org.alfresco.rest.api.rules;
|
||||
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
@@ -24,7 +24,7 @@
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.api.nodes;
|
||||
package org.alfresco.rest.api.rules;
|
||||
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
Reference in New Issue
Block a user