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
17
from keystoneclient import exceptions
18
from keystoneclient.tests.v3 import utils
19
from keystoneclient.v3 import endpoints
22
class EndpointTests(utils.TestCase, utils.CrudTests):
24
super(EndpointTests, self).setUp()
26
self.collection_key = 'endpoints'
27
self.model = endpoints.Endpoint
28
self.manager = self.client.endpoints
30
def new_ref(self, **kwargs):
31
kwargs = super(EndpointTests, self).new_ref(**kwargs)
32
kwargs.setdefault('interface', 'public')
33
kwargs.setdefault('region', uuid.uuid4().hex)
34
kwargs.setdefault('service_id', uuid.uuid4().hex)
35
kwargs.setdefault('url', uuid.uuid4().hex)
36
kwargs.setdefault('enabled', True)
39
def test_create_public_interface(self):
40
ref = self.new_ref(interface='public')
43
def test_create_admin_interface(self):
44
ref = self.new_ref(interface='admin')
47
def test_create_internal_interface(self):
48
ref = self.new_ref(interface='internal')
51
def test_create_invalid_interface(self):
52
ref = self.new_ref(interface=uuid.uuid4().hex)
53
self.assertRaises(exceptions.ValidationError, self.manager.create,
54
**utils.parameterize(ref))
56
def test_update_public_interface(self):
57
ref = self.new_ref(interface='public')
60
def test_update_admin_interface(self):
61
ref = self.new_ref(interface='admin')
64
def test_update_internal_interface(self):
65
ref = self.new_ref(interface='internal')
68
def test_update_invalid_interface(self):
69
ref = self.new_ref(interface=uuid.uuid4().hex)
70
ref['endpoint'] = "fake_endpoint"
71
self.assertRaises(exceptions.ValidationError, self.manager.update,
72
**utils.parameterize(ref))
74
def test_list_public_interface(self):
76
expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
77
self.test_list(expected_path=expected_path, interface=interface)
79
def test_list_admin_interface(self):
81
expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
82
self.test_list(expected_path=expected_path, interface=interface)
84
def test_list_internal_interface(self):
86
expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
87
self.test_list(expected_path=expected_path, interface=interface)
89
def test_list_invalid_interface(self):
90
interface = uuid.uuid4().hex
91
expected_path = 'v3/%s?interface=%s' % (self.collection_key, interface)
92
self.assertRaises(exceptions.ValidationError, self.manager.list,
93
expected_path=expected_path, interface=interface)