From 7a13dabbedff1184c12e3e4f5cf56545f1d01397 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam Date: Tue, 20 Oct 2020 07:34:42 +0530 Subject: Fix the format issues Issue-ID: DOVETAIL-801 Signed-off-by: Kanagaraj Manickam Change-Id: Id0058788d8d2d8fb8a1fa0a7c43fc3c1731d73df --- opnfv_testapi/resources/result_handlers.py | 4 ++-- opnfv_testapi/resources/test_handlers.py | 3 ++- opnfv_testapi/router/url_mappings.py | 3 ++- opnfv_testapi/ui/auth/sign.py | 12 ++++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) (limited to 'opnfv_testapi') diff --git a/opnfv_testapi/resources/result_handlers.py b/opnfv_testapi/resources/result_handlers.py index df8b988..7a0c10d 100644 --- a/opnfv_testapi/resources/result_handlers.py +++ b/opnfv_testapi/resources/result_handlers.py @@ -382,7 +382,7 @@ class ResultsGURHandler(GenericResultHandler): db_keys = [] self._update(query=query, db_keys=db_keys) -#Api for results upload + class ResultsFileUploadHandler(ResultsCLHandler): @swagger.operation(nickname="uploadTestResult") @web.asynchronous @@ -402,7 +402,7 @@ class ResultsFileUploadHandler(ResultsCLHandler): token = mc.get("token") input_token = self.request.headers._dict['Token'] if not token or not input_token == token: - raises.Unauthorized(message.invalid_token()) + raises.Unauthorized(message.invalid_token()) file_array = self.request.files.get('file', None) if file_array is None: msg = 'Please upload a file.' diff --git a/opnfv_testapi/resources/test_handlers.py b/opnfv_testapi/resources/test_handlers.py index 1dbc4cd..ed2a303 100644 --- a/opnfv_testapi/resources/test_handlers.py +++ b/opnfv_testapi/resources/test_handlers.py @@ -361,7 +361,8 @@ class TestsGURHandler(GenericTestHandler): logging.debug('not found') raise gen.Return((False, message.no_auth())) raise gen.Return((True, {})) -#updated new test appi + + class TestsUploadDataHandler(GenericTestHandler): @swagger.operation(nickname="queryTests") @web.asynchronous diff --git a/opnfv_testapi/router/url_mappings.py b/opnfv_testapi/router/url_mappings.py index b9e8dd9..d105c20 100644 --- a/opnfv_testapi/router/url_mappings.py +++ b/opnfv_testapi/router/url_mappings.py @@ -74,7 +74,8 @@ onap_mappings = [ (r'/api/v1/onap/cvp/applications', application_handlers.ApplicationsCLHandler, dict(is_onap=True)), (r'/api/v1/onap/reviews', review_handlers.ReviewsCLHandler), - (r'/api/v1/onap/results/upload/data', result_handlers.ResultsFileUploadHandler, + (r'/api/v1/onap/results/upload/data', + result_handlers.ResultsFileUploadHandler, dict(is_onap=True)), (r'/api/v1/onap/tests/upload/data', test_handlers.TestsUploadDataHandler, dict(is_onap=True)), diff --git a/opnfv_testapi/ui/auth/sign.py b/opnfv_testapi/ui/auth/sign.py index 80f7e33..42f292e 100644 --- a/opnfv_testapi/ui/auth/sign.py +++ b/opnfv_testapi/ui/auth/sign.py @@ -309,12 +309,15 @@ class LoginHandler(base.BaseHandler): "form_id": form_id, } headers = {'Content-Type': 'application/x-www-form-urlencoded'} - response = requests.post('https://identity.linuxfoundation.org', - data=params, headers=headers) + response = requests.post( + 'https://identity.linuxfoundation.org', + data=params, + headers=headers + ) response_text = response.content if "unrecognized username or password" in response_text: raises.Unauthorized(message.invalid_credentials()) - #generate random token and store in memcache + # generate random token and store in memcache token = base.get_token() resp = {'status': 'success'} mc = memcache.Client(['127.0.0.1:11211'], debug=0) @@ -322,12 +325,13 @@ class LoginHandler(base.BaseHandler): self.set_header("token", token) self.finish_request(resp) + class LogoutHandler(base.BaseHandler): def post(self): input_token = self.request.headers._dict['Token'] mc = memcache.Client(['127.0.0.1:11211'], debug=0) token = mc.get("token") - if not token or not input_token == token : + if not token or not input_token == token: raises.Unauthorized(message.invalid_token()) mc.set("token", '') resp = {'Message': 'You have been logged out successfully.'} -- cgit 1.2.3-korg