|
3 | 3 | from django.test import RequestFactory
|
4 | 4 | from django.test.utils import override_settings
|
5 | 5 |
|
6 |
| -from csp.constants import HEADER, HEADER_REPORT_ONLY |
| 6 | +from csp.constants import HEADER, HEADER_REPORT_ONLY, NONCE |
7 | 7 | from csp.decorators import csp, csp_exempt, csp_replace, csp_update
|
8 | 8 | from csp.middleware import CSPMiddleware
|
9 | 9 | from csp.tests.utils import response
|
@@ -44,12 +44,12 @@ def view_without_decorator(request):
|
44 | 44 | policy_list = sorted(response[HEADER].split("; "))
|
45 | 45 | assert policy_list == ["default-src 'self'", "img-src foo.com"]
|
46 | 46 |
|
47 |
| - @csp_update({"img-src": ["bar.com"], "include-nonce-in": ["img-src"]}) |
| 47 | + @csp_update({"img-src": ["bar.com", NONCE]}) |
48 | 48 | def view_with_decorator(request):
|
49 | 49 | return HttpResponse()
|
50 | 50 |
|
51 | 51 | response = view_with_decorator(request)
|
52 |
| - assert response._csp_update == {"img-src": ["bar.com"], "include-nonce-in": ["img-src"]} |
| 52 | + assert response._csp_update == {"img-src": ["bar.com", NONCE]} |
53 | 53 | mw.process_request(request)
|
54 | 54 | assert request.csp_nonce # Here to trigger the nonce creation.
|
55 | 55 | mw.process_response(request, response)
|
@@ -77,12 +77,12 @@ def view_without_decorator(request):
|
77 | 77 | policy_list = sorted(response[HEADER_REPORT_ONLY].split("; "))
|
78 | 78 | assert policy_list == ["default-src 'self'", "img-src foo.com"]
|
79 | 79 |
|
80 |
| - @csp_update({"img-src": ["bar.com"], "include-nonce-in": ["img-src"]}, REPORT_ONLY=True) |
| 80 | + @csp_update({"img-src": ["bar.com", NONCE]}, REPORT_ONLY=True) |
81 | 81 | def view_with_decorator(request):
|
82 | 82 | return HttpResponse()
|
83 | 83 |
|
84 | 84 | response = view_with_decorator(request)
|
85 |
| - assert response._csp_update_ro == {"img-src": ["bar.com"], "include-nonce-in": ["img-src"]} |
| 85 | + assert response._csp_update_ro == {"img-src": ["bar.com", NONCE]} |
86 | 86 | mw.process_request(request)
|
87 | 87 | assert request.csp_nonce # Here to trigger the nonce creation.
|
88 | 88 | mw.process_response(request, response)
|
|
0 commit comments