Merge "Use application_url in API version document"
This commit is contained in:
commit
53df9ade64
@ -17,6 +17,7 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from six.moves import http_client
|
||||
from six.moves import urllib
|
||||
import webob.dec
|
||||
|
||||
from glance.common import wsgi
|
||||
@ -59,14 +60,17 @@ class Controller(object):
|
||||
def index(self, req, explicit=False):
|
||||
"""Respond to a request for all OpenStack API versions."""
|
||||
def build_version_object(version, path, status):
|
||||
url = CONF.public_endpoint or req.host_url
|
||||
url = CONF.public_endpoint or req.application_url
|
||||
# Always add '/' to url end for urljoin href url
|
||||
url = url.rstrip('/') + '/'
|
||||
href = urllib.parse.urljoin(url, path).rstrip('/') + '/'
|
||||
return {
|
||||
'id': 'v%s' % version,
|
||||
'status': status,
|
||||
'links': [
|
||||
{
|
||||
'rel': 'self',
|
||||
'href': '%s/%s/' % (url, path),
|
||||
'href': '%s' % href,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@ -135,6 +135,17 @@ class VersionsTest(base.IsolatedUnitTest):
|
||||
expected = self._get_versions_list(ssl_url)
|
||||
self.assertEqual(expected, results)
|
||||
|
||||
def test_get_version_list_for_external_app(self):
|
||||
url = 'http://customhost:9292/app/api'
|
||||
req = webob.Request.blank('/', base_url=url)
|
||||
self.config(bind_host='127.0.0.1', bind_port=9292)
|
||||
res = versions.Controller().index(req)
|
||||
self.assertEqual(http.MULTIPLE_CHOICES, res.status_int)
|
||||
self.assertEqual('application/json', res.content_type)
|
||||
results = jsonutils.loads(res.body)['versions']
|
||||
expected = self._get_versions_list(url)
|
||||
self.assertEqual(expected, results)
|
||||
|
||||
|
||||
class VersionNegotiationTest(base.IsolatedUnitTest):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user