2360 Fixed Able to update user with Invalid Role 55/15055/1
authorjegan <jegan.s@tataelxsi.co.in>
Sun, 31 Mar 2024 07:39:39 +0000 (07:39 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 20 Mar 2025 14:45:30 +0000 (15:45 +0100)
Change-Id: Id0a5f85ef101e2e04e52f36f775aa3c30a19ba2a
Signed-off-by: jegan <jegan.s@tataelxsi.co.in>
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_nbi/admin_topics.py

index 7c6ad9c..ae54261 100644 (file)
@@ -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", ()):