コード例 #1
0
def test_session_mixed(req, rsp):
    s = Session(
        cookie_names=['session', 'state'],
        cookie_vals={
            'session': ResponseCookie('session=foo; secure; httponly; path=/')
        },
        header_vals={'auth': 'bar'},
    )

    s.apply_req(req)
    s.apply_rsp(rsp)
    assert req.cookies['session'] == 'foo'
    assert rsp.cookies['session'].key == 'session'
    assert rsp.cookies['session'].val == 'foo'
    assert rsp.cookies['session'].secure
    assert rsp.cookies['session'].http_only
    assert rsp.cookies['session'].path == '/'
    assert 'auth' not in rsp.headers

    r = Response()
    r.start_line = 'HTTP/1.1 200 OK'
    r.set_cookie(ResponseCookie('state=bazzers'))
    r.set_cookie(ResponseCookie('session=buzzers'))
    s.get_rsp(r)
    assert s.cookie_vals['session'].val == 'buzzers'
    assert s.cookie_vals['state'].val == 'bazzers'
コード例 #2
0
def test_session_basic(req, rsp):
    s = Session(
        cookie_vals={'session': 'foo'},
        header_vals={'auth': 'bar'},
    )

    assert 'session' not in req.cookies
    assert 'session' not in rsp.cookies
    assert 'auth' not in req.headers
    assert 'auth' not in rsp.headers
    s.apply_req(req)
    s.apply_rsp(rsp)
    assert req.cookies['session'] == 'foo'
    assert rsp.cookies['session'].cookie_str == 'session=foo'
    assert req.headers['auth'] == 'bar'
    assert 'auth' not in rsp.headers
コード例 #3
0
ファイル: test_session.py プロジェクト: MahaKoala/pappy-proxy
def test_session_cookieobj_basic(req, rsp):
    s = Session(
        cookie_vals={'session':ResponseCookie('session=foo; secure; httponly; path=/')},
        header_vals={'auth':'bar'},
    )

    s.apply_req(req)
    s.apply_rsp(rsp)
    assert req.cookies['session'] == 'foo'
    assert rsp.cookies['session'].key == 'session'
    assert rsp.cookies['session'].val == 'foo'
    assert rsp.cookies['session'].secure
    assert rsp.cookies['session'].http_only
    assert rsp.cookies['session'].path == '/'
    assert req.headers['auth'] == 'bar'
    assert 'auth' not in rsp.headers
コード例 #4
0
ファイル: test_session.py プロジェクト: MahaKoala/pappy-proxy
def test_session_basic(req, rsp):
    s = Session(
        cookie_vals={'session':'foo'},
        header_vals={'auth':'bar'},
    )

    assert 'session' not in req.cookies
    assert 'session' not in rsp.cookies
    assert 'auth' not in req.headers
    assert 'auth' not in rsp.headers
    s.apply_req(req)
    s.apply_rsp(rsp)
    assert req.cookies['session'] == 'foo'
    assert rsp.cookies['session'].cookie_str == 'session=foo'
    assert req.headers['auth'] == 'bar'
    assert 'auth' not in rsp.headers
コード例 #5
0
def test_session_cookieobj_basic(req, rsp):
    s = Session(
        cookie_vals={'session':ResponseCookie('session=foo; secure; httponly; path=/')},
        header_vals={'auth':'bar'},
    )

    s.apply_req(req)
    s.apply_rsp(rsp)
    assert req.cookies['session'] == 'foo'
    assert rsp.cookies['session'].key == 'session'
    assert rsp.cookies['session'].val == 'foo'
    assert rsp.cookies['session'].secure
    assert rsp.cookies['session'].http_only
    assert rsp.cookies['session'].path == '/'
    assert req.headers['auth'] == 'bar'
    assert 'auth' not in rsp.headers
コード例 #6
0
ファイル: test_session.py プロジェクト: MahaKoala/pappy-proxy
def test_session_mixed(req, rsp):
    s = Session(
        cookie_names=['session', 'state'],
        cookie_vals={'session':ResponseCookie('session=foo; secure; httponly; path=/')},
        header_vals={'auth':'bar'},
    )

    s.apply_req(req)
    s.apply_rsp(rsp)
    assert req.cookies['session'] == 'foo'
    assert rsp.cookies['session'].key == 'session'
    assert rsp.cookies['session'].val == 'foo'
    assert rsp.cookies['session'].secure
    assert rsp.cookies['session'].http_only
    assert rsp.cookies['session'].path == '/'
    assert 'auth' not in rsp.headers

    r = Response()
    r.start_line = 'HTTP/1.1 200 OK'
    r.set_cookie(ResponseCookie('state=bazzers'))
    r.set_cookie(ResponseCookie('session=buzzers'))
    s.get_rsp(r)
    assert s.cookie_vals['session'].val == 'buzzers'
    assert s.cookie_vals['state'].val == 'bazzers'