summaryrefslogtreecommitdiff
path: root/heat/tests/test_auth_password.py
diff options
context:
space:
mode:
authorAnderson Mesquita <andersonvom@gmail.com>2014-01-14 16:13:16 -0600
committerRichard Lee <rblee88@gmail.com>2014-02-20 15:52:51 -0600
commit9ce4ab13380f96bdaf15311d560cf8a4735f94c8 (patch)
tree5380e6ff88d8e1a39297bc962e1c8c28b02e2e36 /heat/tests/test_auth_password.py
parent440f811c8a030f73cf69a8103fc6a56315b5fc29 (diff)
downloadheat-9ce4ab13380f96bdaf15311d560cf8a4735f94c8.tar.gz
Move X-Auth-Url logic to auth_url middleware
Refactoring the auth_password middleware to move X-Auth-Url logic into the auth_url middleware, so that all X-Auth-Url logic is handled in one place. This also adds the auth_url middleware in front of the auth_password middleware, so that there should be no behavior change Co-Authored-By: Richard Lee <rblee88@gmail.com> Related-Bug: #1259364 Change-Id: I3819cbf1a4c4955752dc7c804b0add1bab2b962c
Diffstat (limited to 'heat/tests/test_auth_password.py')
-rw-r--r--heat/tests/test_auth_password.py62
1 files changed, 2 insertions, 60 deletions
diff --git a/heat/tests/test_auth_password.py b/heat/tests/test_auth_password.py
index 9f7a78670..f7d32c512 100644
--- a/heat/tests/test_auth_password.py
+++ b/heat/tests/test_auth_password.py
@@ -17,7 +17,6 @@
from keystoneclient.v2_0 import client as keystone_client
from keystoneclient.exceptions import Unauthorized
-from oslo.config import cfg
import webob
from heat.common.auth_password import KeystonePasswordAuthProtocol
@@ -98,6 +97,7 @@ class KeystonePasswordAuthProtocolTest(HeatTestCase):
req = webob.Request.blank('/tenant_id1/')
req.headers['X_AUTH_USER'] = 'user_name1'
req.headers['X_AUTH_KEY'] = 'goodpassword'
+ req.headers['X_AUTH_URL'] = self.config['auth_uri']
self.middleware(req.environ, self._start_fake_response)
self.m.VerifyAll()
@@ -112,6 +112,7 @@ class KeystonePasswordAuthProtocolTest(HeatTestCase):
req = webob.Request.blank('/tenant_id1/')
req.headers['X_AUTH_USER'] = 'user_name1'
req.headers['X_AUTH_KEY'] = 'badpassword'
+ req.headers['X_AUTH_URL'] = self.config['auth_uri']
self.middleware(req.environ, self._start_fake_response)
self.m.VerifyAll()
self.assertEqual(401, self.response_status)
@@ -120,62 +121,3 @@ class KeystonePasswordAuthProtocolTest(HeatTestCase):
req = webob.Request.blank('/')
self.middleware(req.environ, self._start_fake_response)
self.assertEqual(401, self.response_status)
-
- def test_multi_cloud(self):
- allowed_auth_uris = ['http://multicloud.test.com:5000/v2.0']
- cfg.CONF.set_override('multi_cloud', True, group='auth_password')
- auth_url = 'http://multicloud.test.com:5000/v2.0'
- cfg.CONF.set_override('allowed_auth_uris',
- allowed_auth_uris,
- group='auth_password')
- self.app = FakeApp(
- expected_env={'HTTP_X_AUTH_URL': auth_url})
- self.middleware = KeystonePasswordAuthProtocol(self.app, self.config)
-
- mock_client = self.m.CreateMock(keystone_client.Client)
- self.m.StubOutWithMock(keystone_client, 'Client')
- keystone_client.Client(
- username='user_name1', password='goodpassword',
- tenant_id='tenant_id1', auth_url=auth_url).AndReturn(mock_client)
- mock_client.auth_ref = TOKEN_RESPONSE
- self.m.ReplayAll()
- req = webob.Request.blank('/tenant_id1/')
- req.headers['X_AUTH_USER'] = 'user_name1'
- req.headers['X_AUTH_KEY'] = 'goodpassword'
- req.headers['X_AUTH_URL'] = auth_url
- self.middleware(req.environ, self._start_fake_response)
- self.m.VerifyAll()
-
- def test_multi_cloud_empty_allowed_uris(self):
- cfg.CONF.set_override('multi_cloud', True, group='auth_password')
- auth_url = 'http://multicloud.test.com:5000/v2.0'
- cfg.CONF.set_override('allowed_auth_uris',
- [],
- group='auth_password')
- req = webob.Request.blank('/tenant_id1/')
- req.headers['X_AUTH_USER'] = 'user_name1'
- req.headers['X_AUTH_KEY'] = 'goodpassword'
- req.headers['X_AUTH_URL'] = auth_url
- self.middleware(req.environ, self._start_fake_response)
- self.assertEqual(401, self.response_status)
-
- def test_multi_cloud_target_not_allowed(self):
- cfg.CONF.set_override('multi_cloud', True, group='auth_password')
- auth_url = 'http://multicloud.test.com:5000/v2.0'
- cfg.CONF.set_override('allowed_auth_uris',
- ['http://some.other.url:5000/v2.0'],
- group='auth_password')
- req = webob.Request.blank('/tenant_id1/')
- req.headers['X_AUTH_USER'] = 'user_name1'
- req.headers['X_AUTH_KEY'] = 'goodpassword'
- req.headers['X_AUTH_URL'] = auth_url
- self.middleware(req.environ, self._start_fake_response)
- self.assertEqual(401, self.response_status)
-
- def test_multi_cloud_no_auth_url(self):
- cfg.CONF.set_override('multi_cloud', True, group='auth_password')
- req = webob.Request.blank('/tenant_id1/')
- req.headers['X_AUTH_USER'] = 'user_name1'
- req.headers['X_AUTH_KEY'] = 'goodpassword'
- self.middleware(req.environ, self._start_fake_response)
- self.assertEqual(400, self.response_status)