Esempio n. 1
0
def test_factory():
    _session_db = {}
    cons = Consumer(_session_db,
                    client_config=CLIENT_CONFIG,
                    server_info=SERVER_INFO,
                    **CONSUMER_CONFIG)

    sid = stateID("https://example.org/", cons.seed)
    cons.state = sid
    cons._backup(sid)
    cons.sdb["seed:%s" % cons.seed] = sid

    kaka = make_cookie(CLIENT_CONFIG["client_id"],
                       cons.state,
                       cons.seed,
                       expire=360,
                       path="/")

    _oac = factory(kaka[1],
                   _session_db,
                   CLIENT_CONFIG["client_id"],
                   client_config=CLIENT_CONFIG,
                   server_info=SERVER_INFO,
                   **CONSUMER_CONFIG)

    assert _oac
    assert _oac.state == cons.state
    assert _oac.seed == cons.seed
Esempio n. 2
0
def test_factory():
    sdb = DictSessionBackend()
    consumer = Consumer(
        sdb,
        client_config=CLIENT_CONFIG,
        server_info=SERVER_INFO,
        settings=CLIENT_SETTINGS,
        **CONSUMER_CONFIG,
    )
    sid = stateID("https://example.org/", consumer.seed)
    _state = sid
    consumer._backup(sid)
    consumer.sdb["seed:%s" % consumer.seed] = sid

    kaka = make_cookie(CLIENT_CONFIG["client_id"],
                       _state,
                       consumer.seed,
                       expire=360,
                       path="/")

    _oac = factory(
        kaka[1],
        sdb,
        CLIENT_CONFIG["client_id"],
        client_config=CLIENT_CONFIG,
        server_info=SERVER_INFO,
        **CONSUMER_CONFIG,
    )

    assert _oac.client_id == consumer.client_id
    assert _oac.seed == consumer.seed
Esempio n. 3
0
def resource(environ, start_response, logger, kaka=None):
    """

    """
    _log_info = logger.info

    _session_db = environ["oic.sessiondb"]
    _conc = environ["oic.consumer.config"]

    _oac = consumer.factory(kaka, _session_db, _conc)

    if _oac is None:
        resp = http_util.Unauthorized("No valid cookie")
        return resp(environ, start_response)
    
    url = "http://localhost:8088/safe"
    response, content = _oac.fetch_protected_resource(url)

    if _oac.debug:
        _log_info("response: %s (%s)" % (response, type(response)))

    resp = http_util.factory(response.status, content)
#    if kaka:
#        resp.headers.append(kaka)

    return resp(environ, start_response)
def test_factory():
    sdb = {}
    consumer = Consumer(sdb, client_config=CLIENT_CONFIG,
                        server_info=SERVER_INFO, **CONSUMER_CONFIG)
    sid = stateID("https://example.org/", consumer.seed)
    _state = sid
    consumer._backup(sid)
    consumer.sdb["seed:%s" % consumer.seed] = sid

    kaka = make_cookie(CLIENT_CONFIG["client_id"], _state, consumer.seed,
                       expire=360, path="/")

    _oac = factory(kaka[1], sdb, CLIENT_CONFIG["client_id"],
                   client_config=CLIENT_CONFIG, server_info=SERVER_INFO,
                   **CONSUMER_CONFIG)

    assert _oac.client_id == consumer.client_id
    assert _oac.seed == consumer.seed