def test_LoginApiUuidResponse(self):
        """Test if Login API does not return UUID's
        """

        # Steps for test scenario
        # 1. create a user account
        # 2. login to the user account with given credentials (loginCmd)
        # 3. delete the user account
        # Validate the following
        # 1. listAccounts should return account created
        # 2. loginResponse should have UUID only is response. Assert by
        #    checking database id is not same as response id
        #    Login also succeeds with non NULL sessionId in response

        self.debug("Creating an user account..")
        self.account = Account.create(
                                     self.apiclient,
                                     self.services["account"],
                                     domainid=self.domain.id
                                     )
        self._cleanup.append(self.account)

        self.debug("Logging into the cloudstack with login API")
        respose = User.login(
                             self.apiclient,
                             username=self.account.name,
                             password=self.services["account"]["password"]
                             )

        self.debug("Login API response: %s" % respose)

        self.assertNotEqual(
                            respose.sessionkey,
                            None,
                            "Login to the CloudStack should be successful" +
                            "response shall have non Null key"
                            )
        return
    def setUpClass(cls):
        testClient = super(TestAdvancedZoneStoppedVM, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        cls.hypervisor = testClient.getHypervisorInfo()
        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient)
        cls._cleanup = []

        try:
            # Create an account
            cls.account = Account.create(cls.apiclient,
                                         cls.testdata["account"],
                                         domainid=cls.domain.id)
            cls._cleanup.append(cls.account)

            # If local storage is enabled, alter the offerings to use
            # localstorage
            if cls.zone.localstorageenable:
                cls.testdata["service_offering"]["storagetype"] = 'local'

            # Create 2 service offerings with different values for
            # for cpunumber, cpuspeed, and memory

            cls.testdata["service_offering"]["cpunumber"] = 1
            cls.testdata["service_offering"]["cpuspeed"] = 128
            cls.testdata["service_offering"]["memory"] = 256

            cls.service_offering = ServiceOffering.create(
                cls.apiclient, cls.testdata["service_offering"])
            cls._cleanup.append(cls.service_offering)

            cls.testdata["service_offering"]["cpunumber"] = 2

            cls.service_offering_2 = ServiceOffering.create(
                cls.apiclient, cls.testdata["service_offering"])
            cls._cleanup.append(cls.service_offering_2)

            # Create isolated network offering
            cls.isolated_network_offering = CreateEnabledNetworkOffering(
                cls.apiclient, cls.testdata["isolated_network_offering"])
            cls._cleanup.append(cls.isolated_network_offering)

            cls.networkid = None
            if str(cls.zone.networktype).lower() == "advanced":
                cls.network = Network.create(
                    cls.apiclient,
                    cls.testdata["isolated_network"],
                    networkofferingid=cls.isolated_network_offering.id,
                    accountid=cls.account.name,
                    domainid=cls.account.domainid,
                    zoneid=cls.zone.id)
                cls.networkid = cls.network.id

            # Create user api client of the account
            cls.userapiclient = testClient.getUserApiClient(
                UserName=cls.account.name, DomainName=cls.account.domain)

            template = get_template(cls.apiclient, cls.zone.id,
                                    cls.testdata["ostype"])
            cls.defaultTemplateId = template.id
            # Set Zones and disk offerings

            # Check that we are able to login to the created account
            respose = User.login(cls.apiclient,
                                 username=cls.account.name,
                                 password=cls.testdata["account"]["password"])

            assert respose.sessionkey is not None, \
                "Login to the CloudStack should be successful\
                            response shall have non Null key"

        except Exception as e:
            cls.tearDownClass()
            raise e
        return
示例#3
0
    def setUpClass(cls):
        testClient = super(TestPathVMLC, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        cls.hypervisor = testClient.getHypervisorInfo()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient)
        cls._cleanup = []

        try:
            # Create an account
            cls.account = Account.create(
                cls.apiclient,
                cls.testdata["account"],
                domainid=cls.domain.id
            )
            cls._cleanup.append(cls.account)

            # If local storage is enabled, alter the offerings to use
            # localstorage
            if cls.zone.localstorageenable:
                cls.testdata["service_offering"]["storagetype"] = 'local'

            # Create 3 service offerings with different values for
            # for cpunumber, cpuspeed, and memory

            cls.testdata["service_offering"]["cpuspeed"] = 128
            cls.testdata["service_offering"]["memory"] = 256

            cls.testdata["service_offering"]["cpunumber"] = 1

            cls.service_offering_1 = ServiceOffering.create(
                cls.apiclient,
                cls.testdata["service_offering"]
            )
            cls._cleanup.append(cls.service_offering_1)

            cls.testdata["service_offering"]["cpunumber"] = 2
            cls.service_offering_2 = ServiceOffering.create(
                cls.apiclient,
                cls.testdata["service_offering"]
            )
            cls._cleanup.append(cls.service_offering_2)

            # Create isolated network offering
            cls.isolated_network_offering = CreateEnabledNetworkOffering(
                cls.apiclient,
                cls.testdata["isolated_network_offering"]
            )
            cls._cleanup.append(cls.isolated_network_offering)

            # Create shared network offering
            cls.testdata["shared_network_offering_all_services"][
                "specifyVlan"] = "True"
            cls.testdata["shared_network_offering_all_services"][
                "specifyIpRanges"] = "True"

            cls.shared_network_offering = CreateEnabledNetworkOffering(
                cls.apiclient,
                cls.testdata["shared_network_offering_all_services"]
            )
            cls._cleanup.append(cls.shared_network_offering)

            cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(
                cls.apiclient,
                cls.testdata["nw_offering_isolated_vpc"]
            )
            cls._cleanup.append(cls.isolated_network_offering_vpc)
            cls.vpc_off = VpcOffering.create(cls.apiclient,
                                             cls.testdata["vpc_offering"]
                                             )
            cls.vpc_off.update(cls.apiclient, state='Enabled')
            cls._cleanup.append(cls.vpc_off)

            # This variable will store the id of vpc network whenever
            # test case creates it
            # If not created, it will be None and will not be used
            cls.vpcid = None

            # Create user api client of the account
            cls.userapiclient = testClient.getUserApiClient(
                UserName=cls.account.name,
                DomainName=cls.account.domain
            )

            # Register a private template in the account
            builtin_info = get_builtin_template_info(cls.apiclient,
                                                     cls.zone.id)

            cls.testdata["privatetemplate"]["url"] = builtin_info[0]
            cls.testdata["privatetemplate"]["hypervisor"] = builtin_info[1]
            cls.testdata["privatetemplate"]["format"] = builtin_info[2]

            # Register new template
            cls.template = Template.register(
                cls.userapiclient,
                cls.testdata["privatetemplate"],
                zoneid=cls.zone.id,
                account=cls.account.name,
                domainid=cls.account.domainid
            )

            # Wait for template to download
            cls.template.download(cls.apiclient)

            # Check that we are able to login to the created account
            respose = User.login(
                cls.apiclient,
                username=cls.account.name,
                password=cls.testdata["account"]["password"]
            )

            assert respose.sessionkey is not None,\
                "Login to the CloudStack should be successful\
                            response shall have non Null key"

        except Exception as e:
            cls.tearDownClass()
            raise e
        return
    def test_LoginApiDomain(self):
        """Test login API with domain
        """

        # Steps for test scenario
        # 1. create a domain
        # 2. create user in the domain
        # 3. login to the user account above using UUID domain/user
        # 4. delete the user account
        # Validate the following
        # 1. listDomains returns created domain
        # 2. listAccounts returns created user
        # 3. loginResponse should have UUID only in responses
        #    Login also succeeds with non NULL sessionId in response

        self.debug("Creating a domain for login with API domain test")
        domain = Domain.create(
                                self.apiclient,
                                self.services["domain"],
                                parentdomainid=self.domain.id
                                )
        self.debug("Domain: %s is created succesfully." % domain.name)
        self.debug(
            "Checking if the created domain is listed in list domains API")
        domains = Domain.list(self.apiclient, id=domain.id, listall=True)

        self.assertEqual(
                         isinstance(domains, list),
                         True,
                         "List domains shall return a valid response"
                         )
        self.debug("Creating an user account in domain: %s" % domain.name)
        self.account = Account.create(
                                     self.apiclient,
                                     self.services["account"],
                                     domainid=domain.id
                                     )
        self._cleanup.append(self.account)

        accounts = Account.list(
                                self.apiclient,
                                name=self.account.name,
                                domainid=self.account.domainid,
                                listall=True
                                )

        self.assertEqual(
                         isinstance(accounts, list),
                         True,
                         "List accounts should return a valid response"
                         )

        self.debug("Logging into the cloudstack with login API")
        respose = User.login(
                             self.apiclient,
                             username=self.account.name,
                             password=self.services["account"]["password"],
                             domainid=domain.id)
        self.debug("Login API response: %s" % respose)

        self.assertNotEqual(
                            respose.sessionkey,
                            None,
                            "Login to the CloudStack should be successful" +
                            "response shall have non Null key"
                            )
        return
 def setUpClass(cls):
     testClient = super(TestPathVolume, cls).getClsTestClient()
     cls.apiclient = testClient.getApiClient()
     cls.testdata = testClient.getParsedTestDataConfig()
     #Get Zone,Domain and templates
     cls.domain = get_domain(cls.apiclient)
     cls.zone = get_zone(cls.apiclient)
     cls.testdata["mode"] = cls.zone.networktype
     cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"])
     cls.testdata["template"]["ostypeid"] = cls.template.ostypeid
     if cls.template == FAILED:
             cls.fail("get_template() failed to return template with description %s" % cls.testdata["ostype"])
     cls._cleanup = []
     try:
         cls.account = Account.create(cls.apiclient,
                                      cls.testdata["account"],
                                      domainid=cls.domain.id
                                      )
         cls._cleanup.append(cls.account)
         #createa two service offerings
         cls.service_offering_1 = ServiceOffering.create(cls.apiclient, cls.testdata["service_offerings"]["small"])
         cls._cleanup.append(cls.service_offering_1)
         # Create Disk offerings
         cls.disk_offering_1 = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"])
         cls._cleanup.append(cls.disk_offering_1)
         #check if zone wide storage is enable
         cls.list_storage = StoragePool.list(cls.apiclient,
                                             scope="ZONE"
                                             )
         if cls.list_storage:
             cls.zone_wide_storage = cls.list_storage[0]
             cls.debug("zone wide storage id is %s" % cls.zone_wide_storage.id)
             cls.testdata["tags"] = "zp"
             update1 = StoragePool.update(cls.apiclient,
                                          id=cls.zone_wide_storage.id,
                                          tags=cls.testdata["tags"]
                                          )
             cls.debug("Storage %s pool tag%s" % (cls.zone_wide_storage.id, update1.tags))
             cls.testdata["service_offerings"]["tags"] = "zp"
             cls.tagged_so = ServiceOffering.create(cls.apiclient, cls.testdata["service_offerings"])
             cls.testdata["service_offerings"]["tags"] = " "
             cls._cleanup.append(cls.tagged_so)
             #create tagged disk offerings
             cls.testdata["disk_offering"]["tags"] = "zp"
             cls.disk_offering_tagged = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"])
             cls._cleanup.append(cls.disk_offering_tagged)
         else:
             cls.debug("No zone wide storage found")
         #check if local storage is enable
         if cls.zone.localstorageenabled:
             cls.testdata["disk_offering"]["tags"] = " "
             cls.testdata["service_offerings"]["storagetype"] = 'local'
             cls.service_offering_2 = ServiceOffering.create(cls.apiclient, cls.testdata["service_offerings"])
             cls._cleanup.append(cls.service_offering_2)
             #craete a compute offering with local storage
             cls.testdata["disk_offering"]["storagetype"] = 'local'
             cls.disk_offering_local = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"])
             cls._cleanup.append(cls.disk_offering_local)
             cls.testdata["disk_offering"]["storagetype"] = ' '
         else:
             cls.debug("No local storage found")
         cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name,
                                                         DomainName=cls.account.domain
                                                         )
         #Check if login is successful with new account
         response = User.login(cls.userapiclient,
                               username=cls.account.name,
                               password=cls.testdata["account"]["password"]
                               )
         assert response.sessionkey is not None
         #response should have non null value
     except Exception as e:
             cls.tearDownClass()
             raise e
     return
示例#6
0
    def setUpClass(cls):
        testClient = super(TestAdvancedZoneStoppedVM, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient)
        cls._cleanup = []

        try:
            # Create an account
            cls.account = Account.create(
                cls.apiclient,
                cls.testdata["account"],
                domainid=cls.domain.id
            )
            cls._cleanup.append(cls.account)

            # If local storage is enabled, alter the offerings to use
            # localstorage
            if cls.zone.localstorageenable:
                cls.testdata["service_offering"]["storagetype"] = 'local'

            # Create 2 service offerings with different values for
            # for cpunumber, cpuspeed, and memory

            cls.testdata["service_offering"]["cpunumber"] = "1"
            cls.testdata["service_offering"]["cpuspeed"] = "128"
            cls.testdata["service_offering"]["memory"] = "256"

            cls.service_offering = ServiceOffering.create(
                cls.apiclient,
                cls.testdata["service_offering"]
            )
            cls._cleanup.append(cls.service_offering)

            cls.testdata["service_offering"]["cpunumber"] = "2"
            cls.testdata["service_offering"]["cpuspeed"] = "256"
            cls.testdata["service_offering"]["memory"] = "512"

            cls.service_offering_2 = ServiceOffering.create(
                cls.apiclient,
                cls.testdata["service_offering"]
            )
            cls._cleanup.append(cls.service_offering_2)

            # Create isolated network offering
            cls.isolated_network_offering = CreateEnabledNetworkOffering(
                cls.apiclient,
                cls.testdata["isolated_network_offering"]
            )
            cls._cleanup.append(cls.isolated_network_offering)

            cls.networkid = None
            if str(cls.zone.networktype).lower() == "advanced":
                cls.network = Network.create(
                    cls.apiclient, cls.testdata["isolated_network"],
                    networkofferingid=cls.isolated_network_offering.id,
                    accountid=cls.account.name,
                    domainid=cls.account.domainid,
                    zoneid=cls.zone.id)
                cls.networkid = cls.network.id

            # Create user api client of the account
            cls.userapiclient = testClient.getUserApiClient(
                UserName=cls.account.name,
                DomainName=cls.account.domain
            )

            template = get_template(
                cls.apiclient,
                cls.zone.id,
                cls.testdata["ostype"])
            cls.defaultTemplateId = template.id
            # Set Zones and disk offerings

            # Check that we are able to login to the created account
            respose = User.login(
                cls.apiclient,
                username=cls.account.name,
                password=cls.testdata["account"]["password"]
            )

            assert respose.sessionkey is not None,\
                "Login to the CloudStack should be successful\
                            response shall have non Null key"

        except Exception as e:
            cls.tearDownClass()
            raise e
        return
    def setUpClass(cls):
        testClient = super(TestPathVMLC, cls).getClsTestClient()
        cls.apiclient = testClient.getApiClient()
        cls.testdata = testClient.getParsedTestDataConfig()
        cls.hypervisor = testClient.getHypervisorInfo()

        # Get Zone, Domain and templates
        cls.domain = get_domain(cls.apiclient)
        cls.zone = get_zone(cls.apiclient)
        cls._cleanup = []

        try:
            # Create an account
            cls.account = Account.create(cls.apiclient,
                                         cls.testdata["account"],
                                         domainid=cls.domain.id)
            cls._cleanup.append(cls.account)

            # If local storage is enabled, alter the offerings to use
            # localstorage
            if cls.zone.localstorageenable:
                cls.testdata["service_offering"]["storagetype"] = 'local'

            # Create 3 service offerings with different values for
            # for cpunumber, cpuspeed, and memory

            cls.testdata["service_offering"]["cpuspeed"] = 128
            cls.testdata["service_offering"]["memory"] = 256

            cls.testdata["service_offering"]["cpunumber"] = 1

            cls.service_offering_1 = ServiceOffering.create(
                cls.apiclient, cls.testdata["service_offering"])
            cls._cleanup.append(cls.service_offering_1)

            cls.testdata["service_offering"]["cpunumber"] = 2
            cls.service_offering_2 = ServiceOffering.create(
                cls.apiclient, cls.testdata["service_offering"])
            cls._cleanup.append(cls.service_offering_2)

            # Create isolated network offering
            cls.isolated_network_offering = CreateEnabledNetworkOffering(
                cls.apiclient, cls.testdata["isolated_network_offering"])
            cls._cleanup.append(cls.isolated_network_offering)

            # Create shared network offering
            cls.testdata["shared_network_offering_all_services"][
                "specifyVlan"] = "True"
            cls.testdata["shared_network_offering_all_services"][
                "specifyIpRanges"] = "True"

            cls.shared_network_offering = CreateEnabledNetworkOffering(
                cls.apiclient,
                cls.testdata["shared_network_offering_all_services"])
            cls._cleanup.append(cls.shared_network_offering)

            cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(
                cls.apiclient, cls.testdata["nw_offering_isolated_vpc"])
            cls._cleanup.append(cls.isolated_network_offering_vpc)
            cls.vpc_off = VpcOffering.create(cls.apiclient,
                                             cls.testdata["vpc_offering"])
            cls.vpc_off.update(cls.apiclient, state='Enabled')
            cls._cleanup.append(cls.vpc_off)

            # This variable will store the id of vpc network whenever
            # test case creates it
            # If not created, it will be None and will not be used
            cls.vpcid = None

            # Create user api client of the account
            cls.userapiclient = testClient.getUserApiClient(
                UserName=cls.account.name, DomainName=cls.account.domain)

            # Register a private template in the account
            builtin_info = get_builtin_template_info(cls.apiclient,
                                                     cls.zone.id)

            cls.testdata["privatetemplate"]["url"] = builtin_info[0]
            cls.testdata["privatetemplate"]["hypervisor"] = builtin_info[1]
            cls.testdata["privatetemplate"]["format"] = builtin_info[2]

            # Register new template
            cls.template = Template.register(cls.userapiclient,
                                             cls.testdata["privatetemplate"],
                                             zoneid=cls.zone.id,
                                             account=cls.account.name,
                                             domainid=cls.account.domainid)

            # Wait for template to download
            cls.template.download(cls.apiclient)

            # Check that we are able to login to the created account
            respose = User.login(cls.apiclient,
                                 username=cls.account.name,
                                 password=cls.testdata["account"]["password"])

            assert respose.sessionkey is not None,\
                "Login to the CloudStack should be successful\
                            response shall have non Null key"

        except Exception as e:
            cls.tearDownClass()
            raise e
        return