X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fadmin_topics.py;h=ada9c7b11502fc5ce67dc78cf9a663f40d8f467b;hp=e887afb3bb310762c5b5c74b7177236b0f352cac;hb=79e40f41887cbc1e56f4b7c3518314952985fa51;hpb=1459d60ec7966fd38be44d44042f8c3f65bcdc9a diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index e887afb..ada9c7b 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -780,7 +780,7 @@ class ProjectTopicAuth(ProjectTopic): project_name = edit_content.get("name") if project_name != final_content["name"]: # It is a true renaming if is_valid_uuid(project_name): - raise EngineException("project name '{}' cannot have an uuid format".format(project_name), + raise EngineException("project name '{}' cannot have an uuid format".format(project_name), HTTPStatus.UNPROCESSABLE_ENTITY) if final_content["name"] == "admin": @@ -1011,6 +1011,11 @@ class RoleTopicAuth(BaseTopic): :param indata: data to be inserted :return: None or raises EngineException """ + # check name is not uuid + role_name = indata.get("name") + if is_valid_uuid(role_name): + raise EngineException("role name '{}' cannot have an uuid format".format(role_name), + HTTPStatus.UNPROCESSABLE_ENTITY) # check name not exists name = indata["name"] # if self.db.get_one(self.topic, {"name": indata.get("name")}, fail_on_empty=False, fail_on_more=False): @@ -1032,6 +1037,17 @@ class RoleTopicAuth(BaseTopic): if "admin" not in final_content["permissions"]: final_content["permissions"]["admin"] = False + # check name is not uuid + role_name = edit_content.get("name") + if is_valid_uuid(role_name): + raise EngineException("role name '{}' cannot have an uuid format".format(role_name), + HTTPStatus.UNPROCESSABLE_ENTITY) + + # Check renaming of admin roles + role = self.auth.get_role(_id) + if role["name"] in ["system_admin", "project_admin"]: + raise EngineException("You cannot rename role '{}'".format(role["name"]), http_code=HTTPStatus.FORBIDDEN) + # check name not exists if "name" in edit_content: role_name = edit_content["name"]