1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-14 15:53:28 +01:00
pywb/tests/test_force_https.py
Ed Summers b4955cca66
Upgrade dependencies (#839)
- Update and pin dependencies to specific versions that support Python 3.7-3.11
- Replace deprecated werkzeug.pop_path_info with wsgiref.shift_path_info
- Use the latest httpbin from psf/httpbin
- Remove unused flask test dependency
- Drop Python 2 and Python <3.7 support
- Ensure greenlet 2 is used for now, as psf/httpbin doesn't yet work with greenlet 3

---------

Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
2024-04-02 17:16:50 -04:00

62 lines
2.6 KiB
Python

from .base_config_test import BaseConfigTest, fmod
# ============================================================================
class TestForceHttps(BaseConfigTest):
@classmethod
def setup_class(cls):
super(TestForceHttps, cls).setup_class('config_test.yaml')
def test_force_https_replay_1(self, fmod):
resp = self.get('/pywb/20140128051539{0}/http://example.com/', fmod,
headers={'X-Forwarded-Proto': 'https'})
assert '"https://localhost:80/pywb/20140128051539{0}/http://www.iana.org/domains/example"'.format(fmod) in resp.text, resp.text
# ============================================================================
class TestForceHttpsConfig(BaseConfigTest):
@classmethod
def setup_class(cls):
super(TestForceHttpsConfig, cls).setup_class('config_test.yaml',
custom_config={'force_scheme': 'https'})
def test_force_https_replay_1(self, fmod):
resp = self.get('/pywb/20140128051539{0}/http://example.com/', fmod)
assert '"https://localhost:80/pywb/20140128051539{0}/http://www.iana.org/domains/example"'.format(fmod) in resp.text, resp.text
# ============================================================================
class TestForceHttpsRedirect(BaseConfigTest):
@classmethod
def setup_class(cls):
super(TestForceHttpsRedirect, cls).setup_class('config_test_redirect_classic.yaml')
def test_force_https_redirect_replay_1(self, fmod):
resp = self.get('/pywb/20140128051539{0}/http://example.com/', fmod,
headers={'X-Forwarded-Proto': 'https'})
assert resp.headers['Location'] == 'https://localhost:80/pywb/20140127171251{0}/http://example.com'.format(fmod)
resp = resp.follow()
assert resp.headers['Location'] == 'https://localhost:80/pywb/20140127171251{0}/http://example.com/'.format(fmod)
resp = resp.follow()
assert '"https://localhost:80/pywb/20140127171251{0}/http://www.iana.org/domains/example"'.format(fmod) in resp.text, resp.text
# ============================================================================
class TestForceHttpsRoot(BaseConfigTest):
@classmethod
def setup_class(cls):
super(TestForceHttpsRoot, cls).setup_class('config_test_root_coll.yaml')
def test_force_https_root_replay_1(self, fmod):
resp = self.get('/20140128051539{0}/http://www.iana.org/domains/example', fmod,
headers={'X-Forwarded-Proto': 'https'})
assert resp.headers['Location'] == 'https://localhost:80/20140128051539{0}/http://www.iana.org/help/example-domains'.format(fmod)