Beispiel #1
0
def test_parse_set_cookie_same_site_strict():
    name, value, params = parse_set_cookie('cookie=123; SameSite=Strict')
    assert name == 'cookie'
    assert value == '123'
    assert params == {
        'secure': False,
        'http_only': False,
        'same_site': 'strict',
    }
Beispiel #2
0
def test_parse_set_cookie_expires():
    name, value, params = parse_set_cookie(
        'id=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT')
    assert name == 'id'
    assert value == 'a3fWa'
    assert params == {
        'secure': False,
        'http_only': False,
        'expires': datetime(2015, 10, 21, 7, 28, 0, tzinfo=timezone.utc),
    }
Beispiel #3
0
def test_parse_set_cookie_domain_2():
    name, value, params = parse_set_cookie(
        'sessionId=e8bb43229de9; Domain=foo.example.com')
    assert name == 'sessionId'
    assert value == 'e8bb43229de9'
    assert params == {
        'secure': False,
        'http_only': False,
        'domain': 'foo.example.com',
    }
Beispiel #4
0
def test_parse_set_cookie_domain():
    name, value, params = parse_set_cookie(
        'qwerty=219ffwef9w0f; Domain=somecompany.co.uk')
    assert name == 'qwerty'
    assert value == '219ffwef9w0f'
    assert params == {
        'secure': False,
        'http_only': False,
        'domain': 'somecompany.co.uk',
    }
Beispiel #5
0
def test_parse_set_cookie_max_age_invalid():
    with pytest.raises(ValueError):
        parse_set_cookie('cookie=123; Max-Age=foo')
Beispiel #6
0
def test_parse_set_cookie_max_age():
    name, value, params = parse_set_cookie('id=a3fWa; Max-Age=2592000')
    assert name == 'id'
    assert value == 'a3fWa'
    assert params == {'secure': False, 'http_only': False, 'max_age': 2592000}
Beispiel #7
0
def test_parse_set_cookie_expires_invalid():
    with pytest.raises(ValueError):
        parse_set_cookie('id=a3fWa; Expires=Thu, 21 Oct 2015 07:28:00 GMT')
Beispiel #8
0
def test_parse_set_cookie():
    name, value, params = parse_set_cookie('sessionId=38afes7a8')
    assert name == 'sessionId'
    assert value == '38afes7a8'
    assert params == {'secure': False, 'http_only': False}
Beispiel #9
0
def test_parse_set_cookie_same_site_invalid():
    with pytest.raises(ValueError):
        parse_set_cookie('cookie=123; SameSite=Invalid')
Beispiel #10
0
def test_parse_set_cookie_http_only():
    name, value, params = parse_set_cookie('cookie=123; HttpOnly')
    assert name == 'cookie'
    assert value == '123'
    assert params == {'secure': False, 'http_only': True}
Beispiel #11
0
def test_parse_set_cookie_path_string():
    name, value, params = parse_set_cookie('cookie=123; Path="/foo/bar"')
    assert name == 'cookie'
    assert value == '123'
    assert params == {'secure': False, 'http_only': False, 'path': '/foo/bar'}