You are viewing a plain text version of this content. The canonical link for it is here.
Posted to custos@airavata.apache.org by GitBox <gi...@apache.org> on 2020/06/15 17:14:10 UTC

[GitHub] [airavata-custos] virendrawali opened a new pull request #76: Add test cases for user management client

virendrawali opened a new pull request #76:
URL: https://github.com/apache/airavata-custos/pull/76


   ## Overview
   Add test cases for user management python sdk in custos. 
   
   ## Description 
   Adding test cases for following APIs
   -  'find users', 
   - 'enable users', 
   - 'get user',
   - 'register user',
   - 'is username available',
   - 'add user attributes',
   - 'delete user attributes',
   - 'add user roles',
   - 'delete user roles',
   - 'delete user', 
        
   ## Types of changes
   <!--- What types of changes does your code introduce? Use `x` in all the boxes that apply: -->
   - [ ] Bug fix (generally a non-breaking change which closes an issue).
   - [x] Enhancement or new feature (adds new functionality).
   - [ ] Breaking change (a bug fix or enhancement which changes existing behavior).
   
   ## Checklist
   - [x] Code is written and works correctly
   - [x] Changes are covered by tests


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airavata-custos] virendrawali commented on a change in pull request #76: Add test cases for user management client

Posted by GitBox <gi...@apache.org>.
virendrawali commented on a change in pull request #76:
URL: https://github.com/apache/airavata-custos/pull/76#discussion_r442997805



##########
File path: custos-client-sdks/custos-python-sdk/tests/test_tenant_management_client.py
##########
@@ -0,0 +1,82 @@
+import pytest
+
+import logging
+from clients.tenant_management_client import TenantManagementClient
+from clients.super_tenant_management_client import SuperTenantManagementClient
+from clients.identity_management_client import IdentityManagementClient
+from custos.integration import TenantManagementService_pb2
+from transport.settings import CustosServerClientSettings
+import clients.utils.utilities as utl
+
+logger = logging.getLogger(__name__)
+
+logger.setLevel(logging.DEBUG)
+# create console handler with a higher log level
+handler = logging.StreamHandler()
+handler.setLevel(logging.DEBUG)
+
+# load APIServerClient with default configuration
+client = TenantManagementClient()
+admin_client = SuperTenantManagementClient()
+id_client = IdentityManagementClient()
+custos_settings = CustosServerClientSettings()
+token = utl.get_token(custos_settings)
+
+
+class TestTenantManagementClient:
+    client_name = "SAMPLE"
+    requester_email = "XXX@iu.edu"
+    contacts = ["2345634324"]
+    redirect_uris = ["http://localhost:8080,http://localhost:8080/user/external_ids"]
+    admin_first_name = "Admin First Name"
+    admin_last_name = "LastName"
+    admin_email = "email"
+    client_uri = "https://domain.org/"
+    scope =  "openid profile email org.cilogon.userinfo"
+    domain = "domain.org"
+    logo_uri = "https://domain.org/static/favicon.png"
+    comment = "Galaxy Portal"
+
+    @pytest.fixture
+    def tenant(self):
+        return client.create_admin_tenant(self.client_name,
+                                          self.requester_email,
+                                          self.admin_first_name,
+                                          self.admin_last_name,
+                                          self.admin_email,
+                                          "admin",
+                                          "1234",
+                                          self.contacts,
+                                          self.redirect_uris,
+                                          self.client_uri,
+                                          self.scope,
+                                          self.domain,
+                                          self.logo_uri,
+                                          self.comment)
+
+    def test_create_tenant(self, tenant):
+        assert type(tenant) is TenantManagementService_pb2.CreateTenantResponse
+
+    def test_get_tenant(self, tenant):
+        client_id = tenant.client_id
+        response = client.get_tenant(client_token=token, client_id=client_id)
+        print(response)
+        assert type(response) is TenantManagementService_pb2.GetTenantResponse
+        assert response.client_id == tenant.client_id
+        assert response.client_name == self.client_name
+        assert response.requester_email == self.requester_email
+        assert response.admin_first_name == self.admin_first_name
+        assert response.admin_last_name == self.admin_last_name
+        assert response.admin_email == self.admin_email
+        assert all([a == b for a, b in zip(response.contacts, self.contacts)])
+        assert all([a == b for a, b in zip(response.redirect_uris, self.redirect_uris)])
+        assert response.scope == self.scope
+        assert response.domain == self.domain
+        assert response.logo_uri == self.logo_uri

Review comment:
       Assert statement is failing here. Could you please check. @isururanawaka 
   
   '''
   >       assert response.logo_uri == self.logo_uri
   E       AssertionError: assert 'https://domain.org/' == 'https://doma...c/favicon.png'
   E         - https://domain.org/static/favicon.png
   E         + https://domain.org/
   '''




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airavata-custos] virendrawali commented on a change in pull request #76: Add test cases for user management client

Posted by GitBox <gi...@apache.org>.
virendrawali commented on a change in pull request #76:
URL: https://github.com/apache/airavata-custos/pull/76#discussion_r443160103



##########
File path: custos-client-sdks/custos-python-sdk/tests/test_tenant_management_client.py
##########
@@ -0,0 +1,82 @@
+import pytest
+
+import logging
+from clients.tenant_management_client import TenantManagementClient
+from clients.super_tenant_management_client import SuperTenantManagementClient
+from clients.identity_management_client import IdentityManagementClient
+from custos.integration import TenantManagementService_pb2
+from transport.settings import CustosServerClientSettings
+import clients.utils.utilities as utl
+
+logger = logging.getLogger(__name__)
+
+logger.setLevel(logging.DEBUG)
+# create console handler with a higher log level
+handler = logging.StreamHandler()
+handler.setLevel(logging.DEBUG)
+
+# load APIServerClient with default configuration
+client = TenantManagementClient()
+admin_client = SuperTenantManagementClient()
+id_client = IdentityManagementClient()
+custos_settings = CustosServerClientSettings()
+token = utl.get_token(custos_settings)
+
+
+class TestTenantManagementClient:
+    client_name = "SAMPLE"
+    requester_email = "XXX@iu.edu"
+    contacts = ["2345634324"]
+    redirect_uris = ["http://localhost:8080,http://localhost:8080/user/external_ids"]
+    admin_first_name = "Admin First Name"
+    admin_last_name = "LastName"
+    admin_email = "email"
+    client_uri = "https://domain.org/"
+    scope =  "openid profile email org.cilogon.userinfo"
+    domain = "domain.org"
+    logo_uri = "https://domain.org/static/favicon.png"
+    comment = "Galaxy Portal"
+
+    @pytest.fixture
+    def tenant(self):
+        return client.create_admin_tenant(self.client_name,
+                                          self.requester_email,
+                                          self.admin_first_name,
+                                          self.admin_last_name,
+                                          self.admin_email,
+                                          "admin",
+                                          "1234",
+                                          self.contacts,
+                                          self.redirect_uris,
+                                          self.client_uri,
+                                          self.scope,
+                                          self.domain,
+                                          self.logo_uri,
+                                          self.comment)
+
+    def test_create_tenant(self, tenant):
+        assert type(tenant) is TenantManagementService_pb2.CreateTenantResponse
+
+    def test_get_tenant(self, tenant):
+        client_id = tenant.client_id
+        response = client.get_tenant(client_token=token, client_id=client_id)
+        print(response)
+        assert type(response) is TenantManagementService_pb2.GetTenantResponse
+        assert response.client_id == tenant.client_id
+        assert response.client_name == self.client_name
+        assert response.requester_email == self.requester_email
+        assert response.admin_first_name == self.admin_first_name
+        assert response.admin_last_name == self.admin_last_name
+        assert response.admin_email == self.admin_email
+        assert all([a == b for a, b in zip(response.contacts, self.contacts)])
+        assert all([a == b for a, b in zip(response.redirect_uris, self.redirect_uris)])
+        assert response.scope == self.scope
+        assert response.domain == self.domain
+        assert response.logo_uri == self.logo_uri

Review comment:
       @isururanawaka I was able to access the services but the logo_uri is not correctly returned by the service. While creating the tenant, we are setting the **logo_uri="https://domain.org/static/favicon.png"** but while we get the tenant information a different URI is returned **logo_uri = "https://domain.org/"**
   
   Could you please advise, as due to this my test case keeps failing. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airavata-custos] virendrawali commented on a change in pull request #76: Add test cases for user management client

Posted by GitBox <gi...@apache.org>.
virendrawali commented on a change in pull request #76:
URL: https://github.com/apache/airavata-custos/pull/76#discussion_r442997805



##########
File path: custos-client-sdks/custos-python-sdk/tests/test_tenant_management_client.py
##########
@@ -0,0 +1,82 @@
+import pytest
+
+import logging
+from clients.tenant_management_client import TenantManagementClient
+from clients.super_tenant_management_client import SuperTenantManagementClient
+from clients.identity_management_client import IdentityManagementClient
+from custos.integration import TenantManagementService_pb2
+from transport.settings import CustosServerClientSettings
+import clients.utils.utilities as utl
+
+logger = logging.getLogger(__name__)
+
+logger.setLevel(logging.DEBUG)
+# create console handler with a higher log level
+handler = logging.StreamHandler()
+handler.setLevel(logging.DEBUG)
+
+# load APIServerClient with default configuration
+client = TenantManagementClient()
+admin_client = SuperTenantManagementClient()
+id_client = IdentityManagementClient()
+custos_settings = CustosServerClientSettings()
+token = utl.get_token(custos_settings)
+
+
+class TestTenantManagementClient:
+    client_name = "SAMPLE"
+    requester_email = "XXX@iu.edu"
+    contacts = ["2345634324"]
+    redirect_uris = ["http://localhost:8080,http://localhost:8080/user/external_ids"]
+    admin_first_name = "Admin First Name"
+    admin_last_name = "LastName"
+    admin_email = "email"
+    client_uri = "https://domain.org/"
+    scope =  "openid profile email org.cilogon.userinfo"
+    domain = "domain.org"
+    logo_uri = "https://domain.org/static/favicon.png"
+    comment = "Galaxy Portal"
+
+    @pytest.fixture
+    def tenant(self):
+        return client.create_admin_tenant(self.client_name,
+                                          self.requester_email,
+                                          self.admin_first_name,
+                                          self.admin_last_name,
+                                          self.admin_email,
+                                          "admin",
+                                          "1234",
+                                          self.contacts,
+                                          self.redirect_uris,
+                                          self.client_uri,
+                                          self.scope,
+                                          self.domain,
+                                          self.logo_uri,
+                                          self.comment)
+
+    def test_create_tenant(self, tenant):
+        assert type(tenant) is TenantManagementService_pb2.CreateTenantResponse
+
+    def test_get_tenant(self, tenant):
+        client_id = tenant.client_id
+        response = client.get_tenant(client_token=token, client_id=client_id)
+        print(response)
+        assert type(response) is TenantManagementService_pb2.GetTenantResponse
+        assert response.client_id == tenant.client_id
+        assert response.client_name == self.client_name
+        assert response.requester_email == self.requester_email
+        assert response.admin_first_name == self.admin_first_name
+        assert response.admin_last_name == self.admin_last_name
+        assert response.admin_email == self.admin_email
+        assert all([a == b for a, b in zip(response.contacts, self.contacts)])
+        assert all([a == b for a, b in zip(response.redirect_uris, self.redirect_uris)])
+        assert response.scope == self.scope
+        assert response.domain == self.domain
+        assert response.logo_uri == self.logo_uri

Review comment:
       Assert statement is failing here. Could you please check. @isururanawaka 
   
   
   ```
   >       assert response.logo_uri == self.logo_uri
   E       AssertionError: assert 'https://domain.org/' == 'https://doma...c/favicon.png'
   E         - https://domain.org/static/favicon.png
   E         + https://domain.org/
   
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airavata-custos] isururanawaka commented on a change in pull request #76: Add test cases for user management client

Posted by GitBox <gi...@apache.org>.
isururanawaka commented on a change in pull request #76:
URL: https://github.com/apache/airavata-custos/pull/76#discussion_r442999521



##########
File path: custos-client-sdks/custos-python-sdk/tests/test_tenant_management_client.py
##########
@@ -0,0 +1,82 @@
+import pytest
+
+import logging
+from clients.tenant_management_client import TenantManagementClient
+from clients.super_tenant_management_client import SuperTenantManagementClient
+from clients.identity_management_client import IdentityManagementClient
+from custos.integration import TenantManagementService_pb2
+from transport.settings import CustosServerClientSettings
+import clients.utils.utilities as utl
+
+logger = logging.getLogger(__name__)
+
+logger.setLevel(logging.DEBUG)
+# create console handler with a higher log level
+handler = logging.StreamHandler()
+handler.setLevel(logging.DEBUG)
+
+# load APIServerClient with default configuration
+client = TenantManagementClient()
+admin_client = SuperTenantManagementClient()
+id_client = IdentityManagementClient()
+custos_settings = CustosServerClientSettings()
+token = utl.get_token(custos_settings)
+
+
+class TestTenantManagementClient:
+    client_name = "SAMPLE"
+    requester_email = "XXX@iu.edu"
+    contacts = ["2345634324"]
+    redirect_uris = ["http://localhost:8080,http://localhost:8080/user/external_ids"]
+    admin_first_name = "Admin First Name"
+    admin_last_name = "LastName"
+    admin_email = "email"
+    client_uri = "https://domain.org/"
+    scope =  "openid profile email org.cilogon.userinfo"
+    domain = "domain.org"
+    logo_uri = "https://domain.org/static/favicon.png"
+    comment = "Galaxy Portal"
+
+    @pytest.fixture
+    def tenant(self):
+        return client.create_admin_tenant(self.client_name,
+                                          self.requester_email,
+                                          self.admin_first_name,
+                                          self.admin_last_name,
+                                          self.admin_email,
+                                          "admin",
+                                          "1234",
+                                          self.contacts,
+                                          self.redirect_uris,
+                                          self.client_uri,
+                                          self.scope,
+                                          self.domain,
+                                          self.logo_uri,
+                                          self.comment)
+
+    def test_create_tenant(self, tenant):
+        assert type(tenant) is TenantManagementService_pb2.CreateTenantResponse
+
+    def test_get_tenant(self, tenant):
+        client_id = tenant.client_id
+        response = client.get_tenant(client_token=token, client_id=client_id)
+        print(response)
+        assert type(response) is TenantManagementService_pb2.GetTenantResponse
+        assert response.client_id == tenant.client_id
+        assert response.client_name == self.client_name
+        assert response.requester_email == self.requester_email
+        assert response.admin_first_name == self.admin_first_name
+        assert response.admin_last_name == self.admin_last_name
+        assert response.admin_email == self.admin_email
+        assert all([a == b for a, b in zip(response.contacts, self.contacts)])
+        assert all([a == b for a, b in zip(response.redirect_uris, self.redirect_uris)])
+        assert response.scope == self.scope
+        assert response.domain == self.domain
+        assert response.logo_uri == self.logo_uri

Review comment:
       I'm doing some modifications right now. Services will be back later.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airavata-custos] virendrawali commented on pull request #76: Add test cases for user management client

Posted by GitBox <gi...@apache.org>.
virendrawali commented on pull request #76:
URL: https://github.com/apache/airavata-custos/pull/76#issuecomment-646795541


   > Are these test cases integrated into the build. How to execute them?
   
   Hi Isuru,
   
   The test cases are not yet integrated. I am running them using py.test command from the terminal. Please note that before that you will have to install pytest library. I will add the library to the requirement.txt file also. 
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org