コード例 #1
0
ファイル: test.py プロジェクト: ravisantoshgudimetla/tempest
 def skip_checks(cls):
     """Class level skip checks. Subclasses verify in here all
     conditions that might prevent the execution of the entire test class.
     Checks implemented here may not make use API calls, and should rely on
     configuration alone.
     In general skip checks that require an API call are discouraged.
     If one is really needed it may be implemented either in the
     resource_setup or at test level.
     """
     identity_version = cls.get_identity_version()
     if 'admin' in cls.credentials and not credentials.is_admin_available(
             identity_version=identity_version):
         msg = "Missing Identity Admin API credentials in configuration."
         raise cls.skipException(msg)
     if 'alt' in cls.credentials and not credentials.is_alt_available(
             identity_version=identity_version):
         msg = "Missing a 2nd set of API credentials in configuration."
         raise cls.skipException(msg)
     if hasattr(cls, 'identity_version'):
         if cls.identity_version == 'v2':
             if not CONF.identity_feature_enabled.api_v2:
                 raise cls.skipException("Identity api v2 is not enabled")
         elif cls.identity_version == 'v3':
             if not CONF.identity_feature_enabled.api_v3:
                 raise cls.skipException("Identity api v3 is not enabled")
コード例 #2
0
    def run_test(self, tenant_isolation, use_accounts_file, admin_creds):

        cfg.CONF.set_default("use_dynamic_credentials", tenant_isolation, group="auth")
        if use_accounts_file:
            accounts = [
                {"username": "******", "tenant_name": "t1", "password": "******"},
                {"username": "******", "tenant_name": "t2", "password": "******"},
            ]
            if admin_creds == "role":
                accounts.append({"username": "******", "tenant_name": "admin", "password": "******", "roles": ["admin"]})
            elif admin_creds == "type":
                accounts.append({"username": "******", "tenant_name": "admin", "password": "******", "types": ["admin"]})
            self.useFixture(mockpatch.Patch("tempest.common.preprov_creds.read_accounts_yaml", return_value=accounts))
            cfg.CONF.set_default("test_accounts_file", use_accounts_file, group="auth")
            self.useFixture(mockpatch.Patch("os.path.isfile", return_value=True))
        else:
            self.useFixture(mockpatch.Patch("os.path.isfile", return_value=False))
            if admin_creds:
                (u, t, p) = ("u", "t", "p")
            else:
                (u, t, p) = (None, None, None)

            cfg.CONF.set_default("admin_username", u, group="auth")
            cfg.CONF.set_default("admin_tenant_name", t, group="auth")
            cfg.CONF.set_default("admin_password", p, group="auth")

        expected = admin_creds is not None or tenant_isolation
        observed = credentials.is_admin_available()
        self.assertEqual(expected, observed)
コード例 #3
0
 def skip_checks(cls):
     """Class level skip checks. Subclasses verify in here all
     conditions that might prevent the execution of the entire test class.
     Checks implemented here may not make use API calls, and should rely on
     configuration alone.
     In general skip checks that require an API call are discouraged.
     If one is really needed it may be implemented either in the
     resource_setup or at test level.
     """
     identity_version = cls.get_identity_version()
     if 'admin' in cls.credentials and not credentials.is_admin_available(
             identity_version=identity_version):
         msg = "Missing Identity Admin API credentials in configuration."
         raise cls.skipException(msg)
     if 'alt' in cls.credentials and not credentials.is_alt_available(
             identity_version=identity_version):
         msg = "Missing a 2nd set of API credentials in configuration."
         raise cls.skipException(msg)
     if hasattr(cls, 'identity_version'):
         if cls.identity_version == 'v2':
             if not CONF.identity_feature_enabled.api_v2:
                 raise cls.skipException("Identity api v2 is not enabled")
         elif cls.identity_version == 'v3':
             if not CONF.identity_feature_enabled.api_v3:
                 raise cls.skipException("Identity api v3 is not enabled")
コード例 #4
0
    def run_test(self, tenant_isolation, use_accounts_file, admin_creds):

        cfg.CONF.set_default('use_dynamic_credentials',
                             tenant_isolation,
                             group='auth')
        if use_accounts_file:
            accounts = [{
                'username': '******',
                'tenant_name': 't1',
                'password': '******'
            }, {
                'username': '******',
                'tenant_name': 't2',
                'password': '******'
            }]
            if admin_creds == 'role':
                accounts.append({
                    'username': '******',
                    'tenant_name': 'admin',
                    'password': '******',
                    'roles': ['admin']
                })
            elif admin_creds == 'type':
                accounts.append({
                    'username': '******',
                    'tenant_name': 'admin',
                    'password': '******',
                    'types': ['admin']
                })
            self.useFixture(
                mockpatch.Patch(
                    'tempest.common.preprov_creds.read_accounts_yaml',
                    return_value=accounts))
            cfg.CONF.set_default('test_accounts_file',
                                 use_accounts_file,
                                 group='auth')
            self.useFixture(
                mockpatch.Patch('os.path.isfile', return_value=True))
        else:
            self.useFixture(
                mockpatch.Patch('os.path.isfile', return_value=False))
            if admin_creds:
                (u, t, p, d) = ('u', 't', 'p', 'd')
            else:
                (u, t, p, d) = (None, None, None, None)

            cfg.CONF.set_default('admin_username', u, group='auth')
            cfg.CONF.set_default('admin_tenant_name', t, group='auth')
            cfg.CONF.set_default('admin_password', p, group='auth')
            cfg.CONF.set_default('admin_domain_name', d, group='auth')

        expected = admin_creds is not None or tenant_isolation
        observed = credentials.is_admin_available(
            identity_version=self.identity_version)
        self.assertEqual(expected, observed)
コード例 #5
0
ファイル: test.py プロジェクト: PandiSelvi/tempest
    def get_tenant_network(cls):
        """Get the network to be used in testing

        :return: network dict including 'id' and 'name'
        """
        # Make sure isolated_creds exists and get a network client
        networks_client = cls.get_client_manager().networks_client
        isolated_creds = getattr(cls, 'isolated_creds', None)
        if credentials.is_admin_available():
            admin_creds = isolated_creds.get_admin_creds()
            networks_client = clients.Manager(admin_creds).networks_client
        return fixed_network.get_tenant_network(isolated_creds,
                                                networks_client)
コード例 #6
0
    def run_test(self, dynamic_creds, use_accounts_file, admin_creds):

        cfg.CONF.set_default('use_dynamic_credentials',
                             dynamic_creds, group='auth')
        if use_accounts_file:
            accounts = [{'username': '******',
                         'tenant_name': 't1',
                         'password': '******'},
                        {'username': '******',
                         'tenant_name': 't2',
                         'password': '******'}]
            if admin_creds == 'role':
                accounts.append({'username': '******',
                                 'tenant_name': 'admin',
                                 'password': '******',
                                 'roles': ['admin']})
            elif admin_creds == 'type':
                accounts.append({'username': '******',
                                 'tenant_name': 'admin',
                                 'password': '******',
                                 'types': ['admin']})
            self.useFixture(mockpatch.Patch(
                'tempest.common.preprov_creds.read_accounts_yaml',
                return_value=accounts))
            cfg.CONF.set_default('test_accounts_file',
                                 use_accounts_file, group='auth')
            self.useFixture(mockpatch.Patch('os.path.isfile',
                                            return_value=True))
        else:
            self.useFixture(mockpatch.Patch('os.path.isfile',
                                            return_value=False))
            if admin_creds:
                username = '******'
                tenant = 't'
                password = '******'
                domain = 'd'
            else:
                username = None
                tenant = None
                password = None
                domain = None

            cfg.CONF.set_default('admin_username', username, group='auth')
            cfg.CONF.set_default('admin_tenant_name', tenant, group='auth')
            cfg.CONF.set_default('admin_password', password, group='auth')
            cfg.CONF.set_default('admin_domain_name', domain, group='auth')

        expected = admin_creds is not None or dynamic_creds
        observed = credentials.is_admin_available(
            identity_version=self.identity_version)
        self.assertEqual(expected, observed)
コード例 #7
0
ファイル: test.py プロジェクト: overcastcloud/tempest
 def skip_checks(cls):
     """Class level skip checks. Subclasses verify in here all
     conditions that might prevent the execution of the entire test class.
     Checks implemented here may not make use API calls, and should rely on
     configuration alone.
     In general skip checks that require an API call are discouraged.
     If one is really needed it may be implemented either in the
     resource_setup or at test level.
     """
     if 'admin' in cls.credentials and not credentials.is_admin_available():
         msg = "Missing Identity Admin API credentials in configuration."
         raise cls.skipException(msg)
     if 'alt' is cls.credentials and not credentials.is_alt_available():
         msg = "Missing a 2nd set of API credentials in configuration."
         raise cls.skipException(msg)
コード例 #8
0
ファイル: test.py プロジェクト: kevinbenton/tempest
 def skip_checks(cls):
     """Class level skip checks. Subclasses verify in here all
     conditions that might prevent the execution of the entire test class.
     Checks implemented here may not make use API calls, and should rely on
     configuration alone.
     In general skip checks that require an API call are discouraged.
     If one is really needed it may be implemented either in the
     resource_setup or at test level.
     """
     if 'admin' in cls.credentials and not credentials.is_admin_available():
         msg = "Missing Identity Admin API credentials in configuration."
         raise cls.skipException(msg)
     if 'alt' is cls.credentials and not credentials.is_alt_available():
         msg = "Missing a 2nd set of API credentials in configuration."
         raise cls.skipException(msg)
コード例 #9
0
    def get_tenant_network(cls):
        """Get the network to be used in testing

        :return: network dict including 'id' and 'name'
        """
        # Make sure isolated_creds exists and get a network client
        networks_client = cls.get_client_manager().networks_client
        cred_provider = cls._get_credentials_provider()
        # In case of nova network, isolated tenants are not able to list the
        # network configured in fixed_network_name, even if the can use it
        # for their servers, so using an admin network client to validate
        # the network name
        if (not CONF.service_available.neutron
                and credentials.is_admin_available()):
            admin_creds = cred_provider.get_admin_creds()
            networks_client = clients.Manager(admin_creds).networks_client
        return fixed_network.get_tenant_network(cred_provider, networks_client)
コード例 #10
0
    def get_tenant_network(cls):
        """Get the network to be used in testing

        :return: network dict including 'id' and 'name'
        """
        # Make sure isolated_creds exists and get a network client
        networks_client = cls.get_client_manager().networks_client
        cred_provider = cls._get_credentials_provider()
        # In case of nova network, isolated tenants are not able to list the
        # network configured in fixed_network_name, even if the can use it
        # for their servers, so using an admin network client to validate
        # the network name
        if (not CONF.service_available.neutron and
                credentials.is_admin_available()):
            admin_creds = cred_provider.get_admin_creds()
            networks_client = clients.Manager(admin_creds).networks_client
        return fixed_network.get_tenant_network(cred_provider,
                                                networks_client)
コード例 #11
0
    def run_test(self, tenant_isolation, use_accounts_file, admin_creds):

        cfg.CONF.set_default('allow_tenant_isolation',
                             tenant_isolation, group='auth')
        if use_accounts_file:
            accounts = [{'username': '******',
                         'tenant_name': 't1',
                         'password': '******'},
                        {'username': '******',
                         'tenant_name': 't2',
                         'password': '******'}]
            if admin_creds == 'role':
                accounts.append({'username': '******',
                                 'tenant_name': 'admin',
                                 'password': '******',
                                 'roles': ['admin']})
            elif admin_creds == 'type':
                accounts.append({'username': '******',
                                 'tenant_name': 'admin',
                                 'password': '******',
                                 'types': ['admin']})
            self.useFixture(mockpatch.Patch(
                'tempest.common.accounts.read_accounts_yaml',
                return_value=accounts))
            cfg.CONF.set_default('test_accounts_file',
                                 use_accounts_file, group='auth')
            self.useFixture(mockpatch.Patch('os.path.isfile',
                                            return_value=True))
        else:
            self.useFixture(mockpatch.Patch('os.path.isfile',
                                            return_value=False))
            if admin_creds:
                (u, t, p) = ('u', 't', 'p')
            else:
                (u, t, p) = (None, None, None)

            cfg.CONF.set_default('admin_username', u, group='identity')
            cfg.CONF.set_default('admin_tenant_name', t, group='identity')
            cfg.CONF.set_default('admin_password', p, group='identity')

        expected = admin_creds is not None or tenant_isolation
        observed = credentials.is_admin_available()
        self.assertEqual(expected, observed)
コード例 #12
0
ファイル: base.py プロジェクト: Dynavisor/tempest
 def skip_checks(cls):
     super(BaseAdminNetworkTest, cls).skip_checks()
     if not credentials.is_admin_available():
         msg = ("Missing Administrative Network API credentials "
                "in configuration.")
         raise cls.skipException(msg)
コード例 #13
0
 def skip_checks(cls):
     super(VolumesV2TransfersTest, cls).skip_checks()
     if not credentials.is_admin_available():
         msg = "Missing Volume Admin API credentials in configuration."
         raise cls.skipException(msg)
コード例 #14
0
 def skip_checks(cls):
     super(TestAggregatesBasicOps, cls).skip_checks()
     if not credentials.is_admin_available():
         msg = ("Missing Identity Admin API credentials in configuration.")
         raise cls.skipException(msg)
コード例 #15
0
    def execute(self, description):
        """
        Execute a http call on an api that are expected to
        result in client errors. First it uses invalid resources that are part
        of the url, and then invalid data for queries and http request bodies.

        :param description: A json file or dictionary with the following
        entries:
            name (required) name for the api
            http-method (required) one of HEAD,GET,PUT,POST,PATCH,DELETE
            url (required) the url to be appended to the catalog url with '%s'
                for each resource mentioned
            resources: (optional) A list of resource names such as "server",
                "flavor", etc. with an element for each '%s' in the url. This
                method will call self.get_resource for each element when
                constructing the positive test case template so negative
                subclasses are expected to return valid resource ids when
                appropriate.
            json-schema (optional) A valid json schema that will be used to
                create invalid data for the api calls. For "GET" and "HEAD",
                the data is used to generate query strings appended to the url,
                otherwise for the body of the http call.

        """
        LOG.info("Executing %s" % description["name"])
        LOG.debug(description)
        generator = importutils.import_class(
            CONF.negative.test_generator)()
        schema = description.get("json-schema", None)
        method = description["http-method"]
        url = description["url"]
        expected_result = None
        if "default_result_code" in description:
            expected_result = description["default_result_code"]

        resources = [self.get_resource(r) for
                     r in description.get("resources", [])]

        if hasattr(self, "resource"):
            # Note(mkoderer): The resources list already contains an invalid
            # entry (see get_resource).
            # We just send a valid json-schema with it
            valid_schema = None
            if schema:
                valid_schema = \
                    valid.ValidTestGenerator().generate_valid(schema)
            new_url, body = self._http_arguments(valid_schema, url, method)
        elif hasattr(self, "_negtest_name"):
            schema_under_test = \
                valid.ValidTestGenerator().generate_valid(schema)
            local_expected_result = \
                generator.generate_payload(self, schema_under_test)
            if local_expected_result is not None:
                expected_result = local_expected_result
            new_url, body = \
                self._http_arguments(schema_under_test, url, method)
        else:
            raise Exception("testscenarios are not active. Please make sure "
                            "that your test runner supports the load_tests "
                            "mechanism")

        if "admin_client" in description and description["admin_client"]:
            if not credentials.is_admin_available():
                msg = ("Missing Identity Admin API credentials in"
                       "configuration.")
                raise self.skipException(msg)
            creds = self.credentials_provider.get_admin_creds()
            os_adm = clients.Manager(credentials=creds)
            client = os_adm.negative_client
        else:
            client = self.client
        resp, resp_body = client.send_request(method, new_url,
                                              resources, body=body)
        self._check_negative_response(expected_result, resp.status, resp_body)
コード例 #16
0
 def skip_checks(cls):
     if not credentials.is_admin_available():
         msg = ("Missing Identity Admin API credentials in configuration.")
         raise cls.skipException(msg)
     super(BaseComputeAdminTest, cls).skip_checks()
コード例 #17
0
ファイル: base.py プロジェクト: Dynavisor/tempest
 def skip_checks(cls):
     if not credentials.is_admin_available():
         raise cls.skipException('v3 Admin auth disabled')
     super(BaseIdentityV3AdminTest, cls).skip_checks()
コード例 #18
0
    def execute(self, description):
        """
        Execute a http call on an api that are expected to
        result in client errors. First it uses invalid resources that are part
        of the url, and then invalid data for queries and http request bodies.

        :param description: A json file or dictionary with the following
        entries:
            name (required) name for the api
            http-method (required) one of HEAD,GET,PUT,POST,PATCH,DELETE
            url (required) the url to be appended to the catalog url with '%s'
                for each resource mentioned
            resources: (optional) A list of resource names such as "server",
                "flavor", etc. with an element for each '%s' in the url. This
                method will call self.get_resource for each element when
                constructing the positive test case template so negative
                subclasses are expected to return valid resource ids when
                appropriate.
            json-schema (optional) A valid json schema that will be used to
                create invalid data for the api calls. For "GET" and "HEAD",
                the data is used to generate query strings appended to the url,
                otherwise for the body of the http call.

        """
        LOG.info("Executing %s" % description["name"])
        LOG.debug(description)
        generator = importutils.import_class(CONF.negative.test_generator)()
        schema = description.get("json-schema", None)
        method = description["http-method"]
        url = description["url"]
        expected_result = None
        if "default_result_code" in description:
            expected_result = description["default_result_code"]

        resources = [
            self.get_resource(r) for r in description.get("resources", [])
        ]

        if hasattr(self, "resource"):
            # Note(mkoderer): The resources list already contains an invalid
            # entry (see get_resource).
            # We just send a valid json-schema with it
            valid_schema = None
            if schema:
                valid_schema = \
                    valid.ValidTestGenerator().generate_valid(schema)
            new_url, body = self._http_arguments(valid_schema, url, method)
        elif hasattr(self, "_negtest_name"):
            schema_under_test = \
                valid.ValidTestGenerator().generate_valid(schema)
            local_expected_result = \
                generator.generate_payload(self, schema_under_test)
            if local_expected_result is not None:
                expected_result = local_expected_result
            new_url, body = \
                self._http_arguments(schema_under_test, url, method)
        else:
            raise Exception("testscenarios are not active. Please make sure "
                            "that your test runner supports the load_tests "
                            "mechanism")

        if "admin_client" in description and description["admin_client"]:
            if not credentials.is_admin_available():
                msg = ("Missing Identity Admin API credentials in"
                       "configuration.")
                raise self.skipException(msg)
            creds = self.credentials_provider.get_admin_creds()
            os_adm = clients.Manager(credentials=creds)
            client = os_adm.negative_client
        else:
            client = self.client
        resp, resp_body = client.send_request(method,
                                              new_url,
                                              resources,
                                              body=body)
        self._check_negative_response(expected_result, resp.status, resp_body)
コード例 #19
0
 def skip_checks(cls):
     super(VolumesV2TransfersTest, cls).skip_checks()
     if not credentials.is_admin_available():
         msg = "Missing Volume Admin API credentials in configuration."
         raise cls.skipException(msg)
コード例 #20
0
ファイル: base.py プロジェクト: PandiSelvi/tempest
 def skip_checks(cls):
     super(BaseAdminNetworkTest, cls).skip_checks()
     if not credentials.is_admin_available():
         msg = ("Missing Administrative Network API credentials "
                "in configuration.")
         raise cls.skipException(msg)
コード例 #21
0
ファイル: base.py プロジェクト: Dynavisor/tempest
 def skip_checks(cls):
     super(BaseComputeAdminTest, cls).skip_checks()
     if not credentials.is_admin_available():
         msg = ("Missing Identity Admin API credentials in configuration.")
         raise cls.skipException(msg)
コード例 #22
0
ファイル: base.py プロジェクト: PandiSelvi/tempest
 def skip_checks(cls):
     if not credentials.is_admin_available():
         raise cls.skipException('v2 Admin auth disabled')
     super(BaseIdentityV2AdminTest, cls).skip_checks()