Exemplo n.º 1
0
    def auth_verify(environ, start_response, logger):
        kwargs = extract_from_request(environ)

        response, auth_is_complete = callback(**kwargs)

        if auth_is_complete and next_module_instance:
            response = next_module_instance(**kwargs)

        return response(environ, start_response)
Exemplo n.º 2
0
    def auth_verify(environ, start_response, logger=None):
        kwargs = extract_from_request(environ)

        response, auth_is_complete = callback(**kwargs)

        if auth_is_complete and next_module_instance:
            response = next_module_instance(**kwargs)

        return response(environ, start_response)
Exemplo n.º 3
0
def wsgi_wrapper(func, **kwargs):
    kwargs = extract_from_request(request.environ, kwargs)
    args = func(**kwargs)

    try:
        resp, state = args
        return resp
    except TypeError:
        resp = args
        return resp
    except Exception as err:
        LOGGER.error("%s" % err)
        raise
Exemplo n.º 4
0
def wsgi_wrapper(environ, start_response, func, session_info, events, jlog):
    kwargs = extract_from_request(environ)

    kwargs['test_cnf'] = session_info['test_conf']
    try:
        oos = kwargs['test_cnf']['out_of_scope']
    except KeyError:
        pass
    else:
        if func.__name__ in oos:
            resp = error_response(
                error='incorrect_behavior',
                descr='You should not talk to this endpoint in this test')
            resp.add_header(CORS_HEADERS)
            return resp(environ, start_response)

    events.store(EV_REQUEST_ARGS, kwargs["request"])
    jlog.info({'operation': func.__name__, 'kwargs': kwargs})
    try:
        args = func(**kwargs)
    except Exception as err:
        events.store(EV_EXCEPTION, err)
        raise

    try:
        resp, state = args
        jlog.info({'response_from': func.__name__, 'response': resp2json(resp),
                   'state': state})
        events.store(EV_RESPONSE, resp.message)
        dump_log(session_info, events)
        resp.headers.extend(CORS_HEADERS)
        return resp(environ, start_response)
    except TypeError:
        resp = args
        try:
            jlog.info({'response_from': func.__name__,
                       'response': resp2json(resp)})
        except Exception:
            pass
        events.store(EV_RESPONSE, resp.message)
        dump_log(session_info, events)
        resp.headers.extend(CORS_HEADERS)
        return resp(environ, start_response)
    except Exception as err:
        jlog.error({'response_from': func.__name__, 'err': err})
        events.store(EV_EXCEPTION, err)
        dump_log(session_info, events)
        resp = ServiceError(err)
        return resp(environ, start_response)
Exemplo n.º 5
0
    def wsgi_wrapper(self, environ, func, **kwargs):
        kwargs = extract_from_request(environ, kwargs)
        self.events.store(EV_REQUEST, kwargs)
        args = func(**kwargs)

        try:
            resp, state = args
            self.store_response(resp)
            return resp
        except TypeError:
            resp = args
            self.store_response(resp)
            return resp
        except Exception as err:
            logger.error("%s" % err)
            raise
Exemplo n.º 6
0
    def wsgi_wrapper(self, environ, func, **kwargs):
        kwargs = extract_from_request(environ, kwargs)
        self.events.store(EV_REQUEST, kwargs)
        args = func(**kwargs)

        try:
            resp, state = args
            self.store_response(resp)
            return resp
        except TypeError:
            resp = args
            self.store_response(resp)
            return resp
        except Exception as err:
            logger.error("%s" % err)
            raise
Exemplo n.º 7
0
def wsgi_wrapper(environ, start_response, func, session_info, events, jlog):
    kwargs = extract_from_request(environ)

    kwargs['test_cnf'] = session_info['test_conf']
    try:
        oos = kwargs['test_cnf']['out_of_scope']
    except KeyError:
        pass
    else:
        if func.__name__ in oos:
            resp = error_response(
                error='incorrect_behavior',
                descr='You should not talk to this endpoint in this test')
            return resp(environ, start_response)

    events.store(EV_REQUEST_ARGS, kwargs["request"])
    jlog.info({'operation': func.__name__, 'kwargs': kwargs})
    args = func(**kwargs)

    try:
        resp, state = args
        jlog.info({
            'response_from': func.__name__,
            'response': resp2json(resp),
            'state': state
        })
        events.store(EV_RESPONSE, resp.message)
        dump_log(session_info, events)
        return resp(environ, start_response)
    except TypeError:
        resp = args
        jlog.info({
            'response_from': func.__name__,
            'response': resp2json(resp)
        })
        events.store(EV_RESPONSE, resp.message)
        dump_log(session_info, events)
        return resp(environ, start_response)
    except Exception as err:
        jlog.error({'response_from': func.__name__, 'err': err})
        events.store(EV_EXCEPTION, err)
        dump_log(session_info, events)
        raise
Exemplo n.º 8
0
def wsgi_wrapper(environ, start_response, func, session, trace):
    kwargs = extract_from_request(environ)
    trace.request(kwargs["request"])
    args = func(**kwargs)

    try:
        resp, state = args
        trace.reply(resp.message)
        dump_log(session, trace)
        return resp(environ, start_response)
    except TypeError:
        resp = args
        trace.reply(resp.message)
        dump_log(session, trace)
        return resp(environ, start_response)
    except Exception as err:
        LOGGER.error("%s" % err)
        trace.error("%s" % err)
        dump_log(session, trace)
        raise
Exemplo n.º 9
0
def wsgi_wrapper(environ, start_response, func, session, trace):
    kwargs = extract_from_request(environ)
    trace.request(kwargs["request"])
    args = func(**kwargs)

    try:
        resp, state = args
        trace.reply(resp.message)
        dump_log(session, trace)
        return resp(environ, start_response)
    except TypeError:
        resp = args
        trace.reply(resp.message)
        dump_log(session, trace)
        return resp(environ, start_response)
    except Exception as err:
        LOGGER.error("%s" % err)
        trace.error("%s" % err)
        dump_log(session, trace)
        raise