2020-06-11 00:54:34 +02:00
|
|
|
from zerver.lib.test_classes import ZulipTestCase
|
2016-09-16 15:25:04 +02:00
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2016-09-16 15:25:04 +02:00
|
|
|
class TestReport(ZulipTestCase):
|
2018-04-11 05:50:08 +02:00
|
|
|
def test_report_csp_violations(self) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
fixture_data = self.fixture_data("csp_report.json")
|
|
|
|
with self.assertLogs(level="WARNING") as warn_logs:
|
2021-02-12 08:19:30 +01:00
|
|
|
result = self.client_post(
|
|
|
|
"/report/csp_violations", fixture_data, content_type="application/json"
|
|
|
|
)
|
2018-04-11 05:50:08 +02:00
|
|
|
self.assert_json_success(result)
|
2021-02-12 08:19:30 +01:00
|
|
|
self.assertEqual(
|
|
|
|
warn_logs.output,
|
|
|
|
[
|
2021-05-10 07:02:14 +02:00
|
|
|
"WARNING:root:CSP violation in document(''). blocked URI(''), original policy(''), violated directive(''), effective directive(''), disposition(''), referrer(''), status code(''), script sample('')"
|
2021-02-12 08:19:30 +01:00
|
|
|
],
|
|
|
|
)
|