Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
 def test_dict_to_tuple(self):
     """ get_dict_as_tuple """
     self.assertEqual(utils.get_dict_as_tuple({'a': 'b'}), ('a', 'b'))
Esempio n. 4
0
 def test_dict_to_tuple(self):
     """ get_dict_as_tuple """
     self.assertEqual(
         utils.get_dict_as_tuple({'a':'b'}),
         ('a', 'b')
     )