Codebase list python-castellan / 233febb
Append a forward slash to the base_url six.moves.urllib.parse.urljoin strips everything that doesn't end with a forward slash, so for example, if the barbican URL is http://ip-address/key-manager, the "key-manager" part will be removed. If the URL is http://ip-address/key-manager/, everything will be fine. Change-Id: I1afcd7ae460633e451bc365fdb87f6e30bb3a60b Kaitlin Farr 6 years ago
2 changed file(s) with 22 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
201201 latest_version = raw_data[-1]
202202 api_version = latest_version.get('id')
203203
204 if endpoint[-1] != '/':
205 endpoint += '/'
206
204207 base_url = urllib.parse.urljoin(
205208 endpoint, api_version)
209
206210 return base_url
207211
208212 def create_key(self, context, algorithm, length,
7575 self.key_mgr._barbican_client = self.mock_barbican
7676 self.key_mgr._current_context = self.ctxt
7777
78 def test_base_url_old_version(self):
79 version = "v1"
80 self.key_mgr.conf.barbican.barbican_api_version = version
81 endpoint = "http://localhost:9311"
82 base_url = self.key_mgr._create_base_url(mock.Mock(),
83 mock.Mock(),
84 endpoint)
85 self.assertEqual(endpoint + "/" + version, base_url)
86
87 def test_base_url_new_version(self):
88 version = "v1"
89 self.key_mgr.conf.barbican.barbican_api_version = version
90 endpoint = "http://localhost/key_manager"
91 base_url = self.key_mgr._create_base_url(mock.Mock(),
92 mock.Mock(),
93 endpoint)
94 self.assertEqual(endpoint + "/" + version, base_url)
95
7896 def test_create_key(self):
7997 # Create order_ref_url and assign return value
8098 order_ref_url = ("http://localhost:9311/v1/orders/"