tests: Add identity v2, v3 FakeClientMixin
This ensures we are speccing the identity proxy API, as we did previously for other services. Change-Id: I4d090bab001f9b7e1d83ca8fee9e7e1117844cd8 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
948034e6c1
commit
c86b9d8cc7
@ -178,16 +178,11 @@ class TestComputev2(
|
|||||||
network_fakes.FakeClientMixin,
|
network_fakes.FakeClientMixin,
|
||||||
image_fakes.FakeClientMixin,
|
image_fakes.FakeClientMixin,
|
||||||
volume_fakes.FakeClientMixin,
|
volume_fakes.FakeClientMixin,
|
||||||
|
identity_fakes.FakeClientMixin,
|
||||||
FakeClientMixin,
|
FakeClientMixin,
|
||||||
utils.TestCommand,
|
utils.TestCommand,
|
||||||
):
|
):
|
||||||
def setUp(self):
|
...
|
||||||
super().setUp()
|
|
||||||
|
|
||||||
self.app.client_manager.identity = identity_fakes.FakeIdentityv2Client(
|
|
||||||
endpoint=fakes.AUTH_URL,
|
|
||||||
token=fakes.AUTH_TOKEN,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def create_one_aggregate(attrs=None):
|
def create_one_aggregate(attrs=None):
|
||||||
|
@ -19,6 +19,7 @@ import uuid
|
|||||||
|
|
||||||
from keystoneauth1 import access
|
from keystoneauth1 import access
|
||||||
from keystoneauth1 import fixture
|
from keystoneauth1 import fixture
|
||||||
|
from openstack.identity.v2 import _proxy
|
||||||
|
|
||||||
from openstackclient.tests.unit import fakes
|
from openstackclient.tests.unit import fakes
|
||||||
from openstackclient.tests.unit import utils
|
from openstackclient.tests.unit import utils
|
||||||
@ -183,14 +184,31 @@ class FakeIdentityv2Client(object):
|
|||||||
raise AttributeError(name)
|
raise AttributeError(name)
|
||||||
|
|
||||||
|
|
||||||
class TestIdentityv2(utils.TestCommand):
|
class FakeClientMixin:
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestIdentityv2, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.app.client_manager.identity = FakeIdentityv2Client(
|
self.app.client_manager.identity = FakeIdentityv2Client(
|
||||||
endpoint=fakes.AUTH_URL,
|
endpoint=fakes.AUTH_URL,
|
||||||
token=fakes.AUTH_TOKEN,
|
token=fakes.AUTH_TOKEN,
|
||||||
)
|
)
|
||||||
|
self.identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
# TODO(stephenfin): Rename to 'identity_client' once all commands are
|
||||||
|
# migrated to SDK
|
||||||
|
self.app.client_manager.sdk_connection.identity = mock.Mock(
|
||||||
|
_proxy.Proxy
|
||||||
|
)
|
||||||
|
self.identity_sdk_client = (
|
||||||
|
self.app.client_manager.sdk_connection.identity
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestIdentityv2(
|
||||||
|
FakeClientMixin,
|
||||||
|
utils.TestCommand,
|
||||||
|
):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
class FakeExtension(object):
|
class FakeExtension(object):
|
||||||
|
@ -20,6 +20,7 @@ import uuid
|
|||||||
|
|
||||||
from keystoneauth1 import access
|
from keystoneauth1 import access
|
||||||
from keystoneauth1 import fixture
|
from keystoneauth1 import fixture
|
||||||
|
from openstack.identity.v3 import _proxy
|
||||||
from osc_lib.cli import format_columns
|
from osc_lib.cli import format_columns
|
||||||
|
|
||||||
from openstackclient.tests.unit import fakes
|
from openstackclient.tests.unit import fakes
|
||||||
@ -666,16 +667,34 @@ class FakeOAuth1Client(FakeIdentityv3Client):
|
|||||||
self.request_tokens.resource_class = fakes.FakeResource(None, {})
|
self.request_tokens.resource_class = fakes.FakeResource(None, {})
|
||||||
|
|
||||||
|
|
||||||
class TestIdentityv3(utils.TestCommand):
|
class FakeClientMixin:
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestIdentityv3, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.app.client_manager.identity = FakeIdentityv3Client(
|
self.app.client_manager.identity = FakeIdentityv3Client(
|
||||||
endpoint=fakes.AUTH_URL,
|
endpoint=fakes.AUTH_URL,
|
||||||
token=fakes.AUTH_TOKEN,
|
token=fakes.AUTH_TOKEN,
|
||||||
)
|
)
|
||||||
|
self.identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
# TODO(stephenfin): Rename to 'identity_client' once all commands are
|
||||||
|
# migrated to SDK
|
||||||
|
self.app.client_manager.sdk_connection.identity = mock.Mock(
|
||||||
|
_proxy.Proxy
|
||||||
|
)
|
||||||
|
self.identity_sdk_client = (
|
||||||
|
self.app.client_manager.sdk_connection.identity
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestIdentityv3(
|
||||||
|
FakeClientMixin,
|
||||||
|
utils.TestCommand,
|
||||||
|
):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
# We don't use FakeClientMixin since we want a different fake legacy client
|
||||||
class TestFederatedIdentity(utils.TestCommand):
|
class TestFederatedIdentity(utils.TestCommand):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestFederatedIdentity, self).setUp()
|
super(TestFederatedIdentity, self).setUp()
|
||||||
@ -683,8 +702,19 @@ class TestFederatedIdentity(utils.TestCommand):
|
|||||||
self.app.client_manager.identity = FakeFederatedClient(
|
self.app.client_manager.identity = FakeFederatedClient(
|
||||||
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
|
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
|
||||||
)
|
)
|
||||||
|
self.identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
# TODO(stephenfin): Rename to 'identity_client' once all commands are
|
||||||
|
# migrated to SDK
|
||||||
|
self.app.client_manager.sdk_connection.identity = mock.Mock(
|
||||||
|
_proxy.Proxy
|
||||||
|
)
|
||||||
|
self.identity_sdk_client = (
|
||||||
|
self.app.client_manager.sdk_connection.identity
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# We don't use FakeClientMixin since we want a different fake legacy client
|
||||||
class TestOAuth1(utils.TestCommand):
|
class TestOAuth1(utils.TestCommand):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestOAuth1, self).setUp()
|
super(TestOAuth1, self).setUp()
|
||||||
@ -692,6 +722,16 @@ class TestOAuth1(utils.TestCommand):
|
|||||||
self.app.client_manager.identity = FakeOAuth1Client(
|
self.app.client_manager.identity = FakeOAuth1Client(
|
||||||
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
|
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
|
||||||
)
|
)
|
||||||
|
self.identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
|
# TODO(stephenfin): Rename to 'identity_client' once all commands are
|
||||||
|
# migrated to SDK
|
||||||
|
self.app.client_manager.sdk_connection.identity = mock.Mock(
|
||||||
|
_proxy.Proxy
|
||||||
|
)
|
||||||
|
self.identity_sdk_client = (
|
||||||
|
self.app.client_manager.sdk_connection.identity
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FakeProject(object):
|
class FakeProject(object):
|
||||||
|
@ -27,7 +27,6 @@ from openstack.image.v2 import metadef_resource_type
|
|||||||
from openstack.image.v2 import service_info as _service_info
|
from openstack.image.v2 import service_info as _service_info
|
||||||
from openstack.image.v2 import task
|
from openstack.image.v2 import task
|
||||||
|
|
||||||
from openstackclient.tests.unit import fakes
|
|
||||||
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
|
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
|
||||||
from openstackclient.tests.unit import utils
|
from openstackclient.tests.unit import utils
|
||||||
|
|
||||||
@ -40,14 +39,12 @@ class FakeClientMixin:
|
|||||||
self.image_client = self.app.client_manager.image
|
self.image_client = self.app.client_manager.image
|
||||||
|
|
||||||
|
|
||||||
class TestImagev2(FakeClientMixin, utils.TestCommand):
|
class TestImagev2(
|
||||||
def setUp(self):
|
identity_fakes.FakeClientMixin,
|
||||||
super().setUp()
|
FakeClientMixin,
|
||||||
|
utils.TestCommand,
|
||||||
self.app.client_manager.identity = identity_fakes.FakeIdentityv3Client(
|
):
|
||||||
endpoint=fakes.AUTH_URL,
|
...
|
||||||
token=fakes.AUTH_TOKEN,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def create_one_image(attrs=None):
|
def create_one_image(attrs=None):
|
||||||
|
@ -38,7 +38,7 @@ from openstack.network.v2 import service_profile as _flavor_profile
|
|||||||
from openstack.network.v2 import trunk as _trunk
|
from openstack.network.v2 import trunk as _trunk
|
||||||
|
|
||||||
from openstackclient.tests.unit import fakes
|
from openstackclient.tests.unit import fakes
|
||||||
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes_v3
|
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes
|
||||||
from openstackclient.tests.unit import utils
|
from openstackclient.tests.unit import utils
|
||||||
|
|
||||||
|
|
||||||
@ -101,19 +101,16 @@ class FakeClientMixin:
|
|||||||
self.network_client = self.app.client_manager.network
|
self.network_client = self.app.client_manager.network
|
||||||
|
|
||||||
|
|
||||||
class TestNetworkV2(FakeClientMixin, utils.TestCommand):
|
class TestNetworkV2(
|
||||||
|
identity_fakes.FakeClientMixin,
|
||||||
|
FakeClientMixin,
|
||||||
|
utils.TestCommand,
|
||||||
|
):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.namespace = argparse.Namespace()
|
self.namespace = argparse.Namespace()
|
||||||
|
|
||||||
self.app.client_manager.identity = (
|
|
||||||
identity_fakes_v3.FakeIdentityv3Client(
|
|
||||||
endpoint=fakes.AUTH_URL,
|
|
||||||
token=fakes.AUTH_TOKEN,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def create_one_extension(attrs=None):
|
def create_one_extension(attrs=None):
|
||||||
"""Create a fake extension.
|
"""Create a fake extension.
|
||||||
|
@ -64,15 +64,14 @@ class FakeClientMixin:
|
|||||||
self.volume_client = self.app.client_manager.volume
|
self.volume_client = self.app.client_manager.volume
|
||||||
|
|
||||||
|
|
||||||
class TestVolumev1(FakeClientMixin, utils.TestCommand):
|
class TestVolumev1(
|
||||||
|
identity_fakes.FakeClientMixin,
|
||||||
|
FakeClientMixin,
|
||||||
|
utils.TestCommand,
|
||||||
|
):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.app.client_manager.identity = identity_fakes.FakeIdentityv2Client(
|
|
||||||
endpoint=fakes.AUTH_URL,
|
|
||||||
token=fakes.AUTH_TOKEN,
|
|
||||||
)
|
|
||||||
|
|
||||||
# avoid circular imports by defining this manually rather than using
|
# avoid circular imports by defining this manually rather than using
|
||||||
# openstackclient.tests.unit.image.v1.fakes.FakeClientMixin
|
# openstackclient.tests.unit.image.v1.fakes.FakeClientMixin
|
||||||
self.app.client_manager.image = mock.Mock(spec=image_v1_proxy.Proxy)
|
self.app.client_manager.image = mock.Mock(spec=image_v1_proxy.Proxy)
|
||||||
|
@ -108,14 +108,14 @@ class FakeClientMixin:
|
|||||||
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
|
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
|
||||||
|
|
||||||
|
|
||||||
class TestVolume(FakeClientMixin, utils.TestCommand):
|
class TestVolume(
|
||||||
|
identity_fakes.FakeClientMixin,
|
||||||
|
FakeClientMixin,
|
||||||
|
utils.TestCommand,
|
||||||
|
):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.app.client_manager.identity = identity_fakes.FakeIdentityv3Client(
|
|
||||||
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
|
|
||||||
)
|
|
||||||
|
|
||||||
# avoid circular imports by defining this manually rather than using
|
# avoid circular imports by defining this manually rather than using
|
||||||
# openstackclient.tests.unit.image.v2.fakes.FakeClientMixin
|
# openstackclient.tests.unit.image.v2.fakes.FakeClientMixin
|
||||||
self.app.client_manager.image = mock.Mock(spec=image_v2_proxy.Proxy)
|
self.app.client_manager.image = mock.Mock(spec=image_v2_proxy.Proxy)
|
||||||
|
@ -82,14 +82,14 @@ class FakeClientMixin:
|
|||||||
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
|
self.volume_sdk_client = self.app.client_manager.sdk_connection.volume
|
||||||
|
|
||||||
|
|
||||||
class TestVolume(FakeClientMixin, utils.TestCommand):
|
class TestVolume(
|
||||||
|
identity_fakes.FakeClientMixin,
|
||||||
|
FakeClientMixin,
|
||||||
|
utils.TestCommand,
|
||||||
|
):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.app.client_manager.identity = identity_fakes.FakeIdentityv3Client(
|
|
||||||
endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN
|
|
||||||
)
|
|
||||||
|
|
||||||
# avoid circular imports
|
# avoid circular imports
|
||||||
from openstackclient.tests.unit.compute.v2 import (
|
from openstackclient.tests.unit.compute.v2 import (
|
||||||
fakes as compute_fakes,
|
fakes as compute_fakes,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user