diff options
author | Giovane <giovaneliberato@gmail.com> | 2015-09-03 18:37:03 -0300 |
---|---|---|
committer | Giovane <giovaneliberato@gmail.com> | 2015-09-03 18:39:47 -0300 |
commit | 7f600c988e0a1626ca0e24a1d7a1fa7797771915 (patch) | |
tree | d3d5b5a8cdc9a480ab289c92335cbb239b0d43ae /service/test/unit/config | |
parent | 19cda9ca7aa1aca18f61ebf659fc490f8ad4c15a (diff) |
#304 Adds PixelatedSite class to hold custom request configuration and remove foundation inline javascript.
Diffstat (limited to 'service/test/unit/config')
-rw-r--r-- | service/test/unit/config/test_site.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/service/test/unit/config/test_site.py b/service/test/unit/config/test_site.py new file mode 100644 index 00000000..77d42ed8 --- /dev/null +++ b/service/test/unit/config/test_site.py @@ -0,0 +1,24 @@ +import unittest +from mockito import mock +from pixelated.config.site import PixelatedSite +from twisted.protocols.basic import LineReceiver + + +class TestPixelatedSite(unittest.TestCase): + def test_add_csp_header_request(self): + request = self.create_request() + request.process() + headers = request.headers + self.assertEqual(headers.get("Content-Security-Policy"), "default-src 'self'; style-src 'self' 'unsafe-inline'") + + def create_request(self): + channel = LineReceiver() + channel.site = PixelatedSite(mock()) + request = PixelatedSite.requestFactory(channel=channel, queued=True) + request.method = "GET" + request.uri = "localhost" + request.clientproto = 'HTTP/1.1' + request.prepath = [] + request.postpath = request.uri.split('/')[1:] + request.path = "/" + return request |