mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
tests: fix cookie rewriter tests to exclude 2.6
This commit is contained in:
parent
4a60e15577
commit
cf6cfc0c44
@ -24,26 +24,10 @@ True
|
|||||||
>>> rewrite_cookie('abc=def; Path=file.html; Expires=Wed, 13 Jan 2021 22:23:01 GMT', urlrewriter, 'coll')
|
>>> rewrite_cookie('abc=def; Path=file.html; Expires=Wed, 13 Jan 2021 22:23:01 GMT', urlrewriter, 'coll')
|
||||||
[('Set-Cookie', 'abc=def; Path=/pywb/20131226101010/http://example.com/some/path/file.html')]
|
[('Set-Cookie', 'abc=def; Path=/pywb/20131226101010/http://example.com/some/path/file.html')]
|
||||||
|
|
||||||
# keep expires
|
|
||||||
>>> rewrite_cookie('abc=def; Path=file.html; Expires=Wed, 13 Jan 2021 22:23:01 GMT', urlrewriter2, 'coll')
|
|
||||||
[('Set-Cookie', 'abc=def; expires=Wed, 13 Jan 2021 22:23:01 GMT; Path=/preview/em_/http://example.com/file.html')]
|
|
||||||
|
|
||||||
# keep expires, UTC->GMT
|
|
||||||
>>> rewrite_cookie('abc=def; Path=file.html; Expires=Wed, 13 Jan 2021 22:23:01 UTC', urlrewriter2, 'coll')
|
|
||||||
[('Set-Cookie', 'abc=def; expires=Wed, 13 Jan 2021 22:23:01 GMT; Path=/preview/em_/http://example.com/file.html')]
|
|
||||||
|
|
||||||
# keep Max-Age
|
# keep Max-Age
|
||||||
>>> rewrite_cookie('abc=def; Path=file.html; Max-Age=1500', urlrewriter2, 'coll')
|
>>> rewrite_cookie('abc=def; Path=file.html; Max-Age=1500', urlrewriter2, 'coll')
|
||||||
[('Set-Cookie', 'abc=def; Max-Age=1500; Path=/preview/em_/http://example.com/file.html')]
|
[('Set-Cookie', 'abc=def; Max-Age=1500; Path=/preview/em_/http://example.com/file.html')]
|
||||||
|
|
||||||
# Secure Remove
|
|
||||||
>>> rewrite_cookie('abc=def; Path=file.html; HttpOnly; Secure', urlrewriter2, 'coll')
|
|
||||||
[('Set-Cookie', 'abc=def; HttpOnly; Path=/preview/em_/http://example.com/file.html')]
|
|
||||||
|
|
||||||
# Secure Keep
|
|
||||||
>>> rewrite_cookie('abc=def; Path=file.html; HttpOnly; Secure', urlrewriter3, 'coll')
|
|
||||||
[('Set-Cookie', 'abc=def; HttpOnly; Path=/preview/em_/http://example.com/file.html; Secure')]
|
|
||||||
|
|
||||||
# Cookie with invalid chars, not parsed
|
# Cookie with invalid chars, not parsed
|
||||||
>>> rewrite_cookie('abc@def=123', urlrewriter, 'coll')
|
>>> rewrite_cookie('abc@def=123', urlrewriter, 'coll')
|
||||||
[]
|
[]
|
||||||
@ -65,9 +49,6 @@ True
|
|||||||
[('Set-Cookie', 'some=value; Path=/pywb/20131226101010/http://example.com/')]
|
[('Set-Cookie', 'some=value; Path=/pywb/20131226101010/http://example.com/')]
|
||||||
|
|
||||||
# Disable for now as it 2.6 doesn't include HttpOnly and Secure
|
# Disable for now as it 2.6 doesn't include HttpOnly and Secure
|
||||||
#>>> rewrite_cookie('some=value; Domain=.example.com; Secure; Path=/diff/path/; HttpOnly; Max-Age=1500', urlrewriter, 'host')
|
|
||||||
[('Set-Cookie', 'some=value; httponly; Path=/pywb/20131226101010/http://example.com/')]
|
|
||||||
|
|
||||||
|
|
||||||
# RootCookieRewriter -- always sets Path=/, removes Domain
|
# RootCookieRewriter -- always sets Path=/, removes Domain
|
||||||
>>> rewrite_cookie('some=value; Path=/diff/path/;', urlrewriter, 'root')
|
>>> rewrite_cookie('some=value; Path=/diff/path/;', urlrewriter, 'root')
|
||||||
@ -90,6 +71,8 @@ True
|
|||||||
from pywb.rewrite.cookie_rewriter import MinimalScopeCookieRewriter
|
from pywb.rewrite.cookie_rewriter import MinimalScopeCookieRewriter
|
||||||
from pywb.rewrite.cookie_rewriter import get_cookie_rewriter
|
from pywb.rewrite.cookie_rewriter import get_cookie_rewriter
|
||||||
from pywb.rewrite.url_rewriter import UrlRewriter
|
from pywb.rewrite.url_rewriter import UrlRewriter
|
||||||
|
import pytest
|
||||||
|
import sys
|
||||||
|
|
||||||
urlrewriter = UrlRewriter('20131226101010/http://example.com/some/path/index.html',
|
urlrewriter = UrlRewriter('20131226101010/http://example.com/some/path/index.html',
|
||||||
'http://localhost:8080/pywb/',
|
'http://localhost:8080/pywb/',
|
||||||
@ -106,3 +89,38 @@ def rewrite_cookie(cookie_str, rewriter=urlrewriter, scope='default'):
|
|||||||
return cookie_rewriter(rewriter).rewrite(cookie_str)
|
return cookie_rewriter(rewriter).rewrite(cookie_str)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(sys.version_info < (2,7), reason='Unsupported')
|
||||||
|
def test_with_expires():
|
||||||
|
# keep expires
|
||||||
|
res = rewrite_cookie('abc=def; Path=file.html; Expires=Wed, 13 Jan 2021 22:23:01 GMT', urlrewriter2, 'coll')
|
||||||
|
assert len(res) == 1
|
||||||
|
assert res[0][1].lower() == 'abc=def; expires=wed, 13 jan 2021 22:23:01 gmt; path=/preview/em_/http://example.com/file.html'
|
||||||
|
|
||||||
|
@pytest.mark.skipif(sys.version_info < (2,7), reason='Unsupported')
|
||||||
|
def test_with_expires_utc_replace():
|
||||||
|
# keep expires, UTC->GMT
|
||||||
|
res = rewrite_cookie('abc=def; Path=file.html; Expires=Wed, 13 Jan 2021 22:23:01 UTC', urlrewriter2, 'coll')
|
||||||
|
assert len(res) == 1
|
||||||
|
assert res[0][1].lower() == 'abc=def; expires=wed, 13 jan 2021 22:23:01 gmt; path=/preview/em_/http://example.com/file.html'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(sys.version_info < (2,7), reason='Unsupported')
|
||||||
|
def test_http_secure_flag():
|
||||||
|
res = rewrite_cookie('some=value; Domain=.example.com; Secure; Path=/diff/path/; HttpOnly; Max-Age=1500', urlrewriter, 'host')
|
||||||
|
assert len(res) == 1
|
||||||
|
assert res[0][1].lower() == 'some=value; httponly; path=/pywb/20131226101010/http://example.com/'
|
||||||
|
|
||||||
|
@pytest.mark.skipif(sys.version_info < (2,7), reason='Unsupported')
|
||||||
|
def test_secure_flag_remove():
|
||||||
|
# Secure Remove
|
||||||
|
res = rewrite_cookie('abc=def; Path=file.html; HttpOnly; Secure', urlrewriter2, 'coll')
|
||||||
|
assert len(res) == 1
|
||||||
|
assert res[0][1].lower() == 'abc=def; httponly; path=/preview/em_/http://example.com/file.html'
|
||||||
|
|
||||||
|
@pytest.mark.skipif(sys.version_info < (2,7), reason='Unsupported')
|
||||||
|
def test_secure_flag_keep():
|
||||||
|
# Secure Keep
|
||||||
|
res = rewrite_cookie('abc=def; Path=file.html; HttpOnly; Secure', urlrewriter3, 'coll')
|
||||||
|
assert res[0][1].lower() == 'abc=def; httponly; path=/preview/em_/http://example.com/file.html; secure'
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user