예제 #1
0
파일: tool.py 프로젝트: rohe/otest
    def set_profile(self, info):
        try:
            old = from_profile(self.sh.profile)

            new = from_profile(to_profile(info))
            for attr in ['enc', 'extra', 'none', 'return_type', 'sig', 'form_post']:
                old[attr] = new[attr]

            # Store new configuration
            try:
                rest = self.sh.extra['rest']
            except KeyError:
                self.conv.tool_conf.update(compress_profile(old))
            else:
                qp = [quote_plus(p) for p in [self.sh.iss, self.sh.tag]]
                _, _conf = rest.read_conf(*qp)
                _conf['tool'].update(compress_profile(old))
                rest.store(qp[0], qp[1], _conf)

                # This will fail if no test has been run before the conf
                # is changed
                try:
                    self.conv.tool_conf = _conf['tool']
                except AttributeError:
                    pass

            # reset all test flows
            self.flows.test_info = {}
            self.flows.complete = {}
            self.sh.reset_session(profile=old['profile'])
            # Back to test list
            return self.inut.flow_list()
        except Exception as err:
            return self.inut.err_response("profile", err)
예제 #2
0
    def create(self, **kwargs):
        logging.info('create test tool configuration')
        # construct profile
        profile = to_profile(kwargs)
        _ent_conf = create_model(profile, ent_info_path=self.ent_info_path)
        state = {}

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = kwargs['iss']

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.app.assigned_ports.register_port(
                kwargs['iss'], kwargs['tag'])
            if self.app.test_tool_base.endswith('/'):
                _base = self.app.test_tool_base[:-1]
            else:
                _base = self.app.test_tool_base
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '{}:{}/authz_cb'.format(_base, _port)

        uqp, qp = unquote_quote(kwargs['iss'], kwargs['tag'])
        _ent_conf['tool']['issuer'] = uqp[0]
        _ent_conf['tool']['tag'] = uqp[1]
        _ent_conf['tool']['profile'] = profile

        _ent_conf.update(from_profile(profile))
        logging.info("Test tool config: {}".format(_ent_conf))

        self.rest.write(qp[0], qp[1], _ent_conf)
        # Do a redirect
        raise cherrypy.HTTPRedirect('/action/update?iss={}&tag={}'.format(
            qp[0], qp[1]))
예제 #3
0
    def basic_entity_configuration(self, io):
        q = parse_qs(io.environ.get('QUERY_STRING'))

        # construct profile
        profile = to_profile(q)
        _ent_conf = create_model(profile, ent_info_path=self.ent_info)
        state = {}

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = q['iss'][0]

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.assigned_ports.register_port(q['iss'][0], q['tag'][0])
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '{}:{}/authz_cb'.format(
                    self.test_tool_base[:-1], _port)

        _ent_conf['tool']['tag'] = q['tag'][0]
        _ent_conf['tool']['issuer'] = q['iss'][0]
        _ent_conf['tool']['profile'] = profile

        _qiss = quote_plus(q['iss'][0])
        _qtag = quote_plus(q['tag'][0])
        io.rest.write(_qiss, _qtag, _ent_conf)
        return '{}form/update/{}/{}'.format(self.baseurl, _qiss, _qtag)
예제 #4
0
파일: app_conf.py 프로젝트: rohe/oidctest
    def basic_entity_configuration(self, io):
        q = parse_qs(io.environ.get('QUERY_STRING'))

        # construct profile
        profile = to_profile(q)
        _ent_conf = create_model(profile, ent_info_path=self.ent_info)
        state = {}

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = q['iss'][0]

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.assigned_ports.register_port(q['iss'][0], q['tag'][0])
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '{}:{}/authz_cb'.format(
                self.test_tool_base[:-1], _port)

        _ent_conf['tool']['tag'] = q['tag'][0]
        _ent_conf['tool']['issuer'] = q['iss'][0]
        _ent_conf['tool']['profile'] = profile

        _qiss = quote_plus(q['iss'][0])
        _qtag = quote_plus(q['tag'][0])
        io.rest.write(_qiss, _qtag, _ent_conf)
        return '{}form/update/{}/{}'.format(self.baseurl, _qiss, _qtag)
예제 #5
0
    def create(self, **kwargs):
        logger.info('create test tool configuration: {} {}'.format(
            kwargs['iss'], kwargs['tag']))

        uqp, qp = unquote_quote(kwargs['iss'], kwargs['tag'])
        if not uqp[0].startswith('https://') and not uqp[0].startswith(
                'http://'):
            err = 'issuer value must start with "https://" or "http://"'
            logger.error(err)
            return as_bytes('Sorry failed to create: {}'.format(err))

        # construct profile
        try:
            profile = to_profile(kwargs)
        except KeyError as err:
            logger.error(err)
            return as_bytes('Sorry failed to create: {}'.format(err))

        _ent_conf = create_model(profile, ent_info_path=self.ent_info_path)

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = kwargs['iss']

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.app.assigned_ports.register_port(
                kwargs['iss'], kwargs['tag'])
            if self.app.test_tool_base.endswith('/'):
                _base = self.app.test_tool_base[:-1]
            else:
                _base = self.app.test_tool_base
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '[ "{}:{}/authz_cb", "{}:{}/authz_post" ]'.format(
                    _base, _port, _base, _port)

        _ent_conf['tool']['issuer'] = uqp[0]
        _ent_conf['tool']['tag'] = uqp[1]
        _ent_conf['tool']['profile'] = profile

        _ent_conf.update(from_profile(profile))
        logger.info("Test tool config: {}".format(_ent_conf))

        self.rest.write(qp[0], qp[1], _ent_conf)
        # Do a redirect
        raise cherrypy.HTTPRedirect('/action/update?iss={}&tag={}'.format(
            qp[0], qp[1]))
예제 #6
0
파일: action.py 프로젝트: rohe/oidctest
    def create(self, **kwargs):
        logger.info(
            'create test tool configuration: {} {}'.format(kwargs['iss'],
                                                           kwargs['tag']))

        uqp, qp = unquote_quote(kwargs['iss'], kwargs['tag'])
        if not uqp[0].startswith('https://') and not uqp[0].startswith('http://'):
            err = 'issuer value must start with "https://" or "http://"'
            logger.error(err)
            return as_bytes('Sorry failed to create: {}'.format(err))

        # construct profile
        try:
            profile = to_profile(kwargs)
        except KeyError as err:
            logger.error(err)
            return as_bytes('Sorry failed to create: {}'.format(err))

        _ent_conf = create_model(profile, ent_info_path=self.ent_info_path)

        if not do_discovery(profile):
            _ent_conf['client']['provider_info']['issuer'] = kwargs['iss']

        if not do_registration(profile):
            # need to create a redirect_uri, means I need to register a port
            _port = self.app.assigned_ports.register_port(kwargs['iss'],
                                                          kwargs['tag'])
            if self.app.test_tool_base.endswith('/'):
                _base = self.app.test_tool_base[:-1]
            else:
                _base = self.app.test_tool_base
            _ent_conf['client']['registration_response'][
                'redirect_uris'] = '[ "{}:{}/authz_cb", "{}:{}/authz_post" ]'.format(_base, _port, _base, _port)

        _ent_conf['tool']['issuer'] = uqp[0]
        _ent_conf['tool']['tag'] = uqp[1]
        _ent_conf['tool']['profile'] = profile

        _ent_conf.update(from_profile(profile))
        logger.info("Test tool config: {}".format(_ent_conf))

        self.rest.write(qp[0], qp[1], _ent_conf)
        # Do a redirect
        raise cherrypy.HTTPRedirect(
            '/action/update?iss={}&tag={}'.format(qp[0], qp[1]))
예제 #7
0
def tool_conf_massage(tc):
    tc['return_type'] = simplify_return_type(tc['return_type'])
    tc['profile'] = to_profile(tc)
    _rm = LABEL[:]
    _rm.extend(['enc', 'sig', 'none'])
    for lab in _rm:
        try:
            del tc[lab]
        except KeyError:
            pass
    try:
        wemail = tc["webfinger_email"]
    except KeyError:
        pass
    else:
        if wemail.startswith('acct:'):
            pass
        else:
            tc["webfinger_email"] = "acct:{}".format(wemail)
    return tc
예제 #8
0
파일: instance.py 프로젝트: rohe/oidctest
def tool_conf_massage(tc):
    tc['return_type'] = simplify_return_type(tc['return_type'])
    tc['profile'] = to_profile(tc)
    _rm = LABEL[:]
    _rm.extend(['enc', 'sig', 'none'])
    for lab in _rm:
        try:
            del tc[lab]
        except KeyError:
            pass
    try:
        wemail = tc["webfinger_email"]
    except KeyError:
        pass
    else:
        if wemail.startswith('acct:'):
            pass
        else:
            tc["webfinger_email"] = "acct:{}".format(wemail)
    return tc
예제 #9
0
    def set_profile(self, info):
        try:
            old = from_profile(self.sh.profile)

            new = from_profile(to_profile(info))
            for attr in [
                    'enc', 'extra', 'none', 'return_type', 'sig', 'form_post'
            ]:
                old[attr] = new[attr]

            # Store new configuration
            try:
                rest = self.sh.extra['rest']
            except KeyError:
                self.conv.tool_conf.update(compress_profile(old))
            else:
                qp = [quote_plus(p) for p in [self.sh.iss, self.sh.tag]]
                _, _conf = rest.read_conf(*qp)
                _conf['tool'].update(compress_profile(old))
                rest.store(qp[0], qp[1], _conf)

                # This will fail if no test has been run before the conf
                # is changed
                try:
                    self.conv.tool_conf = _conf['tool']
                except AttributeError:
                    pass

            # reset all test flows
            self.flows.test_info = {}
            self.flows.complete = {}
            self.sh.reset_session(profile=old['profile'])
            # Back to test list
            return self.inut.flow_list()
        except Exception as err:
            return self.inut.err_response("profile", err)
예제 #10
0
def test_from_to_code():
    for ex, val in TESTS.items():
        f = from_profile(ex)
        assert f == val
        t = to_profile(f)
        assert t == ex
예제 #11
0
def test_from_to_code():
    for ex, val in TESTS.items():
        f = from_profile(ex)
        assert f == val
        t = to_profile(f)
        assert t == ex