def test_set_cookie(cookie_dealer): cookie_value = "Something to pass along" cookie_typ = "sso" cookie_name = "Foobar" kaka = cookie_dealer.create_cookie(cookie_value, cookie_typ, cookie_name) _h = HTTPLib() response = DummyResponse(200, 'OK', {"set-cookie": kaka[1]}) _h.set_cookie(response) res = _h._cookies() assert set(res.keys()) == {'Foobar'}
def test_cookie(cookie_dealer): cookie_value = "Something to pass along" cookie_typ = "sso" cookie_name = "Foobar" kaka = cookie_dealer.create_cookie(cookie_value, cookie_typ, cookie_name) _h = HTTPLib() set_cookie(_h.cookiejar, SimpleCookie(kaka[1])) res = _h._cookies() assert set(res.keys()) == {'Foobar'} kwargs = _h.add_cookies({}) assert 'cookies' in kwargs assert set(kwargs['cookies'].keys()) == {'Foobar'}
def __init__(self, state_db, ca_certs=None, client_authn_factory=None, keyjar=None, verify_ssl=True, config=None, client_cert=None, httplib=None, services=None, service_factory=None, jwks_uri='', module_dirs=None): """ :param ca_certs: Certificates used to verify HTTPS certificates :param client_authn_factory: Factory that this client can use to initiate a client authentication class. :param keyjar: A py:class:`oidcmsg.key_jar.KeyJar` instance :param verify_ssl: Whether the SSL certificate should be verified. :param config: Configuration information passed on to the :py:class:`oidcservice.service_context.ServiceContext` initialization :param client_cert: Certificate used by the HTTP client :param httplib: A HTTP client to use :param services: A list of service definitions :param service_factory: A factory to use when building the :py:class:`oidcservice.service.Service` instances :param jwks_uri: A jwks_uri :return: Client instance """ self.session_interface = StateInterface(state_db) self.http = httplib or HTTPLib( ca_certs=ca_certs, verify_ssl=verify_ssl, client_cert=client_cert) if not keyjar: keyjar = KeyJar() keyjar.verify_ssl = verify_ssl self.events = None self.service_context = ServiceContext(keyjar, config=config, jwks_uri=jwks_uri) if self.service_context.client_id: self.client_id = self.service_context.client_id _cam = client_authn_factory or ca_factory self.service_factory = service_factory or default_service_factory _srvs = services or DEFAULT_SERVICES if not module_dirs: module_dirs = ['oauth2'] self.service = build_services(_srvs, self.service_factory, module_dirs, self.service_context, state_db, _cam) self.service_context.service = self.service self.verify_ssl = verify_ssl
def __init__(self, state_db, client_authn_factory=None, keyjar=None, verify_ssl=True, config=None, httplib=None, services=None, jwks_uri='', httpc_params=None): """ :param client_authn_factory: Factory that this client can use to initiate a client authentication class. :param keyjar: A py:class:`oidcmsg.key_jar.KeyJar` instance :param config: Configuration information passed on to the :py:class:`oidcservice.service_context.ServiceContext` initialization :param httplib: A HTTP client to use :param services: A list of service definitions :param jwks_uri: A jwks_uri :param httpc_params: HTTP request arguments :return: Client instance """ self.session_interface = StateInterface(state_db) self.http = httplib or HTTPLib(httpc_params) if not keyjar: keyjar = KeyJar() keyjar.verify_ssl = verify_ssl self.events = None self.service_context = ServiceContext(keyjar, config=config, jwks_uri=jwks_uri, httpc_params=httpc_params) if self.service_context.client_id: self.client_id = self.service_context.client_id _cam = client_authn_factory or ca_factory _srvs = services or DEFAULT_SERVICES self.service = init_services(_srvs, self.service_context, state_db, _cam) if 'add_ons' in config: do_add_ons(config['add_ons'], self.service) self.service_context.service = self.service self.verify_ssl = verify_ssl
def __init__(self, client_authn_factory=None, keyjar=None, verify_ssl=True, config=None, httplib=None, services=None, jwks_uri='', httpc_params=None): """ :param client_authn_factory: Factory that this client can use to initiate a client authentication class. :param keyjar: A py:class:`oidcmsg.key_jar.KeyJar` instance :param config: Configuration information passed on to the :py:class:`oidcrp.service_context.ServiceContext` initialization :param httplib: A HTTP client to use :param services: A list of service definitions :param jwks_uri: A jwks_uri :param httpc_params: HTTP request arguments :return: Client instance """ Entity.__init__(self, client_authn_factory=client_authn_factory, keyjar=keyjar, config=config, services=services, jwks_uri=jwks_uri, httpc_params=httpc_params) self.http = httplib or HTTPLib(httpc_params) if 'add_ons' in config: do_add_ons(config['add_ons'], self._service) # just ignore verify_ssl until it goes away self.verify_ssl = self.httpc_params.get("verify", True)
def __init__(self, client_authn_factory=None, keyjar=None, verify_ssl=True, config=None, httplib=None, services=None, jwks_uri='', httpc_params=None): """ :param client_authn_factory: Factory that this client can use to initiate a client authentication class. :param keyjar: A py:class:`oidcmsg.key_jar.KeyJar` instance :param config: Configuration information passed on to the :py:class:`oidcservice.service_context.ServiceContext` initialization :param httplib: A HTTP client to use :param services: A list of service definitions :param jwks_uri: A jwks_uri :param httpc_params: HTTP request arguments :return: Client instance """ if httpc_params is None: httpc_params = {"verify": True} self.http = httplib or HTTPLib(httpc_params) # db_conf = config.get('db_conf') # if db_conf: # _storage_cls_name = db_conf.get('abstract_storage_cls') # self._storage_cls = importer(_storage_cls_name) # self.db = self._storage_cls(db_conf.get('default')) # if not keyjar: # key_db_conf = db_conf.get('keyjar', db_conf.get('default')) # keyjar = KeyJar(abstract_storage_cls=self._storage_cls, storage_conf=key_db_conf) # keyjar.verify_ssl = verify_ssl self.events = None self.service_context = ServiceContext(keyjar, config=config, jwks_uri=jwks_uri, httpc_params=httpc_params) self.session_interface = StateInterface(self.service_context.state_db) if self.service_context.get('client_id'): self.client_id = self.service_context.get('client_id') _cam = client_authn_factory or ca_factory _srvs = services or DEFAULT_SERVICES self.service = init_services(_srvs, self.service_context, _cam) if 'add_ons' in config: do_add_ons(config['add_ons'], self.service) self.service_context.service = self.service # just ignore verify_ssl until it goes away self.verify_ssl = httpc_params.get("verify", True)