1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00
pywb/tests_disabled/test_perms_app.py
Ilya Kreymer a4b770d34e new-pywb refactor!
frontendapp compatibility
- add support for separate not found page for 404s (not_found.html)
- support for exception handling with error template (error.html)
- support for home page (index.html)
- add memento headers for replay
- add referrer fallback check
- tests: port integration tests for front-end replay, cdx server
- not included: proxy mode, exact redirect mode, non-framed replay
- move unused tests to tests_disabled
- cli: add optional werkzeug profiler with --profile flag
2017-02-27 19:07:51 -08:00

48 lines
1.4 KiB
Python

import webtest
from pywb.perms.perms_handler import create_perms_checker_app
from pywb.perms.perms_handler import ALLOW, BLOCK
from pywb.framework.wsgi_wrappers import init_app
from .server_mock import make_setup_module, BaseIntegration
setup_module = make_setup_module('tests/test_config.yaml', create_perms_checker_app)
class TestPermsApp(BaseIntegration):
def test_allow(self):
resp = self.testapp.get('/check-access/http://example.com')
assert resp.content_type == 'application/json'
assert ALLOW in resp.text
def test_allow_with_timestamp(self):
resp = self.testapp.get('/check-access/20131024000102/http://example.com')
assert resp.content_type == 'application/json'
assert ALLOW in resp.text
def test_block_with_timestamp(self):
resp = self.testapp.get('/check-access/20131024000102/http://www.iana.org/_img/bookmark_icon.ico')
assert resp.content_type == 'application/json'
assert BLOCK in resp.text
# no longer 'bad' due since surt 0.3b
#def test_bad_url(self):
# resp = self.testapp.get('/check-access/@#$', expect_errors=True, status = 400)
# assert resp.status_int == 404
# assert 'Invalid Url: http://@' in resp.text
def test_not_found(self):
resp = self.testapp.get('/check-access/#abc', expect_errors=True, status = 404)
assert resp.status_int == 404