Revision ea9df6c7
Added by koszko over 1 year ago
test/unit/test_policy_deciding.py | ||
---|---|---|
55 | 55 |
returnval(decide_policy(pqt.make(), "http://unkno.wn/", true, "abcd")); |
56 | 56 |
''') |
57 | 57 |
assert policy['allow'] == True |
58 |
for prop in ('mapping', 'payload', 'nonce', 'csp'): |
|
58 |
for prop in ('mapping', 'payload', 'nonce', 'csp', 'error'):
|
|
59 | 59 |
assert prop not in policy |
60 | 60 |
|
61 | 61 |
policy = execute_in_page( |
... | ... | |
66 | 66 |
}''') |
67 | 67 |
assert policy['allow'] == True |
68 | 68 |
assert policy['mapping'] == '~allow' |
69 |
for prop in ('payload', 'nonce', 'csp'): |
|
69 |
for prop in ('payload', 'nonce', 'csp', 'error'):
|
|
70 | 70 |
assert prop not in policy |
71 | 71 |
|
72 | 72 |
policy = execute_in_page( |
... | ... | |
75 | 75 |
''' |
76 | 76 |
) |
77 | 77 |
assert policy['allow'] == False |
78 |
for prop in ('mapping', 'payload', 'nonce'): |
|
78 |
for prop in ('mapping', 'payload', 'nonce', 'error'):
|
|
79 | 79 |
assert prop not in policy |
80 | 80 |
assert parse_csp(policy['csp']) == { |
81 | 81 |
'prefetch-src': "'none'", |
... | ... | |
92 | 92 |
}''') |
93 | 93 |
assert policy['allow'] == False |
94 | 94 |
assert policy['mapping'] == '~allow' |
95 |
for prop in ('payload', 'nonce'): |
|
95 |
for prop in ('payload', 'nonce', 'error'):
|
|
96 | 96 |
assert prop not in policy |
97 | 97 |
assert parse_csp(policy['csp']) == { |
98 | 98 |
'prefetch-src': "'none'", |
... | ... | |
110 | 110 |
assert policy['allow'] == False |
111 | 111 |
assert policy['mapping'] == 'm1' |
112 | 112 |
assert policy['payload'] == {'identifier': 'res1'} |
113 |
|
|
113 |
assert 'error' not in policy |
|
114 | 114 |
assert policy['nonce'] == \ |
115 | 115 |
sha256('m1:res1:http://kno.wn/:abcd'.encode()).digest().hex() |
116 | 116 |
assert parse_csp(policy['csp']) == { |
... | ... | |
119 | 119 |
'script-src': f"'nonce-{policy['nonce']}'", |
120 | 120 |
'script-src-elem': f"'nonce-{policy['nonce']}'" |
121 | 121 |
} |
122 |
|
|
123 |
policy = execute_in_page( |
|
124 |
'returnval(decide_policy(pqt.make(), "<bad_url>", true, "abcd"));' |
|
125 |
) |
|
126 |
assert policy['allow'] == False |
|
127 |
assert policy['error'] == {'haketilo_error_type': 'deciding_policy'} |
|
128 |
for prop in ('mapping', 'payload', 'nonce'): |
|
129 |
assert prop not in policy |
|
130 |
assert parse_csp(policy['csp']) == { |
|
131 |
'prefetch-src': "'none'", |
|
132 |
'script-src-attr': "'none'", |
|
133 |
'script-src': "'none'", |
|
134 |
'script-src-elem': "'none'" |
|
135 |
} |
Also available in: Unified diff
update error reporting in popup