From f5b7e5d9346eb2d70941e907e48f1d6daba33ac9 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 25 Mar 2021 12:47:54 -0700 Subject: [PATCH] puppeteer_tests: Use POST for flush_caches call. --- tools/test-js-with-puppeteer | 2 +- zerver/views/development/cache.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/test-js-with-puppeteer b/tools/test-js-with-puppeteer index e8497bc712..26e874855f 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 2d9f70932e..906b8212c4 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()