From 110af8effb9e353ba0bb5a222e2da942d540f814 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Thu, 2 Jun 2011 12:02:57 -0400 Subject: Add test case for verifying GET /v2.0/tokens returns 404 Not Found --- test/unit/base.py | 5 ++++- test/unit/test_authn_v2.py | 36 ++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/test/unit/base.py b/test/unit/base.py index d9ace1da..2626bb17 100644 --- a/test/unit/base.py +++ b/test/unit/base.py @@ -210,7 +210,10 @@ class ServiceAPITest(unittest.TestCase): """ Adds some convenience helpers using partials... """ - self.status_ok = functools.partial(self.verify_status, httplib.OK) + self.status_ok = functools.partial(self.verify_status, + httplib.OK) + self.status_not_found = functools.partial(self.verify_status, + httplib.NOT_FOUND) def assert_dict_equal(self, expected, got): """ diff --git a/test/unit/test_authn_v2.py b/test/unit/test_authn_v2.py index b3550033..87931163 100644 --- a/test/unit/test_authn_v2.py +++ b/test/unit/test_authn_v2.py @@ -32,10 +32,27 @@ class TestAuthnV2(base.ServiceAPITest): api_version = '2.0' + def test_authn_get_fails(self): + """ + Test for GH issue #5. GET /tokens works when it should not + """ + url = "/tokens" + req = self.get_request('GET', url) + body = { + "passwordCredentials": { + "username": self.auth_user['id'], + "password": self.auth_user['password'], + "tenantId": self.auth_user['tenant_id'] + } + } + req.body = json.dumps(body) + self.get_response() + self.status_not_found() + @jsonify def test_authn_json(self): url = "/tokens" - req = self.get_request('GET', url) + req = self.get_request('POST', url) body = { "passwordCredentials": { "username": self.auth_user['id'], @@ -51,12 +68,7 @@ class TestAuthnV2(base.ServiceAPITest): u'auth': { u'token': { u'expires': self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - u'id': self.auth_token_id, - u'tenantId': self.auth_user['tenant_id'] - }, - u'user': { - u'username': self.auth_user['id'], - u'tenantId': self.auth_user['tenant_id'] + u'id': self.auth_token_id } } } @@ -65,7 +77,7 @@ class TestAuthnV2(base.ServiceAPITest): @xmlify def test_authn_xml(self): url = "/tokens" - req = self.get_request('GET', url) + req = self.get_request('POST', url) req.body = ' \ - - + """ % (self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), - self.auth_token_id, - self.auth_user['tenant_id'], - self.auth_user['id'], - self.auth_user['tenant_id']) + self.auth_token_id) self.assert_xml_strings_equal(expected, self.res.body) -- cgit