<s> import os <EOL> from django . conf import settings <EOL> from django . test . utils import override_settings <EOL> from olympia . amo . tests import TestCase <EOL> from olympia . lib import settings_base as base_settings <EOL> @ override_settings ( CSP_REPORT_ONLY = False ) <EOL> class TestCSPHeaders ( TestCase ) : <EOL> def test_for_specific_csp_settings ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> assert response . status_code == <NUM_LIT:200> <EOL> assert "<STR_LIT>" in response [ '<STR_LIT>' ] <EOL> assert "<STR_LIT>" in response [ '<STR_LIT>' ] <EOL> assert "<STR_LIT>" in response [ '<STR_LIT>' ] <EOL> assert "<STR_LIT>" in response [ '<STR_LIT>' ] <EOL> assert "<STR_LIT>" in response [ '<STR_LIT>' ] <EOL> assert "<STR_LIT>" in response [ '<STR_LIT>' ] <EOL> assert "<STR_LIT>" in response [ '<STR_LIT>' ] <EOL> def test_unsafe_inline_not_in_script_src ( self ) : <EOL> """<STR_LIT>""" <EOL> assert "<STR_LIT>" not in base_settings . CSP_SCRIPT_SRC <EOL> def test_unsafe_eval_not_in_script_src ( self ) : <EOL> """<STR_LIT>""" <EOL> assert "<STR_LIT>" not in base_settings . CSP_SCRIPT_SRC <EOL> def test_data_uri_not_in_script_src ( self ) : <EOL> """<STR_LIT>""" <EOL> assert '<STR_LIT>' not in base_settings . CSP_SCRIPT_SRC <EOL> def test_http_protocol_not_in_script_src ( self ) : <EOL> """<STR_LIT>""" <EOL> for val in base_settings . CSP_SCRIPT_SRC : <EOL> assert not val . startswith ( '<STR_LIT>' ) <EOL> def test_http_protocol_not_in_frame_src ( self ) : <EOL> """<STR_LIT>""" <EOL> for val in base_settings . CSP_FRAME_SRC : <EOL> assert not val . startswith ( '<STR_LIT>' ) <EOL> def test_http_protocol_not_in_style_src ( self ) : <EOL> """<STR_LIT>""" <EOL> for val in base_settings . CSP_STYLE_SRC : <EOL> assert not val . startswith ( '<STR_LIT>' ) <EOL> def test_http_protocol_not_in_img_src ( self ) : <EOL> """<STR_LIT>""" <EOL> for val in base_settings . CSP_IMG_SRC : <EOL> assert not val . startswith ( '<STR_LIT>' ) <EOL> def test_prod_cdn_in_common_settings ( self ) : <EOL> """<STR_LIT>""" <EOL> prod_cdn_host = base_settings . PROD_CDN_HOST <EOL> assert prod_cdn_host in base_settings . CSP_FONT_SRC <EOL> assert prod_cdn_host in base_settings . CSP_IMG_SRC <EOL> assert prod_cdn_host in base_settings . CSP_SCRIPT_SRC <EOL> assert prod_cdn_host in base_settings . CSP_STYLE_SRC <EOL> def test_self_in_common_settings ( self ) : <EOL> """<STR_LIT>""" <EOL> assert "<STR_LIT>" in base_settings . CSP_CONNECT_SRC <EOL> assert "<STR_LIT>" in base_settings . CSP_FRAME_SRC <EOL> assert "<STR_LIT>" in base_settings . CSP_IMG_SRC <EOL> assert "<STR_LIT>" in base_settings . CSP_SCRIPT_SRC <EOL> assert "<STR_LIT>" in base_settings . CSP_STYLE_SRC <EOL> def test_analytics_in_common_settings ( self ) : <EOL> """<STR_LIT>""" <EOL> analytics_host = base_settings . ANALYTICS_HOST <EOL> assert analytics_host in base_settings . CSP_IMG_SRC <EOL> assert analytics_host in base_settings . CSP_SCRIPT_SRC <EOL> def test_csp_settings_not_overriden_for_prod ( self ) : <EOL> """<STR_LIT>""" <EOL> path = os . path . join ( <EOL> settings . ROOT , '<STR_LIT:src>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> with open ( path ) as f : <EOL> data = f . read ( ) <EOL> assert '<STR_LIT>' not in data </s>
