Fix broken version discovery endpoints
In the version discovery spec, it is noted that both schema and netloc on endpoints reported by version discovery documents are known to be able to be broken, but shade was only fixing scheme. Update the code to do the right thing. Also, add a test to ensure that this behavior occurs correctly. While we're in the tests for this, have the discovery call return a 300, which is what it returns. There are no bugs in this area, but 300 is correct so we should test it that way. Story: 2001027 Change-Id: Id04f6f033c9277e791b602f193d1eaf6ac73047f
This commit is contained in:
parent
e1dfc7228d
commit
40f66c70c3
@ -469,7 +469,7 @@ class OpenStackCloud(
|
|||||||
|
|
||||||
return urllib.parse.ParseResult(
|
return urllib.parse.ParseResult(
|
||||||
catalog_endpoint.scheme,
|
catalog_endpoint.scheme,
|
||||||
discovered_endpoint.netloc,
|
catalog_endpoint.netloc,
|
||||||
discovered_endpoint.path,
|
discovered_endpoint.path,
|
||||||
discovered_endpoint.params,
|
discovered_endpoint.params,
|
||||||
discovered_endpoint.query,
|
discovered_endpoint.query,
|
||||||
|
@ -474,6 +474,7 @@ class RequestsMockTestCase(BaseTestCase):
|
|||||||
discovery_fixture = os.path.join(
|
discovery_fixture = os.path.join(
|
||||||
self.fixtures_directory, image_version_json)
|
self.fixtures_directory, image_version_json)
|
||||||
return dict(method='GET', uri='https://image.example.com/',
|
return dict(method='GET', uri='https://image.example.com/',
|
||||||
|
status_code=300,
|
||||||
text=open(discovery_fixture, 'r').read())
|
text=open(discovery_fixture, 'r').read())
|
||||||
|
|
||||||
def get_designate_discovery_mock_dict(self):
|
def get_designate_discovery_mock_dict(self):
|
||||||
|
64
shade/tests/unit/fixtures/image-version-broken.json
Normal file
64
shade/tests/unit/fixtures/image-version-broken.json
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"versions": [
|
||||||
|
{
|
||||||
|
"status": "CURRENT",
|
||||||
|
"id": "v2.3",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://localhost/v2/",
|
||||||
|
"rel": "self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"status": "SUPPORTED",
|
||||||
|
"id": "v2.2",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://localhost/v2/",
|
||||||
|
"rel": "self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"status": "SUPPORTED",
|
||||||
|
"id": "v2.1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://localhost/v2/",
|
||||||
|
"rel": "self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"status": "SUPPORTED",
|
||||||
|
"id": "v2.0",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://localhost/v2/",
|
||||||
|
"rel": "self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"status": "SUPPORTED",
|
||||||
|
"id": "v1.1",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://localhost/v1/",
|
||||||
|
"rel": "self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"status": "SUPPORTED",
|
||||||
|
"id": "v1.0",
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"href": "http://localhost/v1/",
|
||||||
|
"rel": "self"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -738,3 +738,26 @@ class TestImageVolume(BaseTestImage):
|
|||||||
volume={'id': volume_id}, allow_duplicates=True)
|
volume={'id': volume_id}, allow_duplicates=True)
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
|
|
||||||
|
class TestImageBrokenDiscovery(base.RequestsMockTestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestImageBrokenDiscovery, self).setUp()
|
||||||
|
self.use_glance(image_version_json='image-version-broken.json')
|
||||||
|
|
||||||
|
def test_url_fix(self):
|
||||||
|
# image-version-broken.json has both http urls and localhost as the
|
||||||
|
# host. This is testing that what is discovered is https, because
|
||||||
|
# that's what's in the catalog, and image.example.com for the same
|
||||||
|
# reason.
|
||||||
|
self.register_uris([
|
||||||
|
dict(method='GET',
|
||||||
|
uri='https://image.example.com/v2/images',
|
||||||
|
json={'images': []})
|
||||||
|
])
|
||||||
|
self.assertEqual([], self.cloud.list_images())
|
||||||
|
self.assertEqual(
|
||||||
|
self.cloud._image_client.endpoint_override,
|
||||||
|
'https://image.example.com/v2/')
|
||||||
|
self.assert_calls()
|
||||||
|
Loading…
Reference in New Issue
Block a user