Merge "Fix PEP8 E126 and E202 errors"
This commit is contained in:
commit
ddf0c16a10
@ -19,76 +19,80 @@ from openstackclient.tests.identity.v3 import fakes as identity_fakes
|
||||
|
||||
class TestOAuth1(identity_fakes.TestOAuth1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOAuth1, self).setUp()
|
||||
identity_client = self.app.client_manager.identity
|
||||
self.consumers_mock = identity_client.oauth1.consumers
|
||||
self.consumers_mock.reset_mock()
|
||||
def setUp(self):
|
||||
super(TestOAuth1, self).setUp()
|
||||
identity_client = self.app.client_manager.identity
|
||||
self.consumers_mock = identity_client.oauth1.consumers
|
||||
self.consumers_mock.reset_mock()
|
||||
|
||||
|
||||
class TestConsumerCreate(TestOAuth1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestConsumerCreate, self).setUp()
|
||||
def setUp(self):
|
||||
super(TestConsumerCreate, self).setUp()
|
||||
|
||||
self.consumers_mock.create.return_value = fakes.FakeResource(
|
||||
None, copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
|
||||
loaded=True)
|
||||
self.consumers_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
self.cmd = consumer.CreateConsumer(self.app, None)
|
||||
self.cmd = consumer.CreateConsumer(self.app, None)
|
||||
|
||||
def test_create_consumer(self):
|
||||
arglist = [
|
||||
'--description', identity_fakes.consumer_description
|
||||
]
|
||||
verifylist = [
|
||||
('description', identity_fakes.consumer_description)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
def test_create_consumer(self):
|
||||
arglist = [
|
||||
'--description', identity_fakes.consumer_description,
|
||||
]
|
||||
verifylist = [
|
||||
('description', identity_fakes.consumer_description),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.consumers_mock.create.assert_called_with(
|
||||
identity_fakes.consumer_description)
|
||||
self.consumers_mock.create.assert_called_with(
|
||||
identity_fakes.consumer_description,
|
||||
)
|
||||
|
||||
collist = ('description', 'id', 'secret')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.consumer_description,
|
||||
identity_fakes.consumer_id,
|
||||
identity_fakes.consumer_secret
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
collist = ('description', 'id', 'secret')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.consumer_description,
|
||||
identity_fakes.consumer_id,
|
||||
identity_fakes.consumer_secret,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
|
||||
class TestConsumerDelete(TestOAuth1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestConsumerDelete, self).setUp()
|
||||
def setUp(self):
|
||||
super(TestConsumerDelete, self).setUp()
|
||||
|
||||
# This is the return value for utils.find_resource()
|
||||
self.consumers_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
|
||||
loaded=True)
|
||||
# This is the return value for utils.find_resource()
|
||||
self.consumers_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
self.consumers_mock.delete.return_value = None
|
||||
self.cmd = consumer.DeleteConsumer(self.app, None)
|
||||
self.consumers_mock.delete.return_value = None
|
||||
self.cmd = consumer.DeleteConsumer(self.app, None)
|
||||
|
||||
def test_delete_consumer(self):
|
||||
arglist = [
|
||||
identity_fakes.consumer_id
|
||||
]
|
||||
verifylist = [
|
||||
('consumer', identity_fakes.consumer_id)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
def test_delete_consumer(self):
|
||||
arglist = [
|
||||
identity_fakes.consumer_id,
|
||||
]
|
||||
verifylist = [
|
||||
('consumer', identity_fakes.consumer_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.run(parsed_args)
|
||||
self.assertEqual(result, 0)
|
||||
result = self.cmd.run(parsed_args)
|
||||
self.assertEqual(result, 0)
|
||||
|
||||
self.consumers_mock.delete.assert_called_with(
|
||||
identity_fakes.consumer_id,
|
||||
)
|
||||
self.consumers_mock.delete.assert_called_with(
|
||||
identity_fakes.consumer_id,
|
||||
)
|
||||
|
||||
|
||||
class TestConsumerList(TestOAuth1):
|
||||
@ -125,7 +129,7 @@ class TestConsumerList(TestOAuth1):
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = ((
|
||||
identity_fakes.consumer_id,
|
||||
identity_fakes.consumer_description
|
||||
identity_fakes.consumer_description,
|
||||
), )
|
||||
self.assertEqual(tuple(data), datalist)
|
||||
|
||||
@ -138,29 +142,33 @@ class TestConsumerShow(TestOAuth1):
|
||||
consumer_no_secret = copy.deepcopy(identity_fakes.OAUTH_CONSUMER)
|
||||
del consumer_no_secret['secret']
|
||||
self.consumers_mock.get.return_value = fakes.FakeResource(
|
||||
None, consumer_no_secret, loaded=True)
|
||||
None,
|
||||
consumer_no_secret,
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = consumer.ShowConsumer(self.app, None)
|
||||
|
||||
def test_consumer_show(self):
|
||||
arglist = [
|
||||
identity_fakes.consumer_id
|
||||
identity_fakes.consumer_id,
|
||||
]
|
||||
verifylist = [
|
||||
('consumer', identity_fakes.consumer_id)
|
||||
('consumer', identity_fakes.consumer_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.consumers_mock.get.assert_called_with(
|
||||
identity_fakes.consumer_id)
|
||||
identity_fakes.consumer_id,
|
||||
)
|
||||
|
||||
collist = ('description', 'id' )
|
||||
collist = ('description', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.consumer_description,
|
||||
identity_fakes.consumer_id
|
||||
identity_fakes.consumer_id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
@ -171,12 +179,18 @@ class TestConsumerSet(TestOAuth1):
|
||||
super(TestConsumerSet, self).setUp()
|
||||
|
||||
self.consumers_mock.get.return_value = fakes.FakeResource(
|
||||
None, copy.deepcopy(identity_fakes.OAUTH_CONSUMER), loaded=True)
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.OAUTH_CONSUMER),
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
consumer_updated = copy.deepcopy(identity_fakes.OAUTH_CONSUMER)
|
||||
consumer_updated['description'] = "consumer new description"
|
||||
self.consumers_mock.update.return_value = fakes.FakeResource(
|
||||
None, consumer_updated, loaded=True)
|
||||
None,
|
||||
consumer_updated,
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
self.cmd = consumer.SetConsumer(self.app, None)
|
||||
|
||||
@ -185,11 +199,11 @@ class TestConsumerSet(TestOAuth1):
|
||||
|
||||
arglist = [
|
||||
'--description', new_description,
|
||||
identity_fakes.consumer_id
|
||||
identity_fakes.consumer_id,
|
||||
]
|
||||
verifylist = [
|
||||
('description', new_description),
|
||||
('consumer', identity_fakes.consumer_id)
|
||||
('consumer', identity_fakes.consumer_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.run(parsed_args)
|
||||
@ -197,4 +211,6 @@ class TestConsumerSet(TestOAuth1):
|
||||
|
||||
kwargs = {'description': new_description}
|
||||
self.consumers_mock.update.assert_called_with(
|
||||
identity_fakes.consumer_id, **kwargs)
|
||||
identity_fakes.consumer_id,
|
||||
**kwargs
|
||||
)
|
||||
|
@ -21,152 +21,165 @@ from openstackclient.tests.identity.v3 import fakes as identity_fakes
|
||||
|
||||
class TestIdentityProvider(identity_fakes.TestFederatedIdentity):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIdentityProvider, self).setUp()
|
||||
def setUp(self):
|
||||
super(TestIdentityProvider, self).setUp()
|
||||
|
||||
self.identity_providers_mock = self.app.client_manager.\
|
||||
identity.identity_providers
|
||||
self.identity_providers_mock = self.app.client_manager.\
|
||||
identity.identity_providers
|
||||
|
||||
self.identity_providers_mock.reset_mock()
|
||||
self.identity_providers_mock.reset_mock()
|
||||
|
||||
|
||||
class TestIdentityProviderCreate(TestIdentityProvider):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIdentityProviderCreate, self).setUp()
|
||||
def setUp(self):
|
||||
super(TestIdentityProviderCreate, self).setUp()
|
||||
|
||||
self.identity_providers_mock.create.return_value = \
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
|
||||
loaded=True
|
||||
)
|
||||
|
||||
self.cmd = identity_provider.CreateIdentityProvider(
|
||||
self.app, None)
|
||||
|
||||
def test_create_identity_provider_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.idp_id
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider_id', identity_fakes.idp_id)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'enabled': True,
|
||||
'description': None,
|
||||
}
|
||||
|
||||
self.identity_providers_mock.create.assert_called_with(
|
||||
identity_fakes.idp_id, **kwargs)
|
||||
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.idp_description,
|
||||
True,
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
def test_create_identity_provider_description(self):
|
||||
arglist = ['--description', identity_fakes.idp_description,
|
||||
identity_fakes.idp_id]
|
||||
verifylist = [
|
||||
('identity_provider_id', identity_fakes.idp_id),
|
||||
('description', identity_fakes.idp_description)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'description': identity_fakes.idp_description,
|
||||
'enabled': True,
|
||||
}
|
||||
|
||||
self.identity_providers_mock.create.assert_called_with(
|
||||
identity_fakes.idp_id, **kwargs)
|
||||
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.idp_description, True, identity_fakes.idp_id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
def test_create_identity_provider_disabled(self):
|
||||
|
||||
# Prepare FakeResource object
|
||||
IDENTITY_PROVIDER = copy.deepcopy(identity_fakes.IDENTITY_PROVIDER)
|
||||
IDENTITY_PROVIDER['enabled'] = False
|
||||
IDENTITY_PROVIDER['description'] = None
|
||||
|
||||
self.identity_providers_mock.create.return_value = \
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
IDENTITY_PROVIDER,
|
||||
loaded=True
|
||||
)
|
||||
arglist = ['--disable',
|
||||
identity_fakes.idp_id]
|
||||
verifylist = [
|
||||
('identity_provider_id', identity_fakes.idp_id),
|
||||
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'enabled': False,
|
||||
'description': None
|
||||
}
|
||||
|
||||
self.identity_providers_mock.create.assert_called_with(
|
||||
identity_fakes.idp_id, **kwargs)
|
||||
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
self.identity_providers_mock.create.return_value = \
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
False,
|
||||
identity_fakes.idp_id,
|
||||
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
|
||||
loaded=True,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
self.cmd = identity_provider.CreateIdentityProvider(
|
||||
self.app,
|
||||
None,
|
||||
)
|
||||
|
||||
def test_create_identity_provider_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.idp_id,
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider_id', identity_fakes.idp_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'enabled': True,
|
||||
'description': None,
|
||||
}
|
||||
|
||||
self.identity_providers_mock.create.assert_called_with(
|
||||
identity_fakes.idp_id,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.idp_description,
|
||||
True,
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
def test_create_identity_provider_description(self):
|
||||
arglist = [
|
||||
'--description', identity_fakes.idp_description,
|
||||
identity_fakes.idp_id,
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider_id', identity_fakes.idp_id),
|
||||
('description', identity_fakes.idp_description),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'description': identity_fakes.idp_description,
|
||||
'enabled': True,
|
||||
}
|
||||
|
||||
self.identity_providers_mock.create.assert_called_with(
|
||||
identity_fakes.idp_id,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.idp_description,
|
||||
True,
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
def test_create_identity_provider_disabled(self):
|
||||
|
||||
# Prepare FakeResource object
|
||||
IDENTITY_PROVIDER = copy.deepcopy(identity_fakes.IDENTITY_PROVIDER)
|
||||
IDENTITY_PROVIDER['enabled'] = False
|
||||
IDENTITY_PROVIDER['description'] = None
|
||||
|
||||
self.identity_providers_mock.create.return_value = \
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
IDENTITY_PROVIDER,
|
||||
loaded=True,
|
||||
)
|
||||
arglist = [
|
||||
'--disable',
|
||||
identity_fakes.idp_id,
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider_id', identity_fakes.idp_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'enabled': False,
|
||||
'description': None,
|
||||
}
|
||||
|
||||
self.identity_providers_mock.create.assert_called_with(
|
||||
identity_fakes.idp_id,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
None,
|
||||
False,
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
|
||||
class TestIdentityProviderDelete(TestIdentityProvider):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIdentityProviderDelete, self).setUp()
|
||||
def setUp(self):
|
||||
super(TestIdentityProviderDelete, self).setUp()
|
||||
|
||||
# This is the return value for utils.find_resource()
|
||||
self.identity_providers_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
|
||||
loaded=True)
|
||||
# This is the return value for utils.find_resource()
|
||||
self.identity_providers_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
self.identity_providers_mock.delete.return_value = None
|
||||
self.cmd = identity_provider.DeleteIdentityProvider(
|
||||
self.app, None)
|
||||
self.identity_providers_mock.delete.return_value = None
|
||||
self.cmd = identity_provider.DeleteIdentityProvider(self.app, None)
|
||||
|
||||
def test_delete_identity_provider(self):
|
||||
arglist = [
|
||||
identity_fakes.idp_id
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider', identity_fakes.idp_id)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.identity_providers_mock.delete.assert_called_with(
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
def test_delete_identity_provider(self):
|
||||
arglist = [
|
||||
identity_fakes.idp_id,
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider', identity_fakes.idp_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
self.identity_providers_mock.delete.assert_called_with(
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
|
||||
|
||||
class TestIdentityProviderList(TestIdentityProvider):
|
||||
@ -205,8 +218,7 @@ class TestIdentityProviderList(TestIdentityProvider):
|
||||
datalist = ((
|
||||
identity_fakes.idp_id,
|
||||
True,
|
||||
identity_fakes.idp_description
|
||||
|
||||
identity_fakes.idp_description,
|
||||
), )
|
||||
self.assertEqual(tuple(data), datalist)
|
||||
|
||||
@ -219,7 +231,7 @@ class TestIdentityProviderShow(TestIdentityProvider):
|
||||
self.identity_providers_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
|
||||
loaded=True
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
# Get the command object to test
|
||||
@ -227,24 +239,25 @@ class TestIdentityProviderShow(TestIdentityProvider):
|
||||
|
||||
def test_identity_provider_show(self):
|
||||
arglist = [
|
||||
identity_fakes.idp_id
|
||||
identity_fakes.idp_id,
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider', identity_fakes.idp_id)
|
||||
('identity_provider', identity_fakes.idp_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.identity_providers_mock.get.assert_called_with(
|
||||
identity_fakes.idp_id)
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
|
||||
collist = ('description', 'enabled', 'id' )
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.idp_description,
|
||||
True,
|
||||
identity_fakes.idp_id
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
@ -259,7 +272,6 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
"""Disable Identity Provider
|
||||
|
||||
Set Identity Provider's ``enabled`` attribute to False.
|
||||
|
||||
"""
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
@ -274,23 +286,27 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
|
||||
prepare(self)
|
||||
arglist = [
|
||||
'--disable', identity_fakes.idp_id
|
||||
'--disable', identity_fakes.idp_id,
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider', identity_fakes.idp_id),
|
||||
('enable', False),
|
||||
('disable', True)
|
||||
('disable', True),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.identity_providers_mock.update.assert_called_with(
|
||||
identity_fakes.idp_id, enabled=False)
|
||||
collist = ('description', 'enabled', 'id' )
|
||||
identity_fakes.idp_id,
|
||||
enabled=False,
|
||||
)
|
||||
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.idp_description,
|
||||
False,
|
||||
identity_fakes.idp_id
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
|
||||
@ -298,7 +314,6 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
"""Enable Identity Provider.
|
||||
|
||||
Set Identity Provider's ``enabled`` attribute to True.
|
||||
|
||||
"""
|
||||
def prepare(self):
|
||||
"""Prepare fake return objects before the test is executed"""
|
||||
@ -311,24 +326,24 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
|
||||
prepare(self)
|
||||
arglist = [
|
||||
'--enable', identity_fakes.idp_id
|
||||
'--enable', identity_fakes.idp_id,
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider', identity_fakes.idp_id),
|
||||
('enable', True),
|
||||
('disable', False)
|
||||
('disable', False),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.identity_providers_mock.update.assert_called_with(
|
||||
identity_fakes.idp_id, enabled=True)
|
||||
collist = ('description', 'enabled', 'id' )
|
||||
collist = ('description', 'enabled', 'id')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.idp_description,
|
||||
True,
|
||||
identity_fakes.idp_id
|
||||
identity_fakes.idp_id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
@ -345,18 +360,18 @@ class TestIdentityProviderSet(TestIdentityProvider):
|
||||
resources = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.IDENTITY_PROVIDER),
|
||||
loaded=True
|
||||
loaded=True,
|
||||
)
|
||||
self.identity_providers_mock.update.return_value = resources
|
||||
|
||||
prepare(self)
|
||||
arglist = [
|
||||
identity_fakes.idp_id
|
||||
identity_fakes.idp_id,
|
||||
]
|
||||
verifylist = [
|
||||
('identity_provider', identity_fakes.idp_id),
|
||||
('enable', False),
|
||||
('disable', False)
|
||||
('disable', False),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
|
@ -19,90 +19,96 @@ from openstackclient.tests.identity.v3 import fakes as identity_fakes
|
||||
|
||||
class TestOAuth1(identity_fakes.TestOAuth1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOAuth1, self).setUp()
|
||||
identity_client = self.app.client_manager.identity
|
||||
self.access_tokens_mock = identity_client.oauth1.access_tokens
|
||||
self.access_tokens_mock.reset_mock()
|
||||
self.request_tokens_mock = identity_client.oauth1.request_tokens
|
||||
self.request_tokens_mock.reset_mock()
|
||||
def setUp(self):
|
||||
super(TestOAuth1, self).setUp()
|
||||
identity_client = self.app.client_manager.identity
|
||||
self.access_tokens_mock = identity_client.oauth1.access_tokens
|
||||
self.access_tokens_mock.reset_mock()
|
||||
self.request_tokens_mock = identity_client.oauth1.request_tokens
|
||||
self.request_tokens_mock.reset_mock()
|
||||
|
||||
|
||||
class TestRequestTokenCreate(TestOAuth1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestRequestTokenCreate, self).setUp()
|
||||
def setUp(self):
|
||||
super(TestRequestTokenCreate, self).setUp()
|
||||
|
||||
self.request_tokens_mock.create.return_value = fakes.FakeResource(
|
||||
None, copy.deepcopy(identity_fakes.OAUTH_REQUEST_TOKEN),
|
||||
loaded=True)
|
||||
self.request_tokens_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.OAUTH_REQUEST_TOKEN),
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
self.cmd = token.CreateRequestToken(self.app, None)
|
||||
self.cmd = token.CreateRequestToken(self.app, None)
|
||||
|
||||
def test_create_request_tokens(self):
|
||||
arglist = [
|
||||
'--consumer-key', identity_fakes.consumer_id,
|
||||
'--consumer-secret', identity_fakes.consumer_secret,
|
||||
'--project-id', identity_fakes.project_id
|
||||
]
|
||||
verifylist = [
|
||||
('consumer_key', identity_fakes.consumer_id),
|
||||
('consumer_secret', identity_fakes.consumer_secret),
|
||||
('project_id', identity_fakes.project_id)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
def test_create_request_tokens(self):
|
||||
arglist = [
|
||||
'--consumer-key', identity_fakes.consumer_id,
|
||||
'--consumer-secret', identity_fakes.consumer_secret,
|
||||
'--project-id', identity_fakes.project_id,
|
||||
]
|
||||
verifylist = [
|
||||
('consumer_key', identity_fakes.consumer_id),
|
||||
('consumer_secret', identity_fakes.consumer_secret),
|
||||
('project_id', identity_fakes.project_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.request_tokens_mock.create.assert_called_with(
|
||||
identity_fakes.consumer_id,
|
||||
identity_fakes.consumer_secret,
|
||||
identity_fakes.project_id)
|
||||
self.request_tokens_mock.create.assert_called_with(
|
||||
identity_fakes.consumer_id,
|
||||
identity_fakes.consumer_secret,
|
||||
identity_fakes.project_id,
|
||||
)
|
||||
|
||||
collist = ('expires', 'id', 'key', 'secret')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.request_token_expires,
|
||||
identity_fakes.request_token_id,
|
||||
identity_fakes.request_token_id,
|
||||
identity_fakes.request_token_secret
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
collist = ('expires', 'id', 'key', 'secret')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.request_token_expires,
|
||||
identity_fakes.request_token_id,
|
||||
identity_fakes.request_token_id,
|
||||
identity_fakes.request_token_secret,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
|
||||
class TestRequestTokenAuthorize(TestOAuth1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestRequestTokenAuthorize, self).setUp()
|
||||
def setUp(self):
|
||||
super(TestRequestTokenAuthorize, self).setUp()
|
||||
|
||||
self.request_tokens_mock.authorize.return_value = \
|
||||
fakes.FakeResource(
|
||||
None, copy.deepcopy(identity_fakes.OAUTH_VERIFIER),
|
||||
loaded=True)
|
||||
|
||||
self.cmd = token.AuthorizeRequestToken(self.app, None)
|
||||
|
||||
def test_authorize_request_tokens(self):
|
||||
arglist = [
|
||||
'--request-key', identity_fakes.request_token_id,
|
||||
'--role-ids', identity_fakes.role_id
|
||||
]
|
||||
verifylist = [
|
||||
('request_key', identity_fakes.request_token_id),
|
||||
('role_ids', identity_fakes.role_id)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.request_tokens_mock.authorize.assert_called_with(
|
||||
identity_fakes.request_token_id,
|
||||
[identity_fakes.role_id])
|
||||
|
||||
collist = ('oauth_verifier',)
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.oauth_verifier_pin,
|
||||
self.request_tokens_mock.authorize.return_value = \
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.OAUTH_VERIFIER),
|
||||
loaded=True,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
self.cmd = token.AuthorizeRequestToken(self.app, None)
|
||||
|
||||
def test_authorize_request_tokens(self):
|
||||
arglist = [
|
||||
'--request-key', identity_fakes.request_token_id,
|
||||
'--role-ids', identity_fakes.role_id,
|
||||
]
|
||||
verifylist = [
|
||||
('request_key', identity_fakes.request_token_id),
|
||||
('role_ids', identity_fakes.role_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.request_tokens_mock.authorize.assert_called_with(
|
||||
identity_fakes.request_token_id,
|
||||
[identity_fakes.role_id],
|
||||
)
|
||||
|
||||
collist = ('oauth_verifier',)
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.oauth_verifier_pin,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
|
||||
class TestAccessTokenCreate(TestOAuth1):
|
||||
@ -111,42 +117,45 @@ class TestAccessTokenCreate(TestOAuth1):
|
||||
super(TestAccessTokenCreate, self).setUp()
|
||||
|
||||
self.access_tokens_mock.create.return_value = fakes.FakeResource(
|
||||
None, copy.deepcopy(identity_fakes.OAUTH_ACCESS_TOKEN),
|
||||
loaded=True)
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.OAUTH_ACCESS_TOKEN),
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
self.cmd = token.CreateAccessToken(self.app, None)
|
||||
|
||||
def test_create_access_tokens(self):
|
||||
arglist = [
|
||||
'--consumer-key', identity_fakes.consumer_id,
|
||||
'--consumer-secret', identity_fakes.consumer_secret,
|
||||
'--request-key', identity_fakes.request_token_id,
|
||||
'--request-secret', identity_fakes.request_token_secret,
|
||||
'--verifier', identity_fakes.oauth_verifier_pin
|
||||
]
|
||||
verifylist = [
|
||||
('consumer_key', identity_fakes.consumer_id),
|
||||
('consumer_secret', identity_fakes.consumer_secret),
|
||||
('request_key', identity_fakes.request_token_id),
|
||||
('request_secret', identity_fakes.request_token_secret),
|
||||
('verifier', identity_fakes.oauth_verifier_pin)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
arglist = [
|
||||
'--consumer-key', identity_fakes.consumer_id,
|
||||
'--consumer-secret', identity_fakes.consumer_secret,
|
||||
'--request-key', identity_fakes.request_token_id,
|
||||
'--request-secret', identity_fakes.request_token_secret,
|
||||
'--verifier', identity_fakes.oauth_verifier_pin,
|
||||
]
|
||||
verifylist = [
|
||||
('consumer_key', identity_fakes.consumer_id),
|
||||
('consumer_secret', identity_fakes.consumer_secret),
|
||||
('request_key', identity_fakes.request_token_id),
|
||||
('request_secret', identity_fakes.request_token_secret),
|
||||
('verifier', identity_fakes.oauth_verifier_pin),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.access_tokens_mock.create.assert_called_with(
|
||||
identity_fakes.consumer_id,
|
||||
identity_fakes.consumer_secret,
|
||||
identity_fakes.request_token_id,
|
||||
identity_fakes.request_token_secret,
|
||||
identity_fakes.oauth_verifier_pin)
|
||||
self.access_tokens_mock.create.assert_called_with(
|
||||
identity_fakes.consumer_id,
|
||||
identity_fakes.consumer_secret,
|
||||
identity_fakes.request_token_id,
|
||||
identity_fakes.request_token_secret,
|
||||
identity_fakes.oauth_verifier_pin,
|
||||
)
|
||||
|
||||
collist = ('expires', 'id', 'key', 'secret')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.access_token_expires,
|
||||
identity_fakes.access_token_id,
|
||||
identity_fakes.access_token_id,
|
||||
identity_fakes.access_token_secret
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
collist = ('expires', 'id', 'key', 'secret')
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.access_token_expires,
|
||||
identity_fakes.access_token_id,
|
||||
identity_fakes.access_token_id,
|
||||
identity_fakes.access_token_secret,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
Loading…
Reference in New Issue
Block a user