Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

puppeteer_tests: Use POST for flush_caches call.

Tim Abbottf5b7e5d9346e
diff --git a/tools/test-js-with-puppeteer b/tools/test-js-with-puppeteer
index e8497bc7125..26e874855fd 100755
--- a/tools/test-js-with-puppeteer
+++ b/tools/test-js-with-puppeteer
@@ -90,7 +90,7 @@ def run_tests(files: Iterable[str], external_host: str) -> None:
# Resetting test environment.
reset_zulip_test_database()
# We are calling to /flush_caches to remove all the server-side caches.
- response = requests.get("http://zulip.zulipdev.com:9981/flush_caches")
+ response = requests.post("http://zulip.zulipdev.com:9981/flush_caches")
assert response.status_code == 200
if ret != 0:
diff --git a/zerver/views/development/cache.py b/zerver/views/development/cache.py
index 2d9f70932e7..906b8212c46 100644
--- a/zerver/views/development/cache.py
+++ b/zerver/views/development/cache.py
@@ -1,7 +1,9 @@
import os
from django.http import HttpRequest, HttpResponse
+from django.views.decorators.csrf import csrf_exempt
+from zerver.decorator import require_post
from zerver.lib.cache import get_cache_backend
from zerver.lib.response import json_success
from zerver.models import clear_client_cache, flush_per_request_caches
@@ -9,6 +11,8 @@ from zerver.models import clear_client_cache, flush_per_request_caches
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../")
# This is used only by the Puppeteer Tests to clear all the cache after each run.
+@csrf_exempt
+@require_post
def remove_caches(request: HttpRequest) -> HttpResponse:
cache = get_cache_backend(None)
cache.clear()