Allow to disable /test URL

Change-Id: I01b2a4836ab66ff5cdca72d1a0637d83e0a5b9fb
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
diff --git a/Dockerfile.local b/Dockerfile.local
index 4d62b62..a6658a8 100644
--- a/Dockerfile.local
+++ b/Dockerfile.local
@@ -73,6 +73,8 @@
 # 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 @@
 # 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 @@
 
     @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"\