From 4836bacc5a3ef89cff93fd47240496baeb3c66ca Mon Sep 17 00:00:00 2001 From: tierno Date: Wed, 15 Jan 2020 14:41:48 +0000 Subject: [PATCH] Allow to disable /test URL Change-Id: I01b2a4836ab66ff5cdca72d1a0637d83e0a5b9fb Signed-off-by: tierno --- Dockerfile.local | 2 ++ osm_nbi/nbi.cfg | 3 +++ osm_nbi/nbi.py | 4 ++++ 3 files changed, 9 insertions(+) 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"\
-- 
2.17.1