Allow to disable /test URL 82/8482/1
authortierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 15 Jan 2020 14:41:48 +0000 (14:41 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 15 Jan 2020 14:41:48 +0000 (14:41 +0000)
Change-Id: I01b2a4836ab66ff5cdca72d1a0637d83e0a5b9fb
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
Dockerfile.local
osm_nbi/nbi.cfg
osm_nbi/nbi.py

index 4d62b62..a6658a8 100644 (file)
@@ -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
index b8db711..94d3b26 100644 (file)
@@ -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: ""
index 5b16544..66105d6 100644 (file)
@@ -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 "<html><pre>\ninit\nfile/<name>  download file\ndb-clear/table\nfs-clear[/folder]\nlogin\nlogin2\n"\