From: jegan Date: Sun, 31 Mar 2024 07:39:39 +0000 (+0000) Subject: 2360 Fixed Able to update user with Invalid Role X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=350bf4f13782e5b6582a8454148a8d83fd200383;p=osm%2FNBI.git 2360 Fixed Able to update user with Invalid Role Change-Id: Id0a5f85ef101e2e04e52f36f775aa3c30a19ba2a Signed-off-by: jegan Signed-off-by: garciadeblas --- diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 7c6ad9c..ae54261 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -1124,6 +1124,21 @@ class UserTopicAuth(UserTopic): mapping["role_name"], ): mappings_to_remove.append(mapping) + if len(original_mapping) == 0 or len(mappings_to_remove) == 0: + pid = self.auth.get_project(to_remove["project"])["_id"] + if to_remove.get("role"): + rid = self.auth.get_role(to_remove["role"])["_id"] + + raise AuthconnNotFoundException( + "User is not mapped with project '{}' or role '{}'".format( + to_remove["project"], to_remove["role"] + ) + ) + raise AuthconnNotFoundException( + "User is not mapped with project '{}'".format( + to_remove["project"] + ) + ) # add for to_add in indata.get("add_project_role_mappings", ()):