Skip to content

Commit f6567af

Browse files
authored
Fix the CSP regression (#280)
* fix: csp * fix: failing tests
1 parent d4f6e66 commit f6567af

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

piccolo_api/csp/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async def wrapped_send(message: Message):
2929
if message["type"] == "http.response.start":
3030
headers = message.get("headers", [])
3131
header_value = bytes(
32-
f"default-src: '{self.config.default_src}'", "utf8"
32+
f"default-src '{self.config.default_src}'", "utf8"
3333
)
3434
if self.config.report_uri:
3535
header_value = (

tests/csp/test_csp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_headers(self):
3636
# Make sure the headers got added:
3737
self.assertEqual(
3838
response.headers["content-security-policy"],
39-
"default-src: 'self'",
39+
"default-src 'self'",
4040
)
4141

4242
# Make sure the original headers are still intact:
@@ -53,7 +53,7 @@ def test_default_src(self):
5353

5454
self.assertEqual(
5555
response.headers.get("content-security-policy"),
56-
"default-src: 'none'",
56+
"default-src 'none'",
5757
)
5858

5959
def test_report_uri(self):
@@ -66,5 +66,5 @@ def test_report_uri(self):
6666

6767
self.assertEqual(
6868
response.headers["content-security-policy"],
69-
"default-src: 'self'; report-uri foo.com",
69+
"default-src 'self'; report-uri foo.com",
7070
)

0 commit comments

Comments
 (0)