From db0df82f26822fe4a5a2295f8b86b598dfaaa96c Mon Sep 17 00:00:00 2001 From: "sirish.bitra" Date: Mon, 9 May 2011 20:46:36 +0530 Subject: Modified test cases --- test/unit/test_identity.py | 1765 +++++++++++++++++++------------------------- 1 file changed, 743 insertions(+), 1022 deletions(-) (limited to 'test') diff --git a/test/unit/test_identity.py b/test/unit/test_identity.py index 09170a79..1421d00a 100644 --- a/test/unit/test_identity.py +++ b/test/unit/test_identity.py @@ -3,7 +3,7 @@ import sys # Need to access identity module sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..', '..', '..', 'keystone'))) -from keystone import auth_server + import unittest from webtest import TestApp import httplib2 @@ -55,7 +55,7 @@ def create_tenant(tenantid, auth_token): def create_tenant_group(groupid, tenantid, auth_token): h = httplib2.Http(".cache") - url = '%stenant/%s/groups' % (URL,tenantid) + url = '%stenant/%s/groups' % (URL, tenantid) body = {"group": {"id": groupid, "description": "A description ..." }} @@ -83,11 +83,11 @@ def delete_tenant_group(groupid, tenantid, auth_token): return (resp, content) -def create_global_group(auth_token): +def create_global_group(groupid, auth_token): h = httplib2.Http(".cache") - url = '%s/groups' % (URL) - body = {"group": {"id": 'Admin', + url = '%sgroups' % (URL) + body ={"group": {"id": groupid, "description": "A description ..." }} resp, content = h.request(url, "POST", body=json.dumps(body), @@ -98,7 +98,7 @@ def create_global_group(auth_token): def delete_global_group(groupid, auth_token): h = httplib2.Http(".cache") - url = '%s/groups/%s' % (URL, groupid) + url = '%sgroups/%s' % (URL, groupid) resp, content = h.request(url, "DELETE", body='{}',\ headers={"Content-Type": "application/json",\ "X-Auth-Token": auth_token}) @@ -153,7 +153,7 @@ def create_tenant_xml(tenantid, auth_token): def create_tenant_group_xml(groupid, tenantid, auth_token): h = httplib2.Http(".cache") - url = '%stenant/%s/groups' % (URL,tenantid) + url = '%stenant/%s/groups' % (URL, tenantid) body = ' \ \ @@ -188,7 +188,7 @@ def delete_tenant_group_xml(groupid, tenantid, auth_token): def create_global_group_xml(auth_token): h = httplib2.Http(".cache") - url = '%s/groups' % (URL) + url = '%sgroups' % (URL) body = ' \ \ @@ -203,7 +203,7 @@ def create_global_group_xml(auth_token): def delete_global_group_xml(groupid, auth_token): h = httplib2.Http(".cache") - url = '%s/groups/%s' % (URL, groupid) + url = '%sgroups/%s' % (URL, groupid) resp, content = h.request(url, "DELETE", body='',\ headers={"Content-Type": "application/xml",\ "X-Auth-Token": auth_token, @@ -234,8 +234,10 @@ def get_exp_auth_token(): def get_disabled_token(): return '999888777' + def content_type(resp): - return resp['content-type'].split(';')[0] + return resp['content-type'].split(';')[0] + class identity_test(unittest.TestCase): @@ -246,8 +248,8 @@ class identity_test(unittest.TestCase): h = httplib2.Http(".cache") url = URL resp, content = h.request(url, "GET", body="", - headers={"Content-Type": "application/json"}) - + headers={"Content-Type":\ + "application/json"}) self.assertEqual(200, int(resp['status'])) self.assertEqual('application/json', content_type(resp)) @@ -273,14 +275,11 @@ class authorize_test(identity_test): self.exp_auth_token = get_exp_auth_token() self.disabled_token = get_disabled_token() - - def tearDown(self): delete_token(self.token, self.auth_token) def test_a_authorize(self): resp, content = get_token('joeuser', 'secrete') - self.assertEqual(200, int(resp['status'])) self.assertEqual('application/json', content_type(resp)) @@ -289,11 +288,11 @@ class authorize_test(identity_test): self.assertEqual(200, int(resp['status'])) self.assertEqual('application/xml', content_type(resp)) - def test_a_authorize_user_disaabled(self): + def test_a_authorize_user_disabled(self): h = httplib2.Http(".cache") url = '%stoken' % URL body = {"passwordCredentials": {"username": "disabled", - "password": "self.tenant_group='test_tenant_group'secrete"}} + "password": "secrete"}} resp, content = h.request(url, "POST", body=json.dumps(body), headers={"Content-Type": "application/json"}) content = json.loads(content) @@ -302,11 +301,11 @@ class authorize_test(identity_test): elif int(resp['status']) == 503: self.fail('Service Not Available') self.assertEqual(403, int(resp['status'])) + self.assertEqual('application/json', content_type(resp)) - def test_a_authorize_user_disaabled_xml(self): + def test_a_authorize_user_disabled_xml(self): h = httplib2.Http(".cache") url = '%stoken' % URL - body = ' \