1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
19
from keystoneclient.generic import client
20
from keystoneclient.tests.v3 import utils
23
class DiscoverKeystoneTests(utils.UnauthenticatedTestCase):
25
super(DiscoverKeystoneTests, self).setUp()
26
self.TEST_RESPONSE_DICT = {
28
"values": [{"id": "v3.0",
30
"updated": "2013-03-06T00:00:00Z",
33
"href": "http://127.0.0.1:5000/v3.0/", },
34
{"rel": "describedby",
36
"href": "http://docs.openstack.org/api/"
37
"openstack-identity-service/3/"
39
{"rel": "describedby",
40
"type": "application/pdf",
41
"href": "http://docs.openstack.org/api/"
42
"openstack-identity-service/3/"
43
"identity-dev-guide-3.pdf", },
47
"updated": "2013-03-06T00:00:00Z",
50
"href": "http://127.0.0.1:5000/v2.0/", },
51
{"rel": "describedby",
53
"href": "http://docs.openstack.org/api/"
54
"openstack-identity-service/2.0/"
56
{"rel": "describedby",
57
"type": "application/pdf",
58
"href": "http://docs.openstack.org/api/"
59
"openstack-identity-service/2.0/"
60
"identity-dev-guide-2.0.pdf", }
64
self.TEST_REQUEST_HEADERS = {
65
'User-Agent': 'python-keystoneclient',
66
'Accept': 'application/json',
70
def test_get_version_local(self):
71
httpretty.register_uri(httpretty.GET, "http://localhost:35357/",
73
body=json.dumps(self.TEST_RESPONSE_DICT))
76
versions = cs.discover()
77
self.assertIsInstance(versions, dict)
78
self.assertIn('message', versions)
79
self.assertIn('v3.0', versions)
81
versions['v3.0']['url'],
82
self.TEST_RESPONSE_DICT['versions']['values'][0]['links'][0]
85
versions['v2.0']['url'],
86
self.TEST_RESPONSE_DICT['versions']['values'][1]['links'][0]