<s> from __future__ import absolute_import , division , print_function , unicode_literals <EOL> from aspen import Response <EOL> from aspen . http . request import Request <EOL> from gratipay import security <EOL> from gratipay . testing import Harness <EOL> from pytest import raises <EOL> class TestSecurity ( Harness ) : <EOL> def test_oacm_is_installed_properly ( self ) : <EOL> assert self . client . hxt ( '<STR_LIT>' , '<STR_LIT:/>' ) . code == <NUM_LIT> <EOL> def test_oacm_allows_certain_methods ( self ) : <EOL> for allowed in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> request = Request ( allowed ) <EOL> assert security . only_allow_certain_methods ( request ) is None <EOL> def test_oacm_disallows_a_bunch_of_other_stuff ( self ) : <EOL> for disallowed in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> request = Request ( disallowed ) <EOL> response = raises ( Response , security . only_allow_certain_methods , request ) . value <EOL> assert response . code == <NUM_LIT> <EOL> def test_oacm_doesnt_choke_error_handling ( self ) : <EOL> assert self . client . hit ( "<STR_LIT>" , "<STR_LIT:/>" , raise_immediately = False ) . code == <NUM_LIT> <EOL> def test_ahtr_sets_x_frame_options ( self ) : <EOL> headers = self . client . GET ( '<STR_LIT>' ) . headers <EOL> assert headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_ahtr_sets_x_content_type_options ( self ) : <EOL> headers = self . client . GET ( '<STR_LIT>' ) . headers <EOL> assert headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_ahtr_sets_x_xss_protection ( self ) : <EOL> headers = self . client . GET ( '<STR_LIT>' ) . headers <EOL> assert headers [ '<STR_LIT>' ] == '<STR_LIT>' </s>
