From: Adurti Date: Mon, 25 Mar 2024 08:21:36 +0000 (+0000) Subject: Bug 2356 Fixed: Able to update User with same project and role multiple times X-Git-Tag: v14.0.3~5 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=ee5dbd1689c9b84f94d842ad88824302bb895ca4;p=osm%2FNBI.git Bug 2356 Fixed: Able to update User with same project and role multiple times Change-Id: I1d010d4b1e27d20322d17731a190c85f8448c543 Signed-off-by: Adurti Signed-off-by: garciadeblas --- diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index ec2bba4..768820f 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -1124,6 +1124,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 (