diff options
Diffstat (limited to 'testapi/opnfv_testapi/handlers')
4 files changed, 22 insertions, 72 deletions
diff --git a/testapi/opnfv_testapi/handlers/base_handlers.py b/testapi/opnfv_testapi/handlers/base_handlers.py index 9eac737..3dbd53a 100644 --- a/testapi/opnfv_testapi/handlers/base_handlers.py +++ b/testapi/opnfv_testapi/handlers/base_handlers.py @@ -79,8 +79,8 @@ class GenericApiHandler(web.RequestHandler): @check.valid_token @check.no_body @check.miss_fields - @check.new_not_exists @check.is_authorized + @check.new_not_exists @check.values_check @check.carriers_exist def _create(self, **kwargs): @@ -179,6 +179,7 @@ class GenericApiHandler(web.RequestHandler): @gen.coroutine @check.not_exist @check.is_authorized + @check.is_reource_tied def _delete(self, data, query=None): yield dbapi.db_delete(self.table, query) self.finish_request() @@ -189,6 +190,7 @@ class GenericApiHandler(web.RequestHandler): @check.not_exist @check.updated_one_not_exist @check.is_authorized + @check.is_reource_tied def _update(self, data, query=None, **kwargs): data = self.table_cls.from_dict(data) update_req = self._update_requests(data) @@ -200,6 +202,7 @@ class GenericApiHandler(web.RequestHandler): @gen.coroutine @check.no_body @check.not_exist + @check.is_authorized @check.updated_one_not_exist def pure_update(self, data, query=None, **kwargs): data = self.table_cls.from_dict(data) diff --git a/testapi/opnfv_testapi/handlers/deploy_result_handlers.py b/testapi/opnfv_testapi/handlers/deploy_result_handlers.py index 973bfef..a8fcd88 100644 --- a/testapi/opnfv_testapi/handlers/deploy_result_handlers.py +++ b/testapi/opnfv_testapi/handlers/deploy_result_handlers.py @@ -1,6 +1,7 @@ from opnfv_testapi.handlers import result_handlers from opnfv_testapi.models import deploy_result_models from opnfv_testapi.tornado_swagger import swagger +from bson import objectid class GenericDeployResultHandler(result_handlers.GenericResultHandler): @@ -113,3 +114,17 @@ class DeployResultsHandler(GenericDeployResultHandler): self._create(miss_fields=miss_fields, carriers=carriers, values_check=values_check) + + +class DeployResultHandler(GenericDeployResultHandler): + @swagger.operation(nickname='getTestDeployResultById') + def get(self, result_id): + """ + @description: get a single deploy result by result_id + @rtype: L{DeployResult} + @return 200: Deploy result exist + @raise 404: Deploy result not exist + """ + query = dict() + query["_id"] = objectid.ObjectId(result_id) + self._get_one(query=query) diff --git a/testapi/opnfv_testapi/handlers/result_handlers.py b/testapi/opnfv_testapi/handlers/result_handlers.py index b0691cd..edcac6e 100644 --- a/testapi/opnfv_testapi/handlers/result_handlers.py +++ b/testapi/opnfv_testapi/handlers/result_handlers.py @@ -8,12 +8,9 @@ ############################################################################## from datetime import datetime from datetime import timedelta -import json -import logging from bson import objectid -from opnfv_testapi.common import constants from opnfv_testapi.common import message from opnfv_testapi.common import raises from opnfv_testapi.common.config import CONF @@ -41,7 +38,6 @@ class GenericResultHandler(base_handlers.GenericApiHandler): query = dict() date_range = dict() - query['public'] = {'$not': {'$eq': 'false'}} for k in self.request.query_arguments.keys(): v = self.get_query_argument(k) if k == 'project' or k == 'pod' or k == 'case': @@ -52,21 +48,12 @@ class GenericResultHandler(base_handlers.GenericApiHandler): period = datetime.now() - timedelta(days=v) obj = {"$gte": str(period)} query['start_date'] = obj - elif k == 'trust_indicator': - query[k + '.current'] = float(v) elif k == 'from': date_range.update({'$gte': str(v)}) elif k == 'to': date_range.update({'$lt': str(v)}) elif 'build_id' in k: query[k] = self.get_int(k, v) - elif k == 'signed': - username = self.get_secure_cookie(constants.TESTAPI_ID) - role = self.get_secure_cookie(constants.ROLE) - if role: - del query['public'] - if role != "reviewer": - query['user'] = username elif k not in ['last', 'page', 'descend']: query[k] = v if date_range: @@ -119,12 +106,9 @@ class ResultsCLHandler(GenericResultHandler): - to : ending time in 2016-01-01 or 2016-01-01 00:01:23 - scenario : the test scenario (previously version) - criteria : the global criteria status passed or failed - - trust_indicator : evaluate the stability of the test case - to avoid running systematically long and stable test case - - signed : get logined user result GET /results/project=functest&case=vPing&version=Arno-R1 \ - &pod=pod_name&period=15&signed + &pod=pod_name&period=15 @return 200: all test results consist with query, empty list if no result is found @rtype: L{TestResults} @@ -180,14 +164,6 @@ class ResultsCLHandler(GenericResultHandler): @type page: L{int} @in page: query @required page: False - @param trust_indicator: must be float - @type trust_indicator: L{float} - @in trust_indicator: query - @required trust_indicator: False - @param signed: user results or all results - @type signed: L{string} - @in signed: query - @required signed: False @param descend: true, newest2oldest; false, oldest2newest @type descend: L{string} @in descend: query @@ -231,36 +207,8 @@ class ResultsCLHandler(GenericResultHandler): values_check=values_check) -class ResultsUploadHandler(ResultsCLHandler): - @swagger.operation(nickname="uploadTestResult") - def post(self): - """ - @description: upload and create a test result - @param body: result to be created - @type body: L{ResultCreateRequest} - @in body: body - @rtype: L{CreateResponse} - @return 200: result is created. - @raise 404: pod/project/testcase not exist - @raise 400: body/pod_name/project_name/case_name not provided - """ - logging.info('file upload') - fileinfo = self.request.files['file'][0] - is_public = self.get_body_argument('public') - logging.warning('public:%s', is_public) - logging.info('results is :%s', fileinfo['filename']) - logging.info('results is :%s', fileinfo['body']) - self.json_args = json.loads(fileinfo['body']).copy() - self.json_args['public'] = is_public - - openid = self.get_secure_cookie(constants.TESTAPI_ID) - if openid: - self.json_args['user'] = openid - - super(ResultsUploadHandler, self).post() - - class ResultsGURHandler(GenericResultHandler): + @swagger.operation(nickname='getTestResultById') def get(self, result_id): """ @@ -272,19 +220,3 @@ class ResultsGURHandler(GenericResultHandler): query = dict() query["_id"] = objectid.ObjectId(result_id) self._get_one(query=query) - - @swagger.operation(nickname="updateTestResultById") - def put(self, result_id): - """ - @description: update a single result by _id - @param body: fields to be updated - @type body: L{ResultUpdateRequest} - @in body: body - @rtype: L{Result} - @return 200: update success - @raise 404: result not exist - @raise 403: nothing to update - """ - query = {'_id': objectid.ObjectId(result_id)} - db_keys = [] - self._update(query=query, db_keys=db_keys) diff --git a/testapi/opnfv_testapi/handlers/sign_handlers.py b/testapi/opnfv_testapi/handlers/sign_handlers.py index 7540662..2039971 100644 --- a/testapi/opnfv_testapi/handlers/sign_handlers.py +++ b/testapi/opnfv_testapi/handlers/sign_handlers.py @@ -46,7 +46,7 @@ class SigninReturnHandler(SignBaseHandler): dbapi.db_update(self.table, q_user, login_user) self.clear_cookie(constants.TESTAPI_ID) - self.set_secure_cookie(constants.TESTAPI_ID, user) + self.set_secure_cookie(constants.TESTAPI_ID, user, 1) self.redirect(url=CONF.ui_url) |