mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
perms test: moved test perms policy to perms/test/test_perms_policy.py
all perms related configs exist within perms package
This commit is contained in:
parent
681c2fd8d5
commit
702e5e0143
0
pywb/perms/test/__init__.py
Normal file
0
pywb/perms/test/__init__.py
Normal file
35
pywb/perms/test/test_perms_policy.py
Normal file
35
pywb/perms/test/test_perms_policy.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""
|
||||
An example perms policy used for testing
|
||||
this policy is enabled by adding the following setting to the
|
||||
main config.yaml
|
||||
|
||||
perms_policy: !!python/name:pywb.perms.test.test_perms_policy.perms_policy
|
||||
"""
|
||||
|
||||
from pywb.perms.perms_filter import Perms
|
||||
|
||||
|
||||
#================================================================
|
||||
class TestExclusionPerms(Perms):
|
||||
"""
|
||||
Perm Checker fixture to block a single url for testing
|
||||
"""
|
||||
# sample_archive has captures for this URLKEY
|
||||
URLKEY_EXCLUDED = 'org,iana)/_img/bookmark_icon.ico'
|
||||
|
||||
def allow_url_lookup(self, urlkey):
|
||||
"""
|
||||
Return true/false if url (canonicalized url)
|
||||
should be allowed
|
||||
"""
|
||||
if urlkey == self.URLKEY_EXCLUDED:
|
||||
return False
|
||||
|
||||
return super(TestExclusionPerms, self).allow_url_lookup(urlkey)
|
||||
|
||||
|
||||
#================================================================
|
||||
def perms_policy(wbrequest):
|
||||
return TestExclusionPerms()
|
||||
|
||||
|
@ -101,4 +101,4 @@ reporter: !!python/object/new:tests.fixture.PrintReporter []
|
||||
#domain_specific_rules: rules.yaml
|
||||
|
||||
#perms_checker: !!python/object/new:pywb.cdx.perms.AllowAllPerms []
|
||||
perms_policy: !!python/name:tests.fixture.test_exclusion_perms_policy
|
||||
perms_policy: !!python/name:pywb.perms.test.test_perms_policy.perms_policy
|
||||
|
@ -3,8 +3,6 @@ import pytest
|
||||
|
||||
import yaml
|
||||
|
||||
from pywb.perms.perms_filter import Perms
|
||||
|
||||
@pytest.fixture
|
||||
def testconfig():
|
||||
config = yaml.load(open('test_config.yaml'))
|
||||
@ -25,26 +23,3 @@ class PrintReporter:
|
||||
print wbrequest
|
||||
print cdx
|
||||
pass
|
||||
|
||||
#================================================================
|
||||
class TestExclusionPerms(Perms):
|
||||
"""
|
||||
Perm Checker fixture to block a single url for testing
|
||||
"""
|
||||
# sample_archive has captures for this URLKEY
|
||||
URLKEY_EXCLUDED = 'org,iana)/_img/bookmark_icon.ico'
|
||||
|
||||
def allow_url_lookup(self, urlkey):
|
||||
"""
|
||||
Return true/false if url (canonicalized url)
|
||||
should be allowed
|
||||
"""
|
||||
if urlkey == self.URLKEY_EXCLUDED:
|
||||
return False
|
||||
|
||||
return super(TestExclusionPerms, self).allow_url_lookup(urlkey)
|
||||
|
||||
|
||||
#================================================================
|
||||
def test_exclusion_perms_policy(wbrequest):
|
||||
return TestExclusionPerms()
|
||||
|
@ -3,8 +3,6 @@ from pywb.core.pywb_init import create_wb_router
|
||||
from pywb.framework.wsgi_wrappers import init_app
|
||||
from pywb.cdx.cdxobject import CDXObject
|
||||
|
||||
from fixture import TestExclusionPerms
|
||||
|
||||
class TestWb:
|
||||
TEST_CONFIG = 'test_config.yaml'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user