def test_cron_only_failure(self): from kay.utils import is_dev_server response = self.client.get("/cron") if is_dev_server(): self.assertEqual(response.status_code, 200) else: self.assertEqual(response.status_code, 403) response = self.client.get("/class_based_test_root/cron") if is_dev_server(): self.assertEqual(response.status_code, 200) else: self.assertEqual(response.status_code, 403)
def inner(request, *args, **kwargs): from kay.utils import is_dev_server from kay.conf import settings # Only allow access in the following cases # 1. We are using the dev server in DEBUG mode # 2. The X-AppEngine-Cron request header is set to true if not ((is_dev_server() and settings.DEBUG) or request.headers.get("X-AppEngine-Cron") == "true"): raise Forbidden("This URL is cron only") return func(request, *args, **kwargs)
def inner(request, *args, **kwargs): from kay.utils import is_dev_server from kay.conf import settings # Only allow access in the following cases # 1. We are using the dev server in DEBUG mode # 2. The X-AppEngine-Cron request header is set to true if (not (is_dev_server() and settings.DEBUG) and not request.headers.get("X-AppEngine-Cron") == "true"): raise Forbidden("This URL is cron only") return func(request, *args, **kwargs)