From 7cc8c6cbc1e1c19d1704e9bda25b6a2da8097bd5 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Sun, 5 Jun 2011 12:56:34 -0400 Subject: Add test verifying a missing tenantId key in the password creds works properly in JSON --- test/unit/test_authn_v2.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/unit/test_authn_v2.py b/test/unit/test_authn_v2.py index 284cb7b6..2ec2e07a 100644 --- a/test/unit/test_authn_v2.py +++ b/test/unit/test_authn_v2.py @@ -91,6 +91,42 @@ class TestAuthnV2(base.ServiceAPITest): expires=self.expires, token_id='NOTENANTTOKEN') + url = "/tokens" + req = self.get_request('POST', url) + body = { + "passwordCredentials": { + "username": self.auth_user['id'], + "password": self.auth_user['password'] + } + } + req.body = json.dumps(body) + self.get_response() + self.status_ok() + + expected = { + u'auth': { + u'token': { + u'expires': self.expires.strftime("%Y-%m-%dT%H:%M:%S.%f"), + u'id': 'NOTENANTTOKEN' + } + } + } + self.assert_dict_equal(expected, json.loads(self.res.body)) + + @jsonify + def test_success_none_tenant_json(self): + """ + Test that supplying an existing user/pass, with a tenant ID of None + in the password credentials results in a 200 OK but a token not + matching the token with a tenant attached to it. + """ + # Create a special token for user with no tenant + auth_token = self.fixture_create_token( + user_id=self.auth_user['id'], + tenant_id=None, + expires=self.expires, + token_id='NOTENANTTOKEN') + url = "/tokens" req = self.get_request('POST', url) body = { -- cgit