aboutsummaryrefslogtreecommitdiffstats
path: root/keystone-moon/keystone/tests/unit/catalog/test_core.py
diff options
context:
space:
mode:
Diffstat (limited to 'keystone-moon/keystone/tests/unit/catalog/test_core.py')
-rw-r--r--keystone-moon/keystone/tests/unit/catalog/test_core.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/keystone-moon/keystone/tests/unit/catalog/test_core.py b/keystone-moon/keystone/tests/unit/catalog/test_core.py
index 2f334bb6..b04b0bb7 100644
--- a/keystone-moon/keystone/tests/unit/catalog/test_core.py
+++ b/keystone-moon/keystone/tests/unit/catalog/test_core.py
@@ -10,27 +10,25 @@
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_config import cfg
+import uuid
from keystone.catalog import core
from keystone import exception
from keystone.tests import unit
-CONF = cfg.CONF
-
-
class FormatUrlTests(unit.BaseTestCase):
def test_successful_formatting(self):
url_template = ('http://$(public_bind_host)s:$(admin_port)d/'
- '$(tenant_id)s/$(user_id)s')
+ '$(tenant_id)s/$(user_id)s/$(project_id)s')
+ project_id = uuid.uuid4().hex
values = {'public_bind_host': 'server', 'admin_port': 9090,
- 'tenant_id': 'A', 'user_id': 'B'}
+ 'tenant_id': 'A', 'user_id': 'B', 'project_id': project_id}
actual_url = core.format_url(url_template, values)
- expected_url = 'http://server:9090/A/B'
- self.assertEqual(actual_url, expected_url)
+ expected_url = 'http://server:9090/A/B/%s' % (project_id,)
+ self.assertEqual(expected_url, actual_url)
def test_raises_malformed_on_missing_key(self):
self.assertRaises(exception.MalformedEndpoint,
@@ -73,7 +71,7 @@ class FormatUrlTests(unit.BaseTestCase):
url_template,
values)
- def test_substitution_with_allowed_keyerror(self):
+ def test_substitution_with_allowed_tenant_keyerror(self):
# No value of 'tenant_id' is passed into url_template.
# mod: format_url will return None instead of raising
# "MalformedEndpoint" exception.
@@ -86,3 +84,17 @@ class FormatUrlTests(unit.BaseTestCase):
'user_id': 'B'}
self.assertIsNone(core.format_url(url_template, values,
silent_keyerror_failures=['tenant_id']))
+
+ def test_substitution_with_allowed_project_keyerror(self):
+ # No value of 'project_id' is passed into url_template.
+ # mod: format_url will return None instead of raising
+ # "MalformedEndpoint" exception.
+ # This is intentional behavior since we don't want to skip
+ # all the later endpoints once there is an URL of endpoint
+ # trying to replace 'project_id' with None.
+ url_template = ('http://$(public_bind_host)s:$(admin_port)d/'
+ '$(project_id)s/$(user_id)s')
+ values = {'public_bind_host': 'server', 'admin_port': 9090,
+ 'user_id': 'B'}
+ self.assertIsNone(core.format_url(url_template, values,
+ silent_keyerror_failures=['project_id']))