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:
Maciej Pichura
2022-10-13 12:38:44 +02:00
committed by GitHub
parent 2ecb64628e
commit 1759364b50
21 changed files with 391 additions and 350 deletions

View File

@@ -100,7 +100,7 @@ public class CreateRulesTests extends RestTest
{ {
RestRuleModel ruleModel = createRuleModelWithModifiedValues(); RestRuleModel ruleModel = createRuleModelWithModifiedValues();
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues(); RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues();
@@ -121,7 +121,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = new RestRuleModel(); RestRuleModel ruleModel = new RestRuleModel();
ruleModel.setName("ruleName"); 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.assertStatusCodeIs(NOT_FOUND);
restClient.assertLastError().containsSummary("Folder with id fake-id was 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(); RestRuleModel ruleModel = new RestRuleModel();
ruleModel.setName("ruleName"); 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.assertStatusCodeIs(NOT_FOUND);
restClient.assertLastError().containsSummary("Rule set with id fake-id was 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(""); 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.assertStatusCodeIs(BAD_REQUEST);
restClient.assertLastError().containsSummary("Rule name is a mandatory parameter"); restClient.assertLastError().containsSummary("Rule name is a mandatory parameter");
@@ -160,8 +160,8 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = createRuleModel("duplicateRuleName"); RestRuleModel ruleModel = createRuleModel("duplicateRuleName");
STEP("Create two identical rules"); STEP("Create two identical rules");
RestRuleModel ruleA = 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).withCoreAPI().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. // Check that the names are the same but the ids are different.
ruleA.assertThat().field("name").is(ruleB.getName()); ruleA.assertThat().field("name").is(ruleB.getName());
@@ -180,7 +180,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = new RestRuleModel(); RestRuleModel ruleModel = new RestRuleModel();
ruleModel.setName("ruleName"); 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.assertStatusCodeIs(FORBIDDEN);
restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); restClient.assertLastError().containsSummary("Insufficient permissions to manage rules");
@@ -232,7 +232,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = new RestRuleModel(); RestRuleModel ruleModel = new RestRuleModel();
ruleModel.setName("ruleName"); 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.assertStatusCodeIs(BAD_REQUEST);
restClient.assertLastError().containsSummary("folder is expected"); restClient.assertLastError().containsSummary("folder is expected");
@@ -246,7 +246,7 @@ public class CreateRulesTests extends RestTest
List<String> ruleNames = List.of("ruleA", "ruleB", "ruleC"); List<String> ruleNames = List.of("ruleA", "ruleB", "ruleC");
List<RestRuleModel> ruleModels = ruleNames.stream().map(RulesTestsUtils::createRuleModel).collect(toList()); 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); .createListOfRules(ruleModels);
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -269,7 +269,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleC = createRuleModel("ruleC"); RestRuleModel ruleC = createRuleModel("ruleC");
List<RestRuleModel> ruleModels = List.of(ruleA, ruleB, 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.assertStatusCodeIs(BAD_REQUEST);
restClient.assertLastError().containsSummary("Rule name is a mandatory parameter"); restClient.assertLastError().containsSummary("Rule name is a mandatory parameter");
@@ -282,7 +282,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
UserModel admin = dataUser.getAdminUser(); UserModel admin = dataUser.getAdminUser();
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -298,7 +298,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
UserModel admin = dataUser.getAdminUser(); UserModel admin = dataUser.getAdminUser();
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -314,7 +314,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
UserModel admin = dataUser.getAdminUser(); UserModel admin = dataUser.getAdminUser();
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -331,7 +331,7 @@ public class CreateRulesTests extends RestTest
ruleModel.setIsShared(true); ruleModel.setIsShared(true);
UserModel admin = dataUser.getAdminUser(); UserModel admin = dataUser.getAdminUser();
RestRuleModel rule = restClient.authenticateUser(admin).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(admin).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -346,7 +346,7 @@ public class CreateRulesTests extends RestTest
{ {
RestRuleModel ruleModel = createRuleModel("ruleName"); RestRuleModel ruleModel = createRuleModel("ruleName");
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.include("isShared") .include("isShared")
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
@@ -365,7 +365,7 @@ public class CreateRulesTests extends RestTest
dataUser.addUserToSite(userWithRole, privateSite, userRole); dataUser.addUserToSite(userWithRole, privateSite, userRole);
RestRuleModel ruleModel = createRuleModel("testRule", List.of(createAddAudioAspectAction())); 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 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()); .createSingleRule(createVariousActions());
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues(); RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
@@ -392,7 +392,7 @@ public class CreateRulesTests extends RestTest
@Test @Test
public void createRuleWithActions_userCannotUsePrivateAction() public void createRuleWithActions_userCannotUsePrivateAction()
{ {
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(createRuleWithPrivateAction()); .createSingleRule(createRuleWithPrivateAction());
restClient.assertStatusCodeIs(FORBIDDEN) restClient.assertStatusCodeIs(FORBIDDEN)
@@ -403,7 +403,7 @@ public class CreateRulesTests extends RestTest
@Test @Test
public void createRuleWithActions_adminCanUsePrivateAction() public void createRuleWithActions_adminCanUsePrivateAction()
{ {
restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(createRuleWithPrivateAction()); .createSingleRule(createRuleWithPrivateAction());
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -418,7 +418,7 @@ public class CreateRulesTests extends RestTest
final RestRuleModel ruleModel = createRuleModelWithDefaultValues(); final RestRuleModel ruleModel = createRuleModelWithDefaultValues();
ruleModel.setActions(null); ruleModel.setActions(null);
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -438,7 +438,7 @@ public class CreateRulesTests extends RestTest
invalidAction.setParams(Map.of("dummy-key", "dummy-value")); invalidAction.setParams(Map.of("dummy-key", "dummy-value"));
ruleModel.setActions(List.of(invalidAction)); ruleModel.setActions(List.of(invalidAction));
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -457,7 +457,7 @@ public class CreateRulesTests extends RestTest
invalidAction.setActionDefinitionId(actionDefinitionId); invalidAction.setActionDefinitionId(actionDefinitionId);
ruleModel.setActions(List.of(invalidAction)); ruleModel.setActions(List.of(invalidAction));
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -479,7 +479,7 @@ public class CreateRulesTests extends RestTest
final RestActionBodyExecTemplateModel scriptAction = createCustomActionModel(actionDefinitionId, Map.of(scriptRef, scriptNodeId)); final RestActionBodyExecTemplateModel scriptAction = createCustomActionModel(actionDefinitionId, Map.of(scriptRef, scriptNodeId));
ruleModel.setActions(List.of(scriptAction)); ruleModel.setActions(List.of(scriptAction));
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -503,7 +503,7 @@ public class CreateRulesTests extends RestTest
invalidAction.setParams(Map.of(invalidParameterKey,"dummyValue")); invalidAction.setParams(Map.of(invalidParameterKey,"dummyValue"));
ruleModel.setActions(List.of(invalidAction)); ruleModel.setActions(List.of(invalidAction));
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -524,7 +524,7 @@ public class CreateRulesTests extends RestTest
invalidAction.setParams(Map.of("deep-copy",false)); invalidAction.setParams(Map.of("deep-copy",false));
ruleModel.setActions(List.of(invalidAction)); ruleModel.setActions(List.of(invalidAction));
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -540,7 +540,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
ruleModel.setConditions(createVariousConditions()); ruleModel.setConditions(createVariousConditions());
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues(); RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
@@ -559,7 +559,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
ruleModel.setConditions(createCompositeCondition(null)); ruleModel.setConditions(createCompositeCondition(null));
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues(); RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
@@ -584,7 +584,7 @@ public class CreateRulesTests extends RestTest
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
ruleModel.setConditions(conditions); 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.assertStatusCodeIs(BAD_REQUEST);
restClient.assertLastError().containsSummary("Category in condition is invalid"); restClient.assertLastError().containsSummary("Category in condition is invalid");

View File

@@ -84,19 +84,19 @@ public class DeleteRulesTests extends RestTest
final List<RestRuleModel> createdRules = Stream.of("ruleA", "ruleB", "ruleC") final List<RestRuleModel> createdRules = Stream.of("ruleA", "ruleB", "ruleC")
.map(ruleName -> { .map(ruleName -> {
RestRuleModel ruleModel = createRuleModel(ruleName); RestRuleModel ruleModel = createRuleModel(ruleName);
return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() return restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
}) })
.collect(toList()); .collect(toList());
STEP("Attempt delete one rule"); STEP("Attempt delete one rule");
final RestRuleModel ruleA = createdRules.get(0); 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); restClient.assertStatusCodeIs(NO_CONTENT);
STEP("Get and check the rules from the folder after deleting one of them"); STEP("Get and check the rules from the folder after deleting one of them");
final RestRuleModelsCollection rulesAfterDeletion = final RestRuleModelsCollection rulesAfterDeletion =
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet().getListOfRules(); restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet().getListOfRules();
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
rulesAfterDeletion.assertThat().entriesListCountIs(createdRules.size() - 1); rulesAfterDeletion.assertThat().entriesListCountIs(createdRules.size() - 1);
Assert.assertTrue(rulesAfterDeletion.getEntries() Assert.assertTrue(rulesAfterDeletion.getEntries()
@@ -127,7 +127,7 @@ public class DeleteRulesTests extends RestTest
nonExistingFolder.setNodeRef(FAKE_NODE_REF); nonExistingFolder.setNodeRef(FAKE_NODE_REF);
STEP("Attempt delete the rule in non-existing folder"); 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); restClient.assertLastError().statusCodeIs(NOT_FOUND);
} }
@@ -142,7 +142,7 @@ public class DeleteRulesTests extends RestTest
final RestRuleModel testRule = createRule(ruleFolder); final RestRuleModel testRule = createRule(ruleFolder);
STEP("Attempt delete the rule in non-existing rule set"); 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); restClient.assertLastError().statusCodeIs(NOT_FOUND);
} }
@@ -155,7 +155,7 @@ public class DeleteRulesTests extends RestTest
{ {
final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder(); final FolderModel ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Attempt delete non-existing rule"); 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); restClient.assertLastError().statusCodeIs(NOT_FOUND);
} }
@@ -173,7 +173,7 @@ public class DeleteRulesTests extends RestTest
final FolderModel anotherFolder = dataContent.usingUser(user).usingSite(site).createFolder(); final FolderModel anotherFolder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Attempt delete an existing rule from a wrong but existing (second) folder"); 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); restClient.assertLastError().statusCodeIs(NOT_FOUND);
} }
@@ -189,11 +189,11 @@ public class DeleteRulesTests extends RestTest
final FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); final FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder();
final RestRuleModel ruleModel = createRuleModel("Private site rule"); final RestRuleModel ruleModel = createRuleModel("Private site rule");
final RestRuleModel createdRule = final RestRuleModel createdRule =
restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet() restClient.authenticateUser(privateUser).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
STEP("Try to delete the rule with another user"); 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); restClient.assertLastError().statusCodeIs(FORBIDDEN);
} }
@@ -213,7 +213,7 @@ public class DeleteRulesTests extends RestTest
restClient.authenticateUser(user).withCoreAPI().usingSite(site).addPerson(siteCollaborator); restClient.authenticateUser(user).withCoreAPI().usingSite(site).addPerson(siteCollaborator);
STEP("Check the manager can delete the rule"); 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()); .deleteRule(testRule.getId());
restClient.assertLastError().statusCodeIs(FORBIDDEN); restClient.assertLastError().statusCodeIs(FORBIDDEN);
@@ -230,7 +230,7 @@ public class DeleteRulesTests extends RestTest
final FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); final FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder();
final RestRuleModel ruleModel = createRuleModel("Private site rule"); final RestRuleModel ruleModel = createRuleModel("Private site rule");
final RestRuleModel createdRule = final RestRuleModel createdRule =
restClient.authenticateUser(privateUser).withCoreAPI().usingNode(privateFolder).usingDefaultRuleSet() restClient.authenticateUser(privateUser).withPrivateAPI().usingNode(privateFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
STEP("Create a manager in the private site"); 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); restClient.authenticateUser(privateUser).withCoreAPI().usingSite(privateSite).addPerson(siteManager);
STEP("Check the manager can delete the rule"); 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()); .deleteRule(createdRule.getId());
restClient.assertStatusCodeIs(NO_CONTENT); restClient.assertStatusCodeIs(NO_CONTENT);
@@ -249,6 +249,6 @@ public class DeleteRulesTests extends RestTest
{ {
STEP("Create a rule in the folder"); STEP("Create a rule in the folder");
final RestRuleModel ruleModel = createRuleModel("Test rule"); 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);
} }
} }

View File

@@ -94,8 +94,8 @@ public class ExecuteRulesTests extends RestTest
RestActionBodyExecTemplateModel addLockableAspectAction = createAddAspectAction(LOCKABLE_ASPECT); RestActionBodyExecTemplateModel addLockableAspectAction = createAddAspectAction(LOCKABLE_ASPECT);
RestRuleModel ruleModel = createRuleModel(RULE_NAME_DEFAULT, List.of(addLockableAspectAction)); RestRuleModel ruleModel = createRuleModel(RULE_NAME_DEFAULT, List.of(addLockableAspectAction));
ruleModel.setIsInheritable(true); ruleModel.setIsInheritable(true);
parentFolderRule = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).usingDefaultRuleSet().createSingleRule(ruleModel); parentFolderRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(parentFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
childFolderRule = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues()); childFolderRule = restClient.authenticateUser(user).withPrivateAPI().usingNode(childFolder).usingDefaultRuleSet().createSingleRule(createRuleModelWithDefaultValues());
} }
/** /**
@@ -110,7 +110,7 @@ public class ExecuteRulesTests extends RestTest
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT); assertThat(fileNode).notContainsAspects(AUDIO_ASPECT);
STEP("Execute rule"); 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); restClient.assertStatusCodeIs(HttpStatus.CREATED);
executionResult.assertThat().field("isEachSubFolderIncluded").is(false); executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
@@ -133,7 +133,7 @@ public class ExecuteRulesTests extends RestTest
STEP("Execute rules including inherited rules"); STEP("Execute rules including inherited rules");
RestRuleExecutionModel ruleExecutionRequest = createRuleExecutionRequest(); 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); restClient.assertStatusCodeIs(HttpStatus.CREATED);
executionResult.assertThat().field("isEachSubFolderIncluded").is(false); executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
@@ -162,7 +162,7 @@ public class ExecuteRulesTests extends RestTest
STEP("Execute rules on parent folder including sub-folders"); STEP("Execute rules on parent folder including sub-folders");
RestRuleExecutionModel ruleExecutionRequest = createRuleExecutionRequest(); RestRuleExecutionModel ruleExecutionRequest = createRuleExecutionRequest();
ruleExecutionRequest.setIsEachSubFolderIncluded(true); 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); restClient.assertStatusCodeIs(HttpStatus.CREATED);
executionResult.assertThat().field("isEachSubFolderIncluded").is(true); executionResult.assertThat().field("isEachSubFolderIncluded").is(true);
@@ -189,7 +189,7 @@ public class ExecuteRulesTests extends RestTest
STEP("Disable child rules"); STEP("Disable child rules");
RestRuleModel updatedChildRule = createRuleModelWithDefaultValues(); RestRuleModel updatedChildRule = createRuleModelWithDefaultValues();
updatedChildRule.setIsEnabled(false); 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"); STEP("Check if file aspects don't contain Audio one");
RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolderFile).getNode(); RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolderFile).getNode();
@@ -197,7 +197,7 @@ public class ExecuteRulesTests extends RestTest
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT); assertThat(fileNode).notContainsAspects(AUDIO_ASPECT);
STEP("Execute rule"); 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); restClient.assertStatusCodeIs(HttpStatus.CREATED);
executionResult.assertThat().field("isEachSubFolderIncluded").is(false); executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
@@ -216,7 +216,7 @@ public class ExecuteRulesTests extends RestTest
STEP("Set parent rule as not inheritable"); STEP("Set parent rule as not inheritable");
RestRuleModel updatedParentRule = createRuleModelWithDefaultValues(); RestRuleModel updatedParentRule = createRuleModelWithDefaultValues();
updatedParentRule.setIsInheritable(false); 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"); STEP("Check if file aspects don't contain Audio and Lockable ones");
RestNodeModel fileNode = restClient.authenticateUser(user).withCoreAPI().usingNode(childFolderFile).getNode(); 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); assertThat(fileNode).notContainsAspects(AUDIO_ASPECT, LOCKABLE_ASPECT);
STEP("Execute child folder rules including inherited rules"); 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); restClient.assertStatusCodeIs(HttpStatus.CREATED);
executionResult.assertThat().field("isEachSubFolderIncluded").is(false); executionResult.assertThat().field("isEachSubFolderIncluded").is(false);
@@ -246,10 +246,10 @@ public class ExecuteRulesTests extends RestTest
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder(); FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
dataContent.usingAdmin().usingResource(privateFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN); 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"); 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); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
} }
@@ -264,11 +264,11 @@ public class ExecuteRulesTests extends RestTest
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder(); FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
dataContent.usingAdmin().usingResource(privateFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN); 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); dataUser.usingAdmin().addUserToSite(contributor, privateSite, UserRole.SiteContributor);
STEP("Try to execute private folder's rules by contributor"); 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); restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
} }
@@ -284,7 +284,7 @@ public class ExecuteRulesTests extends RestTest
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder(); FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder();
FileModel privateFile = dataContent.usingAdmin().usingResource(privateFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN); 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); dataUser.usingAdmin().addUserToSite(collaborator, privateSite, UserRole.SiteCollaborator);
STEP("Check if file aspects don't contain Audio one"); STEP("Check if file aspects don't contain Audio one");
@@ -293,7 +293,7 @@ public class ExecuteRulesTests extends RestTest
assertThat(fileNode).notContainsAspects(AUDIO_ASPECT); assertThat(fileNode).notContainsAspects(AUDIO_ASPECT);
STEP("Execute private folder's rules by collaborator"); 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); restClient.assertStatusCodeIs(HttpStatus.CREATED);
STEP("Check if Audio aspect is present"); STEP("Check if Audio aspect is present");

View File

@@ -73,21 +73,21 @@ public class GetInheritedRulesTests extends RestTest
FolderModel parent = dataContent.usingUser(user).usingSite(site).createFolder(); FolderModel parent = dataContent.usingUser(user).usingSite(site).createFolder();
FolderModel child = dataContent.usingUser(user).usingResource(parent).createFolder(); FolderModel child = dataContent.usingUser(user).usingResource(parent).createFolder();
RestRuleModel parentRule = createRuleModelWithModifiedValues(); 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(); 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"); 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()) rules.assertThat().entriesListContains("id", childRule.getId())
.and().entriesListCountIs(1); .and().entriesListCountIs(1);
STEP("Get the rules in the inherited rule set for the child folder"); 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() String inheritedRuleSetId = ruleSets.getEntries().stream()
.filter(ruleSet -> ruleSet.onModel().getInclusionType().equals("inherited")) .filter(ruleSet -> ruleSet.onModel().getInclusionType().equals("inherited"))
.findFirst().get().onModel().getId(); .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()) inheritedRules.assertThat().entriesListContains("id", parentRule.getId())
.and().entriesListCountIs(1); .and().entriesListCountIs(1);
} }
@@ -111,23 +111,23 @@ public class GetInheritedRulesTests extends RestTest
FolderModel folderB = dataContent.usingUser(user).usingResource(folderA).createFolder(); FolderModel folderB = dataContent.usingUser(user).usingResource(folderA).createFolder();
FolderModel folderC = dataContent.usingUser(user).usingResource(folderB).createFolder(); FolderModel folderC = dataContent.usingUser(user).usingResource(folderB).createFolder();
FolderModel folderD = dataContent.usingUser(user).usingResource(folderC).createFolder(); FolderModel folderD = dataContent.usingUser(user).usingResource(folderC).createFolder();
RestRuleModel ruleB = restClient.authenticateUser(user).withCoreAPI().usingNode(folderB).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues()); RestRuleModel ruleB = restClient.authenticateUser(user).withPrivateAPI().usingNode(folderB).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
RestRuleModel ruleC = restClient.authenticateUser(user).withCoreAPI().usingNode(folderC).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues()); RestRuleModel ruleC = restClient.authenticateUser(user).withPrivateAPI().usingNode(folderC).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
RestRuleModel ruleD = restClient.authenticateUser(user).withCoreAPI().usingNode(folderD).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues()); RestRuleModel ruleD = restClient.authenticateUser(user).withPrivateAPI().usingNode(folderD).usingDefaultRuleSet().createSingleRule(createRuleModelWithModifiedValues());
STEP("Link folderA to ruleSetD"); STEP("Link folderA to ruleSetD");
RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel(); RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel();
linkModel.setId(folderD.getNodeRef()); 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"); 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"); STEP("Check the rules for each rule set are as expected");
List<RestRuleModel> expectedRuleIds = List.of(ruleD, ruleB, ruleC); List<RestRuleModel> expectedRuleIds = List.of(ruleD, ruleB, ruleC);
IntStream.range(0, 2).forEach(index -> { IntStream.range(0, 2).forEach(index -> {
String ruleSetId = ruleSets.get(index).onModel().getId(); String ruleSetId = ruleSets.get(index).onModel().getId();
List<RestRuleModel> rules = restClient.authenticateUser(user) List<RestRuleModel> rules = restClient.authenticateUser(user)
.withCoreAPI() .withPrivateAPI()
.usingNode(folderD) .usingNode(folderD)
.usingRuleSet(ruleSetId) .usingRuleSet(ruleSetId)
.getListOfRules() .getListOfRules()

View File

@@ -46,6 +46,7 @@ import org.alfresco.rest.model.RestRuleSetModel;
import org.alfresco.rest.model.RestRuleSetModelsCollection; import org.alfresco.rest.model.RestRuleSetModelsCollection;
import org.alfresco.rest.model.RestRuleSettingsModel; import org.alfresco.rest.model.RestRuleSettingsModel;
import org.alfresco.rest.requests.coreAPI.RestCoreAPI; import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
import org.alfresco.rest.requests.privateAPI.RestPrivateAPI;
import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.SiteModel;
@@ -83,16 +84,16 @@ public class GetRuleSetsTests extends RestTest
notInheritingChildFolder = dataContent.usingUser(user).usingResource(ruleFolder).createFolder(); notInheritingChildFolder = dataContent.usingUser(user).usingResource(ruleFolder).createFolder();
RestRuleSettingsModel doesntInherit = new RestRuleSettingsModel(); RestRuleSettingsModel doesntInherit = new RestRuleSettingsModel();
doesntInherit.setValue(false); doesntInherit.setValue(false);
restClient.authenticateUser(user).withCoreAPI().usingNode(notInheritingChildFolder) restClient.authenticateUser(user).withPrivateAPI().usingNode(notInheritingChildFolder)
.usingIsInheritanceEnabledRuleSetting().updateSetting(doesntInherit); .usingIsInheritanceEnabledRuleSetting().updateSetting(doesntInherit);
STEP("Create a rule in the folder."); STEP("Create a rule in the folder.");
RestRuleModel ruleModel = createRuleModel("ruleName"); RestRuleModel ruleModel = createRuleModel("ruleName");
rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
STEP("Get the rule sets for the folder and find the rule set id"); 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(); .getListOfRuleSets();
ruleSets.assertThat().entriesListCountIs(1); ruleSets.assertThat().entriesListCountIs(1);
ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); 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."); STEP("Use admin to create a private site containing a rule in a rule set that can be inherited.");
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder(); 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. */ /** 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(); FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Get the rule sets for the folder"); STEP("Get the rule sets for the folder");
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI() RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(folder).getListOfRuleSets(); .usingNode(folder).getListOfRuleSets();
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -123,7 +124,7 @@ public class GetRuleSetsTests extends RestTest
public void getRuleSetsList() public void getRuleSetsList()
{ {
STEP("Get the rule sets for the folder"); 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(); .getListOfRuleSets();
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -139,7 +140,7 @@ public class GetRuleSetsTests extends RestTest
STEP("Try to load rule sets for a non-existent folder."); STEP("Try to load rule sets for a non-existent folder.");
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
nonExistentFolder.setNodeRef("fake-id"); nonExistentFolder.setNodeRef("fake-id");
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).getListOfRuleSets(); restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).getListOfRuleSets();
restClient.assertStatusCodeIs(NOT_FOUND); restClient.assertStatusCodeIs(NOT_FOUND);
} }
@@ -148,7 +149,7 @@ public class GetRuleSetsTests extends RestTest
public void getRuleSetsWithoutPermission() public void getRuleSetsWithoutPermission()
{ {
STEP("Check a user cannot list rule sets without read access."); STEP("Check a user cannot list rule sets without read access.");
coreAPIForUser().usingNode(privateFolder).getListOfRuleSets(); privateAPIForUser().usingNode(privateFolder).getListOfRuleSets();
restClient.assertStatusCodeIs(FORBIDDEN); restClient.assertStatusCodeIs(FORBIDDEN);
} }
@@ -162,24 +163,24 @@ public class GetRuleSetsTests extends RestTest
FolderModel childFolder = dataContent.usingUser(user).usingResource(parentFolder).createFolder(); FolderModel childFolder = dataContent.usingUser(user).usingResource(parentFolder).createFolder();
RestRuleSettingsModel enabled = new RestRuleSettingsModel(); RestRuleSettingsModel enabled = new RestRuleSettingsModel();
enabled.setValue(true); 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."); STEP("Link the parent folder to a private rule set.");
RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel(); RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel();
linkModel.setId(privateFolder.getNodeRef()); linkModel.setId(privateFolder.getNodeRef());
coreAPIForAdmin().usingNode(parentFolder).createRuleLink(linkModel); privateAPIForAdmin().usingNode(parentFolder).createRuleLink(linkModel);
STEP("Create a rule on the child folder."); 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."); STEP("Check admin can view both rule sets.");
RestRuleSetModelsCollection adminViewOfRuleSets = coreAPIForAdmin().usingNode(childFolder).getListOfRuleSets(); RestRuleSetModelsCollection adminViewOfRuleSets = privateAPIForAdmin().usingNode(childFolder).getListOfRuleSets();
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
RestRuleSetModel parentRuleSet = adminViewOfRuleSets.getEntries().get(0).onModel(); RestRuleSetModel parentRuleSet = adminViewOfRuleSets.getEntries().get(0).onModel();
RestRuleSetModel childRuleSet = adminViewOfRuleSets.getEntries().get(1).onModel(); RestRuleSetModel childRuleSet = adminViewOfRuleSets.getEntries().get(1).onModel();
STEP("Check the normal user can only view the child rule set."); 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); restClient.assertStatusCodeIs(OK);
userViewOfRuleSets.assertThat().entriesListContains("id", childRuleSet.getId()) userViewOfRuleSets.assertThat().entriesListContains("id", childRuleSet.getId())
.and().entriesListDoesNotContain("id", parentRuleSet.getId()); .and().entriesListDoesNotContain("id", parentRuleSet.getId());
@@ -190,7 +191,7 @@ public class GetRuleSetsTests extends RestTest
public void getRuleSetsAndOwningFolders() public void getRuleSetsAndOwningFolders()
{ {
STEP("Get the rule sets and owning folders"); STEP("Get the rule sets and owning folders");
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI() RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(ruleFolder) .usingNode(ruleFolder)
.include("owningFolder") .include("owningFolder")
.getListOfRuleSets(); .getListOfRuleSets();
@@ -207,7 +208,7 @@ public class GetRuleSetsTests extends RestTest
public void getRuleSetsAndOwnedInclusionType() public void getRuleSetsAndOwnedInclusionType()
{ {
STEP("Get the rule sets and inclusion type"); STEP("Get the rule sets and inclusion type");
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI() RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(ruleFolder) .usingNode(ruleFolder)
.include("inclusionType") .include("inclusionType")
.getListOfRuleSets(); .getListOfRuleSets();
@@ -224,7 +225,7 @@ public class GetRuleSetsTests extends RestTest
public void getRuleSetsAndInheritedInclusionType() public void getRuleSetsAndInheritedInclusionType()
{ {
STEP("Get the rule sets and inclusion type"); STEP("Get the rule sets and inclusion type");
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI() RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(inheritingChildFolder) .usingNode(inheritingChildFolder)
.include("inclusionType") .include("inclusionType")
.getListOfRuleSets(); .getListOfRuleSets();
@@ -241,7 +242,7 @@ public class GetRuleSetsTests extends RestTest
public void getRuleSetsWithoutInheriting() public void getRuleSetsWithoutInheriting()
{ {
STEP("Get the rule sets and inclusion type"); STEP("Get the rule sets and inclusion type");
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI() RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(notInheritingChildFolder) .usingNode(notInheritingChildFolder)
.getListOfRuleSets(); .getListOfRuleSets();
@@ -254,7 +255,7 @@ public class GetRuleSetsTests extends RestTest
public void getRuleSetById() public void getRuleSetById()
{ {
STEP("Get the rule set using its rule set id"); 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); .getRuleSet(ruleSetId);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -272,7 +273,7 @@ public class GetRuleSetsTests extends RestTest
public void getDefaultRuleSetById() public void getDefaultRuleSetById()
{ {
STEP("Get the default rule set for the folder"); 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(); .getDefaultRuleSet();
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -286,7 +287,7 @@ public class GetRuleSetsTests extends RestTest
STEP("Try to load a rule set for a non-existent folder."); STEP("Try to load a rule set for a non-existent folder.");
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
nonExistentFolder.setNodeRef("fake-id"); nonExistentFolder.setNodeRef("fake-id");
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).getDefaultRuleSet(); restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).getDefaultRuleSet();
restClient.assertStatusCodeIs(NOT_FOUND); restClient.assertStatusCodeIs(NOT_FOUND);
} }
@@ -296,7 +297,7 @@ public class GetRuleSetsTests extends RestTest
{ {
STEP("Get the rule set using fake rule set id"); STEP("Get the rule set using fake rule set id");
String fakeRuleSetId = "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); restClient.assertStatusCodeIs(NOT_FOUND);
} }
@@ -305,7 +306,7 @@ public class GetRuleSetsTests extends RestTest
public void getRuleSetAndOwningFolder() public void getRuleSetAndOwningFolder()
{ {
STEP("Get the rule set and owning folder"); STEP("Get the rule set and owning folder");
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI() RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(ruleFolder) .usingNode(ruleFolder)
.include("owningFolder") .include("owningFolder")
.getRuleSet(ruleSetId); .getRuleSet(ruleSetId);
@@ -349,27 +350,27 @@ public class GetRuleSetsTests extends RestTest
RestRuleSettingsModel nonInheriting = new RestRuleSettingsModel(); RestRuleSettingsModel nonInheriting = new RestRuleSettingsModel();
nonInheriting.setKey(IS_INHERITANCE_ENABLED); nonInheriting.setKey(IS_INHERITANCE_ENABLED);
nonInheriting.setValue(false); 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. // 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 linkingFolder = dataContent.usingUser(user).usingResource(nonInheritingFolder).createFolder();
FolderModel descendantFolder = dataContent.usingUser(user).usingResource(linkingFolder).createFolder(); FolderModel descendantFolder = dataContent.usingUser(user).usingResource(linkingFolder).createFolder();
STEP("Create an inheritable rule in the folder and get the rule set id."); STEP("Create an inheritable rule in the folder and get the rule set id.");
RestRuleModel ruleModel = createRuleModelWithModifiedValues(); RestRuleModel ruleModel = createRuleModelWithModifiedValues();
coreAPIForUser().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel); privateAPIForUser().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel);
RestRuleSetModelsCollection ruleSets = coreAPIForUser().usingNode(folder).getListOfRuleSets(); RestRuleSetModelsCollection ruleSets = privateAPIForUser().usingNode(folder).getListOfRuleSets();
String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
STEP("Create the link to the rule from the linking folder"); STEP("Create the link to the rule from the linking folder");
RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel(); RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel();
ruleSetLink.setId(folder.getNodeRef()); ruleSetLink.setId(folder.getNodeRef());
coreAPIForUser().usingNode(linkingFolder).createRuleLink(ruleSetLink); privateAPIForUser().usingNode(linkingFolder).createRuleLink(ruleSetLink);
STEP("Remove the user from the site"); STEP("Remove the user from the site");
dataUser.removeUserFromSite(user, siteModel); dataUser.removeUserFromSite(user, siteModel);
STEP("Get the rule set and inheriting folders"); STEP("Get the rule set and inheriting folders");
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(folder) RestRuleSetModel ruleSet = privateAPIForUser().usingNode(folder)
.include("inheritedBy") .include("inheritedBy")
.getRuleSet(ruleSetId); .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."); STEP("Create a rule in the folder and link to it from the other two.");
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
RestRuleSetModelsCollection ruleSets = coreAPIForAdmin().usingNode(ruleFolder).getListOfRuleSets(); RestRuleSetModelsCollection ruleSets = privateAPIForAdmin().usingNode(ruleFolder).getListOfRuleSets();
String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel(); RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel();
ruleSetLink.setId(ruleFolder.getNodeRef()); ruleSetLink.setId(ruleFolder.getNodeRef());
coreAPIForUser().usingNode(publicFolder).createRuleLink(ruleSetLink); privateAPIForUser().usingNode(publicFolder).createRuleLink(ruleSetLink);
coreAPIForAdmin().usingNode(privateFolder).createRuleLink(ruleSetLink); privateAPIForAdmin().usingNode(privateFolder).createRuleLink(ruleSetLink);
STEP("Get the rule set and linkedToBy field"); STEP("Get the rule set and linkedToBy field");
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder) RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
.include("linkedToBy") .include("linkedToBy")
.getRuleSet(ruleSetId); .getRuleSet(ruleSetId);
@@ -428,13 +429,13 @@ public class GetRuleSetsTests extends RestTest
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder(); FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
dataContent.usingAdmin().usingResource(ruleFolder).createFolder(); dataContent.usingAdmin().usingResource(ruleFolder).createFolder();
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
STEP("Remove the user from the site"); STEP("Remove the user from the site");
dataUser.removeUserFromSite(user, siteModel); dataUser.removeUserFromSite(user, siteModel);
STEP("Get the rule set and isInherited field"); STEP("Get the rule set and isInherited field");
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder) RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
.include("isInherited", "inheritedBy") .include("isInherited", "inheritedBy")
.getDefaultRuleSet(); .getDefaultRuleSet();
@@ -452,17 +453,17 @@ public class GetRuleSetsTests extends RestTest
SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite(); SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite();
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder(); FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); 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"); STEP("Create a second folder in the site that links to the rule set");
FolderModel secondFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder(); FolderModel secondFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
dataContent.usingUser(user).usingResource(secondFolder).createFolder(); dataContent.usingUser(user).usingResource(secondFolder).createFolder();
RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel(); RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel();
ruleSetLink.setId(ruleFolder.getNodeRef()); ruleSetLink.setId(ruleFolder.getNodeRef());
coreAPIForUser().usingNode(secondFolder).createRuleLink(ruleSetLink); privateAPIForUser().usingNode(secondFolder).createRuleLink(ruleSetLink);
STEP("Get the rule set and isInherited field"); STEP("Get the rule set and isInherited field");
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder) RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
.include("isInherited") .include("isInherited")
.getDefaultRuleSet(); .getDefaultRuleSet();
@@ -480,16 +481,16 @@ public class GetRuleSetsTests extends RestTest
SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite(); SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite();
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder(); FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); 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"); STEP("Create a second folder in the site that links to the rule set");
FolderModel secondFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder(); FolderModel secondFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel(); RestRuleSetLinkModel ruleSetLink = new RestRuleSetLinkModel();
ruleSetLink.setId(ruleFolder.getNodeRef()); ruleSetLink.setId(ruleFolder.getNodeRef());
coreAPIForUser().usingNode(secondFolder).createRuleLink(ruleSetLink); privateAPIForUser().usingNode(secondFolder).createRuleLink(ruleSetLink);
STEP("Get the rule set and isInherited field"); STEP("Get the rule set and isInherited field");
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder) RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
.include("isInherited") .include("isInherited")
.getDefaultRuleSet(); .getDefaultRuleSet();
@@ -509,19 +510,19 @@ public class GetRuleSetsTests extends RestTest
STEP("Create a folder with a rule set"); STEP("Create a folder with a rule set");
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder(); FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); 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"); STEP("Create a private folder linking to the rule set");
FolderModel linkingFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); FolderModel linkingFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel(); RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel();
linkModel.setId(ruleFolder.getNodeRef()); linkModel.setId(ruleFolder.getNodeRef());
coreAPIForAdmin().usingNode(linkingFolder).createRuleLink(linkModel); privateAPIForAdmin().usingNode(linkingFolder).createRuleLink(linkModel);
STEP("Remove the user from the site"); STEP("Remove the user from the site");
dataUser.removeUserFromSite(user, siteModel); dataUser.removeUserFromSite(user, siteModel);
STEP("Get the rule set and isLinkedTo field"); STEP("Get the rule set and isLinkedTo field");
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder) RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
.include("isLinkedTo", "linkedToBy", "owningFolder") .include("isLinkedTo", "linkedToBy", "owningFolder")
.getDefaultRuleSet(); .getDefaultRuleSet();
@@ -541,11 +542,11 @@ public class GetRuleSetsTests extends RestTest
SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite(); SiteModel siteModel = dataSite.usingUser(user).createPublicRandomSite();
FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder(); FolderModel ruleFolder = dataContent.usingUser(user).usingSite(siteModel).createFolder();
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
coreAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel); privateAPIForUser().usingNode(ruleFolder).usingDefaultRuleSet().createSingleRule(ruleModel);
dataContent.usingUser(user).usingResource(ruleFolder).createFolder(); dataContent.usingUser(user).usingResource(ruleFolder).createFolder();
STEP("Get the rule set and isLinkedTo field"); STEP("Get the rule set and isLinkedTo field");
RestRuleSetModel ruleSet = coreAPIForUser().usingNode(ruleFolder) RestRuleSetModel ruleSet = privateAPIForUser().usingNode(ruleFolder)
.include("isLinkedTo") .include("isLinkedTo")
.getDefaultRuleSet(); .getDefaultRuleSet();
@@ -563,35 +564,40 @@ public class GetRuleSetsTests extends RestTest
FolderModel childFolder = dataContent.usingUser(user).usingResource(parentFolder).createFolder(); FolderModel childFolder = dataContent.usingUser(user).usingResource(parentFolder).createFolder();
RestRuleSettingsModel enabled = new RestRuleSettingsModel(); RestRuleSettingsModel enabled = new RestRuleSettingsModel();
enabled.setValue(true); 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."); STEP("Link the parent folder to a private rule set.");
RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel(); RestRuleSetLinkModel linkModel = new RestRuleSetLinkModel();
linkModel.setId(privateFolder.getNodeRef()); linkModel.setId(privateFolder.getNodeRef());
coreAPIForAdmin().usingNode(parentFolder).createRuleLink(linkModel); privateAPIForAdmin().usingNode(parentFolder).createRuleLink(linkModel);
STEP("Create a rule on the child folder."); 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."); 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 parentRuleSet = adminViewOfRuleSets.getEntries().get(0).onModel();
RestRuleSetModel childRuleSet = adminViewOfRuleSets.getEntries().get(1).onModel(); RestRuleSetModel childRuleSet = adminViewOfRuleSets.getEntries().get(1).onModel();
STEP("Check the normal user can only view the child rule set."); 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); restClient.assertStatusCodeIs(FORBIDDEN);
coreAPIForUser().usingNode(childFolder).getRuleSet(childRuleSet.getId()); privateAPIForUser().usingNode(childFolder).getRuleSet(childRuleSet.getId());
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
} }
private RestCoreAPI coreAPIForUser()
{
return restClient.authenticateUser(user).withCoreAPI();
}
private RestCoreAPI coreAPIForAdmin() private RestCoreAPI coreAPIForAdmin()
{ {
return restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI(); return restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI();
} }
private RestPrivateAPI privateAPIForUser()
{
return restClient.authenticateUser(user).withPrivateAPI();
}
private RestPrivateAPI privateAPIForAdmin()
{
return restClient.authenticateUser(dataUser.getAdminUser()).withPrivateAPI();
}
} }

View File

@@ -77,7 +77,7 @@ public class GetRulesTests extends RestTest
STEP("Create rules in the folder"); STEP("Create rules in the folder");
createdRules = Stream.of("ruleA", "ruleB").map(ruleName -> { createdRules = Stream.of("ruleA", "ruleB").map(ruleName -> {
RestRuleModel ruleModel = createRuleModel(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()); }).collect(toList());
createdRuleA = createdRules.get(0); createdRuleA = createdRules.get(0);
} }
@@ -90,7 +90,7 @@ public class GetRulesTests extends RestTest
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Get the rules that apply to the folder"); 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); restClient.assertStatusCodeIs(NOT_FOUND);
assertTrue("Expected no rules to be present.", rules.isEmpty()); assertTrue("Expected no rules to be present.", rules.isEmpty());
@@ -105,7 +105,7 @@ public class GetRulesTests extends RestTest
public void getRulesList() public void getRulesList()
{ {
STEP("Get the rules that apply to the folder"); 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); restClient.assertStatusCodeIs(OK);
rules.assertThat().entriesListCountIs(createdRules.size()); rules.assertThat().entriesListCountIs(createdRules.size());
@@ -123,7 +123,7 @@ public class GetRulesTests extends RestTest
STEP("Try to load rules for a non-existent folder."); STEP("Try to load rules for a non-existent folder.");
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
nonExistentFolder.setNodeRef("fake-id"); nonExistentFolder.setNodeRef("fake-id");
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getListOfRules(); restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).usingDefaultRuleSet().getListOfRules();
restClient.assertStatusCodeIs(NOT_FOUND); restClient.assertStatusCodeIs(NOT_FOUND);
} }
@@ -134,7 +134,7 @@ public class GetRulesTests extends RestTest
STEP("Create a folder in existing site"); STEP("Create a folder in existing site");
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Try to load rules for a non-existent rule set."); 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); restClient.assertStatusCodeIs(NOT_FOUND);
} }
@@ -143,7 +143,7 @@ public class GetRulesTests extends RestTest
public void getRulesListWithIncludedFields() public void getRulesListWithIncludedFields()
{ {
STEP("Get the rules that apply to the folder"); 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") .include("isShared")
.getListOfRules(); .getListOfRules();
@@ -169,7 +169,7 @@ public class GetRulesTests extends RestTest
public void getSingleRule() public void getSingleRule()
{ {
STEP("Load a particular rule"); 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); restClient.assertStatusCodeIs(OK);
@@ -187,7 +187,7 @@ public class GetRulesTests extends RestTest
ruleModel.setTriggers(List.of("update")); ruleModel.setTriggers(List.of("update"));
UserModel admin = dataUser.getAdminUser(); UserModel admin = dataUser.getAdminUser();
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); 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); .createSingleRule(ruleModel);
RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues(); RestRuleModel expectedRuleModel = createRuleModelWithModifiedValues();
@@ -208,7 +208,7 @@ public class GetRulesTests extends RestTest
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); RestRuleModel ruleModel = createRuleModelWithDefaultValues();
UserModel admin = dataUser.getAdminUser(); UserModel admin = dataUser.getAdminUser();
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); 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); .createSingleRule(ruleModel);
RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues(); RestRuleModel expectedRuleModel = createRuleModelWithDefaultValues();
@@ -229,7 +229,7 @@ public class GetRulesTests extends RestTest
STEP("Try to load a rule from a non-existent folder."); STEP("Try to load a rule from a non-existent folder.");
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
nonExistentFolder.setNodeRef("fake-id"); 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); restClient.assertStatusCodeIs(NOT_FOUND);
} }
@@ -240,7 +240,7 @@ public class GetRulesTests extends RestTest
STEP("Create a folder in existing site"); STEP("Create a folder in existing site");
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Try to load rules for a non-existent rule set."); 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); restClient.assertStatusCodeIs(NOT_FOUND);
} }
@@ -251,7 +251,7 @@ public class GetRulesTests extends RestTest
STEP("Create a folder in existing site"); STEP("Create a folder in existing site");
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Try to load a rule for a wrong but existing folder."); 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); restClient.assertStatusCodeIs(NOT_FOUND);
} }
@@ -260,7 +260,7 @@ public class GetRulesTests extends RestTest
public void getSingleRuleWithIncludedFields() public void getSingleRuleWithIncludedFields()
{ {
STEP("Load a particular rule"); 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") .include("isShared")
.getSingleRule(createdRuleA.getId()); .getSingleRule(createdRuleA.getId());
@@ -276,10 +276,10 @@ public class GetRulesTests extends RestTest
FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder();
RestRuleModel ruleModel = new RestRuleModel(); RestRuleModel ruleModel = new RestRuleModel();
ruleModel.setName("Private site rule"); 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"); 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() restClient.assertLastError()
.statusCodeIs(FORBIDDEN) .statusCodeIs(FORBIDDEN)
@@ -294,7 +294,7 @@ public class GetRulesTests extends RestTest
SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite(); SiteModel privateSite = dataSite.usingUser(privateUser).createPrivateRandomSite();
FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder(); FolderModel privateFolder = dataContent.usingUser(privateUser).usingSite(privateSite).createFolder();
RestRuleModel ruleModel = createRuleModel("Private site rule"); 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"); STEP("Create a collaborator in the private site");
UserModel collaborator = dataUser.createRandomTestUser(); UserModel collaborator = dataUser.createRandomTestUser();
@@ -302,7 +302,7 @@ public class GetRulesTests extends RestTest
restClient.authenticateUser(privateUser).withCoreAPI().usingSite(privateSite).addPerson(collaborator); restClient.authenticateUser(privateUser).withCoreAPI().usingSite(privateSite).addPerson(collaborator);
STEP("Check the collaborator can view the rule"); 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); restClient.assertStatusCodeIs(OK);
rules.assertThat().entriesListContains("name", "Private site rule"); rules.assertThat().entriesListContains("name", "Private site rule");
@@ -316,11 +316,11 @@ public class GetRulesTests extends RestTest
{ {
STEP("Create a rule with a few actions"); STEP("Create a rule with a few actions");
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); 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()); .createSingleRule(createVariousActions());
STEP("Retrieve the created rule via the GET endpoint"); 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"); STEP("Assert that actions are returned as expected from the GET endpoint");
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -344,11 +344,11 @@ public class GetRulesTests extends RestTest
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); 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); .createSingleRule(ruleModel);
STEP("Retrieve the created rule via the GET endpoint"); 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"); STEP("Assert that conditions are retrieved using the GET endpoint");
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);

View File

@@ -71,7 +71,7 @@ public class ReorderRules extends RestTest
List<RestRuleModel> rules = createRulesInFolder(folder, user); List<RestRuleModel> rules = createRulesInFolder(folder, user);
STEP("Get the default rule set for the folder including the ordered rule ids"); 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(); .include("ruleIds").getDefaultRuleSet();
List<String> expectedRuleIds = rules.stream().map(RestRuleModel::getId).collect(toList()); 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()); List<RestRuleModel> rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser());
STEP("Get the rule set with the ordered list of rules"); 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(); .include("ruleIds").getDefaultRuleSet();
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -114,7 +114,7 @@ public class ReorderRules extends RestTest
RestRuleSetModel ruleSetBody = new RestRuleSetModel(); RestRuleSetModel ruleSetBody = new RestRuleSetModel();
ruleSetBody.setId("-default-"); ruleSetBody.setId("-default-");
ruleSetBody.setRuleIds(reversedRuleIds); ruleSetBody.setRuleIds(reversedRuleIds);
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(folder) RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder)
.include("ruleIds").updateRuleSet(ruleSetBody); .include("ruleIds").updateRuleSet(ruleSetBody);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -130,12 +130,12 @@ public class ReorderRules extends RestTest
List<RestRuleModel> rules = createRulesInFolder(folder, user); List<RestRuleModel> rules = createRulesInFolder(folder, user);
STEP("Get the rule set with its id."); 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(); .include("ruleIds").getDefaultRuleSet();
STEP("Reverse the order of the rules within the rule set"); STEP("Reverse the order of the rules within the rule set");
ruleSetResponse.setRuleIds(Lists.reverse(ruleSetResponse.getRuleIds())); 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); .include("ruleIds").updateRuleSet(ruleSetResponse);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -161,7 +161,7 @@ public class ReorderRules extends RestTest
RestRuleSetModel ruleSetBody = new RestRuleSetModel(); RestRuleSetModel ruleSetBody = new RestRuleSetModel();
ruleSetBody.setId("-default-"); ruleSetBody.setId("-default-");
ruleSetBody.setRuleIds(reversedRuleIds); ruleSetBody.setRuleIds(reversedRuleIds);
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
.include("ruleIds").updateRuleSet(ruleSetBody); .include("ruleIds").updateRuleSet(ruleSetBody);
restClient.assertStatusCodeIs(FORBIDDEN); restClient.assertStatusCodeIs(FORBIDDEN);
@@ -185,7 +185,7 @@ public class ReorderRules extends RestTest
RestRuleSetModel ruleSetBody = new RestRuleSetModel(); RestRuleSetModel ruleSetBody = new RestRuleSetModel();
ruleSetBody.setId("-default-"); ruleSetBody.setId("-default-");
ruleSetBody.setRuleIds(reversedRuleIds); ruleSetBody.setRuleIds(reversedRuleIds);
RestRuleSetModel ruleSet = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder) RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder)
.include("ruleIds").updateRuleSet(ruleSetBody); .include("ruleIds").updateRuleSet(ruleSetBody);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -198,7 +198,7 @@ public class ReorderRules extends RestTest
return IntStream.range(0, 3).mapToObj(index -> return IntStream.range(0, 3).mapToObj(index ->
{ {
RestRuleModel ruleModel = createRuleModelWithDefaultValues(); 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()); }).collect(toList());
} }
} }

View File

@@ -80,11 +80,11 @@ public class RuleSetLinksTests extends RestTest
STEP("Create a rule in the rule folder."); STEP("Create a rule in the rule folder.");
RestRuleModel ruleModel = createRuleModel("ruleName"); RestRuleModel ruleModel = createRuleModel("ruleName");
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
STEP("Get the rule sets for the folder and find the rule set id"); 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(); .getListOfRuleSets();
ruleSets.assertThat().entriesListCountIs(1); ruleSets.assertThat().entriesListCountIs(1);
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
@@ -92,7 +92,7 @@ public class RuleSetLinksTests extends RestTest
STEP("Link to a rule folder"); STEP("Link to a rule folder");
final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(ruleFolder.getNodeRef()); 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"); STEP("Assert link result");
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -101,7 +101,7 @@ public class RuleSetLinksTests extends RestTest
ruleLink.assertThat().isEqualTo(expectedLink); ruleLink.assertThat().isEqualTo(expectedLink);
STEP("Check if folder returns same rules"); STEP("Check if folder returns same rules");
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI() final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(folder) .usingNode(folder)
.usingDefaultRuleSet() .usingDefaultRuleSet()
.getListOfRules(); .getListOfRules();
@@ -109,7 +109,7 @@ public class RuleSetLinksTests extends RestTest
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule); linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
STEP("Check if folder returns rule set with linked inclusionType"); 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) .usingNode(folder)
.include("inclusionType") .include("inclusionType")
.getListOfRuleSets(); .getListOfRuleSets();
@@ -133,11 +133,11 @@ public class RuleSetLinksTests extends RestTest
STEP("Create a rule in the rule folder."); STEP("Create a rule in the rule folder.");
RestRuleModel ruleModel = createRuleModel("ruleName"); RestRuleModel ruleModel = createRuleModel("ruleName");
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
STEP("Get the rule sets for the folder and find the rule set id"); 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(); .getListOfRuleSets();
ruleSets.assertThat().entriesListCountIs(1); ruleSets.assertThat().entriesListCountIs(1);
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
@@ -145,7 +145,7 @@ public class RuleSetLinksTests extends RestTest
STEP("Link to a rule set"); STEP("Link to a rule set");
final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(ruleSetId); 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"); STEP("Assert link result");
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -154,7 +154,7 @@ public class RuleSetLinksTests extends RestTest
ruleLink.assertThat().isEqualTo(expectedLink); ruleLink.assertThat().isEqualTo(expectedLink);
STEP("Check if folder returns same rules"); STEP("Check if folder returns same rules");
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI() final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(folder) .usingNode(folder)
.usingDefaultRuleSet() .usingDefaultRuleSet()
.getListOfRules(); .getListOfRules();
@@ -162,7 +162,7 @@ public class RuleSetLinksTests extends RestTest
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule); linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
STEP("Check if folder returns rule set with linked inclusionType"); 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) .usingNode(folder)
.include("inclusionType") .include("inclusionType")
.getListOfRuleSets(); .getListOfRuleSets();
@@ -186,7 +186,7 @@ public class RuleSetLinksTests extends RestTest
STEP("Link to non-existing rule set"); STEP("Link to non-existing rule set");
final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId("dummy-rule-set-id"); 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"); STEP("Assert link result is 404");
restClient.assertStatusCodeIs(NOT_FOUND); restClient.assertStatusCodeIs(NOT_FOUND);
@@ -205,7 +205,7 @@ public class RuleSetLinksTests extends RestTest
STEP("Link to a folder without rules"); STEP("Link to a folder without rules");
final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(folder2.getNodeRef()); 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"); STEP("Assert link result is 400");
restClient.assertStatusCodeIs(BAD_REQUEST) restClient.assertStatusCodeIs(BAD_REQUEST)
@@ -224,16 +224,16 @@ public class RuleSetLinksTests extends RestTest
STEP("Create rules in both folders."); STEP("Create rules in both folders.");
RestRuleModel ruleModel1 = createRuleModel("ruleName1"); RestRuleModel ruleModel1 = createRuleModel("ruleName1");
restClient.authenticateUser(user).withCoreAPI().usingNode(folder1).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(folder1).usingDefaultRuleSet()
.createSingleRule(ruleModel1); .createSingleRule(ruleModel1);
RestRuleModel ruleModel2 = createRuleModel("ruleName2"); RestRuleModel ruleModel2 = createRuleModel("ruleName2");
restClient.authenticateUser(user).withCoreAPI().usingNode(folder2).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(folder2).usingDefaultRuleSet()
.createSingleRule(ruleModel2); .createSingleRule(ruleModel2);
STEP("Link from a folder with rules"); STEP("Link from a folder with rules");
final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(folder2.getNodeRef()); 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"); STEP("Assert link result is 400");
restClient.assertStatusCodeIs(BAD_REQUEST) restClient.assertStatusCodeIs(BAD_REQUEST)
@@ -254,7 +254,7 @@ public class RuleSetLinksTests extends RestTest
STEP("Link to a file node"); STEP("Link to a file node");
final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(fileContent.getNodeRef()); 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"); STEP("Assert link result is 400");
restClient.assertStatusCodeIs(BAD_REQUEST) restClient.assertStatusCodeIs(BAD_REQUEST)
@@ -273,11 +273,11 @@ public class RuleSetLinksTests extends RestTest
STEP("Create a rule in the parent folder."); STEP("Create a rule in the parent folder.");
RestRuleModel ruleModel = createRuleModel("ruleName"); RestRuleModel ruleModel = createRuleModel("ruleName");
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(parentFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(parentFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
STEP("Get the rule sets for the folder and find the rule set id"); 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(); .getListOfRuleSets();
ruleSets.assertThat().entriesListCountIs(1); ruleSets.assertThat().entriesListCountIs(1);
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
@@ -285,7 +285,7 @@ public class RuleSetLinksTests extends RestTest
STEP("Link to the parent folder"); STEP("Link to the parent folder");
final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(parentFolder.getNodeRef()); 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"); STEP("Assert link result");
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
@@ -294,7 +294,7 @@ public class RuleSetLinksTests extends RestTest
ruleLink.assertThat().isEqualTo(expectedLink); ruleLink.assertThat().isEqualTo(expectedLink);
STEP("Check if child folder returns same rules"); STEP("Check if child folder returns same rules");
final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withCoreAPI() final RestRuleModelsCollection linkedRules = restClient.authenticateUser(user).withPrivateAPI()
.usingNode(childFolder) .usingNode(childFolder)
.usingDefaultRuleSet() .usingDefaultRuleSet()
.getListOfRules(); .getListOfRules();
@@ -302,7 +302,7 @@ public class RuleSetLinksTests extends RestTest
linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule); linkedRules.getEntries().get(0).onModel().assertThat().isEqualTo(rule);
STEP("Check if child folder returns rule set with linked inclusionType"); 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) .usingNode(childFolder)
.include("inclusionType") .include("inclusionType")
.getListOfRuleSets(); .getListOfRuleSets();
@@ -323,14 +323,14 @@ public class RuleSetLinksTests extends RestTest
STEP("Use admin to create a private site with a folder containing a rule."); STEP("Use admin to create a private site with a folder containing a rule.");
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder(); 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()); .createSingleRule(createRuleModelWithDefaultValues());
STEP("Use a normal user to try to link to the rule."); STEP("Use a normal user to try to link to the rule.");
FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder(); FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder();
RestRuleSetLinkModel request = new RestRuleSetLinkModel(); RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(privateFolder.getNodeRef()); request.setId(privateFolder.getNodeRef());
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).createRuleLink(request); restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).createRuleLink(request);
restClient.assertStatusCodeIs(FORBIDDEN); 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."); STEP("Use admin to create a private site with a folder containing a rule.");
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder(); 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()); .createSingleRule(createRuleModelWithDefaultValues());
STEP("Add the normal user as a consumer."); 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(); FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder();
RestRuleSetLinkModel request = new RestRuleSetLinkModel(); RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(privateFolder.getNodeRef()); request.setId(privateFolder.getNodeRef());
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).createRuleLink(request); restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).createRuleLink(request);
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
} }
@@ -373,11 +373,11 @@ public class RuleSetLinksTests extends RestTest
STEP("Create a rule in the rule folder."); STEP("Create a rule in the rule folder.");
RestRuleModel ruleModel = createRuleModel("ruleName"); RestRuleModel ruleModel = createRuleModel("ruleName");
RestRuleModel rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() RestRuleModel rule = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
STEP("Get the rule sets for the folder and find the rule set id"); 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(); .getListOfRuleSets();
ruleSets.assertThat().entriesListCountIs(1); ruleSets.assertThat().entriesListCountIs(1);
final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId(); final String ruleSetId = ruleSets.getEntries().get(0).onModel().getId();
@@ -385,23 +385,23 @@ public class RuleSetLinksTests extends RestTest
STEP("Link to a rule folder"); STEP("Link to a rule folder");
final RestRuleSetLinkModel request = new RestRuleSetLinkModel(); final RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(ruleFolder.getNodeRef()); 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"); 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"); STEP("Assert unlink result");
restClient.assertStatusCodeIs(NO_CONTENT); restClient.assertStatusCodeIs(NO_CONTENT);
STEP("GET the rule set and isLinkedTo field."); 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") .include("isLinkedTo", "linkedToBy", "owningFolder")
.getDefaultRuleSet(); .getDefaultRuleSet();
STEP("Assert linkedTo is false."); STEP("Assert linkedTo is false.");
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
ruleSet.assertThat().field("isLinkedTo").is(false) 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(); final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Attempt to unlink the rule set"); 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"); STEP("Assert unlink result");
restClient.assertStatusCodeIs(BAD_REQUEST) restClient.assertStatusCodeIs(BAD_REQUEST)
@@ -436,7 +436,7 @@ public class RuleSetLinksTests extends RestTest
final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); final FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
STEP("Attempt to unlink the rule set"); 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"); STEP("Assert unlink result");
restClient.assertStatusCodeIs(NOT_FOUND) 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."); STEP("Use admin to create a private site with a folder containing a rule.");
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder(); 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()); .createSingleRule(createRuleModelWithDefaultValues());
STEP("Add the user as a consumer."); STEP("Add the user as a consumer.");
@@ -462,14 +462,14 @@ public class RuleSetLinksTests extends RestTest
FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder(); FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder();
RestRuleSetLinkModel request = new RestRuleSetLinkModel(); RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(privateFolder.getNodeRef()); request.setId(privateFolder.getNodeRef());
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).createRuleLink(request); restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).createRuleLink(request);
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
STEP("Remove the user from the private site."); STEP("Remove the user from the private site.");
dataUser.usingAdmin().removeUserFromSite(user, privateSite); dataUser.usingAdmin().removeUserFromSite(user, privateSite);
STEP("Use the user to try to unlink from the rule set."); 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); 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."); STEP("Use admin to create a private site with a folder containing a rule.");
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite(); SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FolderModel privateFolder = dataContent.usingAdmin().usingSite(privateSite).createFolder(); 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()); .createSingleRule(createRuleModelWithDefaultValues());
STEP("Add the user as a consumer."); STEP("Add the user as a consumer.");
@@ -493,11 +493,11 @@ public class RuleSetLinksTests extends RestTest
FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder(); FolderModel publicFolder = dataContent.usingUser(user).usingSite(site).createFolder();
RestRuleSetLinkModel request = new RestRuleSetLinkModel(); RestRuleSetLinkModel request = new RestRuleSetLinkModel();
request.setId(privateFolder.getNodeRef()); request.setId(privateFolder.getNodeRef());
restClient.authenticateUser(user).withCoreAPI().usingNode(publicFolder).createRuleLink(request); restClient.authenticateUser(user).withPrivateAPI().usingNode(publicFolder).createRuleLink(request);
restClient.assertStatusCodeIs(CREATED); restClient.assertStatusCodeIs(CREATED);
STEP("Use the consumer to try to unlink from the rule set."); 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); restClient.assertStatusCodeIs(NO_CONTENT);
} }

View File

@@ -68,8 +68,8 @@ public class SetInheritanceTests extends RestTest
STEP("Get the -isInheritanceEnabled- rule settings for the folder."); STEP("Get the -isInheritanceEnabled- rule settings for the folder.");
RestRuleSettingsModel ruleSettingsModel = restClient.authenticateUser(siteOwner) RestRuleSettingsModel ruleSettingsModel = restClient.authenticateUser(siteOwner)
.withCoreAPI() .withPrivateAPI()
.usingResource(folder) .usingNode(folder)
.usingIsInheritanceEnabledRuleSetting() .usingIsInheritanceEnabledRuleSetting()
.retrieveSetting(); .retrieveSetting();
@@ -88,8 +88,8 @@ public class SetInheritanceTests extends RestTest
FolderModel nonExistentFolder = FolderModel.getRandomFolderModel(); FolderModel nonExistentFolder = FolderModel.getRandomFolderModel();
nonExistentFolder.setNodeRef("fake-id"); nonExistentFolder.setNodeRef("fake-id");
restClient.authenticateUser(siteOwner) restClient.authenticateUser(siteOwner)
.withCoreAPI() .withPrivateAPI()
.usingResource(nonExistentFolder) .usingNode(nonExistentFolder)
.usingIsInheritanceEnabledRuleSetting() .usingIsInheritanceEnabledRuleSetting()
.retrieveSetting(); .retrieveSetting();
@@ -105,7 +105,7 @@ public class SetInheritanceTests extends RestTest
FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder(); FolderModel folder = dataContent.usingUser(siteOwner).usingSite(site).createFolder();
STEP("Try to get a fake setting from the folder."); 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(); .retrieveSetting();
restClient.assertLastError().statusCodeIs(NOT_FOUND) restClient.assertLastError().statusCodeIs(NOT_FOUND)
@@ -122,8 +122,8 @@ public class SetInheritanceTests extends RestTest
STEP("Try to get the -isInheritanceEnabled- setting without permission."); STEP("Try to get the -isInheritanceEnabled- setting without permission.");
restClient.authenticateUser(noPermissionUser) restClient.authenticateUser(noPermissionUser)
.withCoreAPI() .withPrivateAPI()
.usingResource(folder) .usingNode(folder)
.usingIsInheritanceEnabledRuleSetting() .usingIsInheritanceEnabledRuleSetting()
.retrieveSetting(); .retrieveSetting();
@@ -143,8 +143,8 @@ public class SetInheritanceTests extends RestTest
updateBody.setValue(false); updateBody.setValue(false);
RestRuleSettingsModel ruleSettingsModel = restClient.authenticateUser(siteOwner) RestRuleSettingsModel ruleSettingsModel = restClient.authenticateUser(siteOwner)
.withCoreAPI() .withPrivateAPI()
.usingResource(folder) .usingNode(folder)
.usingIsInheritanceEnabledRuleSetting() .usingIsInheritanceEnabledRuleSetting()
.updateSetting(updateBody); .updateSetting(updateBody);
@@ -166,7 +166,7 @@ public class SetInheritanceTests extends RestTest
RestRuleSettingsModel updateBody = new RestRuleSettingsModel(); RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
updateBody.setValue("banana"); updateBody.setValue("banana");
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(folder).usingIsInheritanceEnabledRuleSetting() restClient.authenticateUser(siteOwner).withPrivateAPI().usingNode(folder).usingIsInheritanceEnabledRuleSetting()
.updateSetting(updateBody); .updateSetting(updateBody);
restClient.assertLastError().statusCodeIs(BAD_REQUEST) restClient.assertLastError().statusCodeIs(BAD_REQUEST)
@@ -184,7 +184,7 @@ public class SetInheritanceTests extends RestTest
RestRuleSettingsModel updateBody = new RestRuleSettingsModel(); RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
updateBody.setValue(true); updateBody.setValue(true);
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(nonExistentFolder).usingIsInheritanceEnabledRuleSetting() restClient.authenticateUser(siteOwner).withPrivateAPI().usingNode(nonExistentFolder).usingIsInheritanceEnabledRuleSetting()
.updateSetting(updateBody); .updateSetting(updateBody);
restClient.assertLastError().statusCodeIs(NOT_FOUND) restClient.assertLastError().statusCodeIs(NOT_FOUND)
@@ -202,7 +202,7 @@ public class SetInheritanceTests extends RestTest
RestRuleSettingsModel updateBody = new RestRuleSettingsModel(); RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
updateBody.setValue(true); updateBody.setValue(true);
restClient.authenticateUser(siteOwner).withCoreAPI().usingResource(folder).usingRuleSetting("-fakeRuleSetting-") restClient.authenticateUser(siteOwner).withPrivateAPI().usingNode(folder).usingRuleSetting("-fakeRuleSetting-")
.updateSetting(updateBody); .updateSetting(updateBody);
restClient.assertLastError().statusCodeIs(NOT_FOUND) restClient.assertLastError().statusCodeIs(NOT_FOUND)
@@ -223,7 +223,7 @@ public class SetInheritanceTests extends RestTest
RestRuleSettingsModel updateBody = new RestRuleSettingsModel(); RestRuleSettingsModel updateBody = new RestRuleSettingsModel();
updateBody.setValue(true); updateBody.setValue(true);
restClient.authenticateUser(collaborator).withCoreAPI().usingResource(folder).usingIsInheritanceEnabledRuleSetting() restClient.authenticateUser(collaborator).withPrivateAPI().usingNode(folder).usingIsInheritanceEnabledRuleSetting()
.updateSetting(updateBody); .updateSetting(updateBody);
restClient.assertLastError().statusCodeIs(FORBIDDEN) restClient.assertLastError().statusCodeIs(FORBIDDEN)

View File

@@ -97,7 +97,7 @@ public class UpdateRulesTests extends RestTest
STEP("Try to update the rule."); STEP("Try to update the rule.");
RestRuleModel updatedRuleModel = createRuleModel("Updated rule name"); 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); .updateRule(rule.getId(), updatedRuleModel);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -118,7 +118,7 @@ public class UpdateRulesTests extends RestTest
RestRuleModel updatedRuleModel = new RestRuleModel(); RestRuleModel updatedRuleModel = new RestRuleModel();
updatedRuleModel.setName("Updated rule name"); updatedRuleModel.setName("Updated rule name");
restClient.authenticateUser(user).withCoreAPI().usingNode(nonExistentFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(nonExistentFolder).usingDefaultRuleSet()
.updateRule(rule.getId(), updatedRuleModel); .updateRule(rule.getId(), updatedRuleModel);
restClient.assertLastError().statusCodeIs(NOT_FOUND) 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."); STEP("Try to update a rule in a non-existent rule set.");
RestRuleModel updatedRuleModel = new RestRuleModel(); RestRuleModel updatedRuleModel = new RestRuleModel();
updatedRuleModel.setName("Updated rule name"); 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); .updateRule(rule.getId(), updatedRuleModel);
restClient.assertLastError().statusCodeIs(NOT_FOUND) restClient.assertLastError().statusCodeIs(NOT_FOUND)
@@ -148,7 +148,7 @@ public class UpdateRulesTests extends RestTest
STEP("Try to update a rule that doesn't exist."); STEP("Try to update a rule that doesn't exist.");
RestRuleModel updatedRuleModel = new RestRuleModel(); RestRuleModel updatedRuleModel = new RestRuleModel();
updatedRuleModel.setName("Updated rule name"); updatedRuleModel.setName("Updated rule name");
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.updateRule("fake-id", updatedRuleModel); .updateRule("fake-id", updatedRuleModel);
restClient.assertLastError().statusCodeIs(NOT_FOUND) restClient.assertLastError().statusCodeIs(NOT_FOUND)
@@ -169,7 +169,7 @@ public class UpdateRulesTests extends RestTest
dataUser.addUserToSite(collaborator, privateSite, SiteCollaborator); dataUser.addUserToSite(collaborator, privateSite, SiteCollaborator);
RestRuleModel ruleModel = new RestRuleModel(); RestRuleModel ruleModel = new RestRuleModel();
ruleModel.setName("ruleName"); 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.assertStatusCodeIs(FORBIDDEN);
restClient.assertLastError().containsSummary("Insufficient permissions to manage rules"); 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."); STEP("Try to update the rule to have no name.");
RestRuleModel updatedRuleModel = createRuleModel(""); 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) restClient.assertLastError().statusCodeIs(BAD_REQUEST)
.containsSummary("Rule name is a mandatory parameter"); .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."); STEP("Try to update the rule id and check it isn't changed.");
RestRuleModel updatedRuleModel = createRuleModel("Rule name"); RestRuleModel updatedRuleModel = createRuleModel("Rule name");
updatedRuleModel.setId("new-rule-id"); 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); .updateRule(rule.getId(), updatedRuleModel);
updatedRule.assertThat().field(ID).is(rule.getId()); updatedRule.assertThat().field(ID).is(rule.getId());
@@ -212,7 +212,7 @@ public class UpdateRulesTests extends RestTest
STEP("Try to update the rule."); STEP("Try to update the rule.");
RestRuleModel updatedRuleModel = createRuleModel("Updated rule name"); 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) .include(IS_SHARED)
.updateRule(rule.getId(), updatedRuleModel); .updateRule(rule.getId(), updatedRuleModel);
@@ -229,7 +229,7 @@ public class UpdateRulesTests extends RestTest
STEP("Try to update the rule - set no actions."); STEP("Try to update the rule - set no actions.");
rule.setActions(null); rule.setActions(null);
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.include(IS_SHARED) .include(IS_SHARED)
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
@@ -251,7 +251,7 @@ public class UpdateRulesTests extends RestTest
invalidAction.setActionDefinitionId(actionDefinitionId); invalidAction.setActionDefinitionId(actionDefinitionId);
invalidAction.setParams(Map.of("dummy-key", "dummy-value")); invalidAction.setParams(Map.of("dummy-key", "dummy-value"));
rule.setActions(List.of(invalidAction)); rule.setActions(List.of(invalidAction));
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.include(IS_SHARED) .include(IS_SHARED)
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
@@ -272,7 +272,7 @@ public class UpdateRulesTests extends RestTest
STEP("Try to update the rule."); STEP("Try to update the rule.");
rule.setName("Updated rule name"); 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) .include(IS_SHARED)
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
@@ -298,7 +298,7 @@ public class UpdateRulesTests extends RestTest
rule.setIsAsynchronous(!RULE_ASYNC_DEFAULT); rule.setIsAsynchronous(!RULE_ASYNC_DEFAULT);
final String updatedErrorScript = "updated-error-script"; final String updatedErrorScript = "updated-error-script";
rule.setErrorScript(updatedErrorScript); 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); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -315,7 +315,7 @@ public class UpdateRulesTests extends RestTest
STEP("Try to update the rule and add conditions."); STEP("Try to update the rule and add conditions.");
rule.setConditions(createVariousConditions()); 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); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -332,7 +332,7 @@ public class UpdateRulesTests extends RestTest
STEP("Try to update the rule and add null conditions."); STEP("Try to update the rule and add null conditions.");
rule.setConditions(null); 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); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -353,7 +353,7 @@ public class UpdateRulesTests extends RestTest
List.of(createCompositeCondition(false, List.of(createSimpleCondition("tag", "equals", "sample_tag"))))); List.of(createCompositeCondition(false, List.of(createSimpleCondition("tag", "equals", "sample_tag")))));
rule.setConditions(compositeCondition); 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); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -372,7 +372,7 @@ public class UpdateRulesTests extends RestTest
STEP("Try to update the rule and remove all conditions."); STEP("Try to update the rule and remove all conditions.");
rule.setConditions(null); 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); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -393,7 +393,7 @@ public class UpdateRulesTests extends RestTest
List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("category", "equals", "fake-category-id"))))); List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("category", "equals", "fake-category-id")))));
rule.setConditions(conditions); rule.setConditions(conditions);
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -413,7 +413,7 @@ public class UpdateRulesTests extends RestTest
List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("size", null, "65500"))))); List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("size", null, "65500")))));
rule.setConditions(conditions); rule.setConditions(conditions);
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -433,7 +433,7 @@ public class UpdateRulesTests extends RestTest
List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition(null, "greater_than", "65500"))))); List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition(null, "greater_than", "65500")))));
rule.setConditions(conditions); rule.setConditions(conditions);
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -453,7 +453,7 @@ public class UpdateRulesTests extends RestTest
List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("size", "greater_than", ""))))); List.of(createCompositeCondition(!INVERTED, List.of(createSimpleCondition("size", "greater_than", "")))));
rule.setConditions(conditions); rule.setConditions(conditions);
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -476,7 +476,7 @@ public class UpdateRulesTests extends RestTest
final RestActionBodyExecTemplateModel addAspectAction = createCustomActionModel("add-features", addAspectParams); final RestActionBodyExecTemplateModel addAspectAction = createCustomActionModel("add-features", addAspectParams);
rule.setActions(Arrays.asList(copyAction, addAspectAction)); 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); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(OK); 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"); final Map<String, Serializable> scriptParams = Map.of("script-ref", "dummy-script-node-id");
rule.setActions(List.of(checkOutAction)); rule.setActions(List.of(checkOutAction));
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -524,7 +524,7 @@ public class UpdateRulesTests extends RestTest
action.setParams(Map.of(aspectNameParam, paramValue)); action.setParams(Map.of(aspectNameParam, paramValue));
rule.setActions(List.of(action)); rule.setActions(List.of(action));
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(BAD_REQUEST); restClient.assertStatusCodeIs(BAD_REQUEST);
@@ -538,12 +538,12 @@ public class UpdateRulesTests extends RestTest
public void updateRuleWithActions_userCannotUsePrivateAction() public void updateRuleWithActions_userCannotUsePrivateAction()
{ {
STEP("Using admin create a rule with a private action."); 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()); .createSingleRule(createRuleWithPrivateAction());
STEP("Try to update the rule with a normal user."); STEP("Try to update the rule with a normal user.");
rule.setName("Updated name"); rule.setName("Updated name");
restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.updateRule(rule.getId(), rule); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(FORBIDDEN) restClient.assertStatusCodeIs(FORBIDDEN)
@@ -555,12 +555,12 @@ public class UpdateRulesTests extends RestTest
public void updateRuleWithActions_adminCanUsePrivateAction() public void updateRuleWithActions_adminCanUsePrivateAction()
{ {
STEP("Using admin create a rule with a private action."); 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()); .createSingleRule(createRuleWithPrivateAction());
STEP("Try to update the rule with the admin user."); STEP("Try to update the rule with the admin user.");
rule.setName("Updated name"); 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); .updateRule(rule.getId(), rule);
restClient.assertStatusCodeIs(OK); restClient.assertStatusCodeIs(OK);
@@ -583,7 +583,7 @@ public class UpdateRulesTests extends RestTest
{ {
STEP("Create a rule called " + name + ", containing actions: " + restActionModels); STEP("Create a rule called " + name + ", containing actions: " + restActionModels);
RestRuleModel ruleModel = createRuleModel(name, restActionModels); RestRuleModel ruleModel = createRuleModel(name, restActionModels);
return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() return restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
} }
@@ -596,7 +596,7 @@ public class UpdateRulesTests extends RestTest
private RestRuleModel createAndSaveRule(final RestRuleModel ruleModel) private RestRuleModel createAndSaveRule(final RestRuleModel ruleModel)
{ {
STEP("Create a rule: " + ruleModel); STEP("Create a rule: " + ruleModel);
return restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet() return restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder).usingDefaultRuleSet()
.createSingleRule(ruleModel); .createSingleRule(ruleModel);
} }
} }

View File

@@ -122,7 +122,7 @@
<dependency.mariadb.version>2.7.4</dependency.mariadb.version> <dependency.mariadb.version>2.7.4</dependency.mariadb.version>
<dependency.tas-utility.version>3.0.56</dependency.tas-utility.version> <dependency.tas-utility.version>3.0.56</dependency.tas-utility.version>
<dependency.rest-assured.version>5.2.0</dependency.rest-assured.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-email.version>1.9</dependency.tas-email.version>
<dependency.tas-webdav.version>1.7</dependency.tas-webdav.version> <dependency.tas-webdav.version>1.7</dependency.tas-webdav.version>
<dependency.tas-ftp.version>1.7</dependency.tas-ftp.version> <dependency.tas-ftp.version>1.7</dependency.tas-ftp.version>

View File

@@ -23,12 +23,13 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.rest.api.nodes; package org.alfresco.rest.api.rules;
import java.util.List; import java.util.List;
import org.alfresco.rest.api.Rules; import org.alfresco.rest.api.Rules;
import org.alfresco.rest.api.model.rules.RuleExecution; 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.RelationshipResource;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction; import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.parameters.Parameters; import org.alfresco.rest.framework.resource.parameters.Parameters;

View File

@@ -24,7 +24,7 @@
* #L% * #L%
*/ */
package org.alfresco.rest.api.nodes; package org.alfresco.rest.api.rules;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; 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.RuleSets;
import org.alfresco.rest.api.model.rules.RuleSetLink; 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.WebApiDescription;
import org.alfresco.rest.framework.WebApiParam; import org.alfresco.rest.framework.WebApiParam;
import org.alfresco.rest.framework.core.ResourceParameter; import org.alfresco.rest.framework.core.ResourceParameter;

View File

@@ -24,12 +24,13 @@
* #L% * #L%
*/ */
package org.alfresco.rest.api.nodes; package org.alfresco.rest.api.rules;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.alfresco.rest.api.RuleSets; import org.alfresco.rest.api.RuleSets;
import org.alfresco.rest.api.model.rules.RuleSet; 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.WebApiDescription;
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
import org.alfresco.rest.framework.resource.RelationshipResource; import org.alfresco.rest.framework.resource.RelationshipResource;

View File

@@ -1,104 +1,105 @@
/* /*
* #%L * #%L
* Alfresco Remote API * Alfresco Remote API
* %% * %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of * If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is * the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms: * provided under the following open source license terms:
* *
* Alfresco is free software: you can redistribute it and/or modify * Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Alfresco is distributed in the hope that it will be useful, * Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.rest.api.nodes; package org.alfresco.rest.api.rules;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.alfresco.rest.api.RuleSettings; import org.alfresco.rest.api.RuleSettings;
import org.alfresco.rest.api.model.rules.RuleSetting; import org.alfresco.rest.api.model.rules.RuleSetting;
import org.alfresco.rest.framework.WebApiDescription; import org.alfresco.rest.api.nodes.NodesEntityResource;
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.resource.RelationshipResource; import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction; import org.alfresco.rest.framework.resource.RelationshipResource;
import org.alfresco.rest.framework.resource.parameters.Parameters; import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.service.Experimental; import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.util.PropertyCheck; import org.alfresco.service.Experimental;
import org.springframework.beans.factory.InitializingBean; import org.alfresco.util.PropertyCheck;
import org.springframework.beans.factory.InitializingBean;
/**
* Folder node rule settings (rule inheritance). /**
*/ * Folder node rule settings (rule inheritance).
@Experimental */
@RelationshipResource (name = "rule-settings", entityResource = NodesEntityResource.class, title = "Folder rule settings") @Experimental
public class NodeRuleSettingsRelation implements RelationshipResourceAction.ReadById<RuleSetting>, @RelationshipResource (name = "rule-settings", entityResource = NodesEntityResource.class, title = "Folder rule settings")
RelationshipResourceAction.Update<RuleSetting>, public class NodeRuleSettingsRelation implements RelationshipResourceAction.ReadById<RuleSetting>,
InitializingBean RelationshipResourceAction.Update<RuleSetting>,
{ InitializingBean
private RuleSettings ruleSettings; {
private RuleSettings ruleSettings;
@Override
public void afterPropertiesSet() throws Exception @Override
{ public void afterPropertiesSet() throws Exception
PropertyCheck.mandatory(this, "ruleSettings", ruleSettings); {
} PropertyCheck.mandatory(this, "ruleSettings", ruleSettings);
}
/**
* Get the given configuration value for the specified folder. /**
* <p> * Get the given configuration value for the specified folder.
* - GET /nodes/{folderId}/rule-settings/{ruleSettingKey} * <p>
* * - GET /nodes/{folderId}/rule-settings/{ruleSettingKey}
* @param folderId The id of the folder. *
* @param ruleSettingKey The setting to retrieve. * @param folderId The id of the folder.
* @param parameters Unused. * @param ruleSettingKey The setting to retrieve.
* @return {@link RuleSetting} The current value of the setting. * @param parameters Unused.
*/ * @return {@link RuleSetting} The current value of the setting.
@WebApiDescription ( */
title = "Get a folder node rule setting", @WebApiDescription (
description = "Returns the specified rule setting for the given folder", title = "Get a folder node rule setting",
successStatus = HttpServletResponse.SC_OK 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 @Override
{ public RuleSetting readById(String folderId, String ruleSettingKey, Parameters parameters) throws RelationshipResourceNotFoundException
return ruleSettings.getRuleSetting(folderId, ruleSettingKey); {
} return ruleSettings.getRuleSetting(folderId, ruleSettingKey);
}
/**
* Set the value of a rule setting for the specified folder. /**
* <p> * Set the value of a rule setting for the specified folder.
* PUT /nodes/{folderId}/rule-settings/{ruleSettingKey} * <p>
* * PUT /nodes/{folderId}/rule-settings/{ruleSettingKey}
* @param folderId The id of the folder. *
* @param ruleSetting The new value of the rule setting. * @param folderId The id of the folder.
* @param parameters Unused. * @param ruleSetting The new value of the rule setting.
* @return The updated rule setting. * @param parameters Unused.
*/ * @return The updated rule setting.
@WebApiDescription ( */
title = "Update folder node rule setting", @WebApiDescription (
description = "Update a rule setting for given node", title = "Update folder node rule setting",
successStatus = HttpServletResponse.SC_OK description = "Update a rule setting for given node",
) successStatus = HttpServletResponse.SC_OK
@Override )
public RuleSetting update(String folderId, RuleSetting ruleSetting, Parameters parameters) @Override
{ public RuleSetting update(String folderId, RuleSetting ruleSetting, Parameters parameters)
return ruleSettings.setRuleSetting(folderId, ruleSetting); {
} return ruleSettings.setRuleSetting(folderId, ruleSetting);
}
public void setRuleSettings(RuleSettings ruleSettings)
{ public void setRuleSettings(RuleSettings ruleSettings)
this.ruleSettings = ruleSettings; {
} this.ruleSettings = ruleSettings;
} }
}

View File

@@ -24,7 +24,7 @@
* #L% * #L%
*/ */
package org.alfresco.rest.api.nodes; package org.alfresco.rest.api.rules;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;

View File

@@ -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;

View File

@@ -869,7 +869,7 @@
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
</bean> </bean>
<bean class="org.alfresco.rest.api.nodes.NodeRulesRelation"> <bean class="org.alfresco.rest.api.rules.NodeRulesRelation">
<property name="rules" ref="Rules" /> <property name="rules" ref="Rules" />
</bean> </bean>
@@ -902,7 +902,7 @@
<property name="ruleMapper" ref="ruleMapper"/> <property name="ruleMapper" ref="ruleMapper"/>
</bean> </bean>
<bean class="org.alfresco.rest.api.nodes.NodeRuleSetsRelation"> <bean class="org.alfresco.rest.api.rules.NodeRuleSetsRelation">
<property name="ruleSets" ref="RuleSets" /> <property name="ruleSets" ref="RuleSets" />
</bean> </bean>
@@ -935,11 +935,11 @@
</property> </property>
</bean> </bean>
<bean class="org.alfresco.rest.api.nodes.NodeRuleSetLinksRelation"> <bean class="org.alfresco.rest.api.rules.NodeRuleSetLinksRelation">
<constructor-arg name="ruleSets" ref="RuleSets" /> <constructor-arg name="ruleSets" ref="RuleSets" />
</bean> </bean>
<bean class="org.alfresco.rest.api.nodes.NodeRuleExecutionsRelation"> <bean class="org.alfresco.rest.api.rules.NodeRuleExecutionsRelation">
<constructor-arg name="rules" ref="Rules" /> <constructor-arg name="rules" ref="Rules" />
</bean> </bean>
@@ -958,7 +958,7 @@
</property> </property>
</bean> </bean>
<bean class="org.alfresco.rest.api.nodes.NodeRuleSettingsRelation"> <bean class="org.alfresco.rest.api.rules.NodeRuleSettingsRelation">
<property name="ruleSettings" ref="RuleSettings" /> <property name="ruleSettings" ref="RuleSettings" />
</bean> </bean>

View File

@@ -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.RuleLoaderTest;
import org.alfresco.rest.api.impl.rules.RuleSetsImplTest; import org.alfresco.rest.api.impl.rules.RuleSetsImplTest;
import org.alfresco.rest.api.impl.rules.RulesImplTest; 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.alfresco.service.Experimental;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;
@@ -45,6 +46,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class) @RunWith(Suite.class)
@Suite.SuiteClasses({ @Suite.SuiteClasses({
NodeRulesRelationTest.class, NodeRulesRelationTest.class,
NodeRuleSetsRelationTest.class,
RulesImplTest.class, RulesImplTest.class,
RuleSetsImplTest.class, RuleSetsImplTest.class,
NodeValidatorTest.class, NodeValidatorTest.class,

View File

@@ -24,7 +24,7 @@
* #L% * #L%
*/ */
package org.alfresco.rest.api.nodes; package org.alfresco.rest.api.rules;
import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.then;

View File

@@ -24,7 +24,7 @@
* #L% * #L%
*/ */
package org.alfresco.rest.api.nodes; package org.alfresco.rest.api.rules;
import static org.mockito.BDDMockito.then; import static org.mockito.BDDMockito.then;