mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-10-06 21:38:26 -04:00
Add Cross-Origin-Resource-Policy header to thumbnail and download media endpoints (#12944)
This commit is contained in:
parent
3c5549e74a
commit
9b683ea80f
5 changed files with 44 additions and 2 deletions
|
@ -481,6 +481,12 @@ class MediaRepoTests(unittest.HomeserverTestCase):
|
|||
|
||||
if expected_found:
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
self.assertEqual(
|
||||
channel.headers.getRawHeaders(b"Cross-Origin-Resource-Policy"),
|
||||
[b"cross-origin"],
|
||||
)
|
||||
|
||||
if expected_body is not None:
|
||||
self.assertEqual(
|
||||
channel.result["body"], expected_body, channel.result["body"]
|
||||
|
@ -549,6 +555,20 @@ class MediaRepoTests(unittest.HomeserverTestCase):
|
|||
[b"noindex, nofollow, noarchive, noimageindex"],
|
||||
)
|
||||
|
||||
def test_cross_origin_resource_policy_header(self) -> None:
|
||||
"""
|
||||
Test that the Cross-Origin-Resource-Policy header is set to "cross-origin"
|
||||
allowing web clients to embed media from the downloads API.
|
||||
"""
|
||||
channel = self._req(b"inline; filename=out" + self.test_image.extension)
|
||||
|
||||
headers = channel.headers
|
||||
|
||||
self.assertEqual(
|
||||
headers.getRawHeaders(b"Cross-Origin-Resource-Policy"),
|
||||
[b"cross-origin"],
|
||||
)
|
||||
|
||||
|
||||
class TestSpamChecker:
|
||||
"""A spam checker module that rejects all media that includes the bytes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue