MCPcopy
hub / github.com/django/django / test_coop_on

Method test_coop_on

tests/middleware/test_security.py:284–300  ·  view source on GitHub ↗

With SECURE_CROSS_ORIGIN_OPENER_POLICY set to a valid value, the middleware adds a "Cross-Origin_Opener-Policy" header to the response.

(self)

Source from the content-addressed store, hash-verified

282 )
283
284 def test_coop_on(self):
285 """
286 With SECURE_CROSS_ORIGIN_OPENER_POLICY set to a valid value, the
287 middleware adds a "Cross-Origin_Opener-Policy" header to the response.
288 """
289 tests = ["same-origin", "same-origin-allow-popups", "unsafe-none"]
290 for value in tests:
291 with (
292 self.subTest(value=value),
293 override_settings(
294 SECURE_CROSS_ORIGIN_OPENER_POLICY=value,
295 ),
296 ):
297 self.assertEqual(
298 self.process_response().headers["Cross-Origin-Opener-Policy"],
299 value,
300 )
301
302 @override_settings(SECURE_CROSS_ORIGIN_OPENER_POLICY="unsafe-none")
303 def test_coop_already_present(self):

Callers

nothing calls this directly

Calls 2

process_responseMethod · 0.95
override_settingsClass · 0.90

Tested by

no test coverage detected