From 8db12e071f2f68a17bcb56eec76f8031f5fddb2c Mon Sep 17 00:00:00 2001 From: Chirag Jog Date: Thu, 12 Jul 2012 20:58:45 +0530 Subject: [PATCH] Rearranging the project test suite according to global configs required * Skipping if the global config required is not set * Cleanup the email tests from project suite --- .../component/test_project_configs.py | 508 +++++++++--------- test/integration/component/test_projects.py | 243 +++------ 2 files changed, 339 insertions(+), 412 deletions(-) diff --git a/test/integration/component/test_project_configs.py b/test/integration/component/test_project_configs.py index 77361647a6d..d153bf3d616 100644 --- a/test/integration/component/test_project_configs.py +++ b/test/integration/component/test_project_configs.py @@ -83,7 +83,7 @@ class Services: "template": { "displaytext": "Public Template", "name": "Public template", - "ostypeid": 'f9b709f2-e0fc-4c0f-80f1-b0494168f58d', + "ostypeid": '7ddbbbb5-bb09-40de-b038-ee78995788ea', "url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2", "hypervisor": 'XenServer', "format": 'VHD', @@ -94,13 +94,7 @@ class Services: "configs": { "project.invite.timeout": 300, }, - "mail_account": { - "server": 'imap.gmail.com', - "email": 'administrator@clogeny.com', - "password": 'fr3sca21!', - "folder": 'inbox', - }, - "ostypeid": 'f9b709f2-e0fc-4c0f-80f1-b0494168f58d', + "ostypeid": '7ddbbbb5-bb09-40de-b038-ee78995788ea', # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, @@ -120,6 +114,16 @@ class TestUserProjectCreation(cloudstackTestCase): # Get Zone cls.zone = get_zone(cls.api_client, cls.services) + configs = Configurations.list( + cls.api_client, + name='allow.user.create.projects' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: allow.user.create.projects") + elif (configs[0].value).lower() != 'true': + raise unittest.SkipTest("'allow.user.create.projects' should be true") + # Create domains, account etc. cls.domain = Domain.create( cls.api_client, @@ -166,7 +170,7 @@ class TestUserProjectCreation(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - def test_01_admin_project_creation(self): + def test_admin_project_creation(self): """Test create project as a domain admin and domain user """ tags = ["advanced", "basic", "sg", "eip", "advancedns"] @@ -175,23 +179,8 @@ class TestUserProjectCreation(cloudstackTestCase): # 2. Create a Project as domain admin # 3. Create a Project as domain user # 4. In both 2 and 3 project creation should be successful - configs = Configurations.list( - self.apiclient, - name='allow.user.create.projects' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'true', - "'allow.user.create.projects' should be true" - ) - # Create project as a domain admin + project = Project.create( self.apiclient, self.services["project"], @@ -259,8 +248,78 @@ class TestUserProjectCreation(cloudstackTestCase): ) return + +class TestProjectCreationNegative(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + cls.api_client = super( + TestProjectCreationNegative, + cls + ).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone + cls.zone = get_zone(cls.api_client, cls.services) + + # Checking for prereqisits - global configs + configs = Configurations.list( + cls.api_client, + name='allow.user.create.projects' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: allow.user.create.projects") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'allow.user.create.projects' should be false") + + # Create domains, account etc. + cls.domain = Domain.create( + cls.api_client, + cls.services["domain"] + ) + + cls.account = Account.create( + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain.id + ) + + cls.user = Account.create( + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain.id + ) + + cls._cleanup = [cls.account, cls.user, cls.domain] + return + + @classmethod + def tearDownClass(cls): + try: + #Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + #Clean up, terminate the created accounts, domains etc + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @unittest.skip("Known bug-able to create project as a domain user") - def test_02_user_project_creation(self): + def test_user_project_creation(self): """Test create project as a domain admin and domain user """ tags = ["advanced", "basic", "sg", "eip", "advancedns"] @@ -269,21 +328,6 @@ class TestUserProjectCreation(cloudstackTestCase): # 2. Create a Project as domain admin. Project creation should be # successful. # 3. Create a Project as domain user. Project creation should fail - configs = Configurations.list( - self.apiclient, - name='allow.user.create.projects' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'allow.user.create.projects' should be true" - ) # Create project as a domain admin project = Project.create( @@ -337,7 +381,10 @@ class TestProjectInviteRequired(cloudstackTestCase): @classmethod def setUpClass(cls): - cls.api_client = super(TestProjectInviteRequired, cls).getClsTestClient().getApiClient() + cls.api_client = super( + TestProjectInviteRequired, + cls + ).getClsTestClient().getApiClient() cls.services = Services().services # Get Zone cls.zone = get_zone(cls.api_client, cls.services) @@ -345,6 +392,17 @@ class TestProjectInviteRequired(cloudstackTestCase): # Create domains, account etc. cls.domain = get_domain(cls.api_client, cls.services) + # Verify 'project.invite.required' is set to false + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("The 'project.invite.required' is not found in global configs") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'project.invite.required' should be false") + cls.account = Account.create( cls.api_client, cls.services["account"], @@ -385,31 +443,16 @@ class TestProjectInviteRequired(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return - def test_03_add_user_to_project(self): + def test_add_user_to_project(self): """Add user to project when 'project.invite.required' is false""" + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following: # 1. Create a Project # 2. Add users to the project. Verify user is added to project # as regular user - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be true" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -485,30 +528,82 @@ class TestProjectInviteRequired(cloudstackTestCase): return - def test_04_add_user_to_project(self): + +class TestProjectInviteRequiredTrue(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + cls.api_client = super( + TestProjectInviteRequiredTrue, + cls + ).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone + cls.zone = get_zone(cls.api_client, cls.services) + + # Create domains, account etc. + cls.domain = get_domain(cls.api_client, cls.services) + + # Verify 'project.invite.required' is set to true + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("The 'project.invite.required' is not found in global configs") + elif (configs[0].value).lower() != 'true': + raise unittest.SkipTest("'project.invite.required' should be true") + + cls.account = Account.create( + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain.id + ) + + cls.user = Account.create( + cls.api_client, + cls.services["user"], + admin=True, + domainid=cls.domain.id + ) + + cls._cleanup = [cls.account, cls.user] + return + + @classmethod + def tearDownClass(cls): + try: + #Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + #Clean up, terminate the created accounts, domains etc + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def test_add_user_to_project(self): """Add user to project when 'project.invite.required' is true""" + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following: # 1. Create a Project # 2. Add users to the project. verify user is shown in pending state - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'true', - "'project.invite.required' should be true" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -584,9 +679,91 @@ class TestProjectInviteRequired(cloudstackTestCase): ) return - def test_05_invitation_timeout(self): + +class TestProjectInviteTimeout(cloudstackTestCase): + + @classmethod + def setUpClass(cls): + cls.api_client = super( + TestProjectInviteTimeout, + cls + ).getClsTestClient().getApiClient() + cls.services = Services().services + # Get Zone + cls.zone = get_zone(cls.api_client, cls.services) + + # Create domains, account etc. + cls.domain = get_domain(cls.api_client, cls.services) + + # Verify 'project.invite.required' is set to true + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("The 'project.invite.required' is not found in global configs") + elif (configs[0].value).lower() != 'true': + raise unittest.SkipTest("'project.invite.required' should be true") + + # Verify 'project.invite.timeout' is set to 300 + configs = Configurations.list( + cls.api_client, + name='project.invite.timeout' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("The 'project.invite.timeout' is not found in global configs") + elif int(configs[0].value) != cls.services["configs"]["project.invite.timeout"]: + raise unittest.SkipTest("'project.invite.timeout' should be: %s " % + cls.services["configs"]["project.invite.timeout"]) + + cls.config = configs[0] + cls.account = Account.create( + cls.api_client, + cls.services["account"], + admin=True, + domainid=cls.domain.id + ) + + cls.user = Account.create( + cls.api_client, + cls.services["user"], + admin=True, + domainid=cls.domain.id + ) + + cls._cleanup = [cls.account, cls.user] + return + + @classmethod + def tearDownClass(cls): + try: + #Cleanup resources used + cleanup_resources(cls.api_client, cls._cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def setUp(self): + self.apiclient = self.testClient.getApiClient() + self.dbclient = self.testClient.getDbConnection() + self.cleanup = [] + return + + def tearDown(self): + try: + #Clean up, terminate the created accounts, domains etc + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + + def test_01_invitation_timeout(self): """Test global config project invitation timeout""" + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following: # 1. Set configuration to 5 mins # 2. Create a Project @@ -594,24 +771,6 @@ class TestProjectInviteRequired(cloudstackTestCase): # 4. As a user accept invitation within 5 mins. Verify invitation is # accepted and user become regular user of project - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.timeout' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - int(config.value), - self.services["configs"]["project.invite.timeout"], - "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -725,9 +884,11 @@ class TestProjectInviteRequired(cloudstackTestCase): ) return - def test_06_invitation_timeout_after_expiry(self): + def test_02_invitation_timeout_after_expiry(self): """Test global config project invitation timeout""" + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following: # 1. Set configuration to 5 mins # 2. Create a Project @@ -735,24 +896,6 @@ class TestProjectInviteRequired(cloudstackTestCase): # 4. As a user accept invitation after 5 mins. Verify invitation is # not accepted and is shown as expired - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.timeout' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - int(config.value), - self.services["configs"]["project.invite.timeout"], - "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -829,7 +972,7 @@ class TestProjectInviteRequired(cloudstackTestCase): # sleep for 'project.invite.timeout' * 2 interval to wait for invite # to expire - time.sleep(int(config.value) * 2) + time.sleep(int(self.config.value) * 2) with self.assertRaises(Exception): # Accept the invite @@ -871,9 +1014,11 @@ class TestProjectInviteRequired(cloudstackTestCase): ) return - def test_07_invite_after_expiry(self): + def test_03_invite_after_expiry(self): """Test global config project invitation timeout""" + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following: # 1. Set configuration to 5 mins # 2. Create a Project @@ -882,24 +1027,6 @@ class TestProjectInviteRequired(cloudstackTestCase): # 5. Resend the invitation # 6. Verify invitation is sent again - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.timeout' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - int(config.value), - self.services["configs"]["project.invite.timeout"], - "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -976,7 +1103,7 @@ class TestProjectInviteRequired(cloudstackTestCase): # sleep for 'project.invite.timeout' * 2 interval to wait for invite # to expire - time.sleep(int(config.value) * 2) + time.sleep(int(self.config.value) * 2) self.debug("Adding %s user again to project: %s" % ( self.user.account.name, @@ -1016,9 +1143,11 @@ class TestProjectInviteRequired(cloudstackTestCase): ) return - def test_08_decline_invitation(self): + def test_04_decline_invitation(self): """Test decline invitation""" + tags = ["advanced", "basic", "sg", "eip", "advancedns"] + # Validate the following: # 1. Set configuration to 5 mins # 2. Create a Project @@ -1027,24 +1156,6 @@ class TestProjectInviteRequired(cloudstackTestCase): # 5. Verify invitation is rejected and user doesn't become regular # user. - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.timeout' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - int(config.value), - self.services["configs"]["project.invite.timeout"], - "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -1142,88 +1253,3 @@ class TestProjectInviteRequired(cloudstackTestCase): "Check for a valid list accounts response" ) return - - @unittest.skip("Requires SMPT configs") - def test_09_invite_to_project_by_email(self): - """Test invite user to project by email""" - tags = ["advanced", "basic", "sg", "eip", "advancedns"] - # Validate the following: - # 1. Set configuration to 5 mins - # 2. Create a Project - # 3. Add users to the project - # 4. As a user decline invitation within 5 mins. - # 5. Verify invitation is rejected and user doesn't become regular - # user. - - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.timeout' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - int(config.value), - self.services["configs"]["project.invite.timeout"], - "'project.invite.timeout' should be %s" % - self.services["configs"]["project.invite.timeout"] - ) - - # Create project as a domain admin - project = Project.create( - self.apiclient, - self.services["project"], - account=self.account.account.name, - domainid=self.account.account.domainid - ) - # Cleanup created project at end of test - self.cleanup.append(project) - - self.debug("Created project with domain admin with ID: %s" % - project.id) - - list_projects_reponse = Project.list( - self.apiclient, - id=project.id, - listall=True - ) - - self.assertEqual( - isinstance(list_projects_reponse, list), - True, - "Check for a valid list projects response" - ) - list_project = list_projects_reponse[0] - - self.assertNotEqual( - len(list_projects_reponse), - 0, - "Check list project response returns a valid project" - ) - - self.assertEqual( - project.name, - list_project.name, - "Check project name from list response" - ) - self.debug("Adding user with email: %s to project: %s" % ( - self.user.account.email, - project.name - )) - - # Add user to the project - project.addAccount( - self.apiclient, - email=self.user.account.user[0].email - ) - - # Fetch the latest mail sent to user - mail_content = fetch_latest_mail( - self.services["mail_account"], - from_mail=self.user.account.user[0].email - ) - return diff --git a/test/integration/component/test_projects.py b/test/integration/component/test_projects.py index a78bb1bc4fb..e0e1b5f0bbf 100644 --- a/test/integration/component/test_projects.py +++ b/test/integration/component/test_projects.py @@ -88,7 +88,7 @@ class Services: "publicport": 22, "protocol": 'TCP', }, - "ostypeid": '8531d1df-faac-4895-a741-238d3b10e6e6', + "ostypeid": '7ddbbbb5-bb09-40de-b038-ee78995788ea', # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, @@ -114,6 +114,16 @@ class TestMultipleProjectCreation(cloudstackTestCase): cls.services ) + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: project.invite.required") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'project.invite.required' should be set to false") + cls.account = Account.create( cls.api_client, cls.services["account"], @@ -165,23 +175,6 @@ class TestMultipleProjectCreation(cloudstackTestCase): # 2. add one account to multiple project. Verify at step 2 an account # is allowed to added to multiple project - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Create project as a domain admin project_1 = Project.create( self.apiclient, @@ -331,6 +324,16 @@ class TestCrossDomainAccountAdd(cloudstackTestCase): cls.services ) + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: project.invite.required") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'project.invite.required' should be set to false") + # Create domains, account etc. cls.new_domain = Domain.create( cls.api_client, @@ -386,23 +389,6 @@ class TestCrossDomainAccountAdd(cloudstackTestCase): # 2. Add different domain account to the project. Add account should # fail - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -471,6 +457,16 @@ class TestDeleteAccountWithProject(cloudstackTestCase): cls.services ) + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: project.invite.required") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'project.invite.required' should be set to false") + # Create account cls.account = Account.create( cls.api_client, @@ -513,23 +509,6 @@ class TestDeleteAccountWithProject(cloudstackTestCase): # 2. Delete account who is owner of the project. Delete account should # fail - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -586,6 +565,17 @@ class TestDeleteDomainWithProject(cloudstackTestCase): cls.services = Services().services # Get Zone cls.zone = get_zone(cls.api_client, cls.services) + + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: project.invite.required") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'project.invite.required' should be set to false") + # Create account cls.domain = Domain.create( cls.api_client, @@ -634,23 +624,6 @@ class TestDeleteDomainWithProject(cloudstackTestCase): # 2. Delete domain forcefully. Verify that project is also deleted as # as part of domain cleanup - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -737,6 +710,16 @@ class TestProjectOwners(cloudstackTestCase): ) cls.zone = get_zone(cls.api_client, cls.services) + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: project.invite.required") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'project.invite.required' should be set to false") + # Create accounts cls.admin = Account.create( cls.api_client, @@ -787,23 +770,6 @@ class TestProjectOwners(cloudstackTestCase): # owner. verify new user is project owner and old account is # regular user of the project. - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -945,23 +911,6 @@ class TestProjectOwners(cloudstackTestCase): # owner. # 3. Update project to add another account as an owner - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -1188,6 +1137,16 @@ class TestProjectResources(cloudstackTestCase): cls.services ) + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: project.invite.required") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'project.invite.required' should be set to false") + # Create account, disk offering etc. cls.disk_offering = DiskOffering.create( cls.api_client, @@ -1243,23 +1202,6 @@ class TestProjectResources(cloudstackTestCase): # 3. Delete the account. Verify resources are still there after # account deletion. - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -1376,23 +1318,6 @@ class TestProjectResources(cloudstackTestCase): # account deletion. # 4. Verify all accounts are unassigned from project. - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Create project as a domain admin project = Project.create( self.apiclient, @@ -1524,6 +1449,16 @@ class TestProjectSuspendActivate(cloudstackTestCase): cls.zone.id, cls.services["ostypeid"] ) + configs = Configurations.list( + cls.api_client, + name='project.invite.required' + ) + + if not isinstance(configs, list): + raise unittest.SkipTest("List configurations has no config: project.invite.required") + elif (configs[0].value).lower() != 'false': + raise unittest.SkipTest("'project.invite.required' should be set to false") + # Create account, service offering, disk offering etc. cls.disk_offering = DiskOffering.create( cls.api_client, @@ -1597,23 +1532,6 @@ class TestProjectSuspendActivate(cloudstackTestCase): # 3. Delete the account. Verify resources are still there after # account deletion. - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - self.debug("Adding %s user to project: %s" % ( self.user.account.name, self.project.name @@ -1748,23 +1666,6 @@ class TestProjectSuspendActivate(cloudstackTestCase): # 1. Activate the project # 2. Verify project is activated and we are able to add resources - # Verify 'project.invite.required' is set to false - configs = Configurations.list( - self.apiclient, - name='project.invite.required' - ) - self.assertEqual( - isinstance(configs, list), - True, - "Check for a valid list configurations response" - ) - config = configs[0] - self.assertEqual( - (config.value).lower(), - 'false', - "'project.invite.required' should be set to false" - ) - # Activating the project self.debug("Activating project: %s" % self.project.name) self.project.activate(self.apiclient)