Use admin credentials for vitrageclient from tempest.conf

Story: #2004053
Task: #28634
Change-Id: I32431783a8d07b54b09da13ce3a00bb191900a68
This commit is contained in:
Ivan Kolodyazhny 2019-02-18 15:59:04 +02:00
parent 64e915e476
commit 883d5698cd
2 changed files with 25 additions and 4 deletions

View File

@ -75,11 +75,13 @@ class TestResource(BaseVitrageTempest):
def test_default_resource_list(self):
"""resource list with default query
get the resources: network, instance, port
get the resources: network, instance, port, zone, host, cluster
"""
# TODO(e0ne): split this test to verify that only network,
# instance and port are returned to non-admin user.
try:
resources = self.vitrage_client.resource.list(all_tenants=False)
self.assertThat(resources, matchers.HasLength(3))
self.assertThat(resources, matchers.HasLength(6))
except Exception as e:
self._handle_exception(e)
raise

View File

@ -15,6 +15,7 @@
from keystoneauth1 import loading as ka_loading
from keystoneauth1 import session as ka_session
from neutronclient.v2_0 import client as neutron_client
from tempest.common import credentials_factory as common_creds
from tempest import config
from vitrage import keystone_client
from vitrage import os_clients
@ -48,7 +49,7 @@ class TempestClients(object):
"""
if not cls._vitrage:
cls._vitrage = vc.Client(
'1', session=keystone_client.get_session(cls._conf))
'1', session=cls._get_session_for_admin())
return cls._vitrage
@classmethod
@ -165,14 +166,32 @@ class TempestClients(object):
cls._gnocchi = os_clients.gnocchi_client(cls._conf)
return cls._gnocchi
@classmethod
def _get_session_for_admin(cls):
admin_creds = common_creds.get_configured_admin_credentials()
password = admin_creds.password
username = admin_creds.username
user_domain_id = admin_creds.user_domain_id
project_name = admin_creds.project_name
project_domain_id = admin_creds.project_domain_id
return cls._get_session(username, password, user_domain_id,
project_name, project_domain_id)
@classmethod
def _get_session_for_user(cls):
password = cls.creds.password
username = cls.creds.username
password = cls.creds.password
user_domain_id = cls.creds.user_domain_id
project_name = cls.creds.project_name
project_domain_id = cls.creds.project_domain_id
return cls._get_session(username, password, user_domain_id,
project_name, project_domain_id)
@classmethod
def _get_session(cls, username, password, user_domain_id, project_name,
project_domain_id):
loader = ka_loading.get_plugin_loader('password')
auth_url = CONF.identity.uri_v3
auth_plugin = loader.load_from_options(