summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSai Krishna <saikrishna1511@gmail.com>2011-05-12 16:34:38 +0530
committerSai Krishna <saikrishna1511@gmail.com>2011-05-12 16:34:38 +0530
commite199cb4541a70709d94deab86657bbde487037e6 (patch)
treeffb455d72fc9b8ca072851b8e57806c1060993b7
parentc98c32d0f1ee4d6f2fd13fad37e9abd0e8801362 (diff)
parenta0c43a05126d9cca83b58b788fbc8e24f004fb66 (diff)
downloadkeystone-e199cb4541a70709d94deab86657bbde487037e6.tar.gz
keystone-e199cb4541a70709d94deab86657bbde487037e6.tar.xz
keystone-e199cb4541a70709d94deab86657bbde487037e6.zip
Merge branch 'master' of https://git.hcleai.com/keystone
Conflicts: README
-rw-r--r--README100
-rw-r--r--keystone/db/sqlalchemy/api.py7
-rw-r--r--keystone/file242
-rw-r--r--keystone/logic/service.py23
-rw-r--r--keystone/pylintrc38
-rw-r--r--pylintrc38
-rw-r--r--test/unit/test_authentication.py33
-rw-r--r--test/unit/test_common.py174
-rw-r--r--test/unit/test_groups.py7
-rw-r--r--test/unit/test_keystone.py7
-rw-r--r--test/unit/test_tenant_groups.py539
-rw-r--r--test/unit/test_tenants.py191
-rw-r--r--test/unit/test_token.py37
-rw-r--r--test/unit/test_users.py374
-rw-r--r--test/unit/test_version.py20
15 files changed, 1083 insertions, 747 deletions
diff --git a/README b/README
index ca31d5d6..35b27cc1 100644
--- a/README
+++ b/README
@@ -1,3 +1,4 @@
+
Keystone: Identity Service
==========================
@@ -60,13 +61,55 @@ Or using pip:
RUNNING KEYSTONE:
-----------------
+<<<<<<< HEAD
+From the topdir
+=======
+During development, you can simply run
+
+ $ bin/keystone-auth
+
+It dumps stdout and stderr onto the terminal.
+
+
+RUNNING KEYSOTNE IN AS ROOT IN PRODUCTION
+---------------------------------------------
+In production, stdout and stderr need to be closed and all theoutput needs tobe redirected to a log file.
+Once the package is installed through setup tools, RPM, deb, or ebuild keystone-control is installed
+as /usr/sbin/keystone-control. Typically, it will be started a script in /etc/init.d/keystoned
+
+keystone-control can invoke keystone-auth and start the keystone daemon with
+
+ $ /usr/sbin/keystone-control auth start
+
+It writes the process id of the daemon into /var/run/keystone/keystine-auth.pid. he daemon can be stopped with
+
+ $ /usr/sbin/keystone-control auth stop
+
+keystone-control has the infrastructure to start and stop multiple servers keystone-xxx
+
+
+DEVELOPMENT OF keystone-control
+-------------------------------
+
+During the development of keystone-control can be started as a user instead of root
+
From the topdir
+>>>>>>> a0c43a05126d9cca83b58b788fbc8e24f004fb66
+
+ $ bin/keystone-control --pid-file pidfile auth <start|stop|restart>
- $ bin/keystone-control --config-file etc/keystone.conf --pid-file=pidfile auth <start|stop|restart>
+config.py takes the config file from topdir/etc/keystone.conf
-The "start" command invokes bin/keystone-auth. During development you can also run
+If the keystone package is also intalled on the system
+/etc/keystone.conf or /etc/keystone/keystone.conf has higher priority
+than <top_dir>/etc/keystone.conf. If you are also doing development on a
+system that has keystone.conf installed in /etc/you need to disambiguate it by
- $ bin/keystone-auth etc/keystone.conf
+ $ bin/keystone-control --confg-file etc/keystone.conf --pid-file pidfile auth <start|stop|restart>
+
+Also, keystone-control calls keystone-auth and it need to be in the PATH
+
+ $ export PATH=<top_dir>/bin:$PATH
@@ -90,7 +133,6 @@ DEMO CLIENT:
$ cd echo/echo
$ python echo_client.py
-
INSTALLING KEYSTONE:
--------------------
@@ -98,11 +140,6 @@ INSTALLING KEYSTONE:
$ sudo python setup.py install
-RUNNING KEYSTONE (Eventlet Server):
------------------------------------
- sudo keystone (start|stop|restart)
-
-
INSTALLING TEST SERVICE:
------------------------
@@ -124,16 +161,11 @@ To clean the test database
$ sqlite3 keystone/keystone.db < test/kill.sql
-To run unit tests:
-
- $ python test/unit/test_identity.py
-
To run client demo (with all auth middleware running locally on sample service):
$ python echo/echo/echo.py
$ python echo/echo/echo_client.py
-
To perform contract validation and load testing, use SoapUI (for now).
Using SOAPUI:
@@ -152,45 +184,15 @@ Unit Test on Identity Services
In order to run the unit test on identity services start the auth sever
$ cd test/unit
- $ ../../bin/keystone-control --config-file ../..etc/keystone.conf --pid-file=pidfile auth start
-
-Once the Identity service is running, go to unit test/unit directory
-
- $ python test_identity.py
-
-You can run a sbuset of tests the following way
- $ grep class test_identity.py
-
-You get something like
-
-
-class identity_test(unittest.TestCase):
-class authorize_test(identity_test):
-class validate_token(authorize_test):
-class tenant_test(unittest.TestCase):
-class create_tenant_test(tenant_test):
-class get_tenants_test(tenant_test):
-class get_tenant_test(tenant_test):
-class update_tenant_test(tenant_test):
-class delete_tenant_test(tenant_test):
-class tenant_group_test(unittest.TestCase):
-class create_tenant_group_test(tenant_group_test):
-class get_tenant_groups_test(tenant_group_test):
-class get_tenant_group_test(tenant_group_test):
-class update_tenant_group_test(tenant_group_test):
-class delete_tenant_group_test(tenant_test):
-class global_group_test(unittest.TestCase):
-class create_global_group_test(global_group_test):
-class create_tenant_group_test(tenant_group_test):
-
-You can choose any class you like to test
+ $ ../../bin/keystone-auth
- $ python test_identity.py delete_tenant_test
+There are 8 groups of tests. They can be run individually or as an entire colection. To run the entire test suite run
-For more on unit testing please refer
+ $ python test_keystone
- $ python test_identity --help
+A test can also be run individually e.g.
+ $ python test_token
DATABASE SCHEMA
diff --git a/keystone/db/sqlalchemy/api.py b/keystone/db/sqlalchemy/api.py
index f1817a24..9fd9a734 100644
--- a/keystone/db/sqlalchemy/api.py
+++ b/keystone/db/sqlalchemy/api.py
@@ -471,6 +471,13 @@ def token_for_user(user_id, session=None):
return result
+def token_for_user_tenant(user_id, tenant_id, session=None):
+ if not session:
+ session = get_session()
+ result = session.query(models.Token).filter_by(
+ user_id=user_id, tenant_id=tenant_id).order_by("expires desc").first()
+ return result
+
def user_tenant_create(values):
user_tenant_ref = models.UserTenantAssociation()
user_tenant_ref.update(values)
diff --git a/keystone/file b/keystone/file
new file mode 100644
index 00000000..b2175cbd
--- /dev/null
+++ b/keystone/file
@@ -0,0 +1,242 @@
+************* Module server
+E: 67: No name 'template' in module 'keystone.common'
+F: 67: Unable to import 'keystone.common.template'
+C: 69: Invalid name "logger" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
+C: 74: Invalid name "service" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
+W: 78: String statement has no effect
+C: 81:is_xml_response: Missing docstring
+C: 87:get_app_root: Missing docstring
+C: 91:get_auth_token: Missing docstring
+C: 98:wrap_error: Missing docstring
+C:101:wrap_error.check_error: Missing docstring
+W:104:wrap_error.check_error: Catch "Exception"
+C:126:send_error: Missing docstring
+C:150:send_result: Missing docstring
+W:179:StaticFilesController.__init__: __init__ method from base class 'Controller' is not called
+C:183:StaticFilesController.get_pdf_contract: Missing docstring
+R:183:StaticFilesController.get_pdf_contract: Method could be a function
+C:190:StaticFilesController.get_wadl_contract: Missing docstring
+R:190:StaticFilesController.get_wadl_contract: Method could be a function
+C:197:StaticFilesController.get_xsd_contract: Missing docstring
+R:197:StaticFilesController.get_xsd_contract: Method could be a function
+C:204:StaticFilesController.get_xsd_atom_contract: Missing docstring
+R:204:StaticFilesController.get_xsd_atom_contract: Method could be a function
+W:217:VersionController.__init__: __init__ method from base class 'Controller' is not called
+C:221:VersionController.get_version_info: Missing docstring
+R:221:VersionController.get_version_info: Method could be a function
+W:249:AuthController.__init__: __init__ method from base class 'Controller' is not called
+C:254:AuthController.authenticate: Missing docstring
+C:261:AuthController.validate_token: Missing docstring
+R:261:AuthController.validate_token: Method could be a function
+C:272:AuthController.delete_token: Missing docstring
+R:272:AuthController.delete_token: Method could be a function
+W:283:TenantController.__init__: __init__ method from base class 'Controller' is not called
+C:287:TenantController.create_tenant: Missing docstring
+R:287:TenantController.create_tenant: Method could be a function
+W:308:TenantController.get_tenants: Redefining name 'tenants' from outer scope (line 63)
+C:293:TenantController.get_tenants: Missing docstring
+R:293:TenantController.get_tenants: Method could be a function
+C:312:TenantController.get_tenant: Missing docstring
+R:312:TenantController.get_tenant: Method could be a function
+C:317:TenantController.update_tenant: Missing docstring
+R:317:TenantController.update_tenant: Method could be a function
+C:323:TenantController.delete_tenant: Missing docstring
+R:323:TenantController.delete_tenant: Method could be a function
+C:328:TenantController.create_tenant_group: Missing docstring
+R:328:TenantController.create_tenant_group: Method could be a function
+C:335:TenantController.get_tenant_groups: Missing docstring
+R:335:TenantController.get_tenant_groups: Method could be a function
+C:355:TenantController.get_tenant_group: Missing docstring
+R:355:TenantController.get_tenant_group: Method could be a function
+C:361:TenantController.update_tenant_group: Missing docstring
+R:361:TenantController.update_tenant_group: Method could be a function
+C:368:TenantController.delete_tenant_group: Missing docstring
+R:368:TenantController.delete_tenant_group: Method could be a function
+W:389:TenantController.get_users_tenant_group: Redefining name 'users' from outer scope (line 66)
+C:374:TenantController.get_users_tenant_group: Missing docstring
+E:377:TenantController.get_users_tenant_group: Undefined variable 'request'
+R:374:TenantController.get_users_tenant_group: Method could be a function
+C:394:TenantController.add_user_tenant_group: Missing docstring
+R:394:TenantController.add_user_tenant_group: Method could be a function
+C:400:TenantController.delete_user_tenant_group: Missing docstring
+R:400:TenantController.delete_user_tenant_group: Method could be a function
+W:412:UserController.__init__: __init__ method from base class 'Controller' is not called
+C:416:UserController.create_user: Missing docstring
+R:416:UserController.create_user: Method could be a function
+W:435:UserController.get_tenant_users: Redefining name 'users' from outer scope (line 66)
+C:423:UserController.get_tenant_users: Missing docstring
+R:423:UserController.get_tenant_users: Method could be a function
+C:440:UserController.get_user_groups: Missing docstring
+R:440:UserController.get_user_groups: Method could be a function
+C:459:UserController.get_user: Missing docstring
+R:459:UserController.get_user: Method could be a function
+C:464:UserController.update_user: Missing docstring
+R:464:UserController.update_user: Method could be a function
+C:471:UserController.delete_user: Missing docstring
+R:471:UserController.delete_user: Method could be a function
+C:476:UserController.set_user_password: Missing docstring
+R:476:UserController.set_user_password: Method could be a function
+C:483:UserController.set_user_enabled: Missing docstring
+R:483:UserController.set_user_enabled: Method could be a function
+W:496:GroupsController.__init__: __init__ method from base class 'Controller' is not called
+C:500:GroupsController.create_group: Missing docstring
+E:501:GroupsController.create_group: Module 'keystone.logic.types.tenant' has no 'GlobalGroup' member
+R:500:GroupsController.create_group: Method could be a function
+C:507:GroupsController.get_groups: Missing docstring
+R:507:GroupsController.get_groups: Method could be a function
+C:527:GroupsController.get_group: Missing docstring
+R:527:GroupsController.get_group: Method could be a function
+C:532:GroupsController.update_group: Missing docstring
+E:533:GroupsController.update_group: Module 'keystone.logic.types.tenant' has no 'GlobalGroup' member
+R:532:GroupsController.update_group: Method could be a function
+C:539:GroupsController.delete_group: Missing docstring
+R:539:GroupsController.delete_group: Method could be a function
+W:560:GroupsController.get_users_global_group: Redefining name 'users' from outer scope (line 66)
+C:544:GroupsController.get_users_global_group: Missing docstring
+R:544:GroupsController.get_users_global_group: Method could be a function
+C:565:GroupsController.add_user_global_group: Missing docstring
+R:565:GroupsController.add_user_global_group: Method could be a function
+C:571:GroupsController.delete_user_global_group: Missing docstring
+R:571:GroupsController.delete_user_global_group: Method could be a function
+W:746:app_factory: Catch "Exception"
+W: 60: Unused import exthandler
+W: 49: Unused import HTTPBadRequest
+W: 49: Unused import HTTPConflict
+W: 43: Unused import json
+W: 48: Unused import descriptors
+W: 47: Unused import Request
+W: 49: Unused import HTTPNotFound
+W: 42: Unused import httplib
+
+
+Report
+======
+334 statements analysed.
+
+Raw metrics
+-----------
+
++----------+-------+------+---------+-----------+
+|type |number |% |previous |difference |
++==========+=======+======+=========+===========+
+|code |529 |81.38 |529 |= |
++----------+-------+------+---------+-----------+
+|docstring |63 |9.69 |63 |= |
++----------+-------+------+---------+-----------+
+|comment |23 |3.54 |23 |= |
++----------+-------+------+---------+-----------+
+|empty |35 |5.38 |35 |= |
++----------+-------+------+---------+-----------+
+
+
+
+Duplication
+-----------
+
++-------------------------+------+---------+-----------+
+| |now |previous |difference |
++=========================+======+=========+===========+
+|nb duplicated lines |0 |0 |= |
++-------------------------+------+---------+-----------+
+|percent duplicated lines |0.000 |0.000 |= |
++-------------------------+------+---------+-----------+
+
+
+
+External dependencies
+---------------------
+::
+
+ keystone
+ \-common
+ | \-wsgi (server)
+ \-logic
+ \-service (server)
+ \-types
+ \-auth (server)
+ \-fault (server)
+ \-tenant (server)
+ \-user (server)
+ routes (server)
+ webob
+ \-Request (server)
+ \-Response (server)
+ \-descriptors (server)
+ \-exc
+ \-HTTPBadRequest (server)
+ \-HTTPConflict (server)
+ \-HTTPNotFound (server)
+
+
+
+Statistics by type
+------------------
+
++---------+-------+-----------+-----------+------------+---------+
+|type |number |old number |difference |%documented |%badname |
++=========+=======+===========+===========+============+=========+
+|module |1 |1 |= |100.00 |0.00 |
++---------+-------+-----------+-----------+------------+---------+
+|class |7 |7 |= |100.00 |0.00 |
++---------+-------+-----------+-----------+------------+---------+
+|method |44 |44 |= |15.91 |0.00 |
++---------+-------+-----------+-----------+------------+---------+
+|function |9 |9 |= |22.22 |0.00 |
++---------+-------+-----------+-----------+------------+---------+
+
+
+
+Messages by category
+--------------------
+
++-----------+-------+---------+-----------+
+|type |number |previous |difference |
++===========+=======+=========+===========+
+|convention |46 |46 |= |
++-----------+-------+---------+-----------+
+|refactor |36 |36 |= |
++-----------+-------+---------+-----------+
+|warning |21 |21 |= |
++-----------+-------+---------+-----------+
+|error |4 |4 |= |
++-----------+-------+---------+-----------+
+
+
+
+Messages
+--------
+
++-----------+------------+
+|message id |occurrences |
++===========+============+
+|C0111 |44 |
++-----------+------------+
+|R0201 |36 |
++-----------+------------+
+|W0611 |8 |
++-----------+------------+
+|W0231 |6 |
++-----------+------------+
+|W0621 |4 |
++-----------+------------+
+|W0703 |2 |
++-----------+------------+
+|E1101 |2 |
++-----------+------------+
+|C0103 |2 |
++-----------+------------+
+|W0105 |1 |
++-----------+------------+
+|F0401 |1 |
++-----------+------------+
+|E0611 |1 |
++-----------+------------+
+|E0602 |1 |
++-----------+------------+
+
+
+
+Global evaluation
+-----------------
+Your code has been rated at 6.32/10 (previous run: 6.32/10)
+
diff --git a/keystone/logic/service.py b/keystone/logic/service.py
index a51e3959..44d0b173 100644
--- a/keystone/logic/service.py
+++ b/keystone/logic/service.py
@@ -51,17 +51,26 @@ class IDMService(object):
# Look for an existing token, or create one,
# TODO: Handle tenant/token search
#
- dtoken = db_api.token_for_user(duser.id)
+ if not credentials.tenant_id:
+ dtoken = db_api.token_for_user(duser.id)
+ else:
+ dtoken = db_api.token_for_user_tenant(duser.id, credentials.tenant_id)
if not dtoken or dtoken.expires < datetime.now():
dtoken = db_models.Token()
dtoken.token_id = str(uuid.uuid4())
dtoken.user_id = duser.id
+
if not duser.tenants:
raise fault.IDMFault("Strange: user %s is not associated "
"with a tenant!" % duser.id)
- dtoken.tenant_id = duser.tenants[0].tenant_id
+ if not credentials.tenant_id and db_api.user_get_by_tenant(duser.id, credentials.tenant_id):
+ raise fault.IDMFault("Error: user %s is not associated "
+ "with a tenant! %s" % (duser.id,
+ credentials.tenant_id))
+ dtoken.tenant_id = credentials.tenant_id
+ else:
+ dtoken.tenant_id = duser.tenants[0].tenant_id
dtoken.expires = datetime.now() + timedelta(days=1)
-
db_api.token_create(dtoken)
return self.__get_auth_data(dtoken, duser)
@@ -849,7 +858,13 @@ class IDMService(object):
if len(duser.tenants) == 0:
raise fault.IDMFault("Strange: user %s is not associated "
"with a tenant!" % duser.id)
- user = auth.User(duser.id, duser.tenants[0].tenant_id, groups)
+ if not dtoken.tenant_id and \
+ db_api.user_get_by_tenant(duser.id, dtoken.tenant_id):
+ raise fault.IDMFault("Error: user %s is not associated "
+ "with a tenant! %s" % (duser.id,
+ dtoken.tenant_id))
+
+ user = auth.User(duser.id, dtoken.tenant_id, groups)
return auth.AuthData(token, user)
def __validate_token(self, token_id, admin=True):
diff --git a/keystone/pylintrc b/keystone/pylintrc
new file mode 100644
index 00000000..135eea4d
--- /dev/null
+++ b/keystone/pylintrc
@@ -0,0 +1,38 @@
+# The format of this file isn't really documented; just use --generate-rcfile
+
+[Messages Control]
+# NOTE(justinsb): We might want to have a 2nd strict pylintrc in future
+# C0111: Don't require docstrings on every method
+# W0511: TODOs in code comments are fine.
+# W0142: *args and **kwargs are fine.
+# W0622: Redefining id is fine.
+disable=C0111,W0511,W0142,W0622
+
+[Basic]
+# Variable names can be 1 to 31 characters long, with lowercase and underscores
+variable-rgx=[a-z_][a-z0-9_]{0,30}$
+
+# Argument names can be 2 to 31 characters long, with lowercase and underscores
+argument-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Method names should be at least 3 characters long
+# and be lowecased with underscores
+method-rgx=([a-z_][a-z0-9_]{2,50}|setUp|tearDown)$
+
+# Module names matching nova-* are ok (files in bin/)
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|(nova-[a-z0-9_-]+))$
+
+# Don't require docstrings on tests.
+no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
+
+[Design]
+max-public-methods=100
+min-public-methods=0
+max-args=6
+
+[Variables]
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+# _ is used by our localization
+additional-builtins=_
diff --git a/pylintrc b/pylintrc
new file mode 100644
index 00000000..135eea4d
--- /dev/null
+++ b/pylintrc
@@ -0,0 +1,38 @@
+# The format of this file isn't really documented; just use --generate-rcfile
+
+[Messages Control]
+# NOTE(justinsb): We might want to have a 2nd strict pylintrc in future
+# C0111: Don't require docstrings on every method
+# W0511: TODOs in code comments are fine.
+# W0142: *args and **kwargs are fine.
+# W0622: Redefining id is fine.
+disable=C0111,W0511,W0142,W0622
+
+[Basic]
+# Variable names can be 1 to 31 characters long, with lowercase and underscores
+variable-rgx=[a-z_][a-z0-9_]{0,30}$
+
+# Argument names can be 2 to 31 characters long, with lowercase and underscores
+argument-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Method names should be at least 3 characters long
+# and be lowecased with underscores
+method-rgx=([a-z_][a-z0-9_]{2,50}|setUp|tearDown)$
+
+# Module names matching nova-* are ok (files in bin/)
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|(nova-[a-z0-9_-]+))$
+
+# Don't require docstrings on tests.
+no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
+
+[Design]
+max-public-methods=100
+min-public-methods=0
+max-args=6
+
+[Variables]
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+# _ is used by our localization
+additional-builtins=_
diff --git a/test/unit/test_authentication.py b/test/unit/test_authentication.py
index c703192b..9d193186 100644
--- a/test/unit/test_authentication.py
+++ b/test/unit/test_authentication.py
@@ -8,16 +8,18 @@ from webtest import TestApp
import httplib2
import json
from lxml import etree
-import unittest
-from webtest import TestApp
-from test_common import *
+
+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, get_token_xml
class authentication_test(unittest.TestCase):
def setUp(self):
- self.token = get_token('joeuser', 'secrete', 'token')
self.tenant = get_tenant()
+ self.token = get_token('joeuser', 'secrete', 'token')
self.user = get_user()
self.userdisabled = get_userdisabled()
self.auth_token = get_auth_token()
@@ -28,21 +30,21 @@ class authentication_test(unittest.TestCase):
delete_token(self.token, self.auth_token)
def test_a_authorize(self):
- resp, content = get_token('joeuser', 'secrete')
+ resp, content = get_token('joeuser', 'secrete', '')
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/json', content_type(resp))
def test_a_authorize_xml(self):
- resp, content = get_token_xml('joeuser', 'secrete')
+ resp, content = get_token_xml('joeuser', 'secrete', '', self.tenant)
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/xml', content_type(resp))
def test_a_authorize_user_disabled(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken' % URL
body = {"passwordCredentials": {"username": "disabled",
"password": "secrete"}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json"})
content = json.loads(content)
if int(resp['status']) == 500:
@@ -53,14 +55,14 @@ class authentication_test(unittest.TestCase):
self.assertEqual('application/json', content_type(resp))
def test_a_authorize_user_disabled_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken' % URL
body = '<?xml version="1.0" encoding="UTF-8"?> \
<passwordCredentials \
xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="secrete" username="disabled" \
/>'
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
content = etree.fromstring(content)
@@ -72,11 +74,11 @@ class authentication_test(unittest.TestCase):
self.assertEqual('application/xml', content_type(resp))
def test_a_authorize_user_wrong(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken' % URL
body = {"passwordCredentials": {"username-w": "disabled",
"password": "secrete"}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json"})
content = json.loads(content)
if int(resp['status']) == 500:
@@ -87,14 +89,14 @@ class authentication_test(unittest.TestCase):
self.assertEqual('application/json', content_type(resp))
def test_a_authorize_user_wrong_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken' % URL
body = '<?xml version="1.0" encoding="UTF-8"?> \
<passwordCredentials \
xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="secrete" username-w="disabled" \
/>'
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
content = etree.fromstring(content)
@@ -105,5 +107,8 @@ class authentication_test(unittest.TestCase):
self.assertEqual(400, int(resp['status']))
self.assertEqual('application/xml', content_type(resp))
+def run():
+ unittest.main()
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/unit/test_common.py b/test/unit/test_common.py
index e023fb3e..f56a76a7 100644
--- a/test/unit/test_common.py
+++ b/test/unit/test_common.py
@@ -8,100 +8,104 @@ from webtest import TestApp
import httplib2
import json
from lxml import etree
-import unittest
-from webtest import TestApp
+
URL = 'http://localhost:8080/v1.0/'
-def get_token(user, pswd, kind=''):
- h = httplib2.Http(".cache")
- url = '%stoken' % URL
+def get_token(user, pswd, kind='', tenant_id=None):
+ header = httplib2.Http(".cache")
+ url = '%stoken' % URL
+ if not tenant_id:
body = {"passwordCredentials": {"username": user,
"password": pswd}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
- headers={"Content-Type": "application/json"})
- content = json.loads(content)
-
- token = str(content['auth']['token']['id'])
- if kind == 'token':
- return token
- else:
- return (resp, content)
+ else:
+ body = {"passwordCredentials": {"username": user,
+ "password": pswd,
+ "tenantId": tenant_id}}
+
+ resp, content = header.request(url, "POST", body=json.dumps(body),
+ headers={"Content-Type": "application/json"})
+ content = json.loads(content)
+ token = str(content['auth']['token']['id'])
+ if kind == 'token':
+ return token
+ else:
+ return (resp, content)
def delete_token(token, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken/%s' % (URL, token)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def create_tenant(tenantid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants' % (URL)
body = {"tenant": {"id": tenantid,
"description": "A description ...",
"enabled": True}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def create_tenant_group(groupid, tenantid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenant/%s/groups' % (URL, tenantid)
body = {"group": {"id": groupid,
"description": "A description ..."}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def delete_tenant(tenantid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s' % (URL, tenantid)
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def delete_tenant_group(groupid, tenantid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenant/%s/groups/%s' % (URL, tenantid, groupid)
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def create_global_group(groupid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups' % (URL)
body = {"group": {"id": groupid,
"description": "A description ..."}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def create_global_group_xml(groupid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups' % (URL)
body = '<?xml version="1.0" encoding="UTF-8"?>\
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="%s"><description>A Description of the group</description>\
</group>' % groupid
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -109,33 +113,39 @@ def create_global_group_xml(groupid, auth_token):
def delete_global_group(groupid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups/%s' % (URL, groupid)
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def delete_global_group_xml(groupid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups/%s' % (URL, groupid)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
return (resp, content)
-def get_token_xml(user, pswd, type=''):
- h = httplib2.Http(".cache")
+def get_token_xml(user, pswd, type='', tenant_id=None):
+ header = httplib2.Http(".cache")
url = '%stoken' % URL
- body = '<?xml version="1.0" encoding="UTF-8"?> \
- <passwordCredentials \
- xmlns="http://docs.openstack.org/idm/api/v1.0" \
- password="%s" username="%s" \
- tenantId="77654"/> ' % (pswd, user)
- resp, content = h.request(url, "POST", body=body,
+ if tenant_id:
+ body = '<?xml version="1.0" encoding="UTF-8"?> \
+ <passwordCredentials \
+ xmlns="http://docs.openstack.org/idm/api/v1.0" \
+ password="%s" username="%s" \
+ tenantId="%s"/> ' % (pswd, user, tenant_id)
+ else:
+ body = '<?xml version="1.0" encoding="UTF-8"?> \
+ <passwordCredentials \
+ xmlns="http://docs.openstack.org/idm/api/v1.0" \
+ password="%s" username="%s" /> ' % (pswd, user)
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
dom = etree.fromstring(content)
@@ -149,9 +159,9 @@ def get_token_xml(user, pswd, type=''):
def delete_token_xml(token, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken/%s' % (URL, token)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -159,14 +169,14 @@ def delete_token_xml(token, auth_token):
def create_tenant_xml(tenantid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants' % (URL)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" id="%s"> \
<description>A description...</description> \
</tenant>' % tenantid
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -174,14 +184,14 @@ def create_tenant_xml(tenantid, auth_token):
def create_tenant_group_xml(groupid, tenantid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenant/%s/groups' % (URL, tenantid)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="%s"> \
<description>A description...</description> \
</group>' % groupid
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -189,9 +199,9 @@ def create_tenant_group_xml(groupid, tenantid, auth_token):
def delete_tenant_xml(tenantid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s' % (URL, tenantid)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -199,9 +209,9 @@ def delete_tenant_xml(tenantid, auth_token):
def delete_tenant_group_xml(groupid, tenantid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenant/%s/groups/%s' % (URL, tenantid, groupid)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -209,24 +219,24 @@ def delete_tenant_group_xml(groupid, tenantid, auth_token):
def create_user(tenantid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, tenantid)
body = {"user": {"password": "secrete",
"id": userid,
"tenantId": tenantid,
"email": "%s@rackspace.com" % userid,
"enabled": True}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def delete_user(tenant, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, tenant, userid)
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
@@ -234,14 +244,14 @@ def delete_user(tenant, userid, auth_token):
def create_user_xml(tenantid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, tenantid)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="joetest@rackspace.com" \
tenantId="%s" id="%s" \
enabled="true" password="secrete"/>' % (tenantid, userid)
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -249,9 +259,9 @@ def create_user_xml(tenantid, userid, auth_token):
def delete_user_xml(tenantid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, tenantid, userid)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -259,20 +269,20 @@ def delete_user_xml(tenantid, userid, auth_token):
def add_user_tenant_group(tenantid, groupid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/groups/%s/users/%s' % (URL, tenantid, groupid, userid)
- resp, content = h.request(url, "PUT", body='',
+ resp, content = header.request(url, "PUT", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def add_user_tenant_group_xml(tenantid, groupid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/groups/%s/users/%s' % (URL, tenantid, groupid, userid)
- resp, content = h.request(url, "PUT", body='',
+ resp, content = header.request(url, "PUT", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -280,20 +290,20 @@ def add_user_tenant_group_xml(tenantid, groupid, userid, auth_token):
def delete_user_tenant_group(tenantid, groupid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/groups/%s/users/%s' % (URL, tenantid, groupid, userid)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def delete_user_tenant_group_xml(tenantid, groupid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/groups/%s/users/%s' % (URL, tenantid, groupid, userid)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -301,20 +311,20 @@ def delete_user_tenant_group_xml(tenantid, groupid, userid, auth_token):
def get_user_tenant_group(tenantid, groupid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/groups/%s/users' % (URL, tenantid, groupid)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def get_user_tenant_group_xml(tenantid, groupid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/groups/%s/users' % (URL, tenantid, groupid)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -322,20 +332,20 @@ def get_user_tenant_group_xml(tenantid, groupid, auth_token):
def add_user_global_group(groupid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups/%s/users/%s' % (URL, groupid, userid)
- resp, content = h.request(url, "PUT", body='',
+ resp, content = header.request(url, "PUT", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def add_user_global_group_xml(groupid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups/%s/users/%s' % (URL, groupid, userid)
- resp, content = h.request(url, "PUT", body='',
+ resp, content = header.request(url, "PUT", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -343,20 +353,20 @@ def add_user_global_group_xml(groupid, userid, auth_token):
def delete_user_global_group(groupid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups/%s/users/%s' % (URL, groupid, userid)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
return (resp, content)
def delete_user_global_group_xml(groupid, userid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups/%s/users/%s' % (URL, groupid, userid)
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
@@ -364,10 +374,10 @@ def delete_user_global_group_xml(groupid, userid, auth_token):
def get_user_global_group(groupid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups/%s/users' % (URL, groupid)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": auth_token})
@@ -387,10 +397,10 @@ def get_email():
def get_user_global_group_xml(groupid, auth_token):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%sgroups/%s/users' % (URL, groupid)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": auth_token,
"ACCEPT": "application/xml"})
diff --git a/test/unit/test_groups.py b/test/unit/test_groups.py
index 8f6ce46a..c1f0e4b3 100644
--- a/test/unit/test_groups.py
+++ b/test/unit/test_groups.py
@@ -8,8 +8,7 @@ from webtest import TestApp
import httplib2
import json
from lxml import etree
-import unittest
-from webtest import TestApp
+
from test_common import *
##
@@ -992,5 +991,9 @@ class delete_users_global_group_test(unittest.TestCase):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(404, int(respG['status']))
+
+def run():
+ unittest.main()
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/unit/test_keystone.py b/test/unit/test_keystone.py
index 400f6cc5..0301bf82 100644
--- a/test/unit/test_keystone.py
+++ b/test/unit/test_keystone.py
@@ -1,9 +1,8 @@
-#TODO (India Team) Need to modify this script
import logging
import os
import unittest
-
-MODULE_EXTENSIONS = set('.py .pyc .pyo'.split())
+from lxml import etree
+MODULE_EXTENSIONS = set('.py'.split())
def unit_test_extractor(tup, path, filenames):
@@ -52,4 +51,4 @@ if __name__ == '__main__':
package_path = os.path.dirname(os.path.abspath(__file__))
suites = get_test_suites(package_path)
for suite in suites:
- unittest.TextTestRunner(verbosity=2).run(suite)
+ unittest.TextTestRunner(verbosity=1).run(suite)
diff --git a/test/unit/test_tenant_groups.py b/test/unit/test_tenant_groups.py
index 3a0b9369..5768e631 100644
--- a/test/unit/test_tenant_groups.py
+++ b/test/unit/test_tenant_groups.py
@@ -4,13 +4,21 @@ import sys
sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__),
'..', '..', '..', '..', 'keystone')))
import unittest
-from webtest import TestApp
import httplib2
import json
+
from lxml import etree
-import unittest
-from webtest import TestApp
-from test_common import *
+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
class tenant_group_test(unittest.TestCase):
@@ -37,28 +45,29 @@ class create_tenant_group_test(tenant_group_test):
def test_tenant_group_create(self):
resp, content = 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))
- respG, contentG = delete_tenant_group(self.tenant_group,
+ resp, content = delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
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')
- if int(respG['status']) not in (200, 201):
- self.fail('Failed due to %d' % int(respG['status']))
+
+ if int(resp['status']) not in (200, 201):
+ 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))
- respG, contentG = delete_tenant_group_xml(self.tenant_group,
+ resp, content = delete_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group_xml(self.tenant_group,
+ resp, content = create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
self.tenant = self.tenant
@@ -68,65 +77,56 @@ class create_tenant_group_test(tenant_group_test):
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- if int(respG['status']) not in (200, 201):
- self.fail('Failed due to %d' % int(respG['status']))
+ if int(resp['status']) not in (200, 201):
+ 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))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- if int(respG['status']) == 200:
+ if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
- self.tenant_group = contentG['group']['id']
- if int(respG['status']) == 500:
+ self.tenant_group = content['group']['id']
+ if int(resp['status']) == 500:
self.fail('IDM fault')
- elif int(respG['status']) == 503:
+ elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(409, int(respG['status']))
- if int(respG['status']) == 200:
- self.tenant = content['tenant']['id']
- self.tenant_group = contentG['group']['id']
-
+ 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))
- respG, contentG = create_tenant_group_xml(self.tenant_group,
+ resp, content = create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group_xml(self.tenant_group,
+ resp_new, content_new = create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
- content = etree.fromstring(content)
- contentG = etree.fromstring(contentG)
- if int(respG['status']) == 200:
- self.tenant = content.get("id")
- self.tenant_group = contentG.get("id")
- if int(respG['status']) == 500:
+ if int(resp['status']) == 500:
self.fail('IDM fault')
- elif int(respG['status']) == 503:
+ elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(409, int(respG['status']))
- if int(respG['status']) == 200:
- self.tenant = content.get("id")
- self.tenant_group = contentG.get("id")
+ self.assertEqual(409, int(resp['status']))
+
def test_tenant_group_create_unauthorized_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group_xml(self.tenant_group,
+ if int(resp['status']) == 200:
+ self.tenant = content['tenant']['id']
+ resp, content = create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
+
if int(resp['status']) == 200:
- self.tenant = content['tenant']['id']
- if int(respG['status']) == 200:
- self.tenant_group = respG['group']['id']
+ self.tenant_group = resp['group']['id']
url = '%stenant/%s/groups' % (URL, self.tenant)
body = {"group": {"id": self.tenant_group,
"description": "A description ..."}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json",
"X-Auth-Token": self.token})
if int(resp['status']) == 500:
@@ -136,7 +136,7 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(401, int(resp['status']))
def test_tenant_group_create_unauthorized_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
@@ -145,7 +145,7 @@ class create_tenant_group_test(tenant_group_test):
<group xmlns="http://docs.openstack.org/idm/api/v1.0" \
id="%s"><description>A description...</description> \
</group>' % self.tenant_group
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.token,
"ACCEPT": "application/xml"})
@@ -156,14 +156,14 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(401, int(resp['status']))
def test_tenant_group_create_expired_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = 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)
body = {"group": {"id": self.tenant_group,
"description": "A description ..."}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
if int(resp['status']) == 500:
@@ -173,7 +173,7 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(403, int(resp['status']))
def test_tenant_group_create_expired_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
@@ -184,7 +184,7 @@ class create_tenant_group_test(tenant_group_test):
id="%s"> \
<description>A description...</description> \
</group>' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -195,14 +195,14 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(403, int(resp['status']))
def test_tenant_group_create_missing_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = 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)
body = {"group": {"id": self.tenant_group,
"description": "A description ..."}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json"})
if int(resp['status']) == 500:
self.fail('IDM fault')
@@ -211,7 +211,7 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(401, int(resp['status']))
def test_tenant_group_create_missing_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
@@ -222,7 +222,7 @@ class create_tenant_group_test(tenant_group_test):
id="%s"> \
<description>A description...</description> \
</group>' % self.tenant_group
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
if int(resp['status']) == 500:
@@ -232,7 +232,7 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(401, int(resp['status']))
def test_tenant_group_create_disabled_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
@@ -240,7 +240,7 @@ class create_tenant_group_test(tenant_group_test):
url = '%stenant/%s/groups' % (URL, self.tenant)
body = '{"group": { "id": "%s", \
"description": "A description ..." } }' % self.tenant_group
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.disabled_token})
@@ -251,7 +251,7 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(403, int(resp['status']))
def test_tenant_group_create_disabled_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
@@ -263,7 +263,7 @@ class create_tenant_group_test(tenant_group_test):
id="%s"> \
<description>A description...</description> \
</group>' % self.tenant_group
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.disabled_token,
"ACCEPT": "application/xml"})
@@ -274,7 +274,7 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(403, int(resp['status']))
def test_tenant_group_create_invalid_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
@@ -282,7 +282,7 @@ class create_tenant_group_test(tenant_group_test):
url = '%stenant/%s/groups' % (URL, self.tenant)
body = '{"group": { "id": "%s", \
"description": "A description ..." } }' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/json",
"X-Auth-Token": 'nonexsitingtoken'})
@@ -293,7 +293,7 @@ class create_tenant_group_test(tenant_group_test):
self.assertEqual(404, int(resp['status']))
def test_tenant_group_create_invalid_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
@@ -305,7 +305,7 @@ class create_tenant_group_test(tenant_group_test):
id="%s"> \
<description>A description...</description> \
</group>' % self.tenant_group
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": 'nonexsitingtoken',
"ACCEPT": "application/xml"})
@@ -320,16 +320,16 @@ class create_tenant_group_test(tenant_group_test):
class get_tenant_groups_test(tenant_group_test):
def test_get_tenant_groups(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -339,14 +339,14 @@ class get_tenant_groups_test(tenant_group_test):
self.assertEqual(200, int(resp['status']))
def test_get_tenant_groups_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group_xml(self.tenant_group,
+ resp, content = create_tenant_group_xml(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -357,15 +357,15 @@ class get_tenant_groups_test(tenant_group_test):
self.assertEqual(200, int(resp['status']))
def test_get_tenant_groups_unauthorized_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups' % (URL, self.tenant)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.token})
if int(resp['status']) == 500:
@@ -375,14 +375,14 @@ class get_tenant_groups_test(tenant_group_test):
self.assertEqual(401, int(resp['status']))
def test_get_tenant_groups_unauthorized_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups' % (URL, self.tenant)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.token,
"ACCEPT": "application/xml"})
@@ -393,14 +393,14 @@ class get_tenant_groups_test(tenant_group_test):
self.assertEqual(401, int(resp['status']))
def test_get_tenant_groups_exp_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups' % (URL, self.tenant)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
if int(resp['status']) == 500:
@@ -410,14 +410,14 @@ class get_tenant_groups_test(tenant_group_test):
self.assertEqual(403, int(resp['status']))
def test_get_tenant_groups_exp_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups' % (URL, self.tenant)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -431,14 +431,14 @@ class get_tenant_groups_test(tenant_group_test):
class get_tenant_group_test(tenant_group_test):
def test_get_tenant_group(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -448,14 +448,14 @@ class get_tenant_group_test(tenant_group_test):
self.assertEqual(200, int(resp['status']))
def test_get_tenant_group_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
#test for Content-Type = application/xml
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -466,15 +466,15 @@ class get_tenant_group_test(tenant_group_test):
self.assertEqual(200, int(resp['status']))
def test_get_tenant_group_bad(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, 'tenant_bad', self.tenant_group)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{',
+ resp, content = header.request(url, "GET", body='{',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -484,14 +484,14 @@ class get_tenant_group_test(tenant_group_test):
self.assertEqual(404, int(resp['status']))
def test_get_tenant_group_bad_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, 'tenant_bad', self.tenant_group)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{',
+ resp, content = header.request(url, "GET", body='{',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -502,14 +502,14 @@ class get_tenant_group_test(tenant_group_test):
self.assertEqual(404, int(resp['status']))
def test_get_tenant_group_not_found(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, self.tenant, 'nonexistinggroup')
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -519,15 +519,15 @@ class get_tenant_group_test(tenant_group_test):
self.assertEqual(404, int(resp['status']))
def test_get_tenant_group_not_found_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, self.tenant, 'nonexistinggroup')
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -541,12 +541,12 @@ class get_tenant_group_test(tenant_group_test):
class update_tenant_group_test(tenant_group_test):
def test_update_tenant_group(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
resp, content = delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
@@ -555,7 +555,7 @@ class update_tenant_group_test(tenant_group_test):
"tenantId":"%s" }}' % (self.tenant_group, self.tenant)
#test for Content-Type = application/json
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
@@ -570,7 +570,7 @@ class update_tenant_group_test(tenant_group_test):
self.assertEqual('A NEW description...', body['group']['description'])
def test_update_tenant_group_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = delete_tenant(self.tenant, str(self.auth_token))
resp, content = create_tenant(self.tenant, str(self.auth_token))
@@ -579,7 +579,7 @@ class update_tenant_group_test(tenant_group_test):
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
@@ -591,7 +591,7 @@ class update_tenant_group_test(tenant_group_test):
</group>' % (self.tenant, self.tenant_group)
#test for Content-Type = application/json
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -610,12 +610,12 @@ class update_tenant_group_test(tenant_group_test):
self.assertEqual('A NEW description...', desc.text)
def test_update_tenant_group_bad(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
resp, content = delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
@@ -623,7 +623,7 @@ class update_tenant_group_test(tenant_group_test):
"id":"%s","tenantId":"%s" }}' % (self.tenant_group, self.tenant)
#test for Content-Type = application/json
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -633,12 +633,12 @@ class update_tenant_group_test(tenant_group_test):
self.assertEqual(400, int(resp['status']))
def test_update_tenant_group_bad_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
resp, content = delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/%s' % (URL, self.tenant, self.tenant_group)
@@ -648,7 +648,7 @@ class update_tenant_group_test(tenant_group_test):
<description_bad>A NEW description...</description> \
</group>' % (self.tenant, self.tenant_group)
#test for Content-Type = application/json
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -659,12 +659,12 @@ class update_tenant_group_test(tenant_group_test):
self.assertEqual(400, int(resp['status']))
def test_update_tenant_group_not_found(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
resp, content = delete_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
url = '%stenant/%s/groups/NonexistingID' % (URL, self.tenant)
@@ -672,7 +672,7 @@ class update_tenant_group_test(tenant_group_test):
data = '{"group": { "description": "A NEW description...",\
"id":"NonexistingID", "tenantId"="test_tenant" }}'
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body=data,
+ resp, content = header.request(url, "GET", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -682,7 +682,7 @@ class update_tenant_group_test(tenant_group_test):
self.assertEqual(404, int(resp['status']))
def test_update_tenant_group_not_found_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenant/%s/groups/NonexistingID' % (URL, self.tenant)
data = '<?xml version="1.0" encoding="UTF-8"?> \
@@ -691,7 +691,7 @@ class update_tenant_group_test(tenant_group_test):
<description_bad>A NEW description...</description> \
</group>'
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body=data,
+ resp, content = header.request(url, "GET", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -721,28 +721,28 @@ class delete_tenant_group_test(tenant_group_test):
def test_delete_tenant_group(self):
resp, content = create_tenant("test_tenant_delete",
str(self.auth_token))
- respG, contentG = create_tenant_group('test_tenant_group_delete',
+ resp, content = create_tenant_group('test_tenant_group_delete',
"test_tenant_delete",
str(self.auth_token))
- respG, contentG = delete_tenant_group('test_tenant_group_delete',
+ resp, content = delete_tenant_group('test_tenant_group_delete',
"test_tenant_delete",
str(self.auth_token))
resp, content = delete_tenant("test_tenant_delete",
str(self.auth_token))
- self.assertEqual(204, int(respG['status']))
+ self.assertEqual(204, int(resp['status']))
def test_delete_tenant_group_xml(self):
resp, content = create_tenant("test_tenant_delete",
str(self.auth_token))
- respG, contentG = create_tenant_group('test_tenant_group_delete',
+ resp, content = create_tenant_group('test_tenant_group_delete',
"test_tenant_delete",
str(self.auth_token))
- respG, contentG = delete_tenant_group('test_tenant_group_delete',
+ resp, content = delete_tenant_group('test_tenant_group_delete',
"test_tenant_delete",
str(self.auth_token))
resp, content = delete_tenant_xml("test_tenant_delete",
str(self.auth_token))
- self.assertEqual(204, int(respG['status']))
+ self.assertEqual(204, int(resp['status']))
class add_user_tenant_group_test(tenant_group_test):
@@ -758,12 +758,12 @@ class add_user_tenant_group_test(tenant_group_test):
self.tenant_group = 'test_tenant_group_add'
def tearDown(self):
- respG, contentG = delete_user_tenant_group(self.tenant,
+ resp, content = delete_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- respG, contentG = delete_user(self.tenant, self.user,
+ resp, content = delete_user(self.tenant, self.user,
str(self.auth_token))
resp, content = delete_tenant_group(self.tenant_group,
self.tenant,
@@ -771,34 +771,32 @@ class add_user_tenant_group_test(tenant_group_test):
resp, content = delete_tenant(self.tenant, self.auth_token)
def test_add_user_tenant_group(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = 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:
self.fail('Service Not Available')
- if int(respG['status']) not in (200, 201):
- self.fail('Failed due to %d' % int(respG['status']))
+ if int(resp['status']) not in (200, 201):
+ self.fail('Failed due to %d' % int(resp['status']))
def test_add_user_tenant_group_xml(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group_xml(self.tenant,
+ resp, content = add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
@@ -807,39 +805,37 @@ class add_user_tenant_group_test(tenant_group_test):
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- if int(respG['status']) not in (200, 201):
- self.fail('Failed due to %d' % int(respG['status']))
+ if int(resp['status']) not in (200, 201):
+ self.fail('Failed due to %d' % int(resp['status']))
def test_add_user_tenant_group_conflict(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = 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:
self.fail('Service Not Available')
- self.assertEqual(409, int(respG['status']))
+ self.assertEqual(409, int(resp['status']))
def test_add_user_tenant_group_conflict_xml(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group_xml(self.tenant,
+ resp, content = add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user, str(self.auth_token))
- respG, contentG = add_user_tenant_group_xml(self.tenant,
+ resp, content = add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
@@ -848,36 +844,34 @@ class add_user_tenant_group_test(tenant_group_test):
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(409, int(respG['status']))
+ self.assertEqual(409, int(resp['status']))
def test_add_user_tenant_group_unauthorized(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, self.token)
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(401, int(respG['status']))
+ self.assertEqual(401, int(resp['status']))
def test_add_user_tenant_group_unauthorized_xml(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group_xml(self.tenant,
+ resp, content = add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user, self.token)
@@ -885,36 +879,34 @@ class add_user_tenant_group_test(tenant_group_test):
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(401, int(respG['status']))
+ self.assertEqual(401, int(resp['status']))
def test_add_user_tenant_group_forbidden(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, self.disabled_token)
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(403, int(respG['status']))
+ self.assertEqual(403, int(resp['status']))
def test_add_user_tenant_group_forbidden_xml(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group_xml(self.tenant,
+ resp, content = add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
self.disabled_token)
@@ -923,7 +915,7 @@ class add_user_tenant_group_test(tenant_group_test):
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(403, int(respG['status']))
+ self.assertEqual(403, int(resp['status']))
class get_users_tenant_group_test(tenant_group_test):
@@ -939,12 +931,12 @@ class get_users_tenant_group_test(tenant_group_test):
self.tenant_group = 'test_tenant_group_add'
def tearDown(self):
- respG, contentG = delete_user_tenant_group(self.tenant,
+ resp, content = delete_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- respG, contentG = delete_user(self.tenant, self.user,
+ resp, content = delete_user(self.tenant, self.user,
str(self.auth_token))
resp, content = delete_tenant_group(self.tenant_group,
self.tenant,
@@ -952,247 +944,240 @@ class get_users_tenant_group_test(tenant_group_test):
resp, content = delete_tenant(self.tenant, self.auth_token)
def test_get_users_tenant_group(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ 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,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, str(self.auth_token))
- respG, contentG = get_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = 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))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(200, int(respG['status']))
-
- def test_get_users_tenant_group_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group_xml(self.tenant,
+ resp, content = add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- respG, contentG = get_user_tenant_group_xml(self.tenant,
+ resp, content = 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))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(200, int(respG['status']))
-
- def test_get_users_tenant_group_unauthorized(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant,
+ resp, content = add_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
self.auth_token)
- respG, contentG = get_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = 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))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(401, int(respG['status']))
-
- def test_get_users_tenant_group_unauthorized_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ self.assertEqual(401, int(resp['status']))
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, self.auth_token)
- respG, contentG = get_user_tenant_group_xml(self.tenant,
+ resp, content = get_user_tenant_group_xml(self.tenant,
self.tenant_group,
str(self.token))
+
+
+ def test_get_users_tenant_group_forbidden(self):
+ resp, content = 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(respG['status']))
-
- def test_get_users_tenant_group_forbidden(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, self.auth_token)
- respG, contentG = get_user_tenant_group(self.tenant,
+ resp, content = get_user_tenant_group(self.tenant,
self.tenant_group,
str(self.disabled_token))
+
+ 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))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(403, int(respG['status']))
-
- def test_get_users_tenant_group_forbidden_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, self.auth_token)
- respG, contentG = get_user_tenant_group_xml(self.tenant,
+ resp, content = 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))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(403, int(respG['status']))
-
- def test_get_users_tenant_group_expired(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, self.auth_token)
- respG, contentG = get_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = 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))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(403, int(respG['status']))
-
- def test_get_users_tenant_group_expired_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant, self.tenant_group,
+ resp, content = add_user_tenant_group(self.tenant, self.tenant_group,
self.user, self.auth_token)
- respG, contentG = get_user_tenant_group_xml(self.tenant,
+ resp, content = get_user_tenant_group_xml(self.tenant,
self.tenant_group,
str(self.exp_auth_token))
- if int(resp['status']) == 500:
- self.fail('IDM fault')
- elif int(resp['status']) == 503:
- self.fail('Service Not Available')
- self.assertEqual(403, int(respG['status']))
+
+ self.assertEqual(403, int(resp['status']))
class delete_users_tenant_group_test(tenant_group_test):
def test_delete_user_tenant_group(self):
- h = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ 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,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group(self.tenant,
+ resp, content = add_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- respG, contentG = delete_user_tenant_group(self.tenant,
+ resp, content = delete_user_tenant_group(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
+
+ self.assertEqual(204, int(resp['status']))
+
+ def test_delete_user_tenant_group_xml(self):
+ resp, content = 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(204, int(respG['status']))
-
- def test_delete_user_tenant_group_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant(self.tenant, str(self.auth_token))
- respG, contentG = create_tenant_group(self.tenant_group,
+ resp, content = create_tenant_group(self.tenant_group,
self.tenant,
str(self.auth_token))
- respG, contentG = create_user(self.tenant, self.user,
+ resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
- respG, contentG = add_user_tenant_group_xml(self.tenant,
+ resp, content = add_user_tenant_group_xml(self.tenant,
self.tenant_group,
self.user,
str(self.auth_token))
- respG, contentG = delete_user_tenant_group_xml(self.tenant,
+ resp, content = delete_user_tenant_group_xml(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:
- self.fail('Service Not Available')
- self.assertEqual(204, int(respG['status']))
+
+ self.assertEqual(204, int(resp['status']))
def test_delete_user_tenant_group_notfound(self):
- h = httplib2.Http(".cache")
-
- respG, contentG = delete_user_tenant_group(self.tenant,
+ resp, content = delete_user_tenant_group(self.tenant,
self.tenant_group,
'NonExistinguser',
str(self.auth_token))
-
- if int(respG['status']) == 500:
+ if int(resp['status']) == 500:
self.fail('IDM fault')
- elif int(respG['status']) == 503:
+ elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(404, int(respG['status']))
+ self.assertEqual(404, int(resp['status']))
def test_delete_user_tenant_group_notfound_xml(self):
- h = httplib2.Http(".cache")
-
- respG, contentG = delete_user_tenant_group_xml(self.tenant,
+ resp, content = delete_user_tenant_group_xml(self.tenant,
self.tenant_group,
'NonExistinguser',
str(self.auth_token))
-
- if int(respG['status']) == 500:
+ if int(resp['status']) == 500:
self.fail('IDM fault')
- elif int(respG['status']) == 503:
+ elif int(resp['status']) == 503:
self.fail('Service Not Available')
- self.assertEqual(404, int(respG['status']))
+ self.assertEqual(404, int(resp['status']))
+def run():
+ unittest.main()
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/unit/test_tenants.py b/test/unit/test_tenants.py
index c2b41e25..c322409b 100644
--- a/test/unit/test_tenants.py
+++ b/test/unit/test_tenants.py
@@ -4,20 +4,24 @@ import sys
sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__),
'..', '..', '..', '..', 'keystone')))
import unittest
-from webtest import TestApp
import httplib2
import json
from lxml import etree
-import unittest
-from webtest import TestApp
-from test_common import *
+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
+
+
+
+
class tenant_test(unittest.TestCase):
def setUp(self):
self.token = get_token('joeuser', 'secrete', 'token')
- self.tenant = get_tenant()
+ self.tenant = 'test_tenant'
self.user = get_user()
self.userdisabled = get_userdisabled()
self.auth_token = get_auth_token()
@@ -31,10 +35,8 @@ class tenant_test(unittest.TestCase):
class create_tenant_test(tenant_test):
def test_tenant_create(self):
- resp, content = delete_tenant('test_tenant', str(self.auth_token))
- resp, content = create_tenant('test_tenant', str(self.auth_token))
- self.tenant = 'test_tenant'
-
+ resp, content = delete_tenant(self.tenant, str(self.auth_token))
+ resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
@@ -45,52 +47,43 @@ 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('test_tenant', str(self.auth_token))
- resp, content = create_tenant_xml('test_tenant', str(self.auth_token))
- self.tenant = 'test_tenant'
+ resp, content = delete_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
-
if int(resp['status']) not in (200, 201):
-
self.fail('Failed due to %d' % int(resp['status']))
def test_tenant_create_again(self):
- resp, content = create_tenant("test_tenant", str(self.auth_token))
- resp, content = create_tenant("test_tenant", str(self.auth_token))
+ resp, content = 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))
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(409, int(resp['status']))
- if int(resp['status']) == 200:
- self.tenant = content['tenant']['id']
-
+
def test_tenant_create_again_xml(self):
- resp, content = create_tenant_xml("test_tenant", str(self.auth_token))
- resp, content = create_tenant_xml("test_tenant", str(self.auth_token))
+ resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
+ resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
- if int(resp['status']) == 200:
- self.tenant = content.get("id")
-
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(409, int(resp['status']))
- if int(resp['status']) == 200:
- self.tenant = content.get("id")
+
def test_tenant_create_forbidden_token(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
@@ -98,7 +91,7 @@ class create_tenant_test(tenant_test):
body = {"tenant": {"id": self.tenant,
"description": "A description ...",
"enabled": True}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json",
"X-Auth-Token": self.token})
@@ -109,8 +102,8 @@ class create_tenant_test(tenant_test):
self.assertEqual(401, int(resp['status']))
def test_tenant_create_forbidden_token_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant_xml("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
@@ -121,7 +114,7 @@ class create_tenant_test(tenant_test):
enabled="true" id="%s"> \
<description>A description...</description> \
</tenant>' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.token,
"ACCEPT": "application/xml"})
@@ -133,19 +126,17 @@ class create_tenant_test(tenant_test):
self.assertEqual(401, int(resp['status']))
def test_tenant_create_expired_token(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
-
url = '%stenants' % (URL)
body = {"tenant": {"id": self.tenant,
"description": "A description ...",
"enabled": True}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
-
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
@@ -153,8 +144,8 @@ class create_tenant_test(tenant_test):
self.assertEqual(403, int(resp['status']))
def test_tenant_create_expired_token_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant_xml("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
@@ -166,7 +157,7 @@ class create_tenant_test(tenant_test):
<description>A description...</description> \
</tenant>' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -178,8 +169,8 @@ class create_tenant_test(tenant_test):
self.assertEqual(403, int(resp['status']))
def test_tenant_create_missing_token(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
@@ -187,7 +178,7 @@ class create_tenant_test(tenant_test):
body = {"tenant": {"id": self.tenant,
"description": "A description ...",
"enabled": True}}
- resp, content = h.request(url, "POST", body=json.dumps(body),
+ resp, content = header.request(url, "POST", body=json.dumps(body),
headers={"Content-Type": "application/json"})
if int(resp['status']) == 500:
@@ -197,23 +188,20 @@ class create_tenant_test(tenant_test):
self.assertEqual(401, int(resp['status']))
def test_tenant_create_missing_token_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant_xml("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = 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)
-
body = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" id="%s"> \
<description>A description...</description> \
</tenant>' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
-
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
@@ -221,8 +209,8 @@ class create_tenant_test(tenant_test):
self.assertEqual(401, int(resp['status']))
def test_tenant_create_disabled_token(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
@@ -230,7 +218,7 @@ class create_tenant_test(tenant_test):
body = '{"tenant": { "id": "%s", \
"description": "A description ...", "enabled"\
:true } }' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.disabled_token})
@@ -241,23 +229,21 @@ class create_tenant_test(tenant_test):
self.assertEqual(403, int(resp['status']))
def test_tenant_create_disabled_token_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant_xml("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = 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)
body = '<?xml version="1.0" encoding="UTF-8"?> \
<tenant xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" id="%s"> \
<description>A description...</description> \
</tenant>' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.disabled_token,
"ACCEPT": "application/xml"})
-
if int(resp['status']) == 500:
self.fail('IDM fault')
elif int(resp['status']) == 503:
@@ -265,8 +251,8 @@ class create_tenant_test(tenant_test):
self.assertEqual(403, int(resp['status']))
def test_tenant_create_invalid_token(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = create_tenant(self.tenant, str(self.auth_token))
if int(resp['status']) == 200:
self.tenant = content['tenant']['id']
@@ -274,7 +260,7 @@ class create_tenant_test(tenant_test):
body = '{"tenant": { "id": "%s", \
"description": "A description ...", "enabled"\
:true } }' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/json",
"X-Auth-Token": 'nonexsitingtoken'})
@@ -285,8 +271,8 @@ class create_tenant_test(tenant_test):
self.assertEqual(404, int(resp['status']))
def test_tenant_create_invalid_token_xml(self):
- h = httplib2.Http(".cache")
- resp, content = create_tenant_xml("test_tenant", str(self.auth_token))
+ header = httplib2.Http(".cache")
+ resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
content = etree.fromstring(content)
if int(resp['status']) == 200:
self.tenant = content.get('id')
@@ -297,7 +283,7 @@ class create_tenant_test(tenant_test):
enabled="true" id="%s"> \
<description>A description...</description> \
</tenant>' % self.tenant
- resp, content = h.request(url, "POST", body=body,
+ resp, content = header.request(url, "POST", body=body,
headers={"Content-Type": "application/xml",
"X-Auth-Token": 'nonexsitingtoken',
"ACCEPT": "application/xml"})
@@ -312,11 +298,11 @@ class create_tenant_test(tenant_test):
class get_tenants_test(tenant_test):
def test_get_tenants(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants' % (URL)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -326,11 +312,11 @@ class get_tenants_test(tenant_test):
self.assertEqual(200, int(resp['status']))
def test_get_tenants_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants' % (URL)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -341,11 +327,11 @@ class get_tenants_test(tenant_test):
self.assertEqual(200, int(resp['status']))
def test_get_tenants_unauthorized_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants' % (URL)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.token})
if int(resp['status']) == 500:
@@ -355,11 +341,11 @@ class get_tenants_test(tenant_test):
self.assertEqual(401, int(resp['status']))
def test_get_tenants_unauthorized_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants' % (URL)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.token,
"ACCEPT": "application/xml"})
@@ -370,11 +356,11 @@ class get_tenants_test(tenant_test):
self.assertEqual(401, int(resp['status']))
def test_get_tenants_exp_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants' % (URL)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
if int(resp['status']) == 500:
@@ -384,11 +370,11 @@ class get_tenants_test(tenant_test):
self.assertEqual(403, int(resp['status']))
def test_get_tenants_exp_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants' % (URL)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -402,11 +388,11 @@ class get_tenants_test(tenant_test):
class get_tenant_test(tenant_test):
def test_get_tenant(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/%s' % (URL, self.tenant)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -416,11 +402,11 @@ class get_tenant_test(tenant_test):
self.assertEqual(200, int(resp['status']))
def test_get_tenant_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/%s' % (URL, self.tenant)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -431,11 +417,11 @@ class get_tenant_test(tenant_test):
self.assertEqual(200, int(resp['status']))
def test_get_tenant_bad(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/%s' % (URL, 'tenant_bad')
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -445,11 +431,11 @@ class get_tenant_test(tenant_test):
self.assertEqual(404, int(resp['status']))
def test_get_tenant_bad_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/%s' % (URL, 'tenant_bad')
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -460,11 +446,11 @@ class get_tenant_test(tenant_test):
self.assertEqual(404, int(resp['status']))
def test_get_tenant_not_found(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/NonexistingID' % (URL)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -474,11 +460,11 @@ class get_tenant_test(tenant_test):
self.assertEqual(404, int(resp['status']))
def test_get_tenant_not_found_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/NonexistingID' % (URL)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -492,13 +478,13 @@ class get_tenant_test(tenant_test):
class update_tenant_test(tenant_test):
def test_update_tenant(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/%s' % (URL, self.tenant)
data = '{"tenant": { "description": "A NEW description..." ,\
"enabled":true }}'
#test for Content-Type = application/json
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
body = json.loads(content)
@@ -507,11 +493,11 @@ class update_tenant_test(tenant_test):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(200, int(resp['status']))
- self.assertEqual(int(self.tenant), int(body['tenant']['id']))
+ self.assertEqual(self.tenant, body['tenant']['id'])
self.assertEqual('A NEW description...', body['tenant']['description'])
def test_update_tenant_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant_xml(self.tenant, str(self.auth_token))
url = '%stenants/%s' % (URL, self.tenant)
data = '<?xml version="1.0" encoding="UTF-8"?> \
@@ -521,7 +507,7 @@ class update_tenant_test(tenant_test):
</tenant>'
#test for Content-Type = application/json
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -532,18 +518,18 @@ class update_tenant_test(tenant_test):
elif int(resp['status']) == 503:
self.fail('Service Not Available')
self.assertEqual(200, int(resp['status']))
- self.assertEqual(int(self.tenant), int(body.get('id')))
+ self.assertEqual(self.tenant, body.get('id'))
self.assertEqual('A NEW description...', desc.text)
def test_update_tenant_bad(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/%s' % (URL, self.tenant)
data = '{"tenant": { "description_bad": "A NEW description...",\
"enabled":true }}'
#test for Content-Type = application/json
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -553,7 +539,7 @@ class update_tenant_test(tenant_test):
self.assertEqual(400, int(resp['status']))
def test_update_tenant_bad_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/%s' % (URL, self.tenant)
data = '<?xml version="1.0" encoding="UTF-8"?> \
@@ -562,7 +548,7 @@ class update_tenant_test(tenant_test):
<description_bad>A NEW description...</description> \
</tenant>'
#test for Content-Type = application/json
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -573,13 +559,13 @@ class update_tenant_test(tenant_test):
self.assertEqual(400, int(resp['status']))
def test_update_tenant_not_found(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/NonexistingID' % (URL)
data = '{"tenant": { "description": "A NEW description...",\
"enabled":true }}'
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body=data,
+ resp, content = header.request(url, "GET", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -589,7 +575,7 @@ class update_tenant_test(tenant_test):
self.assertEqual(404, int(resp['status']))
def test_update_tenant_not_found_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_tenant(self.tenant, str(self.auth_token))
url = '%stenants/NonexistingID' % (URL)
data = '<?xml version="1.0" encoding="UTF-8"?> \
@@ -598,7 +584,7 @@ class update_tenant_test(tenant_test):
<description_bad>A NEW description...</description> \
</tenant>'
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body=data,
+ resp, content = header.request(url, "GET", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -637,5 +623,8 @@ class delete_tenant_test(tenant_test):
str(self.auth_token))
self.assertEqual(204, int(resp['status']))
+def run():
+ unittest.main()
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/unit/test_token.py b/test/unit/test_token.py
index 622de6f0..c4633166 100644
--- a/test/unit/test_token.py
+++ b/test/unit/test_token.py
@@ -4,13 +4,11 @@ import sys
sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__),
'..', '..', '..', '..', 'keystone')))
import unittest
-from webtest import TestApp
import httplib2
-import json
-from lxml import etree
-import unittest
-from webtest import TestApp
-from test_common import *
+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
class validate_token(unittest.TestCase):
@@ -28,10 +26,10 @@ class validate_token(unittest.TestCase):
delete_token(self.token, self.auth_token)
def test_validate_token_true(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken/%s?belongsTo=%s' % (URL, self.token, self.tenant)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -42,9 +40,9 @@ class validate_token(unittest.TestCase):
self.assertEqual('application/json', content_type(resp))
def test_validate_token_true_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken/%s?belongsTo=%s' % (URL, self.token, self.tenant)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -56,10 +54,10 @@ class validate_token(unittest.TestCase):
self.assertEqual('application/xml', content_type(resp))
def test_validate_token_expired(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken/%s?belongsTo=%s' % (URL, self.exp_auth_token,
self.tenant)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
if int(resp['status']) == 500:
@@ -70,11 +68,11 @@ class validate_token(unittest.TestCase):
self.assertEqual('application/json', content_type(resp))
def test_validate_token_expired_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken/%s?belongsTo=%s' % (URL, self.exp_auth_token,
self.tenant)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -86,10 +84,10 @@ class validate_token(unittest.TestCase):
self.assertEqual('application/xml', content_type(resp))
def test_validate_token_invalid(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken/%s?belongsTo=%s' % (URL, 'NonExistingToken',
self.tenant)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
@@ -101,10 +99,10 @@ class validate_token(unittest.TestCase):
self.assertEqual('application/json', content_type(resp))
def test_validate_token_invalid_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stoken/%s?belongsTo=%s' % (URL, 'NonExistingToken',
self.tenant)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
if int(resp['status']) == 500:
@@ -114,5 +112,8 @@ class validate_token(unittest.TestCase):
self.assertEqual(401, int(resp['status']))
self.assertEqual('application/json', content_type(resp))
+def run():
+ unittest.main()
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/unit/test_users.py b/test/unit/test_users.py
index 05a3e2ee..49318b95 100644
--- a/test/unit/test_users.py
+++ b/test/unit/test_users.py
@@ -8,11 +8,16 @@ from webtest import TestApp
import httplib2
import json
from lxml import etree
-import unittest
-from webtest import TestApp
-from test_common import *
+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, get_token_xml
+from test_common import get_password, get_email, get_none_token
+from test_common import get_non_existing_token, delete_user, delete_user_xml
+from test_common import create_user, create_user_xml, handle_user_resp
+
class user_test(unittest.TestCase):
def setUp(self):
@@ -153,11 +158,11 @@ class create_user_test(user_test):
class get_user_test(user_test):
def test_a_user_get_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -165,11 +170,11 @@ class get_user_test(user_test):
self.assertEqual(200, resp_val)
def test_a_user_get_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -179,12 +184,12 @@ class get_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_get_expired_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
resp_val = int(resp['status'])
@@ -192,12 +197,12 @@ class get_user_test(user_test):
self.assertEqual(403, resp_val)
def test_a_user_get_expired_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -207,12 +212,12 @@ class get_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_get_disabled_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.disabled_token})
resp_val = int(resp['status'])
@@ -220,12 +225,12 @@ class get_user_test(user_test):
self.assertEqual(403, resp_val)
def test_a_user_get_disabled_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.disabled_token,
"ACCEPT": "application/xml"})
@@ -235,12 +240,12 @@ class get_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_get_missing_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.missing_token})
resp_val = int(resp['status'])
@@ -248,12 +253,12 @@ class get_user_test(user_test):
self.assertEqual(401, resp_val)
def test_a_user_get_missing_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.missing_token,
"ACCEPT": "application/xml"})
@@ -263,12 +268,12 @@ class get_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_get_invalid_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.invalid_token})
resp_val = int(resp['status'])
@@ -276,12 +281,12 @@ class get_user_test(user_test):
self.assertEqual(404, resp_val)
def test_a_user_get_invalid_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.invalid_token,
"ACCEPT": "application/xml"})
@@ -291,11 +296,11 @@ class get_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_get_disabled_user(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant,
self.userdisabled)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -304,10 +309,10 @@ class get_user_test(user_test):
self.assertEqual(403, resp_val)
def test_a_user_get_disabled_user_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.userdisabled)
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -317,10 +322,10 @@ class get_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_get_disabled_tenant(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, '0000', self.userdisabled)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -328,10 +333,10 @@ class get_user_test(user_test):
self.assertEqual(403, resp_val)
def test_a_user_get_disabled_tenant_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, '0000', self.userdisabled)
#test for Content-Type = application/json
- resp, content = h.request(url, "GET", body='',
+ resp, content = header.request(url, "GET", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -344,12 +349,12 @@ class get_user_test(user_test):
class delete_user_test(user_test):
def test_a_user_delete_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -360,11 +365,11 @@ class delete_user_test(user_test):
self.assertEqual(204, resp_val)
def test_a_user_delete_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -376,12 +381,12 @@ class delete_user_test(user_test):
self.assertEqual(204, resp_val)
def test_a_user_delete_expired_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
resp_val = int(resp['status'])
@@ -392,12 +397,12 @@ class delete_user_test(user_test):
self.assertEqual(403, resp_val)
def test_a_user_delete_expired_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -410,12 +415,12 @@ class delete_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_delete_missing_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.missing_token})
resp_val = int(resp['status'])
@@ -426,12 +431,12 @@ class delete_user_test(user_test):
self.assertEqual(401, resp_val)
def test_a_user_delete_missing_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.missing_token,
"ACCEPT": "application/xml"})
@@ -444,12 +449,12 @@ class delete_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_delete_invalid_token(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.invalid_token})
resp_val = int(resp['status'])
@@ -460,12 +465,12 @@ class delete_user_test(user_test):
self.assertEqual(404, resp_val)
def test_a_user_delete_invalid_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.user, self.tenant,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.invalid_token,
"ACCEPT": "application/xml"})
@@ -478,10 +483,10 @@ class delete_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_a_user_delete_disabled_tenant(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, '0000', self.userdisabled)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='{}',
+ resp, content = header.request(url, "DELETE", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -493,10 +498,10 @@ class delete_user_test(user_test):
self.assertEqual(403, resp_val)
def test_a_user_delete_disabled_tenant_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, '0000', self.userdisabled)
#test for Content-Type = application/json
- resp, content = h.request(url, "DELETE", body='',
+ resp, content = header.request(url, "DELETE", body='',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -513,9 +518,9 @@ class delete_user_test(user_test):
class get_users_test(user_test):
def test_users_get_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -526,9 +531,9 @@ class get_users_test(user_test):
self.assertEqual(200, resp_val)
def test_users_get_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -541,9 +546,9 @@ class get_users_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_get_expired_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
resp_val = int(resp['status'])
@@ -554,9 +559,9 @@ class get_users_test(user_test):
self.assertEqual(403, resp_val)
def test_users_get_expired_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -569,9 +574,9 @@ class get_users_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_get_disabled_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.disabled_token})
resp_val = int(resp['status'])
@@ -582,9 +587,9 @@ class get_users_test(user_test):
self.assertEqual(403, resp_val)
def test_users_get_disabled_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.disabled_token,
"ACCEPT": "application/xml"})
@@ -597,9 +602,9 @@ class get_users_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_get_missing_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.missing_token})
resp_val = int(resp['status'])
@@ -610,9 +615,9 @@ class get_users_test(user_test):
self.assertEqual(401, resp_val)
def test_users_get_missing_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.missing_token,
"ACCEPT": "application/xml"})
@@ -625,9 +630,9 @@ class get_users_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_get_invalid_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.invalid_token})
resp_val = int(resp['status'])
@@ -638,9 +643,9 @@ class get_users_test(user_test):
self.assertEqual(404, resp_val)
def test_users_get_invalid_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, self.tenant)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.invalid_token,
"ACCEPT": "application/xml"})
@@ -653,9 +658,9 @@ class get_users_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_get_disabled_tenant_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, "0000")
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -667,9 +672,9 @@ class get_users_test(user_test):
self.assertEqual(403, resp_val)
def test_users_get_disabled_tenant_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users' % (URL, "0000")
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -685,9 +690,9 @@ class get_users_test(user_test):
class get_users_group_test(user_test):
def test_users_group_get_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -698,9 +703,9 @@ class get_users_group_test(user_test):
self.assertEqual(200, resp_val)
def test_users_group_get_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -713,9 +718,9 @@ class get_users_group_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_group_get_expired_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
resp_val = int(resp['status'])
@@ -726,9 +731,9 @@ class get_users_group_test(user_test):
self.assertEqual(403, resp_val)
def test_users_group_get_expired_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -741,9 +746,9 @@ class get_users_group_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_group_get_disabled_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.disabled_token})
resp_val = int(resp['status'])
@@ -754,9 +759,9 @@ class get_users_group_test(user_test):
self.assertEqual(403, resp_val)
def test_users_group_get_disabled_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.disabled_token,
"ACCEPT": "application/xml"})
@@ -769,9 +774,9 @@ class get_users_group_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_group_get_missing_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.missing_token})
resp_val = int(resp['status'])
@@ -782,9 +787,9 @@ class get_users_group_test(user_test):
self.assertEqual(401, resp_val)
def test_users_group_get_missing_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.missing_token,
"ACCEPT": "application/xml"})
@@ -797,9 +802,9 @@ class get_users_group_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_group_get_invalid_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.invalid_token})
resp_val = int(resp['status'])
@@ -810,9 +815,9 @@ class get_users_group_test(user_test):
self.assertEqual(404, resp_val)
def test_users_group_get_invalid_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, self.tenant, self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.invalid_token,
"ACCEPT": "application/xml"})
@@ -825,9 +830,9 @@ class get_users_group_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_users_group_get_disabled_tenant_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, "0000", self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -839,9 +844,9 @@ class get_users_group_test(user_test):
self.assertEqual(403, resp_val)
def test_users_group_get_disabled_tenant_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/groups' % (URL, "0000", self.user)
- resp, content = h.request(url, "GET", body='{}',
+ resp, content = header.request(url, "GET", body='{}',
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -857,14 +862,14 @@ class get_users_group_test(user_test):
class update_user_test(user_test):
def test_user_update_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '{"user": { "email": "updatedjoeuser@rackspace.com"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -880,14 +885,14 @@ class update_user_test(user_test):
content['user']['email'])
def test_user_update_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="updatedjoeuser@rackspace.com" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -904,10 +909,10 @@ class update_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_update_user_disabled_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.userdisabled)
data = '{"user": { "email": "updatedjoeuser@rackspace.com"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -919,12 +924,12 @@ class update_user_test(user_test):
self.assertEqual(403, resp_val)
def test_user_update_user_disabled_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.userdisabled)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="updatedjoeuser@rackspace.com" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -938,12 +943,12 @@ class update_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_update_email_conflict_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '{"user": { "email": "joe@rackspace.com"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -955,14 +960,14 @@ class update_user_test(user_test):
self.assertEqual(409, resp_val)
def test_user_update_email_conflict_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="joe@rackspace.com" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -976,12 +981,12 @@ class update_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_update_bad_request_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '{"user_bad": { "bad": "updatedjoeuser@rackspace.com"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -994,14 +999,14 @@ class update_user_test(user_test):
self.assertEqual(400, resp_val)
def test_user_update_bad_request_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="updatedjoeuser@rackspace.com" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -1016,10 +1021,10 @@ class update_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_update_expired_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '{"user": { "email": "updatedjoeuser@rackspace.com"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
resp_val = int(resp['status'])
@@ -1031,12 +1036,12 @@ class update_user_test(user_test):
self.assertEqual(403, resp_val)
def test_user_update_expired_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="updatedjoeuser@rackspace.com" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -1050,10 +1055,10 @@ class update_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_update_disabled_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '{"user": { "email": "updatedjoeuser@rackspace.com"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.disabled_token})
resp_val = int(resp['status'])
@@ -1065,12 +1070,12 @@ class update_user_test(user_test):
self.assertEqual(403, resp_val)
def test_user_update_disabled_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="updatedjoeuser@rackspace.com" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.disabled_token,
"ACCEPT": "application/xml"})
@@ -1084,11 +1089,11 @@ class update_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_update_invalid_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '{"user": { "email": "updatedjoeuser@rackspace.com"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.invalid_token})
resp_val = int(resp['status'])
@@ -1101,12 +1106,12 @@ class update_user_test(user_test):
self.assertEqual(404, resp_val)
def test_user_update_invalid_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="updatedjoeuser@rackspace.com" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.invalid_token,
"ACCEPT": "application/xml"})
@@ -1120,10 +1125,10 @@ class update_user_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_update_missing_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '{"user": { "email": "updatedjoeuser@rackspace.com"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.missing_token})
resp_val = int(resp['status'])
@@ -1135,12 +1140,12 @@ class update_user_test(user_test):
self.assertEqual(401, resp_val)
def test_user_update_missing_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
email="updatedjoeuser@rackspace.com" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.missing_token,
"ACCEPT": "application/xml"})
@@ -1157,12 +1162,12 @@ class update_user_test(user_test):
class set_password_test(user_test):
def test_user_password_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '{"user": { "password": "p@ssword"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -1176,14 +1181,14 @@ class set_password_test(user_test):
self.assertEqual('p@ssword', content['user']['password'])
def test_user_password_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="p@ssword" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -1199,11 +1204,11 @@ class set_password_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_password_user_disabled_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' \
% (URL, self.tenant, self.userdisabled)
data = '{"user": { "password": "p@ssword"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -1215,12 +1220,12 @@ class set_password_test(user_test):
self.assertEqual(403, resp_val)
def test_user_password_user_disabled_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s' % (URL, self.tenant, self.userdisabled)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="p@ssword" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -1234,12 +1239,12 @@ class set_password_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_password_bad_request_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '{"user_bad": { "password": "p@ssword"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -1252,14 +1257,14 @@ class set_password_test(user_test):
self.assertEqual(400, resp_val)
def test_user_password_bad_request_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
user xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="p@ssword" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -1274,10 +1279,10 @@ class set_password_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_password_expired_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '{"user": { "password": "p@ssword"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
resp_val = int(resp['status'])
@@ -1289,12 +1294,12 @@ class set_password_test(user_test):
self.assertEqual(403, resp_val)
def test_user_password_expired_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="p@ssword" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -1308,10 +1313,10 @@ class set_password_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_password_disabled_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '{"user": { "password": "p@ssword"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.disabled_token})
resp_val = int(resp['status'])
@@ -1323,12 +1328,12 @@ class set_password_test(user_test):
self.assertEqual(403, resp_val)
def test_user_password_disabled_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="p@ssword" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.disabled_token,
"ACCEPT": "application/xml"})
@@ -1342,10 +1347,10 @@ class set_password_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_password_invalid_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '{"user": { "password": "p@ssword"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.invalid_token})
resp_val = int(resp['status'])
@@ -1357,12 +1362,12 @@ class set_password_test(user_test):
self.assertEqual(404, resp_val)
def test_user_password_invalid_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="p@ssword" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.invalid_token,
"ACCEPT": "application/xml"})
@@ -1376,10 +1381,10 @@ class set_password_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_password_missing_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '{"user": { "password": "p@ssword"}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.missing_token})
resp_val = int(resp['status'])
@@ -1391,12 +1396,12 @@ class set_password_test(user_test):
self.assertEqual(401, resp_val)
def test_user_password_missing_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
password="p@ssword" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.missing_token,
"ACCEPT": "application/xml"})
@@ -1413,12 +1418,12 @@ class set_password_test(user_test):
class set_enabled_test(user_test):
def test_user_enabled_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = {"user": {"enabled": True}}
- resp, content = h.request(url, "PUT", body=json.dumps(data),
+ resp, content = header.request(url, "PUT", body=json.dumps(data),
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -1433,14 +1438,14 @@ class set_enabled_test(user_test):
self.assertEqual(True, content['user']['enabled'])
def test_user_enabled_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -1456,12 +1461,12 @@ class set_enabled_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_enabled_bad_request_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '{"user_bad": { "enabled": true}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.auth_token})
resp_val = int(resp['status'])
@@ -1474,14 +1479,14 @@ class set_enabled_test(user_test):
self.assertEqual(400, resp_val)
def test_user_enabled_bad_request_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
resp, content = create_user_xml(self.tenant, self.user,
str(self.auth_token))
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
user xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.auth_token,
"ACCEPT": "application/xml"})
@@ -1496,10 +1501,10 @@ class set_enabled_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_enabled_expired_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '{"user": { "enabled": true}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.exp_auth_token})
resp_val = int(resp['status'])
@@ -1511,12 +1516,12 @@ class set_enabled_test(user_test):
self.assertEqual(403, resp_val)
def test_user_enabled_expired_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.exp_auth_token,
"ACCEPT": "application/xml"})
@@ -1530,10 +1535,10 @@ class set_enabled_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_enabled_disabled_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '{"user": { "enabled": true}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.disabled_token})
resp_val = int(resp['status'])
@@ -1545,12 +1550,12 @@ class set_enabled_test(user_test):
self.assertEqual(403, resp_val)
def test_user_enabled_disabled_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.disabled_token,
"ACCEPT": "application/xml"})
@@ -1564,10 +1569,10 @@ class set_enabled_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_enabled_invalid_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '{"user": { "enabled": true}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.invalid_token})
resp_val = int(resp['status'])
@@ -1579,12 +1584,12 @@ class set_enabled_test(user_test):
self.assertEqual(404, resp_val)
def test_user_enabled_invalid_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",\
"X-Auth-Token": self.invalid_token,
"ACCEPT": "application/xml"})
@@ -1598,10 +1603,10 @@ class set_enabled_test(user_test):
self.assertEqual('application/xml', content_type(resp))
def test_user_enabled_missing_token_json(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/enabled' % (URL, self.tenant, self.user)
data = '{"user": { "enabled": true}}'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/json",
"X-Auth-Token": self.missing_token})
resp_val = int(resp['status'])
@@ -1613,12 +1618,12 @@ class set_enabled_test(user_test):
self.assertEqual(401, resp_val)
def test_user_enabled_missing_token_xml(self):
- h = httplib2.Http(".cache")
+ header = httplib2.Http(".cache")
url = '%stenants/%s/users/%s/password' % (URL, self.tenant, self.user)
data = '<?xml version="1.0" encoding="UTF-8"?> \
<user xmlns="http://docs.openstack.org/idm/api/v1.0" \
enabled="true" />'
- resp, content = h.request(url, "PUT", body=data,
+ resp, content = header.request(url, "PUT", body=data,
headers={"Content-Type": "application/xml",
"X-Auth-Token": self.missing_token,
"ACCEPT": "application/xml"})
@@ -1631,5 +1636,8 @@ class set_enabled_test(user_test):
self.assertEqual(401, resp_val)
self.assertEqual('application/xml', 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 bb35a741..b83e7d0d 100644
--- a/test/unit/test_version.py
+++ b/test/unit/test_version.py
@@ -4,13 +4,8 @@ import sys
sys.path.append(os.path.abspath(os.path.join(os.path.abspath(__file__),
'..', '..', '..', '..', 'keystone')))
import unittest
-from webtest import TestApp
import httplib2
-import json
-from lxml import etree
-import unittest
-from webtest import TestApp
-from test_common import *
+from test_common import URL, content_type
class version_test(unittest.TestCase):
@@ -19,22 +14,21 @@ class version_test(unittest.TestCase):
#here to call below method will call as last test case
def test_a_get_version_json(self):
- h = httplib2.Http(".cache")
- url = URL
- resp, content = h.request(url, "GET", body="",
+ header = httplib2.Http(".cache")
+ resp, content = header.request(URL, "GET", body="",
headers={"Content-Type": "application/json"})
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/json', content_type(resp))
def test_a_get_version_xml(self):
- h = httplib2.Http(".cache")
- url = URL
- resp, content = h.request(url, "GET", body="",
+ header = httplib2.Http(".cache")
+ resp, content = header.request(URL, "GET", body="",
headers={"Content-Type": "application/xml",
"ACCEPT": "application/xml"})
-
self.assertEqual(200, int(resp['status']))
self.assertEqual('application/xml', content_type(resp))
+
+
if __name__ == '__main__':
unittest.main()