Example #1
0
def run_one(test_id, flows, profile, profiles, io, sh, **kw_args):
    try:
        redirs = kw_args["cinfo"]["client"]["redirect_uris"]
    except KeyError:
        redirs = kw_args["cinfo"]["registered"]["redirect_uris"]

    io = ClIO(flows=flows, profile=profile, **kw_args)
    sh = SessionHandler(None, profile, flows, **kw_args)

    _flow = flows[test_id]
    _cli = make_client(**kw_args)
    conversation = Conversation(
        _flow,
        _cli,
        kw_args["msg_factory"],
        interaction=kw_args["conf"].INTERACTION,
        trace_cls=Trace,
        callback_uris=redirs,
    )
    # noinspection PyTypeChecker
    try:
        run_flow(profiles, conversation, test_id, kw_args["conf"], profile, kw_args["check_factory"], io, sh)
    except Exception as err:
        exception_trace("", err, logger)
        print(conversation.trace)
Example #2
0
def application(environ, start_response):
    session = environ['beaker.session']
    path = environ.get('PATH_INFO', '').lstrip('/')

    try:
        _cli = session["client"]
    except KeyError:
        _cli = session["client"] = make_client(**KW_ARGS)
        session["done"] = []

    _flows = KW_ARGS["flows"]

    if path == "robots.txt":
        return static(environ, start_response, "static/robots.txt")
    elif path.startswith("static/"):
        return static(environ, start_response, path)
    elif path.startswith("export/"):
        return static(environ, start_response, path)

    if path == "":  # list
        session["done"] = []
        session["flows"] = make_list(**KW_ARGS)
        return flow_list(environ, start_response,
                         node_dict(_flows, session["flows"]), session["done"])
    elif path in list(_flows.keys()):
        try:
            redirs = KW_ARGS["cinfo"]["client"]["redirect_uris"]
        except KeyError:
            redirs = KW_ARGS["cinfo"]["registered"]["redirect_uris"]

        conversation = Conversation(_flows[path], _cli, redirs)
        session["rf_args"] = {
            "profiles": KW_ARGS["profiles"],
            "test_id": path,
            "conv": conversation,
            "conf": KW_ARGS["conf"],
            "profile": KW_ARGS["profile"]
        }

        try:
            resp = run_flow(**session["rf_args"])
        except Exception as err:
            resp = ServiceError("%s" % err)
            return resp(environ, start_response)
        else:
            if resp:
                return resp(environ, start_response)
            else:
                session["done"].append(path)
                return flow_list(environ, start_response,
                                 node_dict(_flows, session["flows"]),
                                 session["done"])
    else:
        logger.debug("unknown side: %s" % path)
        resp = NotFound("Couldn't find the side you asked for!")
        return resp(environ, start_response)
Example #3
0
def application(environ, start_response):
    session = environ['beaker.session']
    path = environ.get('PATH_INFO', '').lstrip('/')

    try:
        _cli = session["client"]
    except KeyError:
        _cli = session["client"] = make_client(**KW_ARGS)
        session["done"] = []

    _flows = KW_ARGS["flows"]

    if path == "robots.txt":
        return static(environ, start_response, "static/robots.txt")
    elif path.startswith("static/"):
        return static(environ, start_response, path)
    elif path.startswith("export/"):
        return static(environ, start_response, path)

    if path == "":  # list
        session["done"] = []
        session["flows"] = make_list(**KW_ARGS)
        return flow_list(environ, start_response,
                         node_dict(_flows, session["flows"]),
                         session["done"])
    elif path in list(_flows.keys()):
        try:
            redirs = KW_ARGS["cinfo"]["client"]["redirect_uris"]
        except KeyError:
            redirs = KW_ARGS["cinfo"]["registered"]["redirect_uris"]

        conversation = Conversation(_flows[path], _cli, redirs)
        session["rf_args"] = {
            "profiles": KW_ARGS["profiles"], "test_id": path,
            "conv": conversation, "conf": KW_ARGS["conf"],
            "profile": KW_ARGS["profile"]}

        try:
            resp = run_flow(**session["rf_args"])
        except Exception as err:
            resp = ServiceError("%s" % err)
            return resp(environ, start_response)
        else:
            if resp:
                return resp(environ, start_response)
            else:
                session["done"].append(path)
                return flow_list(environ, start_response,
                                 node_dict(_flows, session["flows"]),
                                 session["done"])
    else:
        logger.debug("unknown side: %s" % path)
        resp = NotFound("Couldn't find the side you asked for!")
        return resp(environ, start_response)
Example #4
0
def main(flows, profile, profiles, **kw_args):
    try:
        redirs = kw_args["cinfo"]["client"]["redirect_uris"]
    except KeyError:
        redirs = kw_args["cinfo"]["registered"]["redirect_uris"]

    test_list = make_list(flows, profile, **kw_args)

    for tid in test_list:
        _flow = flows[tid]
        _cli = make_client(**kw_args)
        conversation = Conversation(_flow, _cli, redirs)
        # noinspection PyTypeChecker
        run_flow(profiles, conversation, tid, kw_args["conf"], profile)
        print conversation.trace
Example #5
0
def main(flows, profile, profiles, **kw_args):
    try:
        redirs = kw_args["cinfo"]["client"]["redirect_uris"]
    except KeyError:
        redirs = kw_args["cinfo"]["registered"]["redirect_uris"]

    test_list = make_list(flows, profile, **kw_args)

    for tid in test_list:
        io = ClIO(flows=flows, profile=profile, **kw_args)
        sh = SessionHandler(profile, flows, **kw_args)

        _flow = flows[tid]
        _cli, _cliconf = make_client(**kw_args)
        conversation = Conversation(
            _flow,
            _cli,
            kw_args["msg_factory"],
            interaction=kw_args["conf"].INTERACTION,
            trace_cls=Trace,
            callback_uris=redirs,
        )

        _cli.conv = conversation
        # noinspection PyTypeChecker
        try:
            info = run_flow(profiles, conversation, tid, kw_args["conf"], profile, kw_args["check_factory"], io, sh)
            if info["status"] == OK:
                print("+{}".format(tid))
            else:
                print("!{}".format(tid))
                for ev in conversation.events:
                    print(ev)
                break
        except Exception as err:
            exception_trace("", err, logger)
            print(conversation.trace)
            break
Example #6
0
def main(flows, profile, profiles, **kw_args):
    try:
        redirs = kw_args["cinfo"]["client"]["redirect_uris"]
    except KeyError:
        redirs = kw_args["cinfo"]["registered"]["redirect_uris"]

    test_list = make_list(flows, profile, **kw_args)

    for tid in test_list:
        io = ClIO(flows=flows, profile=profile, **kw_args)
        sh = SessionHandler(profile, flows, **kw_args)

        _flow = flows[tid]
        _cli, _cliconf = make_client(**kw_args)
        conversation = Conversation(_flow,
                                    _cli,
                                    kw_args["msg_factory"],
                                    interaction=kw_args["conf"].INTERACTION,
                                    trace_cls=Trace,
                                    callback_uris=redirs)

        _cli.conv = conversation
        # noinspection PyTypeChecker
        try:
            info = run_flow(profiles, conversation, tid, kw_args["conf"],
                            profile, kw_args["check_factory"], io, sh)
            if info['status'] == OK:
                print('+{}'.format(tid))
            else:
                print('!{}'.format(tid))
                for ev in conversation.events:
                    print(ev)
                break
        except Exception as err:
            exception_trace("", err, logger)
            print(conversation.trace)
            break
Example #7
0
def run_one(test_id, flows, profile, profiles, io, sh, **kw_args):
    try:
        redirs = kw_args["cinfo"]["client"]["redirect_uris"]
    except KeyError:
        redirs = kw_args["cinfo"]["registered"]["redirect_uris"]

    io = ClIO(flows=flows, profile=profile, **kw_args)
    sh = SessionHandler(None, profile, flows, **kw_args)

    _flow = flows[test_id]
    _cli = make_client(**kw_args)
    conversation = Conversation(_flow,
                                _cli,
                                kw_args["msg_factory"],
                                interaction=kw_args["conf"].INTERACTION,
                                trace_cls=Trace,
                                callback_uris=redirs)
    # noinspection PyTypeChecker
    try:
        run_flow(profiles, conversation, test_id, kw_args["conf"], profile,
                 kw_args["check_factory"], io, sh)
    except Exception as err:
        exception_trace("", err, logger)
        print(conversation.trace)