|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from django.core.exceptions import ImproperlyConfigured |
4 | | -from django.test import SimpleTestCase, TestCase |
| 4 | +from django.test import Client, SimpleTestCase, TestCase |
5 | 5 |
|
6 | 6 | from content.public_data import ordered_podcasts, podcast_seasons, public_projection |
7 | 7 | from core.seo import validated_canonical_url |
@@ -285,7 +285,12 @@ def test_homepage_uses_the_same_latest_episode(self) -> None: |
285 | 285 | public_projection()["podcasts"][0]["title"], |
286 | 286 | ) |
287 | 287 |
|
288 | | - def test_get_and_head_are_supported_but_post_is_not(self) -> None: |
289 | | - self.assertEqual(self.client.get("/podcast?page=2").status_code, 200) |
290 | | - self.assertEqual(self.client.head("/podcast?page=2").status_code, 200) |
291 | | - self.assertEqual(self.client.post("/podcast?page=2").status_code, 405) |
| 288 | + def test_get_and_head_are_supported_but_post_is_rejected_before_csrf(self) -> None: |
| 289 | + csrf_client = Client(enforce_csrf_checks=True) |
| 290 | + |
| 291 | + self.assertEqual(csrf_client.get("/podcast?page=2").status_code, 200) |
| 292 | + self.assertEqual(csrf_client.head("/podcast?page=2").status_code, 200) |
| 293 | + |
| 294 | + response = csrf_client.post("/podcast?page=2") |
| 295 | + self.assertEqual(response.status_code, 405) |
| 296 | + self.assertEqual(response.headers["Allow"], "GET, HEAD") |
0 commit comments