Repository: cloudstack Updated Branches: refs/heads/master fcf2c1b6b -> 7a79fd1c5
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a79fd1c/test/integration/component/test_acl_listsnapshot.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_acl_listsnapshot.py b/test/integration/component/test_acl_listsnapshot.py new file mode 100644 index 0000000..ac8748d --- /dev/null +++ b/test/integration/component/test_acl_listsnapshot.py @@ -0,0 +1,2853 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +""" +Test cases relating to listSnapshot() relating to parameters - id,listall,isrecursive,account and domainid +""" +#Import Local Modules +import marvin +from marvin.cloudstackTestCase import * +from marvin.cloudstackAPI import * +from marvin.lib.utils import * +from marvin.lib.base import * +from marvin.lib.common import * +from nose.plugins.attrib import attr +#Import System modules +import time + +_multiprocess_shared_ = True + +class TestSnapshotList(cloudstackTestCase): + @classmethod + def setUpClass(cls): + """ + Create the following domain tree and accounts that are reqiured for executing listSnapshot test cases: + Under ROOT - create 2 domaind D1 and D2 + Under D1 - Create 2 subdomain D11 and D12 + Under D11 - Create subdimain D111 + + Under each of the domain create 1 admin user and couple of regular users. + + As each of these users , deploy Virtual machines and take a snapshot of the ROOT volume. + + """ + cls.testclient = super(TestSnapshotList, cls).getClsTestClient() + cls.apiclient = cls.testclient.getApiClient() + cls.testdata = cls.testClient.getParsedTestDataConfig() + cls.acldata = cls.testdata["acl"] + + cls.domain_1 = None + cls.domain_2 = None + cleanup = None + + try: + + # backup default apikey and secretkey + cls.default_apikey = cls.apiclient.connection.apiKey + cls.default_secretkey = cls.apiclient.connection.securityKey + + # Create domains + cls.domain_1 = Domain.create( + cls.apiclient, + cls.acldata["domain1"] + ) + cls.domain_11 = Domain.create( + cls.apiclient, + cls.acldata["domain11"], + parentdomainid=cls.domain_1.id + ) + cls.domain_111 = Domain.create( + cls.apiclient, + cls.acldata["domain111"], + parentdomainid=cls.domain_11.id, + ) + cls.domain_12 = Domain.create( + cls.apiclient, + cls.acldata["domain12"], + parentdomainid=cls.domain_1.id + ) + cls.domain_2 = Domain.create( + cls.apiclient, + cls.acldata["domain2"] + ) + # Create 1 admin account and 2 user accounts for doamin_1 + cls.account_d1 = Account.create( + cls.apiclient, + cls.acldata["accountD1"], + admin=True, + domainid=cls.domain_1.id + ) + + user = cls.generateKeysForUser(cls.apiclient,cls.account_d1) + cls.user_d1_apikey = user.apikey + cls.user_d1_secretkey = user.secretkey + + cls.account_d1a = Account.create( + cls.apiclient, + cls.acldata["accountD1A"], + admin=False, + domainid=cls.domain_1.id + ) + user = cls.generateKeysForUser(cls.apiclient,cls.account_d1a) + cls.user_d1a_apikey = user.apikey + cls.user_d1a_secretkey = user.secretkey + + + cls.account_d1b = Account.create( + cls.apiclient, + cls.acldata["accountD1B"], + admin=False, + domainid=cls.domain_1.id + ) + + user = cls.generateKeysForUser(cls.apiclient,cls.account_d1b) + cls.user_d1b_apikey = user.apikey + cls.user_d1b_secretkey = user.secretkey + + # Create 1 admin and 2 user accounts for doamin_11 + cls.account_d11 = Account.create( + cls.apiclient, + cls.acldata["accountD11"], + admin=True, + domainid=cls.domain_11.id + ) + user = cls.generateKeysForUser(cls.apiclient,cls.account_d11) + cls.user_d11_apikey = user.apikey + cls.user_d11_secretkey = user.secretkey + + cls.account_d11a = Account.create( + cls.apiclient, + cls.acldata["accountD11A"], + admin=False, + domainid=cls.domain_11.id + ) + user = cls.generateKeysForUser(cls.apiclient,cls.account_d11a) + cls.user_d11a_apikey = user.apikey + cls.user_d11a_secretkey = user.secretkey + + cls.account_d11b = Account.create( + cls.apiclient, + cls.acldata["accountD11B"], + admin=False, + domainid=cls.domain_11.id + ) + user = cls.generateKeysForUser(cls.apiclient,cls.account_d11b) + cls.user_d11b_apikey = user.apikey + cls.user_d11b_secretkey = user.secretkey + + # Create 1 user account for doamin_111 + + cls.account_d111a = Account.create( + cls.apiclient, + cls.acldata["accountD111A"], + admin=False, + domainid=cls.domain_111.id + ) + user = cls.generateKeysForUser(cls.apiclient,cls.account_d111a) + cls.user_d111a_apikey = user.apikey + cls.user_d111a_secretkey = user.secretkey + + # Create 2 user accounts for doamin_12 + cls.account_d12a = Account.create( + cls.apiclient, + cls.acldata["accountD12A"], + admin=False, + domainid=cls.domain_12.id + ) + user = cls.generateKeysForUser(cls.apiclient,cls.account_d12a) + cls.user_d12a_apikey = user.apikey + cls.user_d12a_secretkey = user.secretkey + + cls.account_d12b = Account.create( + cls.apiclient, + cls.acldata["accountD12B"], + admin=False, + domainid=cls.domain_12.id + ) + + user = cls.generateKeysForUser(cls.apiclient,cls.account_d12b) + cls.user_d12b_apikey = user.apikey + cls.user_d12b_secretkey = user.secretkey + + # Create 1 user account for domain_2 + + cls.account_d2a = Account.create( + cls.apiclient, + cls.acldata["accountD2"], + admin=False, + domainid=cls.domain_2.id + ) + + user = cls.generateKeysForUser(cls.apiclient,cls.account_d2a) + cls.user_d2a_apikey = user.apikey + cls.user_d2a_secretkey = user.secretkey + + + # Create admin user account + + cls.account_a = Account.create( + cls.apiclient, + cls.acldata["accountROOTA"], + admin=True, + ) + + user = cls.generateKeysForUser(cls.apiclient,cls.account_a) + cls.user_a_apikey = user.apikey + cls.user_a_secretkey = user.secretkey + # create service offering + cls.service_offering = ServiceOffering.create( + cls.apiclient, + cls.acldata["service_offering"]["small"] + ) + + cls.zone = get_zone(cls.apiclient,cls.testclient.getZoneForTests()) + cls.acldata['mode'] = cls.zone.networktype + cls.template = get_template(cls.apiclient, cls.zone.id, cls.acldata["ostype"]) + + # deploy VM + + cls.apiclient.connection.apiKey = cls.user_d1_apikey + cls.apiclient.connection.securityKey = cls.user_d1_secretkey + cls.vm_d1 = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD1"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d1_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d1.id) + cls.vm_d1_snapshot=Snapshot.create(cls.apiclient,cls.vm_d1_volume[0].id) + + + cls.apiclient.connection.apiKey = cls.user_d1a_apikey + cls.apiclient.connection.securityKey = cls.user_d1a_secretkey + cls.vm_d1a = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD1A"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d1a_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d1a.id) + cls.vm_d1a_snapshot=Snapshot.create(cls.apiclient,cls.vm_d1a_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_d1b_apikey + cls.apiclient.connection.securityKey = cls.user_d1b_secretkey + cls.vm_d1b = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD1B"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d1b_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d1b.id) + cls.vm_d1b_snapshot=Snapshot.create(cls.apiclient,cls.vm_d1b_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_d11_apikey + cls.apiclient.connection.securityKey = cls.user_d11_secretkey + cls.vm_d11 = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD11"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d11_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d11.id) + cls.vm_d11_snapshot=Snapshot.create(cls.apiclient,cls.vm_d11_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_d11a_apikey + cls.apiclient.connection.securityKey = cls.user_d11a_secretkey + cls.vm_d11a = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD11A"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d11a_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d11a.id) + cls.vm_d11a_snapshot=Snapshot.create(cls.apiclient,cls.vm_d11a_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_d11b_apikey + cls.apiclient.connection.securityKey = cls.user_d11b_secretkey + cls.vm_d11b = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD11B"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d11b_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d11b.id) + cls.vm_d11b_snapshot=Snapshot.create(cls.apiclient,cls.vm_d11b_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_d111a_apikey + cls.apiclient.connection.securityKey = cls.user_d111a_secretkey + cls.vm_d111a = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD111A"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d111a_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d111a.id) + cls.vm_d111a_snapshot=Snapshot.create(cls.apiclient,cls.vm_d111a_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_d12a_apikey + cls.apiclient.connection.securityKey = cls.user_d12a_secretkey + cls.vm_d12a = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD12A"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d12a_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d12a.id) + cls.vm_d12a_snapshot=Snapshot.create(cls.apiclient,cls.vm_d12a_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_d12b_apikey + cls.apiclient.connection.securityKey = cls.user_d12b_secretkey + cls.vm_d12b = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD12B"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d12b_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d12b.id) + cls.vm_d12b_snapshot=Snapshot.create(cls.apiclient,cls.vm_d12b_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_d2a_apikey + cls.apiclient.connection.securityKey = cls.user_d2a_secretkey + cls.vm_d2 = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmD2A"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_d2_volume=Volume.list(cls.apiclient,virtualmachineid=cls.vm_d2.id) + cls.vm_d2_snapshot=Snapshot.create(cls.apiclient,cls.vm_d2_volume[0].id) + + cls.apiclient.connection.apiKey = cls.user_a_apikey + cls.apiclient.connection.securityKey = cls.user_a_secretkey + cls.vm_a = VirtualMachine.create( + cls.apiclient, + cls.acldata["vmROOTA"], + zoneid=cls.zone.id, + serviceofferingid=cls.service_offering.id, + templateid=cls.template.id + ) + cls.vm_a_volume =Volume.list(cls.apiclient,virtualmachineid=cls.vm_a.id) + cls.vm_a_snapshot=Snapshot.create(cls.apiclient,cls.vm_a_volume[0].id) + + cls.cleanup = [ + cls.account_a, + cls.service_offering, + ] + except Exception as e: + cls.domain_1.delete(cls.apiclient,cleanup="true") + cls.domain_2.delete(cls.apiclient,cleanup="true") + cleanup_resources(cls.apiclient, cls.cleanup) + raise Exception("Failed to create the setup required to execute the test cases: %s" % e) + + @classmethod + def tearDownClass(cls): + cls.apiclient = super(TestSnapshotList, cls).getClsTestClient().getApiClient() + cls.apiclient.connection.apiKey = cls.default_apikey + cls.apiclient.connection.securityKey = cls.default_secretkey + cls.domain_1.delete(cls.apiclient,cleanup="true") + cls.domain_2.delete(cls.apiclient,cleanup="true") + cleanup_resources(cls.apiclient, cls.cleanup) + return + + def setUp(cls): + cls.apiclient = cls.testClient.getApiClient() + cls.dbclient = cls.testClient.getDbConnection() + + def tearDown(cls): + # restore back default apikey and secretkey + cls.apiclient.connection.apiKey = cls.default_apikey + cls.apiclient.connection.securityKey = cls.default_secretkey + return + +## Domain Admin - Test cases with listall =true + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_listall_true(self): + """ + Test listing of Snapshots by passing listall="true" parameter as domain admin + Validate that it returns all the Snapshots that is owned by accounts in this domain and all its subdomain + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true") + self.debug ("List as Domain Admin - listall=true - %s" % snapshotList) + + self.assertEqual(len(snapshotList) == 9, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id), + self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d1b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_listall_true_rec_true(self): + """ + Test listing of Snapshots by passing listall="true"i and isrecusriv="true" parameter as domain admin + Validate that it returns all the Snapshots that is owned by accounts in this domain and all its subdomain + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true",isrecursive="true") + self.debug ("List as Domain Admin - listall=true,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 9, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id), + self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d1b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_listall_true_rec_false(self): + """ + Test listing of Snapshots by passing listall="true" and isrecusriv="false" parameter as domain admin + Validate that it returns all the Snapshots that is owned by accounts in this domain and all its subdomain + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true",isrecursive="false") + self.debug ("List as Domain Admin - listall=true,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 9, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id), + self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d1b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## Domain Admin - Test cases with listall=false + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_listall_false(self): + """ + Test listing of Snapshots by passing listall="false" parameter as domain admin + Validate that it returns all the Snapshots that is owned by the domain admin + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false") + self.debug ("List as Domain Admin - listall=false - %s" % snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_listall_false_rec_true(self): + """ + Test listing of Snapshots by passing listall="false" and isrecusrive="true" parameter as domain admin + Validate that it returns all the Snapshots that is owned by the domain admin + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false",isrecursive="true") + self.debug ("List as Domain Admin - listall=false,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_listall_false_rec_false(self): + """ + Test listing of Snapshots by passing listall="false" and isrecusrive="false" parameter as domain admin + Validate that it returns all the Snapshots that is owned by the domain admin + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false",isrecursive="false") + self.debug ("List as Domain Admin - listall=false,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## Domain Admin - Test cases without passing listall paramter + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin(self): + """ + Test listing of Snapshots by passing no parameter as domain admin + Validate that it returns all the Snapshots that is owned by the domain admin + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient) + self.debug ("List as Domain Admin - %s" % snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_rec_true(self): + """ + Test listing of Snapshots by passing isrecusrive="true" parameter as domain admin + Validate that it returns all the Snapshots that is owned by the domain admin + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,isrecursive="true") + self.debug ("List as Domain Admin - isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_true_rec_false(self): + """ + Test listing of Snapshots by passing isrecusrive="false" parameter as domain admin + Validate that it returns all the Snapshots that is owned by the domain admin + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,isrecursive="false") + self.debug ("List as Domain Admin - isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## Domain Admin - Test cases when domainId is passed with listall =true + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_listall_true(self): + """ + Test listing of Snapshots by passing domainId and listall="true" parameter as domain admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="true") + self.debug ("List as Domain Admin passing domainId - listall=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_listall_true_rec_true(self): + """ + Test listing of Snapshots by passing domainId ,listall="true" and isrecursive="true" parameter as domain admin + Validate that it returns all the Snapshots in the subdomain and the domain passed + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="true",isrecursive="true") + self.debug ("List as Domain Admin passing domainId - listall=true,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 4, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_listall_true_rec_false(self): + """ + Test listing of Snapshots by passing domainId ,listall="true" and isrecursive="false" parameter as domain admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="true",isrecursive="false") + self.debug ("List as Domain Admin passing domainId - listall=true,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## Domain Admin - Test cases when domainId is passed with listall=false + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_listall_false(self): + """ + Test listing of Snapshots by passing domainId ,listall="false" parameter as domain admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="false") + self.debug ("List as Domain Admin passing domainId - listall=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_listall_false_rec_true(self): + """ + Test listing of Snapshots by passing domainId ,listall="false" and isrecursive="true" parameter as domain admin + Validate that it returns all the Snapshots in the subdomain and the domain passed + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="false",isrecursive="true") + self.debug ("List as Domain Admin passing domainId - listall=false,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 4, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_listall_false_rec_false(self): + """ + Test listing of Snapshots by passing domainId ,listall="false" and isrecursive="false" parameter as domain admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="false",isrecursive="false") + self.debug ("List as Domain Admin passing domainId - listall=false,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## Domain Admin - Test cases when domainId is passed with no listall parameter + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid(self): + """ + + Test listing of Snapshots by passing domainId parameter as domain admin + Validate that it returns all the Snapshots in the domain passed + """ + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id) + self.debug ("List as Domain Admin passing domainId - %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_rec_true(self): + """ + Test listing of Snapshots by passing domainId and isrecursive="true" parameter as domain admin + Validate that it returns all the Snapshots in the subdomain and domain passed + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,isrecursive="true") + self.debug ("List as Domain Admin passing domainId - isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 4, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_rec_false(self): + """ + Test listing of Snapshots by passing domainId and isrecursive="false" parameter as domain admin + Validate that it returns all the Snapshots in the subdomain and domain passed + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,isrecursive="false") + self.debug ("List as Domain Admin passing domainId - isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## Domain Admin - Test cases when account and domainId is passed with listall =true + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid_listall_true(self): + """ + Test listing of Snapshots by passing account ,domainId and listall="true" parameter as domain admin + Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="true") + self.debug ("List as Domain Admin passing domainId and accountId - listall=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid_listall_true_rec_true(self): + """ + Test listing of Snapshots by passing account ,domainId and listall="true" and isrecursive="true" parameter as domain admin + Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="true",isrecursive="true") + self.debug ("List as Domain Admin passing domainId and accountId - listall=true,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid_listall_true_rec_false(self): + """ + Test listing of Snapshots by passing account ,domainId , listall="true" and isrecursive="false" parameter as domain admin + Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="true",isrecursive="false") + self.debug ("List as Domain Admin passing domainId and accountId - listall=true,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## Domain Admin - Test cases when account and domainId is passed with listall=false + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid_listall_false(self): + """ + Test listing of Snapshots by passing account ,domainId and listall="false" parameter as domain admin + Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="false") + self.debug ("List as Domain Admin passing domainId and accountId - listall=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid_listall_false_rec_true(self): + """ + Test listing of Snapshots by passing account ,domainId and listall="false" and isrecursive="true" parameter as domain admin + Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="false",isrecursive="true") + self.debug ("List as Domain Admin passing domainId and accountId - listall=false,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid_listall_false_rec_false(self): + """ + Test listing of Snapshots by passing account ,domainId , listall="false" and isrecursive="false" parameter as domain admin + Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="false",isrecursive="false") + self.debug ("List as Domain Admin passing domainId and accountId - listall=false,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## Domain Admin - Test cases when account and domainId is passed with listall not passed + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid(self): + """ + Test listing of Snapshots by passing account ,domainId parameter as domain admin + Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id) + self.debug ("List as Domain Admin passing domainId and accountId - %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid_rec_true(self): + """ + Test listing of Snapshots by passing account ,domainId and isrecursive="true" parameter as domain admin + # Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,isrecursive="true") + self.debug ("List as Domain Admin passing domainId and accountId - isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_domainadmin_domainid_accountid_rec_false(self): + """ + Test listing of Snapshots by passing account ,domainId and isrecursive="false" parameter as domain admin + Validate that it returns all the Snapshots owned by the account passed in account parameter + """ + + self.apiclient.connection.apiKey = self.user_d1_apikey + self.apiclient.connection.securityKey = self.user_d1_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,isrecursive="false") + self.debug ("List as Domain Admin passing domainId and accountId - isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## ROOT Admin - Test cases with listall =true + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_listall_true(self): + """ + Test listing of Snapshots by passing listall="true" parameter as admin + Validate that it returns all the Snapshots + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true") + self.debug ("List as ROOT Admin - listall=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) >= 11, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id), + self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d1b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d2_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id)): + + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_listall_true_rec_true(self): + """ + Test listing of Snapshots by passing listall="true" and isrecusrive="true" parameter as admin + Validate that it returns all the Snapshots + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true",isrecursive="true") + self.debug ("List as ROOT Admin - listall=true,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) >= 11, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id), + self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d1b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d2_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id)): + + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_listall_true_rec_false(self): + """ + Test listing of Snapshots by passing listall="true" and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true",isrecursive="false") + self.debug ("List as ROOT Admin - listall=true,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) >= 11, + True, + "Number of items in list response check failed!!") + + if (self.checkForExistenceOfValue(snapshotList,self.vm_d1_snapshot.id), + self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d1b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d12b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d2_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id)): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## ROOT Admin - Test cases with listall=false + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_listall_false(self): + """ + Test listing of Snapshots by passing listall="false" parameter as admin + Validate that it returns all the Snapshots owned by admin + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false") + self.debug ("List as ROOT Admin - listall=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_listall_false_rec_true(self): + """ + Test listing of Snapshots by passing listall="false" and isrecusrive="true" parameter as admin + Validate that it returns all the Snapshots owned by admin + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false",isrecursive="true") + self.debug ("List as ROOT Admin - listall=false,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_listall_false_rec_false(self): + """ + Test listing of Snapshots by passing listall="false" and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots owned by admin + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false",isrecursive="false") + self.debug ("List as ROOT Admin - listall=false,isrecursive=false %s" %snapshotList) + + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## ROOT Admin - Test cases without passing listall paramter + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin(self): + """ + Test listing of Snapshots by passing no parameter as admin + Validate that it returns all the Snapshots owned by admin + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient) + self.debug ("List as ROOT Admin %s" %snapshotList) + + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_rec_true(self): + """ + Test listing of Snapshots by passing isrecusrive="true" parameter as admin + Validate that it returns all the Snapshots owned by admin + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,isrecursive="true") + self.debug ("List as ROOT Admin - isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_rec_false(self): + """ + Test listing of Snapshots by passing isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots owned by admin + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,isrecursive="false") + self.debug ("List as ROOT Admin passing domainId - isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## ROOT Admin - Test cases when domainId is passed with listall =true + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_listall_true(self): + """ + Test listing of Snapshots by passing domainid and listall="true" parameter as admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="true") + self.debug ("List as ROOT Admin passing domainId - listall=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_listall_true_rec_true(self): + """ + Test listing of Snapshots by passing domainid , listall="true" and isrecusrive="true" parameter as admin + Validate that it returns all the Snapshots in the subdomain and the domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="true",isrecursive="true") + self.debug ("List as ROOT Admin passing domainId - listall=true,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 4, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_listall_true_rec_false(self): + """ + Test listing of Snapshots by passing domainid, listall="true" and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="true",isrecursive="false") + self.debug ("List as ROOT Admin passing domainId - listall=true,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## ROOT Admin - Test cases when domainId is passed with listall=false + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_listall_false(self): + """ + Test listing of Snapshots by passing domainid, listall="false" parameter as admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="false") + self.debug ("List as ROOT Admin passing domainId - listall=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_listall_false_rec_true(self): + """ + Test listing of Snapshots by passing domainid, listall="false" and isrecusrive="true" parameter as admin + Validate that it returns all the Snapshots in the subdoamin and domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="false",isrecursive="true") + self.debug ("List as ROOT Admin passing domainId - listall=false,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 4, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_listall_false_rec_false(self): + """ + Test listing of Snapshots by passing domainid, listall="false" and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,listall="false",isrecursive="false") + self.debug ("List as ROOT Admin passing domainId - listall=false,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## ROOT Admin - Test cases when domainId is passed with no listall parameter + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid(self): + """ + Test listing of Snapshots by passing domainid parameter as admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id) + self.debug ("List as ROOT Admin passing domainId - %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_rec_true(self): + """ + Test listing of Snapshots by passing domainid and isrecusrive="true" parameter as admin + Validate that it returns all the Snapshots in the subdmain and domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,isrecursive="true") + self.debug ("List as ROOT Admin passing domainId - isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 4, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d111a_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_rec_false(self): + """ + Test listing of Snapshots by passing domainid and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots in the domain passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_11.id,isrecursive="false") + self.debug ("List as ROOT Admin passing domainId - isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 3, + True, + "Number of items in list response check failed!!") + + if ( self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11a_snapshot.id) and + self.checkForExistenceOfValue(snapshotList,self.vm_d11b_snapshot.id) ): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## ROOT Admin - Test cases when account and domainId is passed with listall =true + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid_listall_true(self): + """ + Test listing of Snapshots by passing domainid,account ,listall = "true" parameter as admin + Validate that it returns all the Snapshots of account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="true") + self.debug ("List as ROOT Admin passing domainId and accountId - listall=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid_listall_true_rec_true(self): + """ + Test listing of Snapshots by passing domainid,account ,listall = "true" and isrecusrive="true" parameter as admin + Validate that it returns all the Snapshots of the account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="true",isrecursive="true") + self.debug ("List as ROOT Admin passing domainId and accountId - listall=true,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid_listall_true_rec_false(self): + """ + Test listing of Snapshots by passing domainid,account ,listall = "true" and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots of the account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="true",isrecursive="false") + self.debug ("List as ROOT Admin passing domainId and accountId - listall=true,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## ROOT Admin - Test cases when account and domainId is passed with listall=false + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid_listall_false(self): + """ + Test listing of Snapshots by passing domainid,account ,listall = "false" parameter as admin + Validate that it returns all the Snapshots of the account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="false") + self.debug ("List as ROOT Admin passing domainId and accountId - listall=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid_listall_false_rec_true(self): + """ + Test listing of Snapshots by passing domainid,account ,listall = "false" and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots of the account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="false",isrecursive="true") + self.debug ("List as ROOT Admin passing domainId and accountId - listall=false,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid_listall_false_rec_false(self): + """ + Test listing of Snapshots by passing domainid,account ,listall = "false" and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots of the account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,listall="false",isrecursive="false") + self.debug ("List as ROOT Admin passing domainId and accountId - listall=false,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## ROOT Admin - Test cases when account and domainId is passed with listall not passed + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid(self): + """ + Test listing of Snapshots by passing domainid,account parameter as admin + Validate that it returns all the Snapshots of the account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id) + self.debug ("List as ROOT Admin passing domainId and accountId - %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid_rec_true(self): + """ + Test listing of Snapshots by passing domainid,account and isrecusrive="true" parameter as admin + Validate that it returns all the Snapshots of the account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,isrecursive="true") + self.debug ("List as ROOT Admin passing domainId and accountId - isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_rootadmin_domainid_accountid_rec_false(self): + """ + Test listing of Snapshots by passing domainid,account and isrecusrive="false" parameter as admin + Validate that it returns all the Snapshots of the account that is passed + """ + + self.apiclient.connection.apiKey = self.user_a_apikey + self.apiclient.connection.securityKey = self.user_a_secretkey + snapshotList = Snapshot.list(self.apiclient,account=self.account_d11.user[0].username,domainid=self.domain_11.id,isrecursive="false") + self.debug ("List as ROOT Admin passing domainId and accountId - isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d11_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## Regular User - Test cases with listall =true + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_listall_true(self): + """ + Test listing of Snapshots by passing listall="true" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true") + self.debug ("List as Regular User - listall=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_listall_true_rec_true(self): + """ + Test listing of Snapshots by passing listall="true" and isrecusrive="true" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true",isrecursive="true") + self.debug ("List as Regular User - listall=true,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_listall_true_rec_false(self): + """ + Test listing of Snapshots by passing listall="true" and isrecusrive="false" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="true",isrecursive="false") + self.debug ("List as Regular User - listall=true,isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## Regular User - Test cases with listall=false + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_listall_false(self): + """ + Test listing of Snapshots by passing domainid,account,listall="false" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false") + self.debug ("List as Regular User - listall=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_listall_false_rec_true(self): + """ + Test listing of Snapshots by passing listall="false" and isrecusrive="true" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false",isrecursive="true") + self.debug ("List as Regular User - listall=false,isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_listall_false_rec_false(self): + """ + Test listing of Snapshots by passing listall="false" and isrecusrive="false" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,listall="false",isrecursive="false") + self.debug ("List as Regular User - listall=false,isrecursive=false %s" %snapshotList) + + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + +## Regular User - Test cases without passing listall paramter + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser(self): + """ + Test listing of Snapshots by passing no parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient) + self.debug ("List as Regular User %s" %snapshotList) + + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_rec_true(self): + """ + Test listing of Snapshots by passing isrecusrive="true" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,isrecursive="true") + self.debug ("List as Regular User - isrecursive=true %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_rec_false(self): + """ + Test listing of Snapshots by passing isrecusrive="false" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,isrecursive="false") + self.debug ("List as Regular User passing domainId - isrecursive=false %s" %snapshotList) + + self.assertEqual(len(snapshotList) == 1, + True, + "Number of items in list response check failed!!") + + if self.checkForExistenceOfValue(snapshotList,self.vm_d1a_snapshot.id): + accountAccess = True + else: + accountAccess = False + + self.assertEqual(accountAccess, + True, + "Account access check failed!!") + +## Regular User - Test cases when domainId is passed with listall =true + + @attr(tags=["advanced"],required_hardware="false") + def test_listSnapshot_as_regularuser_domainid_listall_true(self): + """ + Test listing of Snapshots by passing domainid,listall="true" parameter as regular user + Validate that it returns all the Snapshots of the account the user belongs to + """ + + self.apiclient.connection.apiKey = self.user_d1a_apikey + self.apiclient.connection.securityKey = self.user_d1a_secretkey + snapshotList = Snapshot.list(self.apiclient,domainid=self.domain_1.id,listall="true") + self.debug ("List as Regular User passing domainId - listall=true %s" %snapshotList) + + self.assertEqual(len(snapsho <TRUNCATED>