Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config option to override url for versions
The versions url returns the wrong data when cinder api is behind a proxy. This adds a new config option so it can be set properly. DocImpact Change-Id: I46a90120b21e43bf8dca9e5f0efdf339f0d3e8e6 Closes-Bug: #1384379
- Loading branch information
wanghao
committed
Mar 2, 2015
1 parent
1e2ac58
commit 2eb25ab
Showing
2 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (c) 2015 - 2016 Huawei Technologies Co., Ltd. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import webob | ||
|
||
from cinder.api import versions | ||
from cinder import test | ||
|
||
|
||
class VersionsTest(test.TestCase): | ||
|
||
"""Test the version information returned from the API service.""" | ||
|
||
def test_get_version_list_public_endpoint(self): | ||
req = webob.Request.blank('/', base_url='http://127.0.0.1:8776/') | ||
req.accept = 'application/json' | ||
self.override_config('public_endpoint', 'https://example.com:8776') | ||
res = versions.Versions().index(req) | ||
results = res['versions'] | ||
expected = [ | ||
{ | ||
'id': 'v1.0', | ||
'status': 'SUPPORTED', | ||
'updated': '2014-06-28T12:20:21Z', | ||
'links': [{'rel': 'self', | ||
'href': 'https://example.com:8776/v1/'}], | ||
}, | ||
{ | ||
'id': 'v2.0', | ||
'status': 'CURRENT', | ||
'updated': '2012-11-21T11:33:21Z', | ||
'links': [{'rel': 'self', | ||
'href': 'https://example.com:8776/v2/'}], | ||
}, | ||
] | ||
self.assertEqual(expected, results) | ||
|
||
def test_get_version_list(self): | ||
req = webob.Request.blank('/', base_url='http://127.0.0.1:8776/') | ||
req.accept = 'application/json' | ||
res = versions.Versions().index(req) | ||
results = res['versions'] | ||
expected = [ | ||
{ | ||
'id': 'v1.0', | ||
'status': 'SUPPORTED', | ||
'updated': '2014-06-28T12:20:21Z', | ||
'links': [{'rel': 'self', | ||
'href': 'http://127.0.0.1:8776/v1/'}], | ||
}, | ||
{ | ||
'id': 'v2.0', | ||
'status': 'CURRENT', | ||
'updated': '2012-11-21T11:33:21Z', | ||
'links': [{'rel': 'self', | ||
'href': 'http://127.0.0.1:8776/v2/'}], | ||
}, | ||
] | ||
self.assertEqual(expected, results) |