summaryrefslogtreecommitdiff
path: root/heat/tests/api/aws/test_api_ec2token.py
diff options
context:
space:
mode:
authorMiguel Grinberg <miguelgrinberg50@gmail.com>2015-07-28 10:57:38 -0700
committerhuangtianhua <huangtianhua@huawei.com>2015-08-13 01:36:31 +0000
commitc786a9e105e0b51a96448bb9d83fc135de81a1e6 (patch)
tree272152a0d2a1642ed4b6e86f498b307f48ad46f9 /heat/tests/api/aws/test_api_ec2token.py
parent487a211a8a3d603ae4b77087836081037fa49c70 (diff)
downloadheat-c786a9e105e0b51a96448bb9d83fc135de81a1e6.tar.gz
Get auth_uri from [clients_keystone] section for ec2tokens
When a specific auth_uri for ec2 isn't configured, this endpoint needs to be obtained from the heat specific [clients_keystone] section if available, and only when that is not available the [keystone_authtoken] setting should be used. Change-Id: Ie6db2845772ceee88073704bc345a6c303f396c1 Partial-Bug: #1446918
Diffstat (limited to 'heat/tests/api/aws/test_api_ec2token.py')
-rw-r--r--heat/tests/api/aws/test_api_ec2token.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/heat/tests/api/aws/test_api_ec2token.py b/heat/tests/api/aws/test_api_ec2token.py
index 006dc1f92..9a5d0f7cf 100644
--- a/heat/tests/api/aws/test_api_ec2token.py
+++ b/heat/tests/api/aws/test_api_ec2token.py
@@ -13,6 +13,7 @@
import json
+import mock
from oslo_config import cfg
from oslo_utils import importutils
@@ -54,12 +55,28 @@ class Ec2TokenTest(common.HeatTestCase):
def test_conf_get_opts(self):
cfg.CONF.set_default('auth_uri', 'http://192.0.2.9/v2.0/',
group='ec2authtoken')
+ cfg.CONF.set_default('auth_uri', 'this-should-be-ignored',
+ group='clients_keystone')
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual('http://192.0.2.9/v2.0/', ec2._conf_get('auth_uri'))
self.assertEqual(
'http://192.0.2.9/v2.0/ec2tokens',
ec2._conf_get_keystone_ec2_uri('http://192.0.2.9/v2.0/'))
+ def test_conf_get_clients_keystone_opts(self):
+ cfg.CONF.set_default('auth_uri', None, group='ec2authtoken')
+ cfg.CONF.set_default('auth_uri', 'http://192.0.2.9',
+ group='clients_keystone')
+ with mock.patch('keystoneclient.discover.Discover') as discover:
+ class MockDiscover(object):
+ def url_for(self, endpoint):
+ return 'http://192.0.2.9/v3/'
+ discover.return_value = MockDiscover()
+ ec2 = ec2token.EC2Token(app=None, conf={})
+ self.assertEqual(
+ 'http://192.0.2.9/v3/ec2tokens',
+ ec2._conf_get_keystone_ec2_uri('http://192.0.2.9/v3/'))
+
def test_conf_get_ssl_default_options(self):
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertTrue(ec2.ssl_options['verify'],