summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsirish.bitra <sirish.bitra@gmail.com>2011-05-12 17:06:34 +0530
committersirish.bitra <sirish.bitra@gmail.com>2011-05-12 17:06:34 +0530
commit8c813e9a92d041cc94ea1948a385e57256fceead (patch)
treea9a83479136fd2c255320481ff7ae378ec33a908
parenta0c43a05126d9cca83b58b788fbc8e24f004fb66 (diff)
pylintrc optimization
-rw-r--r--test/unit/test_tenant_groups.py533
-rw-r--r--test/unit/test_tenants.py185
-rw-r--r--test/unit/test_token.py47
-rw-r--r--test/unit/test_version.py11
4 files changed, 403 insertions, 373 deletions
diff --git a/test/unit/test_tenant_groups.py b/test/unit/test_tenant_groups.py
index 5768e631..6634b280 100644
--- a/test/unit/test_tenant_groups.py
+++ b/test/unit/test_tenant_groups.py
@@ -8,52 +8,43 @@ import httplib2
import json
from lxml import etree
-from test_common import URL, get_token, get_tenant, get_user
-from test_common import get_userdisabled, get_auth_token
-from test_common import get_exp_auth_token, get_disabled_token
-from test_common import delete_user, create_user
-from test_common import delete_user_tenant_group_xml, delete_user_tenant_group
-from test_common import add_user_tenant_group_xml, add_user_tenant_group
-from test_common import create_tenant_group, get_user_tenant_group_xml
-from test_common import create_tenant, get_user_tenant_group
-from test_common import delete_tenant_group, delete_tenant_xml, delete_tenant
-from test_common import delete_tenant_group_xml, create_tenant_group_xml
-from test_common import create_tenant_xml
+import test_common as util
+
class tenant_group_test(unittest.TestCase):
def setUp(self):
- self.token = get_token('joeuser', 'secrete', 'token')
- self.tenant = get_tenant()
- self.user = get_user()
- self.userdisabled = get_userdisabled()
- self.auth_token = get_auth_token()
- self.exp_auth_token = get_exp_auth_token()
- self.disabled_token = get_disabled_token()
+ self.token = util.get_token('joeuser', 'secrete', 'token')
+ self.tenant = util.get_tenant()
+ self.user = util.get_user()
+ self.userdisabled = util.get_userdisabled()
+ self.auth_token = util.get_auth_token()
+ self.exp_auth_token = util.get_exp_auth_token()
+ self.disabled_token = util.get_disabled_token()
self.tenant_group = 'test_tenant_group_add'
def tearDown(self):
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
self.auth_token)
- resp, content = delete_tenant(self.tenant, self.auth_token)
+ resp, content = util.delete_tenant(self.tenant, self.auth_token)
class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create(self):
- resp, content = delete_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.delete_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
@@ -62,16 +53,17 @@ class create_tenant_group_test(tenant_group_test):
self.fail('Failed due to %d' % int(resp['status']))
def test_tenant_group_create_xml(self):
- resp, content = delete_tenant_xml(self.tenant, str(self.auth_token))
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
- resp, content = delete_tenant_group_xml(self.tenant_group,
+ resp, content = util.delete_tenant_xml(self.tenant,
+ str(self.auth_token))
+ resp, content = util.create_tenant_xml(self.tenant,
+ str(self.auth_token))
+ resp, content = util.delete_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_tenant_group_xml(self.tenant_group,
+ resp, content = util.create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
- self.tenant = self.tenant
- self.tenant_group = self.tenant_group
+
content = etree.fromstring(content)
if int(resp['status']) == 500:
self.fail('IDM fault')
@@ -81,11 +73,12 @@ class create_tenant_group_test(tenant_group_test):
self.fail('Failed due to %d' % int(resp['status']))
def test_tenant_group_create_again(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant,
+ str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
if int(resp['status']) == 200:
@@ -98,11 +91,12 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(409, int(resp['status']))
def test_tenant_group_create_again_xml(self):
- resp, content = create_tenant_xml("test_tenant", str(self.auth_token))
- resp, content = create_tenant_group_xml(self.tenant_group,
+ resp, content = util.create_tenant_xml("test_tenant",
+ str(self.auth_token))
+ resp, content = util.create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp_new, content_new = create_tenant_group_xml(self.tenant_group,
+ resp_new, content_new = util.create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
if int(resp['status']) == 500:
@@ -114,16 +108,16 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_unauthorized_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- resp, content = create_tenant_group_xml(self.tenant_group,
+ resp, content = util.create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
if int(resp['status']) == 200:
self.tenant_group = resp['group']['id']
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = {"group": {"id": self.tenant_group,
"description": "A description ..."}}
resp, content = header.request(url, "POST", body=json.dumps(body),
@@ -137,10 +131,10 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_unauthorized_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="%s"><description>A description...</description> \
@@ -157,10 +151,10 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_expired_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = {"group": {"id": self.tenant_group,
"description": "A description ..."}}
resp, content = header.request(url, "POST", body=json.dumps(body),
@@ -174,11 +168,12 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_expired_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="%s"> \
@@ -196,10 +191,10 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_missing_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = {"group": {"id": self.tenant_group,
"description": "A description ..."}}
resp, content = header.request(url, "POST", body=json.dumps(body),
@@ -212,11 +207,12 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_missing_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="%s"> \
@@ -233,11 +229,11 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_disabled_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = '{"group": { "id": "%s", \
"description": "A description ..." } }' % self.tenant_group
resp, content = header.request(url, "POST", body=body,
@@ -252,12 +248,12 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_disabled_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="%s"> \
@@ -275,11 +271,11 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_invalid_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = '{"group": { "id": "%s", \
"description": "A description ..." } }' % self.tenant
resp, content = header.request(url, "POST", body=body,
@@ -294,12 +290,13 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create_invalid_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="%s"> \
@@ -321,13 +318,13 @@ class get_tenant_groups_test(tenant_group_test):
def test_get_tenant_groups(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -340,12 +337,12 @@ class get_tenant_groups_test(tenant_group_test):
def test_get_tenant_groups_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group_xml(self.tenant_group,
+ resp, content = util.create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
@@ -358,12 +355,12 @@ class get_tenant_groups_test(tenant_group_test):
def test_get_tenant_groups_unauthorized_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -376,11 +373,11 @@ class get_tenant_groups_test(tenant_group_test):
def test_get_tenant_groups_unauthorized_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -394,11 +391,11 @@ class get_tenant_groups_test(tenant_group_test):
def test_get_tenant_groups_exp_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -411,11 +408,11 @@ class get_tenant_groups_test(tenant_group_test):
def test_get_tenant_groups_exp_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups' % (URL, self.tenant)
+ url = '%stenant/%s/groups' % (util.URL, self.tenant)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -432,11 +429,12 @@ class get_tenant_group_test(tenant_group_test):
def test_get_tenant_group(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
+ url = '%stenant/%s/groups/%s' % (util.URL, self.tenant,
+ self.tenant_group)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -449,11 +447,12 @@ class get_tenant_group_test(tenant_group_test):
def test_get_tenant_group_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
+ url = '%stenant/%s/groups/%s' % (util.URL, self.tenant,
+ self.tenant_group)
#test for Content-Type = application/xml
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -467,11 +466,12 @@ class get_tenant_group_test(tenant_group_test):
def test_get_tenant_group_bad(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, 'tenant_bad', self.tenant_group)
+ url = '%stenant/%s/groups/%s' % (util.URL, 'tenant_bad',
+ self.tenant_group)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{',
@@ -485,11 +485,12 @@ class get_tenant_group_test(tenant_group_test):
def test_get_tenant_group_bad_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, 'tenant_bad', self.tenant_group)
+ url = '%stenant/%s/groups/%s' % (util.URL, 'tenant_bad',
+ self.tenant_group)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{',
headers={"Content-Type": "application/xml",
@@ -503,11 +504,12 @@ class get_tenant_group_test(tenant_group_test):
def test_get_tenant_group_not_found(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, self.tenant, 'nonexistinggroup')
+ url = '%stenant/%s/groups/%s' % (util.URL, self.tenant,
+ 'nonexistinggroup')
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -520,11 +522,12 @@ class get_tenant_group_test(tenant_group_test):
def test_get_tenant_group_not_found_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, self.tenant, 'nonexistinggroup')
+ url = '%stenant/%s/groups/%s' % (util.URL, self.tenant,
+ 'nonexistinggroup')
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
@@ -542,14 +545,15 @@ class update_tenant_group_test(tenant_group_test):
def test_update_tenant_group(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
+ url = '%stenant/%s/groups/%s' % (util.URL, self.tenant,
+ self.tenant_group)
data = '{"group": { "id":"%s","description": "A NEW description..." ,\
"tenantId":"%s" }}' % (self.tenant_group, self.tenant)
@@ -571,19 +575,20 @@ class update_tenant_group_test(tenant_group_test):
def test_update_tenant_group_xml(self):
header = httplib2.Http(".cache")
- resp, content = delete_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.delete_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
+ url = '%stenant/%s/groups/%s' % (util.URL, self.tenant,
+ self.tenant_group)
data = '<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
tenantId="%s" id="%s"> \
@@ -611,14 +616,15 @@ class update_tenant_group_test(tenant_group_test):
def test_update_tenant_group_bad(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
+ url = '%stenant/%s/groups/%s' % (util.URL, self.tenant,
+ self.tenant_group)
data = '{"group": { "description_bad": "A NEW description...",\
"id":"%s","tenantId":"%s" }}' % (self.tenant_group, self.tenant)
#test for Content-Type = application/json
@@ -634,14 +640,15 @@ class update_tenant_group_test(tenant_group_test):
def test_update_tenant_group_bad_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
+ url = '%stenant/%s/groups/%s' % (util.URL, self.tenant,
+ self.tenant_group)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
tenantId="%s" id="%s"> \
@@ -660,14 +667,14 @@ class update_tenant_group_test(tenant_group_test):
def test_update_tenant_group_not_found(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- url = '%stenant/%s/groups/NonexistingID' % (URL, self.tenant)
+ url = '%stenant/%s/groups/NonexistingID' % (util.URL, self.tenant)
data = '{"group": { "description": "A NEW description...",\
"id":"NonexistingID", "tenantId"="test_tenant" }}'
@@ -683,8 +690,8 @@ class update_tenant_group_test(tenant_group_test):
def test_update_tenant_group_not_found_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenant/%s/groups/NonexistingID' % (URL, self.tenant)
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenant/%s/groups/NonexistingID' % (util.URL, self.tenant)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="NonexistingID", "tenant_id"="test_tenant"> \
@@ -705,42 +712,40 @@ class update_tenant_group_test(tenant_group_test):
class delete_tenant_group_test(tenant_group_test):
def test_delete_tenant_group_not_found(self):
- #resp,content=create_tenant("test_tenant_delete", str(self.auth_token))
- resp, content = delete_tenant_group("test_tenant_delete111",
+ resp, content = util.delete_tenant_group("test_tenant_delete111",
self.tenant,
str(self.auth_token))
self.assertEqual(404, int(resp['status']))
def test_delete_tenant_group_not_found_xml(self):
- #resp,content=create_tenant("test_tenant_delete", str(self.auth_token))
- resp, content = delete_tenant_group_xml("test_tenant_delete111",
+ resp, content = util.delete_tenant_group_xml("test_tenant_delete111",
self.tenant,
str(self.auth_token))
self.assertEqual(404, int(resp['status']))
def test_delete_tenant_group(self):
- resp, content = create_tenant("test_tenant_delete",
+ resp, content = util.create_tenant("test_tenant_delete",
str(self.auth_token))
- resp, content = create_tenant_group('test_tenant_group_delete',
+ resp, content = util.create_tenant_group('test_tenant_group_delete',
"test_tenant_delete",
str(self.auth_token))
- resp, content = delete_tenant_group('test_tenant_group_delete',
+ resp, content = util.delete_tenant_group('test_tenant_group_delete',
"test_tenant_delete",
str(self.auth_token))
- resp, content = delete_tenant("test_tenant_delete",
+ resp, content = util.delete_tenant("test_tenant_delete",
str(self.auth_token))
self.assertEqual(204, int(resp['status']))
def test_delete_tenant_group_xml(self):
- resp, content = create_tenant("test_tenant_delete",
+ resp, content = util.create_tenant("test_tenant_delete",
str(self.auth_token))
- resp, content = create_tenant_group('test_tenant_group_delete',
+ resp, content = util.create_tenant_group('test_tenant_group_delete',
"test_tenant_delete",
str(self.auth_token))
- resp, content = delete_tenant_group('test_tenant_group_delete',
+ resp, content = util.delete_tenant_group('test_tenant_group_delete',
"test_tenant_delete",
str(self.auth_token))
- resp, content = delete_tenant_xml("test_tenant_delete",
+ resp, content = util.delete_tenant_xml("test_tenant_delete",
str(self.auth_token))
self.assertEqual(204, int(resp['status']))
@@ -748,39 +753,41 @@ class delete_tenant_group_test(tenant_group_test):
class add_user_tenant_group_test(tenant_group_test):
def setUp(self):
- self.token = get_token('joeuser', 'secrete', 'token')
+ self.token = util.get_token('joeuser', 'secrete', 'token')
self.tenant = 'test_tenant'
- self.user = get_user()
- self.userdisabled = get_userdisabled()
- self.auth_token = get_auth_token()
- self.exp_auth_token = get_exp_auth_token()
- self.disabled_token = get_disabled_token()
+ self.user = util.get_user()
+ self.userdisabled = util.get_userdisabled()
+ self.auth_token = util.get_auth_token()
+ self.exp_auth_token = util.get_exp_auth_token()
+ self.disabled_token = util.get_disabled_token()
self.tenant_group = 'test_tenant_group_add'
def tearDown(self):
- resp, content = delete_user_tenant_group(self.tenant,
+ resp, content = util.delete_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- resp, content = delete_user(self.tenant, self.user,
+ resp, content = util.delete_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
self.auth_token)
- resp, content = delete_tenant(self.tenant, self.auth_token)
+ resp, content = util.delete_tenant(self.tenant, self.auth_token)
def test_add_user_tenant_group(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, str(self.auth_token))
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user,
+ str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
@@ -790,13 +797,13 @@ class add_user_tenant_group_test(tenant_group_test):
self.fail('Failed due to %d' % int(resp['status']))
def test_add_user_tenant_group_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
- self.tenant,
- str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
+ self.tenant,
+ str(self.auth_token))
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
@@ -809,16 +816,20 @@ class add_user_tenant_group_test(tenant_group_test):
self.fail('Failed due to %d' % int(resp['status']))
def test_add_user_tenant_group_conflict(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, str(self.auth_token))
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user,
+ str(self.auth_token))
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user,
+ str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
@@ -826,16 +837,16 @@ class add_user_tenant_group_test(tenant_group_test):
self.assertEqual(409, int(resp['status']))
def test_add_user_tenant_group_conflict_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user, str(self.auth_token))
- resp, content = add_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
@@ -847,15 +858,16 @@ class add_user_tenant_group_test(tenant_group_test):
self.assertEqual(409, int(resp['status']))
def test_add_user_tenant_group_unauthorized(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, self.token)
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user, self.token)
if int(resp['status']) == 500:
self.fail('IDM fault')
@@ -864,16 +876,16 @@ class add_user_tenant_group_test(tenant_group_test):
self.assertEqual(401, int(resp['status']))
def test_add_user_tenant_group_unauthorized_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
- str(self.auth_token))
+ resp, content = util.create_user(self.tenant, self.user,
+ str(self.auth_token))
- resp, content = add_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group_xml(self.tenant,
self.tenant_group,
- self.user, self.token)
+ self.user, self.token)
if int(resp['status']) == 500:
self.fail('IDM fault')
@@ -882,15 +894,17 @@ class add_user_tenant_group_test(tenant_group_test):
self.assertEqual(401, int(resp['status']))
def test_add_user_tenant_group_forbidden(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
- self.tenant,
- str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
+ self.tenant,
+ str(self.auth_token))
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, self.disabled_token)
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user,
+ self.disabled_token)
if int(resp['status']) == 500:
self.fail('IDM fault')
@@ -899,14 +913,14 @@ class add_user_tenant_group_test(tenant_group_test):
self.assertEqual(403, int(resp['status']))
def test_add_user_tenant_group_forbidden_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
self.disabled_token)
@@ -921,126 +935,133 @@ class add_user_tenant_group_test(tenant_group_test):
class get_users_tenant_group_test(tenant_group_test):
def setUp(self):
- self.token = get_token('joeuser', 'secrete', 'token')
+ self.token = util.get_token('joeuser', 'secrete', 'token')
self.tenant = 'test_tenant'
- self.user = get_user()
- self.userdisabled = get_userdisabled()
- self.auth_token = get_auth_token()
- self.exp_auth_token = get_exp_auth_token()
- self.disabled_token = get_disabled_token()
+ self.user = util.get_user()
+ self.userdisabled = util.get_userdisabled()
+ self.auth_token = util.get_auth_token()
+ self.exp_auth_token = util.get_exp_auth_token()
+ self.disabled_token = util.get_disabled_token()
self.tenant_group = 'test_tenant_group_add'
def tearDown(self):
- resp, content = delete_user_tenant_group(self.tenant,
+ resp, content = util.delete_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- resp, content = delete_user(self.tenant, self.user,
+ resp, content = util.delete_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = delete_tenant_group(self.tenant_group,
+ resp, content = util.delete_tenant_group(self.tenant_group,
self.tenant,
self.auth_token)
- resp, content = delete_tenant(self.tenant, self.auth_token)
+ resp, content = util.delete_tenant(self.tenant, self.auth_token)
def test_get_users_tenant_group(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, str(self.auth_token))
- resp, content = get_user_tenant_group(self.tenant, self.tenant_group,
- str(self.auth_token))
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user,
+ str(self.auth_token))
+ resp, content = util.get_user_tenant_group(self.tenant,
+ self.tenant_group,
+ str(self.auth_token))
self.assertEqual(200, int(resp['status']))
def test_get_users_tenant_group_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- resp, content = get_user_tenant_group_xml(self.tenant,
+ resp, content = util.get_user_tenant_group_xml(self.tenant,
self.tenant_group,
str(self.auth_token))
self.assertEqual(200, int(resp['status']))
def test_get_users_tenant_group_unauthorized(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant,
+ resp, content = util.add_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
self.auth_token)
- resp, content = get_user_tenant_group(self.tenant, self.tenant_group,
- str(self.token))
+ resp, content = util.get_user_tenant_group(self.tenant,
+ self.tenant_group,
+ str(self.token))
self.assertEqual(401, int(resp['status']))
def test_get_users_tenant_group_unauthorized_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(401, int(resp['status']))
- resp, content = create_tenant_group(self.tenant_group,
+
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, self.auth_token)
- resp, content = get_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user, self.auth_token)
+ resp, content = util.get_user_tenant_group_xml(self.tenant,
self.tenant_group,
str(self.token))
+ self.assertEqual(401, int(resp['status']))
def test_get_users_tenant_group_forbidden(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, self.auth_token)
- resp, content = get_user_tenant_group(self.tenant,
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user, self.auth_token)
+ resp, content = util.get_user_tenant_group(self.tenant,
self.tenant_group,
str(self.disabled_token))
@@ -1048,58 +1069,62 @@ class get_users_tenant_group_test(tenant_group_test):
self.assertEqual(403, int(resp['status']))
def test_get_users_tenant_group_forbidden_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, self.auth_token)
- resp, content = get_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user, self.auth_token)
+ resp, content = util.get_user_tenant_group_xml(self.tenant,
self.tenant_group,
str(self.disabled_token))
self.assertEqual(403, int(resp['status']))
def test_get_users_tenant_group_expired(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
- self.user, self.auth_token)
- resp, content = get_user_tenant_group(self.tenant, self.tenant_group,
- str(self.exp_auth_token))
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
+ self.user, self.auth_token)
+ resp, content = util.get_user_tenant_group(self.tenant,
+ self.tenant_group,
+ str(self.exp_auth_token))
self.assertEqual(403, int(resp['status']))
def test_get_users_tenant_group_expired_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = util.add_user_tenant_group(self.tenant,
+ self.tenant_group,
self.user, self.auth_token)
- resp, content = get_user_tenant_group_xml(self.tenant,
+ resp, content = util.get_user_tenant_group_xml(self.tenant,
self.tenant_group,
str(self.exp_auth_token))
@@ -1109,21 +1134,21 @@ class get_users_tenant_group_test(tenant_group_test):
class delete_users_tenant_group_test(tenant_group_test):
def test_delete_user_tenant_group(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group(self.tenant,
+ resp, content = util.add_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- resp, content = delete_user_tenant_group(self.tenant,
+ resp, content = util.delete_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
@@ -1132,21 +1157,21 @@ class delete_users_tenant_group_test(tenant_group_test):
self.assertEqual(204, int(resp['status']))
def test_delete_user_tenant_group_xml(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = util.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- resp, content = create_tenant_group(self.tenant_group,
+ resp, content = util.create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- resp, content = create_user(self.tenant, self.user,
+ resp, content = util.create_user(self.tenant, self.user,
str(self.auth_token))
- resp, content = add_user_tenant_group_xml(self.tenant,
+ resp, content = util.add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- resp, content = delete_user_tenant_group_xml(self.tenant,
+ resp, content = util.delete_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
@@ -1155,7 +1180,7 @@ class delete_users_tenant_group_test(tenant_group_test):
self.assertEqual(204, int(resp['status']))
def test_delete_user_tenant_group_notfound(self):
- resp, content = delete_user_tenant_group(self.tenant,
+ resp, content = util.delete_user_tenant_group(self.tenant,
self.tenant_group,
'NonExistinguser',
str(self.auth_token))
@@ -1166,7 +1191,7 @@ class delete_users_tenant_group_test(tenant_group_test):
self.assertEqual(404, int(resp['status']))
def test_delete_user_tenant_group_notfound_xml(self):
- resp, content = delete_user_tenant_group_xml(self.tenant,
+ resp, content = util.delete_user_tenant_group_xml(self.tenant,
self.tenant_group,
'NonExistinguser',
str(self.auth_token))
diff --git a/test/unit/test_tenants.py b/test/unit/test_tenants.py
index c322409b..103dd578 100644
--- a/test/unit/test_tenants.py
+++ b/test/unit/test_tenants.py
@@ -7,36 +7,29 @@ import unittest
import httplib2
import json
from lxml import etree
-from test_common import URL, get_token, get_user
-from test_common import get_userdisabled, get_auth_token
-from test_common import get_exp_auth_token, get_disabled_token, create_tenant
-from test_common import create_tenant_xml, delete_tenant, delete_tenant_xml
-
-
-
-
+import test_common as utils
class tenant_test(unittest.TestCase):
def setUp(self):
- self.token = get_token('joeuser', 'secrete', 'token')
+ self.token = utils.get_token('joeuser', 'secrete', 'token')
self.tenant = 'test_tenant'
- self.user = get_user()
- self.userdisabled = get_userdisabled()
- self.auth_token = get_auth_token()
- self.exp_auth_token = get_exp_auth_token()
- self.disabled_token = get_disabled_token()
+ self.user = utils.get_user()
+ self.userdisabled = utils.get_userdisabled()
+ self.auth_token = utils.get_auth_token()
+ self.exp_auth_token = utils.get_exp_auth_token()
+ self.disabled_token = utils.get_disabled_token()
def tearDown(self):
- resp, content = delete_tenant(self.tenant, self.auth_token)
+ resp, content = utils.delete_tenant(self.tenant, self.auth_token)
class create_tenant_test(tenant_test):
def test_tenant_create(self):
- resp, content = delete_tenant(self.tenant, str(self.auth_token))
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.delete_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
@@ -47,8 +40,10 @@ class create_tenant_test(tenant_test):
self.fail('Failed due to %d' % int(resp['status']))
def test_tenant_create_xml(self):
- resp, content = delete_tenant_xml(self.tenant, str(self.auth_token))
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = utils.delete_tenant_xml(self.tenant,
+ str(self.auth_token))
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 500:
self.fail('IDM fault')
@@ -59,10 +54,12 @@ class create_tenant_test(tenant_test):
def test_tenant_create_again(self):
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant(self.tenant,
+ str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant(self.tenant,
+ str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
@@ -71,8 +68,10 @@ class create_tenant_test(tenant_test):
def test_tenant_create_again_xml(self):
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 500:
self.fail('IDM fault')
@@ -83,11 +82,11 @@ class create_tenant_test(tenant_test):
def test_tenant_create_forbidden_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = {"tenant": {"id": self.tenant,
"description": "A description ...",
"enabled": True}}
@@ -103,12 +102,13 @@ class create_tenant_test(tenant_test):
def test_tenant_create_forbidden_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" id="%s"> \
@@ -127,10 +127,11 @@ class create_tenant_test(tenant_test):
def test_tenant_create_expired_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant(self.tenant,
+ str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = {"tenant": {"id": self.tenant,
"description": "A description ...",
"enabled": True}}
@@ -145,12 +146,13 @@ class create_tenant_test(tenant_test):
def test_tenant_create_expired_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" id="%s"> \
@@ -170,11 +172,12 @@ class create_tenant_test(tenant_test):
def test_tenant_create_missing_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant(self.tenant,
+ str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = {"tenant": {"id": self.tenant,
"description": "A description ...",
"enabled": True}}
@@ -189,11 +192,12 @@ class create_tenant_test(tenant_test):
def test_tenant_create_missing_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" id="%s"> \
@@ -210,11 +214,12 @@ class create_tenant_test(tenant_test):
def test_tenant_create_disabled_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant(self.tenant,
+ str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = '{"tenant": { "id": "%s", \
"description": "A description ...", "enabled"\
:true } }' % self.tenant
@@ -230,11 +235,12 @@ class create_tenant_test(tenant_test):
def test_tenant_create_disabled_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" id="%s"> \
@@ -252,11 +258,12 @@ class create_tenant_test(tenant_test):
def test_tenant_create_invalid_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant(self.tenant,
+ str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = '{"tenant": { "id": "%s", \
"description": "A description ...", "enabled"\
:true } }' % self.tenant
@@ -272,12 +279,13 @@ class create_tenant_test(tenant_test):
def test_tenant_create_invalid_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
- url = '%stenants' % (URL)
+ url = '%stenants' % (utils.URL)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" id="%s"> \
@@ -299,8 +307,8 @@ class get_tenants_test(tenant_test):
def test_get_tenants(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants' % (utils.URL)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -313,8 +321,8 @@ class get_tenants_test(tenant_test):
def test_get_tenants_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants' % (utils.URL)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -328,8 +336,8 @@ class get_tenants_test(tenant_test):
def test_get_tenants_unauthorized_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants' % (utils.URL)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -342,8 +350,8 @@ class get_tenants_test(tenant_test):
def test_get_tenants_unauthorized_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants' % (utils.URL)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -357,8 +365,8 @@ class get_tenants_test(tenant_test):
def test_get_tenants_exp_token(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants' % (utils.URL)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -371,8 +379,8 @@ class get_tenants_test(tenant_test):
def test_get_tenants_exp_token_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants' % (utils.URL)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -389,8 +397,8 @@ class get_tenant_test(tenant_test):
def test_get_tenant(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/%s' % (URL, self.tenant)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/%s' % (utils.URL, self.tenant)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -403,8 +411,8 @@ class get_tenant_test(tenant_test):
def test_get_tenant_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/%s' % (URL, self.tenant)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/%s' % (utils.URL, self.tenant)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -418,8 +426,8 @@ class get_tenant_test(tenant_test):
def test_get_tenant_bad(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/%s' % (URL, 'tenant_bad')
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/%s' % (utils.URL, 'tenant_bad')
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
@@ -432,8 +440,8 @@ class get_tenant_test(tenant_test):
def test_get_tenant_bad_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/%s' % (URL, 'tenant_bad')
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/%s' % (utils.URL, 'tenant_bad')
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -447,8 +455,8 @@ class get_tenant_test(tenant_test):
def test_get_tenant_not_found(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/NonexistingID' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/NonexistingID' % (utils.URL)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
@@ -461,8 +469,8 @@ class get_tenant_test(tenant_test):
def test_get_tenant_not_found_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/NonexistingID' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/NonexistingID' % (utils.URL)
#test for Content-Type = application/json
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -479,8 +487,8 @@ class update_tenant_test(tenant_test):
def test_update_tenant(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/%s' % (URL, self.tenant)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/%s' % (utils.URL, self.tenant)
data = '{"tenant": { "description": "A NEW description..." ,\
"enabled":true }}'
#test for Content-Type = application/json
@@ -498,8 +506,9 @@ class update_tenant_test(tenant_test):
def test_update_tenant_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
- url = '%stenants/%s' % (URL, self.tenant)
+ resp, content = utils.create_tenant_xml(self.tenant,
+ str(self.auth_token))
+ url = '%stenants/%s' % (utils.URL, self.tenant)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true"> \
@@ -523,8 +532,8 @@ class update_tenant_test(tenant_test):
def test_update_tenant_bad(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/%s' % (URL, self.tenant)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/%s' % (utils.URL, self.tenant)
data = '{"tenant": { "description_bad": "A NEW description...",\
"enabled":true }}'
#test for Content-Type = application/json
@@ -540,8 +549,8 @@ class update_tenant_test(tenant_test):
def test_update_tenant_bad_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/%s' % (URL, self.tenant)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/%s' % (utils.URL, self.tenant)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true"> \
@@ -560,8 +569,8 @@ class update_tenant_test(tenant_test):
def test_update_tenant_not_found(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/NonexistingID' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/NonexistingID' % (utils.URL)
data = '{"tenant": { "description": "A NEW description...",\
"enabled":true }}'
#test for Content-Type = application/json
@@ -576,8 +585,8 @@ class update_tenant_test(tenant_test):
def test_update_tenant_not_found_xml(self):
header = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- url = '%stenants/NonexistingID' % (URL)
+ resp, content = utils.create_tenant(self.tenant, str(self.auth_token))
+ url = '%stenants/NonexistingID' % (utils.URL)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true"> \
@@ -598,28 +607,30 @@ class update_tenant_test(tenant_test):
class delete_tenant_test(tenant_test):
def test_delete_tenant_not_found(self):
- #resp,content=create_tenant("test_tenant_delete", str(self.auth_token))
- resp, content = delete_tenant("test_tenant_delete111",
+ #resp,content=utils.create_tenant("test_tenant_delete",
+ # str(self.auth_token))
+ resp, content = utils.delete_tenant("test_tenant_delete111",
str(self.auth_token))
self.assertEqual(404, int(resp['status']))
def test_delete_tenant_not_found_xml(self):
- #resp,content=create_tenant("test_tenant_delete", str(self.auth_token))
- resp, content = delete_tenant_xml("test_tenant_delete111",
+ #resp,content=utils.create_tenant("test_tenant_delete",
+ # str(self.auth_token))
+ resp, content = utils.delete_tenant_xml("test_tenant_delete111",
str(self.auth_token))
self.assertEqual(404, int(resp['status']))
def test_delete_tenant(self):
- resp, content = create_tenant("test_tenant_delete",
+ resp, content = utils.create_tenant("test_tenant_delete",
str(self.auth_token))
- resp, content = delete_tenant("test_tenant_delete",
+ resp, content = utils.delete_tenant("test_tenant_delete",
str(self.auth_token))
self.assertEqual(204, int(resp['status']))
def test_delete_tenant_xml(self):
- resp, content = create_tenant_xml("test_tenant_delete",
+ resp, content = utils.create_tenant_xml("test_tenant_delete",
str(self.auth_token))
- resp, content = delete_tenant_xml("test_tenant_delete",
+ resp, content = utils.delete_tenant_xml("test_tenant_delete",
str(self.auth_token))
self.assertEqual(204, int(resp['status']))
diff --git a/test/unit/test_token.py b/test/unit/test_token.py
index c4633166..9177e87a 100644
--- a/test/unit/test_token.py
+++ b/test/unit/test_token.py
@@ -5,30 +5,27 @@ sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__),
'..', '..', '..', '..', 'keystone')))
import unittest
import httplib2
-from test_common import URL, get_token, get_tenant, get_user
-from test_common import get_userdisabled, get_auth_token
-from test_common import get_exp_auth_token, get_disabled_token
-from test_common import delete_token, content_type
+import test_common as utils
class validate_token(unittest.TestCase):
def setUp(self):
- self.token = get_token('joeuser', 'secrete', 'token')
- self.tenant = get_tenant()
- self.user = get_user()
- self.userdisabled = get_userdisabled()
- self.auth_token = get_auth_token()
- self.exp_auth_token = get_exp_auth_token()
- self.disabled_token = get_disabled_token()
+ self.token = utils.get_token('joeuser', 'secrete', 'token')
+ self.tenant = utils.get_tenant()
+ self.user = utils.get_user()
+ self.userdisabled = utils.get_userdisabled()
+ self.auth_token = utils.get_auth_token()
+ self.exp_auth_token = utils.get_exp_auth_token()
+ self.disabled_token = utils.get_disabled_token()
def tearDown(self):
- delete_token(self.token, self.auth_token)
+ utils.delete_token(self.token, self.auth_token)
def test_validate_token_true(self):
header = httplib2.Http(".cache")
- url = '%stoken/%s?belongsTo=%s' % (URL, self.token, self.tenant)
+ url = '%stoken/%s?belongsTo=%s' % (utils.URL, self.token, self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
@@ -37,11 +34,11 @@ class validate_token(unittest.TestCase):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(200, int(resp['status']))
- self.assertEqual('application/json', content_type(resp))
+ self.assertEqual('application/json', utils.content_type(resp))
def test_validate_token_true_xml(self):
header = httplib2.Http(".cache")
- url = '%stoken/%s?belongsTo=%s' % (URL, self.token, self.tenant)
+ url = '%stoken/%s?belongsTo=%s' % (utils.URL, self.token, self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
@@ -51,11 +48,11 @@ class validate_token(unittest.TestCase):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(200, int(resp['status']))
- self.assertEqual('application/xml', content_type(resp))
+ self.assertEqual('application/xml', utils.content_type(resp))
def test_validate_token_expired(self):
header = httplib2.Http(".cache")
- url = '%stoken/%s?belongsTo=%s' % (URL, self.exp_auth_token,
+ url = '%stoken/%s?belongsTo=%s' % (utils.URL, self.exp_auth_token,
self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
@@ -65,12 +62,12 @@ class validate_token(unittest.TestCase):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(403, int(resp['status']))
- self.assertEqual('application/json', content_type(resp))
+ self.assertEqual('application/json', utils.content_type(resp))
def test_validate_token_expired_xml(self):
header = httplib2.Http(".cache")
- url = '%stoken/%s?belongsTo=%s' % (URL, self.exp_auth_token,
+ url = '%stoken/%s?belongsTo=%s' % (utils.URL, self.exp_auth_token,
self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
@@ -81,11 +78,11 @@ class validate_token(unittest.TestCase):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(403, int(resp['status']))
- self.assertEqual('application/xml', content_type(resp))
+ self.assertEqual('application/xml', utils.content_type(resp))
def test_validate_token_invalid(self):
header = httplib2.Http(".cache")
- url = '%stoken/%s?belongsTo=%s' % (URL, 'NonExistingToken',
+ url = '%stoken/%s?belongsTo=%s' % (utils.URL, 'NonExistingToken',
self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
@@ -96,11 +93,11 @@ class validate_token(unittest.TestCase):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(401, int(resp['status']))
- self.assertEqual('application/json', content_type(resp))
+ self.assertEqual('application/json', utils.content_type(resp))
def test_validate_token_invalid_xml(self):
header = httplib2.Http(".cache")
- url = '%stoken/%s?belongsTo=%s' % (URL, 'NonExistingToken',
+ url = '%stoken/%s?belongsTo=%s' % (utils.URL, 'NonExistingToken',
self.tenant)
resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
@@ -110,10 +107,8 @@ class validate_token(unittest.TestCase):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(401, int(resp['status']))
- self.assertEqual('application/json', content_type(resp))
+ self.assertEqual('application/json', utils.content_type(resp))
-def run():
- unittest.main()
if __name__ == '__main__':
unittest.main()
diff --git a/test/unit/test_version.py b/test/unit/test_version.py
index b83e7d0d..462a796a 100644
--- a/test/unit/test_version.py
+++ b/test/unit/test_version.py
@@ -5,8 +5,7 @@ sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__),
'..', '..', '..', '..', 'keystone')))
import unittest
import httplib2
-from test_common import URL, content_type
-
+import test_common as utils
class version_test(unittest.TestCase):
@@ -15,18 +14,18 @@ class version_test(unittest.TestCase):
def test_a_get_version_json(self):
header = httplib2.Http(".cache")
- resp, content = header.request(URL, "GET", body="",
+ resp, content = header.request(utils.URL, "GET", body="",
headers={"Content-Type": "application/json"})
self.assertEqual(200, int(resp['status']))
- self.assertEqual('application/json', content_type(resp))
+ self.assertEqual('application/json', utils.content_type(resp))
def test_a_get_version_xml(self):
header = httplib2.Http(".cache")
- resp, content = header.request(URL, "GET", body="",
+ resp, content = header.request(utils.URL, "GET", body="",
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
self.assertEqual(200, int(resp['status']))
- self.assertEqual('application/xml', content_type(resp))
+ self.assertEqual('application/xml', utils.content_type(resp))