From eb66ddcfff4cfad51fad44e0a764e9c336ae9f6b Mon Sep 17 00:00:00 2001 From: Dylan Young Date: Thu, 26 May 2022 02:15:47 -0300 Subject: [PATCH] fixup! GH-36 Add tests for multi-policy support and csp_append/csp_select decorators --- csp/tests/test_decorators.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/csp/tests/test_decorators.py b/csp/tests/test_decorators.py index 978e108..4b5dcb3 100644 --- a/csp/tests/test_decorators.py +++ b/csp/tests/test_decorators.py @@ -170,6 +170,22 @@ def view_with_decorator(request): assert policy_list == ["default-src 'self'"] +def test_csp_case_insensitive(): + @csp(img_src=['foo.com'], font_src=['bar.com']) + def view_with_decorator(request): + return HttpResponse() + response = view_with_decorator(REQUEST) + assert response._csp_config == { + policy_names.last_policy_name: { + 'img-src': ['foo.com'], + 'font-src': ['bar.com'], + } + } + mw.process_response(REQUEST, response) + policy_list = sorted(response[HEADER].split("; ")) + assert policy_list == ["font-src bar.com", "img-src foo.com"] + + def test_csp_with_args(): @csp( {'img-src': ['foo.com']},