From c768937d5bb7b31e827aca36c9ab8c3cf1fdb34b Mon Sep 17 00:00:00 2001 From: Eduardo Sousa Date: Tue, 4 Jun 2019 16:01:46 +0100 Subject: [PATCH] Fixing bug 732 Change-Id: I43b5bbe3aa9b615c40ef72c9faa9e4fd7ffd724f Signed-off-by: Eduardo Sousa --- osm_nbi/admin_topics.py | 8 ++++---- osm_nbi/nbi.py | 1 - osm_nbi/validation.py | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index fd4d0e9..968788a 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -656,7 +656,7 @@ class ProjectTopicAuth(ProjectTopic): """ projects = self.auth.get_project_list() current_project = [project for project in projects - if project["name"] == session["project_id"]][0] + if project["name"] in session["project_id"]][0] if _id == current_project["_id"]: raise EngineException("You cannot delete your own project", http_code=HTTPStatus.CONFLICT) @@ -761,12 +761,12 @@ class RoleTopicAuth(BaseTopic): for role_def in role_definitions.keys(): if role_def in ignore_fields: continue - if role_def == ".": + if role_def == "root": if isinstance(role_definitions[role_def], bool): continue else: raise ValidationError("Operation authorization \".\" should be True/False.") - if role_def[-1] == ".": + if role_def[-1] == ":": raise ValidationError("Operation cannot end with \".\"") role_def_matches = [op for op in operations if op.startswith(role_def)] @@ -831,7 +831,7 @@ class RoleTopicAuth(BaseTopic): """ roles = self.auth.get_role_list() system_admin_role = [role for role in roles - if roles["name"] == "system_admin"][0] + if role["name"] == "system_admin"][0] if _id == system_admin_role["_id"]: raise EngineException("You cannot edit system_admin role", http_code=HTTPStatus.FORBIDDEN) diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 20e0520..cc56984 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -217,7 +217,6 @@ class Server(object): "": {"METHODS": ("GET", "POST", "DELETE", "PATCH", "PUT")} }, "projects": {"METHODS": ("GET", "POST"), - # Added PUT to allow Project Name modification "": {"METHODS": ("GET", "DELETE", "PUT")} }, "roles": {"METHODS": ("GET", "POST"), diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index f6c90c1..acb53c0 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -648,8 +648,9 @@ roles_new_schema = { "type": "object", "properties": { "name": shortname_schema, + "root": bool_schema, }, - "required": ["name"], + "required": ["name", "root"], "additionalProperties": True } roles_edit_schema = { @@ -657,10 +658,9 @@ roles_edit_schema = { "title": "Roles edit schema for administrators", "type": "object", "properties": { - "_id": id_schema, - "name": shortname_schema, + "root": bool_schema, }, - "required": ["_id", "name"], + "required": ["root"], "additionalProperties": True, "minProperties": 1 } -- 2.25.1