コード例 #1
0
ファイル: test_setup.py プロジェクト: rohe/otest
def setup_conv():
    entity = Client(client_authn_method=CLIENT_AUTHN_METHOD,
                    verify_ssl=False)
    entity.provider_info = ProviderConfigurationResponse(
        authorization_endpoint="https://example.com",
    )

    cls_factories = {'': oper.factory}
    func_factory = func.factory

    flow_state = FlowState('flows', profile_handler=ProfileHandler,
                           cls_factories=cls_factories,
                           func_factory=func_factory,
                           display_order=OP_ORDER)
    iss = 'https://example.org'
    tag = 'foobar'
    session_handler = SessionHandler(iss, tag,
                                     flows=flow_state,
                                     tool_conf={})  # , rest=rest, **webenv)
    session_handler.iss = iss
    session_handler.tag = tag

    info = WebIh(session=session_handler, profile_handler=ProfileHandler)

    conv = Conversation([], entity, factory, callback_uris=[])
    conv.events = Events()
    conv.tool_config = {}
    return {'conv': conv, 'io': info}
コード例 #2
0
ファイル: test_setup.py プロジェクト: tpazderka/otest
def setup_conv():
    entity = Client(client_authn_method=CLIENT_AUTHN_METHOD, verify_ssl=False)
    entity.provider_info = ProviderConfigurationResponse(
        authorization_endpoint="https://example.com", )

    cls_factories = {'': oper.factory}
    func_factory = func.factory

    flow_state = FlowState('flows',
                           profile_handler=ProfileHandler,
                           cls_factories=cls_factories,
                           func_factory=func_factory,
                           display_order=OP_ORDER)
    iss = 'https://example.org'
    tag = 'foobar'
    session_handler = SessionHandler(iss, tag, flows=flow_state,
                                     tool_conf={})  # , rest=rest, **webenv)
    session_handler.iss = iss
    session_handler.tag = tag

    info = WebIh(session=session_handler, profile_handler=ProfileHandler)

    conv = Conversation([], entity, factory, callback_uris=[])
    conv.events = Events()
    conv.tool_config = {}
    return {'conv': conv, 'io': info}
コード例 #3
0
ファイル: instance.py プロジェクト: rohe/oidctest
    def new_map(self, sid=''):
        if not sid:
            sid = rndstr(16)

        op = self.provider_cls(**self.as_args)

        op.baseurl = '{}{}'.format(self.base_url, sid)
        op.name = op.baseurl

        _conv = Conversation(None, op, None)
        _conv.events = self.as_args['event_db']
        _conv.data = self.data

        sh = SessionHandler(flows=self.flows, order=self.order)
        sh.init_session(self.profile)

        self._db[sid] = {
            'op': op,
            'conv': _conv,
            'ts': time.time(),
            'selected': {},
            'session_handler': sh,
            'headlines': self.headlines
        }

        return sid
コード例 #4
0
ファイル: clrp.py プロジェクト: selfissued/oidctest
def run_return_types(test_id, oper_id, kwargs, return_types, single=True):
    for rtyp in return_types:
        kwargs['profile'] = rtyp
        kwargs['opid'] = oper_id + '_' + rtyp
        kwargs['tool_conf']['tag'] = kwargs['opid']

        sh = SessionHandler(**kwargs)
        sh.init_session(profile=rtyp)

        res = Result(sh, SimpleProfileHandler)

        io = ClIO(**kwargs)
        io.session = sh

        tester = ClTester(io, sh, **kwargs)

        if single:
            tester.run(test_id, **kwargs)

            res.store_test_info()
            res.write_info(test_id)
            return True
        else:
            if not tester.match_profile(test_id):
                continue
            elif tester.run(test_id, **kwargs):
                print('+ {}'.format(test_id))
                return True
            else:
                res = Result(sh, SimpleProfileHandler)
                res.result()
                return False
コード例 #5
0
ファイル: test_20_session.py プロジェクト: rohe/oidctest
def test_session_setup():
    sh = SessionHandler(profiles, "C.T.T.T", flow_state, oper,
                        tool_conf={'profile': 'C.T.T.T'})
    sh.session_init()
    sh.session_setup(path="OP-claims-sub")
    assert sh['testid'] == "OP-claims-sub"
    assert len(sh['sequence']) == 10
    assert sh['index'] == 0
    assert sh['flow']['group'] == 'claims Request Parameter'
コード例 #6
0
ファイル: clrp.py プロジェクト: rohe/oidctest
def run_return_types(test_id, oper_id, kwargs, return_types):
    if len(return_types) == 1:
        single = True
    else:
        single = False

    for rtyp in return_types:  # One return_type at the time
        kwargs['profile'] = rtyp
        kwargs['opid'] = oper_id + '_' + rtyp
        kwargs['tool_conf']['tag'] = kwargs['opid']

        sh = SessionHandler(**kwargs)
        sh.init_session()

        # res = Result(sh, SimpleProfileHandler)

        io = ClIh(session=sh, **kwargs)
        io.session = sh

        tester = ClTester(io, sh, **kwargs)

        if single:
            _res = tester.run(test_id, **kwargs)
            if _res is None:
                return False

            try:
                print('{} [{}] {}'.format(SIGN[_res], rtyp, test_id))
            except Exception as err:
                print('****' + test_id + '*****')
                raise
            # res.store_test_info()
            # res.write_info(test_id)
            # sh.test_flows.store_test_info(tester)
            return True
        else:
            if not tester.match_profile(test_id):
                continue
            elif tester.run(test_id, **kwargs):
                print('+ [{}] {}'.format(rtyp, test_id))
            else:
                sh.test_flows.store_test_info(tester)
                return False
コード例 #7
0
ファイル: clrp.py プロジェクト: deanraspa/oidctest
def run_return_types(test_id, oper_id, kwargs, return_types):
    if len(return_types) == 1:
        single = True
    else:
        single = False

    for rtyp in return_types:  # One return_type at the time
        kwargs['profile'] = rtyp
        kwargs['opid'] = oper_id + '_' + rtyp
        kwargs['tool_conf']['tag'] = kwargs['opid']

        sh = SessionHandler(**kwargs)
        sh.init_session()

        # res = Result(sh, SimpleProfileHandler)

        io = ClIh(session=sh, **kwargs)
        io.session = sh

        tester = ClTester(io, sh, **kwargs)

        if single:
            _res = tester.run(test_id, **kwargs)
            if _res is None:
                return False

            try:
                print('{} [{}] {}'.format(SIGN[_res], rtyp, test_id))
            except Exception as err:
                print('****' + test_id + '*****')
                raise
            # res.store_test_info()
            # res.write_info(test_id)
            # sh.test_flows.store_test_info(tester)
            return True
        else:
            if not tester.match_profile(test_id):
                continue
            elif tester.run(test_id, **kwargs):
                print('+ [{}] {}'.format(rtyp, test_id))
            else:
                sh.test_flows.store_test_info(tester)
                return False
コード例 #8
0
ファイル: cloprp.py プロジェクト: selfissued/oidctest
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
コード例 #9
0
ファイル: cloprp.py プロジェクト: selfissued/oidctest
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)
コード例 #10
0
def test_session_setup():
    sh = SessionHandler(profiles, "C.T.T.T", flows.FLOWS, oper)
    sh.session_init()

    sh.session_setup(path="rp-discovery-webfinger_acct")
コード例 #11
0
def test_session_init():
    sh = SessionHandler(profiles, "C.T.T.T", flows.FLOWS, oper)
    sh.session_init()
    # Make sure all flows got in there
    assert _eq(sh["flow_names"], flows.FLOWS.keys())
コード例 #12
0
ファイル: clrp.py プロジェクト: selfissued/oidctest
            else:
                rtypes = [cargs.profile]

        if len(rtypes) == 1:
            run_return_types(cargs.test_id, cargs.id, kwargs,
                             return_types=rtypes)
        else:
            _res = run_return_types(cargs.test_id, cargs.id, kwargs, rtypes,
                                    False)
            if cargs.exit and _res is False:
                exit()
    else:
        if cargs.profile:
            rtypes = [cargs.profile]
        else:
            rtypes = ['C']

        _sh = SessionHandler(**kwargs)
        _sh.init_session(profile=rtypes[0])

        if cargs.group:
            test_ids = [t for t in _sh["flow_names"] if
                        t.startswith(cargs.group)]
        else:
            test_ids = _sh["flow_names"]

        for tid in test_ids:
            _res = run_return_types(tid, cargs.id, kwargs, rtypes, False)
            if cargs.exit and _res is False:
                exit(-1)
コード例 #13
0
ファイル: test_20_session.py プロジェクト: rohe/oidctest
def test_session_init():
    sh = SessionHandler(profiles, "C.T.T.T", flow_state, oper,
                        tool_conf={'profile': 'C.T.T.T'})
    sh.session_init()
    assert len(sh['tests']) == 61
    assert len(list(flow_state.keys())) > len(sh['tests'])
コード例 #14
0
ファイル: op_test_tool.py プロジェクト: deanraspa/oidctest
        }
    }

    _conf = importlib.import_module(args.config)
    if args.htmldir:
        _html = FileSystem(args.htmldir)
    else:
        _html = FileSystem(_conf.PRE_HTML)
    _html.sync()

    rest = REST('')
    webenv = make_webenv(_conf, rest)

    session_handler = SessionHandler(args.issuer,
                                     args.tag,
                                     flows=webenv['flow_state'],
                                     rest=rest,
                                     version=_vers,
                                     **webenv)
    session_handler.iss = args.issuer
    session_handler.tag = args.tag
    info = WebIh(session=session_handler, pre_html=_html, **webenv)
    tester = WebTester(info,
                       session_handler,
                       flows=webenv['flow_state'],
                       check_factory=check.factory,
                       **webenv)

    log_root = os.path.join(folder, 'log')
    _tar = OPTar(folder)
    cherrypy.tree.mount(_tar, '/mktar')
    cherrypy.tree.mount(_tar, '/backup')
コード例 #15
0
ファイル: op_test_tool.py プロジェクト: rohe/oidctest
            'tools.staticfile.filename': os.path.join(folder, 'static/robots.txt')
        }
    }

    _conf = importlib.import_module(args.config)
    if args.htmldir:
        _html = FileSystem(args.htmldir)
    else:
        _html = FileSystem(_conf.PRE_HTML)
    _html.sync()

    rest = REST('')
    webenv = make_webenv(_conf, rest)

    session_handler = SessionHandler(args.issuer, args.tag,
                                     flows=webenv['flow_state'], rest=rest,
                                     version=_vers, **webenv)
    session_handler.iss = args.issuer
    session_handler.tag = args.tag
    info = WebIh(session=session_handler, pre_html=_html, **webenv)
    tester = WebTester(info, session_handler, flows=webenv['flow_state'],
                       check_factory=check.factory, **webenv)

    log_root = os.path.join(folder, 'log')
    _tar = OPTar(folder)
    cherrypy.tree.mount(_tar, '/mktar')
    cherrypy.tree.mount(_tar, '/backup')
    cherrypy.tree.mount(OPLog(log_root, _html, version=_vers,
                              iss=args.issuer, tag=args.tag), '/log')

    cherrypy.tree.mount(