def run_test(self, dynamic_creds, use_accounts_file, creds):

        cfg.CONF.set_default('use_dynamic_credentials',
                             dynamic_creds,
                             group='auth')
        if use_accounts_file:
            accounts = [
                dict(username="******" % ii,
                     project_name="t%s" % ii,
                     password="******") for ii in creds
            ]
            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))
        expected = len(set(creds)) > 1 or dynamic_creds
        observed = credentials.is_alt_available(
            identity_version=self.identity_version)
        self.assertEqual(expected, observed)
예제 #2
0
파일: test.py 프로젝트: jerryz1982/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")
예제 #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, dynamic_creds, use_accounts_file, creds):

        cfg.CONF.set_default("use_dynamic_credentials", dynamic_creds, group="auth")
        if use_accounts_file:
            accounts = [dict(username="******" % ii, tenant_name="t%s" % ii, password="******") for ii in creds]
            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))
            cred_prefix = ["", "alt_"]
            for ii in range(0, 2):
                if len(creds) > ii:
                    username = "******" % creds[ii]
                    tenant = "t%s" % creds[ii]
                    password = "******"
                    domain = "d"
                else:
                    username = None
                    tenant = None
                    password = None
                    domain = None

                cfg.CONF.set_default("%susername" % cred_prefix[ii], username, group="identity")
                cfg.CONF.set_default("%stenant_name" % cred_prefix[ii], tenant, group="identity")
                cfg.CONF.set_default("%spassword" % cred_prefix[ii], password, group="identity")
                cfg.CONF.set_default("%sdomain_name" % cred_prefix[ii], domain, group="identity")

        expected = len(set(creds)) > 1 or dynamic_creds
        observed = credentials.is_alt_available(identity_version=self.identity_version)
        self.assertEqual(expected, observed)
예제 #5
0
파일: test.py 프로젝트: sapcc/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. Skipping here prevents any other
        class fixture from being executed i.e. no credentials or other
        resource allocation will happen.

        Tests defined in the test class will no longer appear in test results.
        The `setUpClass` for the entire test class will be marked as SKIPPED
        instead.

        At this stage no test credentials are available, so skip checks
        should rely on configuration alone. This is deliberate since skips
        based on the result of an API call are discouraged.

        The following checks are implemented in `test.py` already:

        - check that alt credentials are available when requested by the test
        - check that admin credentials are available when requested by the test
        - check that the identity version specified by the test is marked as
          enabled in the configuration

        Overriders of skip_checks must always invoke skip_check on `super`
        first.

        Example::

            @classmethod
            def skip_checks(cls):
                super(Example, cls).skip_checks()
                if not CONF.service_available.my_service:
                    skip_msg = ("%s skipped as my_service is not available")
                    raise cls.skipException(skip_msg % cls.__name__)
        """
        cls.__skip_checks_called = True
        identity_version = cls.get_identity_version()
        # setting force_tenant_isolation to True also needs admin credentials.
        if ('admin' in cls.credentials or 'alt_admin' in cls.credentials
                or getattr(cls, 'force_tenant_isolation', False)):
            if not credentials.is_admin_available(
                    identity_version=identity_version):
                raise cls.skipException(
                    "Missing Identity Admin API credentials in configuration.")
        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")
예제 #6
0
파일: test.py 프로젝트: openstack/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. Skipping here prevents any other
        class fixture from being executed i.e. no credentials or other
        resource allocation will happen.

        Tests defined in the test class will no longer appear in test results.
        The `setUpClass` for the entire test class will be marked as SKIPPED
        instead.

        At this stage no test credentials are available, so skip checks
        should rely on configuration alone. This is deliberate since skips
        based on the result of an API call are discouraged.

        The following checks are implemented in `test.py` already:

        - check that alt credentials are available when requested by the test
        - check that admin credentials are available when requested by the test
        - check that the identity version specified by the test is marked as
          enabled in the configuration

        Overriders of skip_checks must always invoke skip_check on `super`
        first.

        Example::

            @classmethod
            def skip_checks(cls):
                super(Example, cls).skip_checks()
                if not CONF.service_available.my_service:
                    skip_msg = ("%s skipped as my_service is not available")
                    raise cls.skipException(skip_msg % cls.__name__)
        """
        cls.__skip_checks_called = True
        identity_version = cls.get_identity_version()
        # setting force_tenant_isolation to True also needs admin credentials.
        if ('admin' in cls.credentials or
                getattr(cls, 'force_tenant_isolation', False)):
            if not credentials.is_admin_available(
                    identity_version=identity_version):
                raise cls.skipException(
                    "Missing Identity Admin API credentials in configuration.")
        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")
예제 #7
0
    def run_test(self, dynamic_creds, use_accounts_file, creds):

        cfg.CONF.set_default('use_dynamic_credentials',
                             dynamic_creds,
                             group='auth')
        if use_accounts_file:
            accounts = [
                dict(username="******" % ii,
                     project_name="t%s" % ii,
                     password="******") for ii in creds
            ]
            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))
            cred_prefix = ['', 'alt_']
            for ii in range(0, 2):
                if len(creds) > ii:
                    username = '******' % creds[ii]
                    project = 't%s' % creds[ii]
                    password = '******'
                    domain = 'd'
                else:
                    username = None
                    project = None
                    password = None
                    domain = None

                cfg.CONF.set_default('%susername' % cred_prefix[ii],
                                     username,
                                     group='identity')
                cfg.CONF.set_default('%sproject_name' % cred_prefix[ii],
                                     project,
                                     group='identity')
                cfg.CONF.set_default('%spassword' % cred_prefix[ii],
                                     password,
                                     group='identity')
                cfg.CONF.set_default('%sdomain_name' % cred_prefix[ii],
                                     domain,
                                     group='identity')

        expected = len(set(creds)) > 1 or dynamic_creds
        observed = credentials.is_alt_available(
            identity_version=self.identity_version)
        self.assertEqual(expected, observed)
예제 #8
0
    def run_test(self, dynamic_creds, use_accounts_file, creds):

        cfg.CONF.set_default('use_dynamic_credentials',
                             dynamic_creds, group='auth')
        if use_accounts_file:
            accounts = [dict(username="******" % ii,
                             project_name="t%s" % ii,
                             password="******") for ii in creds]
            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))
            cred_prefix = ['', 'alt_']
            for ii in range(0, 2):
                if len(creds) > ii:
                    username = '******' % creds[ii]
                    project = 't%s' % creds[ii]
                    password = '******'
                    domain = 'd'
                else:
                    username = None
                    project = None
                    password = None
                    domain = None

                cfg.CONF.set_default('%susername' % cred_prefix[ii], username,
                                     group='identity')
                cfg.CONF.set_default('%sproject_name' % cred_prefix[ii],
                                     project, group='identity')
                cfg.CONF.set_default('%spassword' % cred_prefix[ii], password,
                                     group='identity')
                cfg.CONF.set_default('%sdomain_name' % cred_prefix[ii], domain,
                                     group='identity')

        expected = len(set(creds)) > 1 or dynamic_creds
        observed = credentials.is_alt_available(
            identity_version=self.identity_version)
        self.assertEqual(expected, observed)
예제 #9
0
    def run_test(self, dynamic_creds, use_accounts_file, creds):

        cfg.CONF.set_default('use_dynamic_credentials',
                             dynamic_creds, group='auth')
        if use_accounts_file:
            accounts = [dict(username="******" % ii,
                             project_name="t%s" % ii,
                             password="******") for ii in creds]
            self.useFixture(fixtures.MockPatch(
                'tempest.lib.common.preprov_creds.read_accounts_yaml',
                return_value=accounts))
            cfg.CONF.set_default('test_accounts_file',
                                 use_accounts_file, group='auth')
            self.useFixture(fixtures.MockPatch('os.path.isfile',
                                               return_value=True))
        else:
            self.useFixture(fixtures.MockPatch('os.path.isfile',
                                               return_value=False))
        expected = len(set(creds)) > 1 or dynamic_creds
        observed = credentials.is_alt_available(
            identity_version=self.identity_version)
        self.assertEqual(expected, observed)