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):
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_send_time(self) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
self.login("hamlet")
|
2016-09-16 15:25:04 +02:00
|
|
|
|
|
|
|
params = dict(
|
|
|
|
time=5,
|
|
|
|
received=6,
|
|
|
|
displayed=7,
|
2021-02-12 08:20:45 +01:00
|
|
|
locally_echoed="true",
|
|
|
|
rendered_content_disparity="true",
|
2016-09-16 15:25:04 +02:00
|
|
|
)
|
|
|
|
|
2023-04-26 03:09:19 +02:00
|
|
|
result = self.client_post("/json/report/send_times", params)
|
2016-09-16 15:25:04 +02:00
|
|
|
self.assert_json_success(result)
|
|
|
|
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_narrow_time(self) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
self.login("hamlet")
|
2016-09-16 15:25:04 +02:00
|
|
|
|
|
|
|
params = dict(
|
|
|
|
initial_core=5,
|
|
|
|
initial_free=6,
|
|
|
|
network=7,
|
|
|
|
)
|
|
|
|
|
2023-04-26 03:09:19 +02:00
|
|
|
result = self.client_post("/json/report/narrow_times", params)
|
2016-09-16 15:25:04 +02:00
|
|
|
self.assert_json_success(result)
|
|
|
|
|
2020-08-31 09:22:40 +02:00
|
|
|
def test_anonymous_user_narrow_time(self) -> None:
|
|
|
|
params = dict(
|
|
|
|
initial_core=5,
|
|
|
|
initial_free=6,
|
|
|
|
network=7,
|
|
|
|
)
|
|
|
|
|
2023-04-26 03:09:19 +02:00
|
|
|
result = self.client_post("/json/report/narrow_times", params)
|
2020-08-31 09:22:40 +02:00
|
|
|
self.assert_json_success(result)
|
|
|
|
|
2017-11-05 10:51:25 +01:00
|
|
|
def test_unnarrow_time(self) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
self.login("hamlet")
|
2016-09-16 15:25:04 +02:00
|
|
|
|
|
|
|
params = dict(
|
2020-08-31 09:22:40 +02:00
|
|
|
initial_core=5,
|
|
|
|
initial_free=6,
|
|
|
|
)
|
|
|
|
|
2023-04-26 03:09:19 +02:00
|
|
|
result = self.client_post("/json/report/unnarrow_times", params)
|
2020-08-31 09:22:40 +02:00
|
|
|
self.assert_json_success(result)
|
|
|
|
|
|
|
|
def test_anonymous_user_unnarrow_time(self) -> None:
|
|
|
|
params = dict(
|
2016-09-16 15:25:04 +02:00
|
|
|
initial_core=5,
|
|
|
|
initial_free=6,
|
|
|
|
)
|
|
|
|
|
2023-04-26 03:09:19 +02:00
|
|
|
result = self.client_post("/json/report/unnarrow_times", params)
|
2016-09-16 15:25:04 +02:00
|
|
|
self.assert_json_success(result)
|
|
|
|
|
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
|
|
|
],
|
|
|
|
)
|