def __call__(self, req): """ apply security info for a request. :param SwaggerRequest req: the request to be authorized. :return: the updated request :rtype: SwaggerRequest """ if not req._security: return req for s in req._security: for k, v in six.iteritems(s): if not k in self.__info: logger.info('missing: [{0}]'.format(k)) continue logger.info('applying: [{0}]'.format(k)) header, cred = self.__info[k] if header: req._p['header'].update(cred) else: utils.nv_tuple_list_replace(req._p['query'], utils.get_dict_as_tuple(cred)) return req
def __call__(self, req): """ apply security info for a request. :param Request req: the request to be authorized. :return: the updated request :rtype: Request """ if not req._security: return req for s in req._security: for k, v in six.iteritems(s): if not k in self.__info: logger.info('missing: [{0}]'.format(k)) continue logger.info('applying: [{0}]'.format(k)) header, cred = self.__info[k] if header: req._p['header'].update(cred) else: utils.nv_tuple_list_replace(req._p['query'], utils.get_dict_as_tuple(cred)) return req
def test_nv_tuple_list_replace(self): """ nv_tuple_list_replace """ d = [(1, 1), (2, 2), (3, 3)] utils.nv_tuple_list_replace(d, (1, 4)) self.assertEqual(d, [(1, 4), (2, 2), (3, 3)]) utils.nv_tuple_list_replace(d, (4, 4)) self.assertEqual(d, [(1, 4), (2, 2), (3, 3), (4, 4)])
def test_nv_tuple_list_replace(self): """ nv_tuple_list_replace """ d = [ (1, 1), (2, 2), (3, 3) ] utils.nv_tuple_list_replace(d, (1, 4)) self.assertEqual(d, [ (1, 4), (2, 2), (3, 3) ]) utils.nv_tuple_list_replace(d, (4, 4)) self.assertEqual(d, [ (1, 4), (2, 2), (3, 3), (4, 4) ])