From dab82680003368d358df501fddc5a8c03561664e Mon Sep 17 00:00:00 2001 From: rohitsakala Date: Thu, 16 Feb 2017 13:22:05 +0530 Subject: Add token based authentication for post/update/delete As the mongodb database is not so secure today, this has been added. The token is stored in the mongoDB database. For now, authenticate variable is set false so that there would be no problem in accessing the databse by jenkins jobs. JIRA: FUNCTEST-730 Change-Id: I12b3907d650fc63efbdb031ebf3dd09519750109 Signed-off-by: rohitsakala --- testapi/opnfv_testapi/common/config.py | 5 +++++ testapi/opnfv_testapi/common/constants.py | 1 + 2 files changed, 6 insertions(+) (limited to 'testapi/opnfv_testapi/common') diff --git a/testapi/opnfv_testapi/common/config.py b/testapi/opnfv_testapi/common/config.py index 82d9c4d..84a1273 100644 --- a/testapi/opnfv_testapi/common/config.py +++ b/testapi/opnfv_testapi/common/config.py @@ -34,6 +34,7 @@ class APIConfig: self.mongo_dbname = None self.api_port = None self.api_debug_on = None + self.api_authenticate_on = None self._parser = None self.swagger_base_url = None @@ -77,6 +78,9 @@ class APIConfig: obj.api_port = obj._get_int_parameter("api", "port") obj.api_debug_on = obj._get_bool_parameter("api", "debug") + obj.api_authenticate_on = obj._get_bool_parameter("api", + "authenticate") + obj.swagger_base_url = obj._get_parameter("swagger", "base_url") return obj @@ -90,4 +94,5 @@ class APIConfig: self.mongo_dbname, self.api_port, self.api_debug_on, + self.api_authenticate_on, self.swagger_base_url) diff --git a/testapi/opnfv_testapi/common/constants.py b/testapi/opnfv_testapi/common/constants.py index 4d39a14..71bd952 100644 --- a/testapi/opnfv_testapi/common/constants.py +++ b/testapi/opnfv_testapi/common/constants.py @@ -10,6 +10,7 @@ DEFAULT_REPRESENTATION = "application/json" HTTP_BAD_REQUEST = 400 +HTTP_UNAUTHORIZED = 401 HTTP_FORBIDDEN = 403 HTTP_NOT_FOUND = 404 HTTP_OK = 200 -- cgit 1.2.3-korg