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]))
def test_1(): rest = REST('http://localhost') cnf = create_model('C.T.T.T') cnf['tool']['issuer'] = 'http://example.com/op' cnf['tool']['sig'] = True qiss = quote_plus(cnf['tool']['issuer']) qtag = cnf['tool']['tag'] rest.write(qiss, qtag, cnf) _ecnf = rest.construct_config(qiss, qtag) assert set(_ecnf.keys()) == {'client', 'keys', 'tool'} assert set(_ecnf['client'].keys()) == {'behaviour', 'client_prefs', 'registration_info'}
def test_1(): rest = REST('http://localhost') cnf = create_model('C.T.T.T') cnf['tool']['issuer'] = 'http://example.com/op' cnf['tool']['sig'] = True qiss = quote_plus(cnf['tool']['issuer']) qtag = cnf['tool']['tag'] rest.write(qiss, qtag, cnf) _ecnf = rest.construct_config(qiss, qtag) assert set(_ecnf.keys()) == {'client', 'keys', 'tool'} assert set(_ecnf['client'].keys()) == { 'behaviour', 'client_prefs', 'registration_info' }
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]))
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]))
parser.add_argument('-i', dest='issuer') parser.add_argument('-l', dest='ui_locales') parser.add_argument('-L', dest='claims_locales') parser.add_argument('-p', dest='profile', default='C.T.T.T') parser.add_argument('-s', dest='sig', action='store_true') parser.add_argument('-t', dest='tag') parser.add_argument('-x', dest='extra', action='store_true') parser.add_argument('-w', dest='webfinger_email') parser.add_argument('-W', dest='webfinger_url') args = parser.parse_args() ent_info_path='{}/entity_info'.format(args.entity_root) rest = REST('', '{}/entities'.format(args.entity_root), ent_info_path) cnf = create_model(args.profile, ent_info_path) for item in ['sig', 'enc', 'extra']: if getattr(args, item): cnf['tool'][item] = True for item in ['acr_values', 'login_hint', 'ui_locales', 'claims_locales', 'webfinger_url', 'webfinger_email', 'issuer', 'profile', 'tag']: v = getattr(args, item) if v: cnf['tool'][item] = v qiss = quote_plus(cnf['tool']['issuer']) qtag = cnf['tool']['tag'] rest.write(qiss, qtag, cnf)
parser.add_argument('-i', dest='issuer') parser.add_argument('-l', dest='ui_locales') parser.add_argument('-L', dest='claims_locales') parser.add_argument('-p', dest='profile', default='C.T.T.T') parser.add_argument('-s', dest='sig', action='store_true') parser.add_argument('-t', dest='tag') parser.add_argument('-x', dest='extra', action='store_true') parser.add_argument('-w', dest='webfinger_email') parser.add_argument('-W', dest='webfinger_url') args = parser.parse_args() ent_info_path = '{}/entity_info'.format(args.entity_root) rest = REST('', '{}/entities'.format(args.entity_root), ent_info_path) cnf = create_model(args.profile, ent_info_path) for item in ['sig', 'enc', 'extra']: if getattr(args, item): cnf['tool'][item] = True for item in [ 'acr_values', 'login_hint', 'ui_locales', 'claims_locales', 'webfinger_url', 'webfinger_email', 'issuer', 'profile', 'tag' ]: v = getattr(args, item) if v: cnf['tool'][item] = v qiss = quote_plus(cnf['tool']['issuer']) qtag = cnf['tool']['tag']