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
def test_null_str_allowed(): r = OriginRule(rule='null', kind=RuleKind.STR) req_allow = 'null' assert r.allow_origin(req_allow) == req_allow
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
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
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
def test_path_disallow_star(test): r = OriginRule(rule='http://*.website.com', kind=RuleKind.PATH) assert r.allow_origin(test) is None
def test_str(allow): r = OriginRule(rule=allow) assert r.allow_origin('dummy.net') == r.rule
def test_null_regex_not_allowed(): r = OriginRule(rule='^null$', kind=RuleKind.REGEX) req_allow = 'null' assert r.allow_origin(req_allow) is None
def test_null_path_not_allowed(): r = OriginRule(rule='null', kind=RuleKind.PATH) req_allow = 'null' assert r.allow_origin(req_allow) is None