summaryrefslogtreecommitdiffstats
path: root/tests/test_versions.py
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2013-03-14 13:29:47 -0400
committerDan Prince <dprince@redhat.com>2013-03-21 15:21:04 -0400
commit620e6e37803ca94a9708413c35039e5097f6d9d4 (patch)
tree70185dbe9313999bead8b07fc94f0d65b757e98a /tests/test_versions.py
parentba3f41f068f763ec96f7da19ed1fa1698f3c5fcf (diff)
downloadkeystone-620e6e37803ca94a9708413c35039e5097f6d9d4.tar.gz
keystone-620e6e37803ca94a9708413c35039e5097f6d9d4.tar.xz
keystone-620e6e37803ca94a9708413c35039e5097f6d9d4.zip
Make versions aware of enabled pipelines.
Updates to make our versions controller a bit smarter so that it only returns information on API versions which are actually running. With these changes a user can disable the v2.0 or v3 API versions in their pipeline, restart keystone, and then have versions return information only for the versions which are actually running. This is important because auth_token now uses info from the keystone versions controller (in some cases) to dynamically select an API version. Fixes LP Bug #1158470. Change-Id: I0fa8a82f08e7247c44fb7f4ff8dbb7d4ad58b9cc
Diffstat (limited to 'tests/test_versions.py')
-rw-r--r--tests/test_versions.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/test_versions.py b/tests/test_versions.py
index 0ca2edda..5d5de56d 100644
--- a/tests/test_versions.py
+++ b/tests/test_versions.py
@@ -16,6 +16,7 @@
# limitations under the License.
from keystone import config
+from keystone import controllers
from keystone.openstack.common import jsonutils
from keystone import test
@@ -193,3 +194,65 @@ class VersionTestCase(test.TestCase):
self._paste_in_port(expected['version'],
'http://localhost:%s/v3/' % CONF.admin_port)
self.assertEqual(data, expected)
+
+ def test_v2_disabled(self):
+ self.stubs.Set(controllers, '_VERSIONS', ['v3'])
+ client = self.client(self.public_app)
+ # request to /v2.0 should fail
+ resp = client.get('/v2.0/')
+ self.assertEqual(resp.status_int, 404)
+
+ # request to /v3 should pass
+ resp = client.get('/v3/')
+ self.assertEqual(resp.status_int, 200)
+ data = jsonutils.loads(resp.body)
+ expected = v3_VERSION_RESPONSE
+ self._paste_in_port(expected['version'],
+ 'http://localhost:%s/v3/' % CONF.public_port)
+ self.assertEqual(data, expected)
+
+ # only v3 information should be displayed by requests to /
+ v3_only_response = {
+ "versions": {
+ "values": [
+ v3_EXPECTED_RESPONSE
+ ]
+ }
+ }
+ self._paste_in_port(v3_only_response['versions']['values'][0],
+ 'http://localhost:%s/v3/' % CONF.public_port)
+ resp = client.get('/')
+ self.assertEqual(resp.status_int, 300)
+ data = jsonutils.loads(resp.body)
+ self.assertEqual(data, v3_only_response)
+
+ def test_v3_disabled(self):
+ self.stubs.Set(controllers, '_VERSIONS', ['v2.0'])
+ client = self.client(self.public_app)
+ # request to /v3 should fail
+ resp = client.get('/v3/')
+ self.assertEqual(resp.status_int, 404)
+
+ # request to /v2.0 should pass
+ resp = client.get('/v2.0/')
+ self.assertEqual(resp.status_int, 200)
+ data = jsonutils.loads(resp.body)
+ expected = v2_VERSION_RESPONSE
+ self._paste_in_port(expected['version'],
+ 'http://localhost:%s/v2.0/' % CONF.public_port)
+ self.assertEqual(data, expected)
+
+ # only v2 information should be displayed by requests to /
+ v2_only_response = {
+ "versions": {
+ "values": [
+ v2_EXPECTED_RESPONSE
+ ]
+ }
+ }
+ self._paste_in_port(v2_only_response['versions']['values'][0],
+ 'http://localhost:%s/v2.0/' % CONF.public_port)
+ resp = client.get('/')
+ self.assertEqual(resp.status_int, 300)
+ data = jsonutils.loads(resp.body)
+ self.assertEqual(data, v2_only_response)