Skip to content

Commit 2c4e02e

Browse files
Ajit GeorgeAjit George
authored andcommitted
Verify GraphManager.permissions builder style
1 parent 5425e9f commit 2c4e02e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

test-complete/src/test/java/com/marklogic/client/functionaltest/TestSemanticsGraphManager.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public static void tearDownAfterClass() throws Exception {
6868
tearDownJavaRESTServer(dbName, fNames, restServerName);
6969
deleteRESTUser("eval-user");
7070
deleteUserRole("test-eval");
71+
deleteUserRole("test-perm2");
7172
}
7273

7374
@After
@@ -862,20 +863,28 @@ public void testPermissions_noTrx() throws Exception {
862863
for (Capability capability : perms.get("test-perm")) {
863864
assertTrue("capability should be UPDATE, not [" + capability + "]", capability == Capability.UPDATE);
864865
}
866+
867+
// Create another Role to check for builder style permissions support.
868+
createUserRolesWithPrevilages("test-perm2");
865869

866870
// Set Capability for the User
867-
perms = gmTestPerm.permission("test-perm", Capability.EXECUTE);
871+
perms = gmTestPerm.permission("test-perm", Capability.EXECUTE).permission("test-perm2", Capability.EXECUTE).permission("test-perm2", Capability.READ);
868872
// Merge Permissions
869873
gmTestPerm.mergePermissions(uri, perms);
870874
// gmTestPerm.writePermissions(uri, perms);
871875
// Get Permissions And Validate
872876
perms = gmTestPerm.getPermissions(uri);
873877
System.out.println("Permissions after setting execute , Should see Execute & Update" + gmTestPerm.getPermissions(uri));
874878
for (Capability capability : perms.get("test-perm")) {
875-
assertTrue("capability should be UPDATE && Execute, not [" + capability + "]", capability == Capability.UPDATE
879+
assertTrue("capability for role test-perm should be UPDATE && Execute, not [" + capability + "]", capability == Capability.UPDATE
880+
|| capability == Capability.EXECUTE);
881+
}
882+
for (Capability capability : perms.get("test-perm2")) {
883+
assertTrue("capability for role test-perm2 should be EXECUTE && READ, not [" + capability + "]", capability == Capability.READ
876884
|| capability == Capability.EXECUTE);
877885
}
878886
assertTrue("Did not have expected capabilities", perms.get("test-perm").size() == 2);
887+
assertTrue("Did not have expected capabilities", perms.get("test-perm2").size() == 2);
879888

880889
// Write Read permission to uri and validate permissions are overwritten
881890
// with write
@@ -890,6 +899,7 @@ public void testPermissions_noTrx() throws Exception {
890899
gmTestPerm.deletePermissions(uri);
891900
perms = gmTestPerm.getPermissions(uri);
892901
assertNull(perms.get("test-perm"));
902+
assertNull(perms.get("test-perm2"));
893903

894904
// Set and Write Execute Permission
895905
perms = gmTestPerm.permission("test-perm", Capability.EXECUTE);
@@ -939,7 +949,9 @@ public void testPermissions_noTrx() throws Exception {
939949
String readContent = convertReaderToString(readFile);
940950
assertTrue("Did not get receive expected string content, Received:: " + readContent,
941951
readContent.contains("http://www.daml.org/2001/12/factbook/vi#A113932"));
942-
952+
953+
//Delete the role
954+
deleteUserRole("test-perm2");
943955
}
944956

945957
/*

0 commit comments

Comments
 (0)