mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
* embargo: add support for per-collection date range embargo with embargo options of 'before', 'after', 'newer' and 'older' 'before' and 'after' accept a timestamp 'newer' and 'older' options configured with a dictionary consisting of any combo of 'years', 'months', 'days' add basic test for each embargo option * acl/embargo work: - support acl access value 'allow_ignore_embargo' for overriding embargo - support 'user' in acl setting, matched with value of 'X-Pywb-ACL-User' header - support passing through 'X-Pywb-ACL-User' setting to warcserver - aclmanager: support -u/--user param for adding, removing and matching rules - tests: add test for 'allow_ignore_embargo', user-specific acl rule matching * docs: add docs for new embargo system! * docs: add info on how to configure ACL header with short examples to usage page. sample-deploy: add examples of configuring X-pywb-ACL-user header based on IP for nginx and apache sample deployments * docs: fix access control page header, text tweaks * bump version to 2.6.0b0
57 lines
2.4 KiB
Python
57 lines
2.4 KiB
Python
from .base_config_test import BaseConfigTest, fmod
|
|
|
|
import webtest
|
|
import os
|
|
|
|
from six.moves.urllib.parse import urlencode
|
|
|
|
|
|
# ============================================================================
|
|
class TestEmbargoApp(BaseConfigTest):
|
|
@classmethod
|
|
def setup_class(cls):
|
|
super(TestEmbargoApp, cls).setup_class('config_test_access.yaml')
|
|
|
|
def test_embargo_before(self):
|
|
resp = self.testapp.get('/pywb-embargo-before/20140126201054mp_/http://www.iana.org/domains/reserved', status=404)
|
|
|
|
resp = self.testapp.get('/pywb-embargo-before/20140127mp_/http://example.com/', status=200)
|
|
assert resp.headers['Content-Location'] == 'http://localhost:80/pywb-embargo-before/20140127171251mp_/http://example.com'
|
|
|
|
def test_embargo_after(self):
|
|
resp = self.testapp.get('/pywb-embargo-after/20140126201054mp_/http://www.iana.org/domains/reserved', status=200)
|
|
|
|
resp = self.testapp.get('/pywb-embargo-after/20140127mp_/http://example.com/', status=200)
|
|
assert resp.headers['Content-Location'] == 'http://localhost:80/pywb-embargo-after/20130729195151mp_/http://test@example.com/'
|
|
|
|
def test_embargo_older(self):
|
|
resp = self.testapp.get('/pywb-embargo-older/20140126201054mp_/http://www.iana.org/domains/reserved', status=404)
|
|
|
|
resp = self.testapp.get('/pywb-embargo-older/20140127mp_/http://example.com/', status=404)
|
|
|
|
def test_embargo_newer(self):
|
|
resp = self.testapp.get('/pywb-embargo-newer/20140126201054mp_/http://www.iana.org/domains/reserved', status=200)
|
|
|
|
resp = self.testapp.get('/pywb-embargo-newer/20140127mp_/http://example.com/', status=200)
|
|
assert resp.headers['Content-Location'] == 'http://localhost:80/pywb-embargo-newer/20140127171251mp_/http://example.com'
|
|
|
|
def test_embargo_ignore_acl(self):
|
|
# embargoed
|
|
resp = self.testapp.get('/pywb-embargo-acl/20140126201054mp_/http://example.com/', status=404)
|
|
|
|
# ignore embargo
|
|
resp = self.testapp.get('/pywb-embargo-acl/20140126201054mp_/http://example.com/?example=2', status=200)
|
|
|
|
|
|
def test_embargo_ignore_acl_with_header_only(self):
|
|
# ignore embargo with custom header only
|
|
headers = {"X-Pywb-ACL-User": "staff2"}
|
|
resp = self.testapp.get('/pywb-embargo-acl/20140126201054mp_/http://example.com/?example=1', status=200, headers=headers)
|
|
|
|
resp = self.testapp.get('/pywb-embargo-acl/20140126201054mp_/http://example.com/?example=1', status=404)
|
|
|
|
|
|
|
|
|
|
|