Пример #1
0
 def test_get_creds(self):
     test_accounts_class = accounts.NotLockingAccounts('test_name')
     for i in xrange(len(self.test_accounts)):
         creds = test_accounts_class.get_creds(i)
         msg = "Empty credentials returned for ID %s" % str(i)
         self.assertIsNotNone(creds, msg)
     self.assertRaises(exceptions.InvalidConfiguration,
                       test_accounts_class.get_creds,
                       id=len(self.test_accounts))
Пример #2
0
def get_isolated_credentials(name,
                             network_resources=None,
                             force_tenant_isolation=False):
    # If a test requires a new account to work, it can have it via forcing
    # tenant isolation. A new account will be produced only for that test.
    # In case admin credentials are not available for the account creation,
    # the test should be skipped else it would fail.
    if CONF.auth.allow_tenant_isolation or force_tenant_isolation:
        return isolated_creds.IsolatedCreds(
            name=name, network_resources=network_resources)
    else:
        if CONF.auth.locking_credentials_provider:
            # Most params are not relevant for pre-created accounts
            return accounts.Accounts(name=name)
        else:
            return accounts.NotLockingAccounts(name=name)
Пример #3
0
def is_alt_available():
    # If dynamic credentials is enabled admin will be available
    if CONF.auth.use_dynamic_credentials:
        return True
    # Check whether test accounts file has the admin specified or not
    if (CONF.auth.test_accounts_file
            and os.path.isfile(CONF.auth.test_accounts_file)):
        check_accounts = accounts.Accounts(name='check_alt')
    else:
        check_accounts = accounts.NotLockingAccounts(name='check_alt')
    try:
        if not check_accounts.is_multi_user():
            return False
        else:
            return True
    except exceptions.InvalidConfiguration:
        return False
Пример #4
0
def get_isolated_credentials(name):
    # If a test requires a new account to work, it can have it via forcing
    # tenant isolation. A new account will be produced only for that test.
    # In case admin credentials are not available for the account creation,
    # the test should be skipped else it would fail.
    #if CONF.auth.allow_tenant_isolation or force_tenant_isolation:
    #    return isolated_creds.IsolatedCreds(
    #        name=name,
    #        network_resources=network_resources,
    #        identity_version=identity_version)
    #else:
    #CONF.auth.test_accounts_file means arrow.conf->[auth]->test_accounts_file
    #test_accounts_file = /usr/share/openstack-tempest-kilo/etc/accounts.yaml
    #We can use two kinds of configuration files : arrow.conf or account.yaml
    if (CONF.auth.test_accounts_file
            and os.path.isfile(CONF.auth.test_accounts_file)):
        # Most params are not relevant for pre-created accounts
        return accounts.Accounts(name=name, identity_version=identity_version)
    else:
        return accounts.NotLockingAccounts(name=name,
                                           identity_version=identity_version)
Пример #5
0
def get_credentials_provider(name,
                             network_resources=None,
                             force_tenant_isolation=False,
                             identity_version=None):
    # If a test requires a new account to work, it can have it via forcing
    # dynamic credentials. A new account will be produced only for that test.
    # In case admin credentials are not available for the account creation,
    # the test should be skipped else it would fail.
    if CONF.auth.use_dynamic_credentials or force_tenant_isolation:
        return dynamic_creds.DynamicCredentialProvider(
            name=name,
            network_resources=network_resources,
            identity_version=identity_version)
    else:
        if (CONF.auth.test_accounts_file
                and os.path.isfile(CONF.auth.test_accounts_file)):
            # Most params are not relevant for pre-created accounts
            return accounts.Accounts(name=name,
                                     identity_version=identity_version)
        else:
            return accounts.NotLockingAccounts(
                name=name, identity_version=identity_version)
Пример #6
0
 def test_get_creds_roles_nonlocking_invalid(self):
     test_accounts_class = accounts.NotLockingAccounts('v2', 'test_name')
     self.assertRaises(exceptions.InvalidConfiguration,
                       test_accounts_class.get_creds_by_roles,
                       ['fake_role'])