Bug 2356 Fixed: Able to update User with same project and role multiple times 73/14273/4
authorAdurti <adurti.v@tataelxsi.co.in>
Mon, 25 Mar 2024 08:21:36 +0000 (08:21 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 13 Dec 2024 08:30:41 +0000 (09:30 +0100)
Change-Id: I1d010d4b1e27d20322d17731a190c85f8448c543
Signed-off-by: Adurti <adurti.v@tataelxsi.co.in>
osm_nbi/admin_topics.py

index 0803ad6..b4f8980 100644 (file)
@@ -1159,6 +1159,15 @@ class UserTopicAuth(UserTopic):
 
             # set
             if indata.get("project_role_mappings"):
+                duplicates = []
+                for pr in indata.get("project_role_mappings"):
+                    if pr not in duplicates:
+                        duplicates.append(pr)
+                if len(indata.get("project_role_mappings")) > len(duplicates):
+                    raise EngineException(
+                        "Project-role combination should not be repeated",
+                        http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
+                    )
                 for to_set in indata["project_role_mappings"]:
                     for mapping in original_mapping:
                         if to_set["project"] in (