Example #1
0
def test_regex_disallow_singlechar(test):
    domain = 'website.com'
    r = OriginRule(rule=r'^test\S\.website\.com$', kind=RuleKind.REGEX)
    req_allow = f'{test}.{domain}'
    assert r.allow_origin(req_allow) is None
Example #2
0
def test_null_str_allowed():
    r = OriginRule(rule='null', kind=RuleKind.STR)
    req_allow = 'null'
    assert r.allow_origin(req_allow) == req_allow
Example #3
0
def test_path_allow_range_incl(test):
    domain = 'website.com'
    r = OriginRule(rule=f'http://test[1y].{domain}', kind=RuleKind.PATH)
    req_allow = f'http://{test}.{domain}'
    assert r.allow_origin(req_allow) == req_allow
Example #4
0
def test_path_disallow_range_excl(test):
    domain = 'website.com'
    r = OriginRule(rule=f'http://test[!1y].{domain}', kind=RuleKind.PATH)
    req_allow = f'{test}.{domain}'
    assert r.allow_origin(req_allow) is None
Example #5
0
def test_path_disallow_singlechar(test):
    domain = 'website.com'
    r = OriginRule(rule=f'http://test?.{domain}', kind=RuleKind.PATH)
    req_allow = f'http://{test}.{domain}'
    assert r.allow_origin(req_allow) is None
Example #6
0
def test_path_disallow_star(test):
    r = OriginRule(rule='http://*.website.com', kind=RuleKind.PATH)
    assert r.allow_origin(test) is None
Example #7
0
def test_str(allow):
    r = OriginRule(rule=allow)
    assert r.allow_origin('dummy.net') == r.rule
Example #8
0
def test_null_regex_not_allowed():
    r = OriginRule(rule='^null$', kind=RuleKind.REGEX)
    req_allow = 'null'
    assert r.allow_origin(req_allow) is None
Example #9
0
def test_null_path_not_allowed():
    r = OriginRule(rule='null', kind=RuleKind.PATH)
    req_allow = 'null'
    assert r.allow_origin(req_allow) is None