airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject [airavata] 12/13: Adding tests for group roles
Date Mon, 11 Dec 2017 19:56:17 GMT
This is an automated email from the ASF dual-hosted git repository.

smarru pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit 0fb711cb3ee1b6c85ad9d04ba75d37dcbd584014
Author: Sachin Kariyattin <sachin9675@gmail.com>
AuthorDate: Tue Dec 5 23:07:08 2017 -0500

    Adding tests for group roles
---
 .../registry/SharingRegistryServerHandlerTest.java     | 18 +++++++++++++++++-
 .../sharing/registry/SharingRegistryServiceTest.java   | 15 +++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
index 0e81e68..bddb0b9 100644
--- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServerHandlerTest.java
@@ -19,7 +19,7 @@
  */
 package org.apache.airavata.sharing.registry;
 
-import junit.framework.Assert;
+import org.junit.Assert;
 import org.apache.airavata.common.exception.ApplicationSettingsException;
 import org.apache.airavata.sharing.registry.models.*;
 import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
@@ -138,6 +138,22 @@ public class SharingRegistryServerHandlerTest {
         Assert.assertTrue(sharingRegistryServerHandler.getGroupMembersOfTypeGroup(domainId,
groupId1, 0, 10).size() == 1);
         Assert.assertTrue(sharingRegistryServerHandler.getGroupMembersOfTypeUser(domainId,
groupId2, 0, 10).size() == 2);
 
+        // Group roles tests
+
+        // user has owner access
+        Assert.assertTrue(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1,
userId1));
+
+        // user has admin access
+        Assert.assertTrue(sharingRegistryServerHandler.addGroupAdmins(domainId, groupId1,
Arrays.asList(userId2)));
+        Assert.assertTrue(sharingRegistryServerHandler.hasAdminAccess(domainId, groupId1,
userId2));
+        Assert.assertTrue(sharingRegistryServerHandler.removeGroupAdmins(domainId, groupId1,
Arrays.asList(userId2)));
+        Assert.assertFalse(sharingRegistryServerHandler.hasAdminAccess(domainId, groupId1,
userId2));
+
+        // transfer group ownership
+        Assert.assertTrue(sharingRegistryServerHandler.transferGroupOwnership(domainId, groupId1,
userId2));
+        Assert.assertTrue(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1,
userId2));
+        Assert.assertTrue(sharingRegistryServerHandler.transferGroupOwnership(domainId, groupId1,
userId1));
+        Assert.assertFalse(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1,
userId2));
 
         //Creating permission types
         PermissionType permissionType1 = new PermissionType();
diff --git a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
index 0957b87..027399e 100644
--- a/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
+++ b/modules/sharing-registry/sharing-registry-server/src/test/java/org/apache/airavata/sharing/registry/SharingRegistryServiceTest.java
@@ -179,6 +179,21 @@ public class SharingRegistryServiceTest {
 
         sharingServiceClient.addChildGroupsToParentGroup(domainId, Arrays.asList("test-group-2"),
"test-group-1");
 
+        //Group roles
+        Assert.assertTrue(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1", "test-user-1"));
+
+        // user has admin access
+        Assert.assertTrue(sharingServiceClient.addGroupAdmins(domainId, "test-group-1", Arrays.asList("test-user-2")));
+        Assert.assertTrue(sharingServiceClient.hasAdminAccess(domainId, "test-group-1", "test-user-2"));
+        Assert.assertTrue(sharingServiceClient.removeGroupAdmins(domainId, "test-group-1",
Arrays.asList("test-user-2")));
+        Assert.assertFalse(sharingServiceClient.hasAdminAccess(domainId, "test-group-1",
"test-user-2"));
+
+        // transfer group ownership
+        Assert.assertTrue(sharingServiceClient.transferGroupOwnership(domainId, "test-group-1",
"test-user-2"));
+        Assert.assertTrue(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1", "test-user-2"));
+        Assert.assertTrue(sharingServiceClient.transferGroupOwnership(domainId, "test-group-1",
"test-user-1"));
+        Assert.assertFalse(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1",
"test-user-2"));
+
         PermissionType permissionType1 = new PermissionType();
         //required
         permissionType1.setPermissionTypeId("READ");

-- 
To stop receiving notification emails like this one, please contact
"commits@airavata.apache.org" <commits@airavata.apache.org>.

Mime
View raw message