Skip to content

Commit fd3a94d

Browse files
josecastroleonmgariepy
authored andcommitted
Fix bug in endpoint group deletion
There is a typo in the endpoint group deletion, due to this you can't remove endpoint groups once assigned. I am adding also the unit tests to avoid this kind of issues in the future Task: 30640 Story: 2005521 Change-Id: Ie938f2c9894bb39b4c0ed1f7aa3a6a751a303058 (cherry picked from commit 04e03b2)
1 parent b507f60 commit fd3a94d

4 files changed

Lines changed: 565 additions & 3 deletions

File tree

openstackclient/identity/v3/endpoint_group.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ def take_action(self, parsed_args):
204204

205205
if endpointgroup:
206206
# List projects associated to the endpoint group
207-
columns = ('ID', 'Name')
207+
columns = ('ID', 'Name', 'Description')
208208
data = client.endpoint_filter.list_projects_for_endpoint_group(
209209
endpoint_group=endpointgroup.id)
210210
elif project:
211-
columns = ('ID', 'Name')
211+
columns = ('ID', 'Name', 'Description')
212212
data = client.endpoint_filter.list_endpoint_groups_for_project(
213213
project=project.id)
214214
else:
@@ -251,7 +251,7 @@ def take_action(self, parsed_args):
251251
parsed_args.project,
252252
parsed_args.project_domain)
253253

254-
client.endpoint_filter.delete_endpoint_group_to_project(
254+
client.endpoint_filter.delete_endpoint_group_from_project(
255255
endpoint_group=endpointgroup.id,
256256
project=project.id)
257257

openstackclient/tests/unit/identity/v3/fakes.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@
235235
'service_id': service_id,
236236
'region_id': endpoint_region,
237237
}
238+
endpoint_group_filters_2 = {
239+
'region_id': endpoint_region,
240+
}
241+
endpoint_group_file_path = '/tmp/path/to/file'
238242

239243
ENDPOINT_GROUP = {
240244
'id': endpoint_group_id,
@@ -1044,6 +1048,64 @@ def create_one_endpoint_filter(attrs=None):
10441048
return endpoint_filter
10451049

10461050

1051+
class FakeEndpointGroup(object):
1052+
"""Fake one or more endpoint group."""
1053+
1054+
@staticmethod
1055+
def create_one_endpointgroup(attrs=None):
1056+
"""Create a fake endpoint group.
1057+
1058+
:param Dictionary attrs:
1059+
A dictionary with all attributes
1060+
:return:
1061+
A FakeResource object, with id, url, and so on
1062+
"""
1063+
1064+
attrs = attrs or {}
1065+
1066+
# set default attributes.
1067+
endpointgroup_info = {
1068+
'id': 'endpoint-group-id-' + uuid.uuid4().hex,
1069+
'name': 'endpoint-group-name-' + uuid.uuid4().hex,
1070+
'filters': {
1071+
'region': 'region-' + uuid.uuid4().hex,
1072+
'service_id': 'service-id-' + uuid.uuid4().hex,
1073+
},
1074+
'description': 'endpoint-group-description-' + uuid.uuid4().hex,
1075+
'links': 'links-' + uuid.uuid4().hex,
1076+
}
1077+
endpointgroup_info.update(attrs)
1078+
1079+
endpoint = fakes.FakeResource(info=copy.deepcopy(endpointgroup_info),
1080+
loaded=True)
1081+
return endpoint
1082+
1083+
@staticmethod
1084+
def create_one_endpointgroup_filter(attrs=None):
1085+
"""Create a fake endpoint project relationship.
1086+
1087+
:param Dictionary attrs:
1088+
A dictionary with all attributes of endpointgroup filter
1089+
:return:
1090+
A FakeResource object with project, endpointgroup and so on
1091+
"""
1092+
attrs = attrs or {}
1093+
1094+
# Set default attribute
1095+
endpointgroup_filter_info = {
1096+
'project': 'project-id-' + uuid.uuid4().hex,
1097+
'endpointgroup': 'endpointgroup-id-' + uuid.uuid4().hex,
1098+
}
1099+
1100+
# Overwrite default attributes if there are some attributes set
1101+
endpointgroup_filter_info.update(attrs)
1102+
1103+
endpointgroup_filter = fakes.FakeModel(
1104+
copy.deepcopy(endpointgroup_filter_info))
1105+
1106+
return endpointgroup_filter
1107+
1108+
10471109
class FakeService(object):
10481110
"""Fake one or more service."""
10491111

0 commit comments

Comments
 (0)