From: tierno Date: Wed, 15 Jan 2020 14:41:48 +0000 (+0000) Subject: Allow to disable /test URL X-Git-Tag: v7.0.1rc2~4 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=4836bacc5a3ef89cff93fd47240496baeb3c66ca;p=osm%2FNBI.git Allow to disable /test URL Change-Id: I01b2a4836ab66ff5cdca72d1a0637d83e0a5b9fb Signed-off-by: tierno --- diff --git a/Dockerfile.local b/Dockerfile.local index 4d62b62..a6658a8 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -73,6 +73,8 @@ ENV OSMNBI_STATIC_DIR /app/NBI/osm_nbi/html_public # logs # ENV OSMNBI_LOG_FILE /app/log/nbi.log ENV OSMNBI_LOG_LEVEL DEBUG +# ENV OSMNBI_SERVER_ENABLE_TEST False + # message ENV OSMNBI_MESSAGE_DRIVER kafka ENV OSMNBI_MESSAGE_HOST kafka diff --git a/osm_nbi/nbi.cfg b/osm_nbi/nbi.cfg index b8db711..94d3b26 100644 --- a/osm_nbi/nbi.cfg +++ b/osm_nbi/nbi.cfg @@ -44,6 +44,9 @@ server.thread_pool: 10 # Uncomment for allow basic authentication apart from bearer # auth.allow_basic_authentication: True +# comment or set to False to disable /test URL +server.enable_test: True + log.screen: False log.access_file: "" log.error_file: "" diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 5b16544..66105d6 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -716,6 +716,10 @@ class Server(object): @cherrypy.expose def test(self, *args, **kwargs): + if not cherrypy.config.get("server.enable_test") or (isinstance(cherrypy.config["server.enable_test"], str) and + cherrypy.config["server.enable_test"].lower() == "false"): + cherrypy.response.status = HTTPStatus.METHOD_NOT_ALLOWED.value + return "test URL is disabled" thread_info = None if args and args[0] == "help": return "
\ninit\nfile/  download file\ndb-clear/table\nfs-clear[/folder]\nlogin\nlogin2\n"\