summaryrefslogtreecommitdiff
path: root/openstackclient/tests/identity/v3/fakes.py
diff options
context:
space:
mode:
authorSteve Martinelli <stevemar@ca.ibm.com>2013-12-09 17:50:07 -0600
committerSteve Martinelli <stevemar@ca.ibm.com>2014-06-14 17:21:17 -0400
commitd5aaba9d8284ea1cafe137b367ef9c9297b31e75 (patch)
treea77f98a652e76461670ba160a7979e83e8f41fa7 /openstackclient/tests/identity/v3/fakes.py
parent0da5bfe42875457a26a0c5040fcc3b0e1ffb5d2a (diff)
downloadpython-openstackclient-d5aaba9d8284ea1cafe137b367ef9c9297b31e75.tar.gz
Refactor oauth1 code for updates
The keystoneclient code for oauth1 support has changed. As such, we should remove the delete, list and authenticate functions, since they are not in keystoneclient. Also, we must now pass in the project id when creating a request token. Additionally we must now pass in roles when authorizing a request token. Added functional tests to ensure output and input args are the same. bp add-oauth-support Change-Id: I559c18a73ad95a0c8b7a6a95f463b78334186f61
Diffstat (limited to 'openstackclient/tests/identity/v3/fakes.py')
-rw-r--r--openstackclient/tests/identity/v3/fakes.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/openstackclient/tests/identity/v3/fakes.py b/openstackclient/tests/identity/v3/fakes.py
index 86ef2f0c..711a423d 100644
--- a/openstackclient/tests/identity/v3/fakes.py
+++ b/openstackclient/tests/identity/v3/fakes.py
@@ -139,6 +139,43 @@ ASSIGNMENT_WITH_DOMAIN_ID_AND_GROUP_ID = {
'role': {'id': role_id},
}
+consumer_id = 'test consumer id'
+consumer_description = 'someone we trust'
+consumer_secret = 'test consumer secret'
+
+OAUTH_CONSUMER = {
+ 'id': consumer_id,
+ 'secret': consumer_secret,
+ 'description': consumer_description
+}
+
+access_token_id = 'test access token id'
+access_token_secret = 'test access token secret'
+access_token_expires = '2014-05-18T03:13:18.152071Z'
+
+OAUTH_ACCESS_TOKEN = {
+ 'id': access_token_id,
+ 'expires': access_token_expires,
+ 'key': access_token_id,
+ 'secret': access_token_secret
+}
+
+request_token_id = 'test request token id'
+request_token_secret = 'test request token secret'
+request_token_expires = '2014-05-17T11:10:51.511336Z'
+
+OAUTH_REQUEST_TOKEN = {
+ 'id': request_token_id,
+ 'expires': request_token_expires,
+ 'key': request_token_id,
+ 'secret': request_token_secret
+}
+
+oauth_verifier_pin = '6d74XaDS'
+OAUTH_VERIFIER = {
+ 'oauth_verifier': oauth_verifier_pin
+}
+
class FakeIdentityv3Client(object):
def __init__(self, **kwargs):
@@ -146,6 +183,8 @@ class FakeIdentityv3Client(object):
self.domains.resource_class = fakes.FakeResource(None, {})
self.groups = mock.Mock()
self.groups.resource_class = fakes.FakeResource(None, {})
+ self.oauth1 = mock.Mock()
+ self.oauth1.resource_class = fakes.FakeResource(None, {})
self.projects = mock.Mock()
self.projects.resource_class = fakes.FakeResource(None, {})
self.roles = mock.Mock()
@@ -169,6 +208,18 @@ class FakeFederatedClient(FakeIdentityv3Client):
self.identity_providers.resource_class = fakes.FakeResource(None, {})
+class FakeOAuth1Client(FakeIdentityv3Client):
+ def __init__(self, **kwargs):
+ super(FakeOAuth1Client, self).__init__(**kwargs)
+
+ self.access_tokens = mock.Mock()
+ self.access_tokens.resource_class = fakes.FakeResource(None, {})
+ self.consumers = mock.Mock()
+ self.consumers.resource_class = fakes.FakeResource(None, {})
+ self.request_tokens = mock.Mock()
+ self.request_tokens.resource_class = fakes.FakeResource(None, {})
+
+
class TestIdentityv3(utils.TestCommand):
def setUp(self):
super(TestIdentityv3, self).setUp()
@@ -187,3 +238,13 @@ class TestFederatedIdentity(utils.TestCommand):
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN
)
+
+
+class TestOAuth1(utils.TestCommand):
+ def setUp(self):
+ super(TestOAuth1, self).setUp()
+
+ self.app.client_manager.identity = FakeOAuth1Client(
+ endpoint=fakes.AUTH_URL,
+ token=fakes.AUTH_TOKEN
+ )