Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: tests/test_parser.py

Issue 29793573: Issue 6701 - Implement CSP support in python-abp (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Left Patch Set: Check negation first, and added some tests Created June 7, 2018, 11:12 p.m.
Right Patch Set: Removing handling and testing for ~csp Created June 14, 2018, 7:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « abp/filters/parser.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 }, 60 },
61 '@@http://bla$~script,~other,sitekey=foo|bar': { 61 '@@http://bla$~script,~other,sitekey=foo|bar': {
62 'selector': {'type': ST.URL_PATTERN, 'value': 'http://bla'}, 62 'selector': {'type': ST.URL_PATTERN, 'value': 'http://bla'},
63 'action': FA.ALLOW, 63 'action': FA.ALLOW,
64 'options': [ 64 'options': [
65 (OPT.SCRIPT, False), 65 (OPT.SCRIPT, False),
66 (OPT.OTHER, False), 66 (OPT.OTHER, False),
67 (OPT.SITEKEY, ['foo', 'bar']), 67 (OPT.SITEKEY, ['foo', 'bar']),
68 ], 68 ],
69 }, 69 },
70 "||foo.com^$csp=script-src 'self' * 'unsafe-inline'": { 70 "||foo.com^$csp=script-src 'self' * 'unsafe-inline',script,sitekey=foo," +
71 'other,match-case,domain=foo.com': {
71 'selector': {'type': ST.URL_PATTERN, 'value': '||foo.com^'}, 72 'selector': {'type': ST.URL_PATTERN, 'value': '||foo.com^'},
72 'action': FA.BLOCK, 73 'action': FA.BLOCK,
73 'options': [ 74 'options': [
74 (OPT.CSP, "script-src 'self' * 'unsafe-inline'"), 75 (OPT.CSP, "script-src 'self' * 'unsafe-inline'"),
75 ], 76 ('script', True),
76 }, 77 ('sitekey', ['foo']),
77 'bla$match-case,csp=first csp,script,other,domain=foo.com,sitekey=foo': { 78 ('other', True),
Vasily Kuznetsov 2018/06/08 16:41:48 It seems like this test does more or less the sane
rhowell 2018/06/12 21:13:18 Done.
78 'selector': {'type': ST.URL_PATTERN, 'value': 'bla'},
79 'action': FA.BLOCK,
80 'options': [
81 ('match-case', True), 79 ('match-case', True),
82 ('csp', 'first csp'),
83 ('script', True),
84 ('other', True),
85 ('domain', [('foo.com', True)]), 80 ('domain', [('foo.com', True)]),
86 ('sitekey', ['foo']),
87 ],
88 },
89 'bla$~match-case,~csp=csp,~script,~other,~third-party,domain=~bar.com': {
90 'selector': {'type': ST.URL_PATTERN, 'value': 'bla'},
91 'action': FA.BLOCK,
92 'options': [
93 ('match-case', False),
94 ('csp=csp', False),
Vasily Kuznetsov 2018/06/08 16:41:48 Hm, I think this should be ('csp', False). I guess
rhowell 2018/06/12 21:13:18 Done.
95 ('script', False),
96 ('other', False),
97 ('third-party', False),
98 ('domain', [('bar.com', False)]),
99 ], 81 ],
100 }, 82 },
101 '@@bla$script,other,domain=foo.com|~bar.foo.com,csp=c s p': { 83 '@@bla$script,other,domain=foo.com|~bar.foo.com,csp=c s p': {
Vasily Kuznetsov 2018/06/08 16:41:48 This one adds testing, of a CSP option in an excep
rhowell 2018/06/12 21:13:18 I already combined the first two csp tests, so now
102 'selector': {'type': ST.URL_PATTERN, 'value': 'bla'}, 84 'selector': {'type': ST.URL_PATTERN, 'value': 'bla'},
103 'action': FA.ALLOW, 85 'action': FA.ALLOW,
104 'options': [ 86 'options': [
105 ('script', True), 87 ('script', True),
106 ('other', True), 88 ('other', True),
107 ('domain', [('foo.com', True), ('bar.foo.com', False)]), 89 ('domain', [('foo.com', True), ('bar.foo.com', False)]),
108 ('csp', 'c s p'), 90 ('csp', 'c s p'),
109 ], 91 ],
110 }, 92 },
111 # Element hiding filters and exceptions. 93 # Element hiding filters and exceptions.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 def test_exception_timing(): 181 def test_exception_timing():
200 result = parse_filterlist(['! good line', '%bad line%']) 182 result = parse_filterlist(['! good line', '%bad line%'])
201 assert next(result) == Comment('good line') 183 assert next(result) == Comment('good line')
202 with pytest.raises(ParseError): 184 with pytest.raises(ParseError):
203 next(result) 185 next(result)
204 186
205 187
206 def test_parse_line_bytes(): 188 def test_parse_line_bytes():
207 line = parse_line(b'! \xc3\xbc') 189 line = parse_line(b'! \xc3\xbc')
208 assert line.text == '\xfc' 190 assert line.text == '\xfc'
LEFTRIGHT

Powered by Google App Engine
This is Rietveld