diff options
| author | Jay Pipes <jaypipes@gmail.com> | 2011-06-02 12:02:57 -0400 |
|---|---|---|
| committer | Jay Pipes <jaypipes@gmail.com> | 2011-06-02 12:02:57 -0400 |
| commit | 110af8effb9e353ba0bb5a222e2da942d540f814 (patch) | |
| tree | 87c0d39ced08d0823c12a3a43cb53c1e882eaea8 /test | |
| parent | cd8e6816ff7cd99db7c50fa2c9a2f96250d05860 (diff) | |
Add test case for verifying GET /v2.0/tokens returns 404 Not Found
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/base.py | 5 | ||||
| -rw-r--r-- | 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 = '<?xml version="1.0" encoding="UTF-8"?> \ <passwordCredentials \ xmlns="http://docs.openstack.org/identity/api/v2.0" \ @@ -78,12 +90,8 @@ class TestAuthnV2(base.ServiceAPITest): expected = """ <auth xmlns="http://docs.openstack.org/identity/api/v2.0"> - <token expires="%s" id="%s" tenantId="%s"/> - <user username="%s" tenantId="%s"/> + <token expires="%s" id="%s" /> </auth> """ % (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) |
