#NEWLINE# def test_authentication_middleware_adds_authorization_header_to_response_authorized_with_cookie( self ) : #NEWLINE# #INDENT# environ [ 'MONGOREST_SETTINGS_MODULE' ] = 'tests.fixtures.middlewares_test_auth_settings' #NEWLINE# class TestResource ( ListResourceMixin ) : #NEWLINE# #INDENT# def list( self , request ) : #NEWLINE# #INDENT# request . environ [ 'session' ] [ 'test' ] = 'test' #NEWLINE# request . environ [ 'collection' ] = 'collection' #NEWLINE# return Response ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . test_client = self . client ( WSGIDispatcher ( resources = [ TestResource ] ) , Response ) #NEWLINE# session_store = locate ( settings . SESSION_STORE ) ( ) #NEWLINE# session = session_store . new ( ) #NEWLINE# session_store . save ( self ) #NEWLINE# response = self . test_client . get ( '/' , headers = [ ( 'Cookie' , 'session_id={0}' . format ( session . sid ) ) ] ) #NEWLINE# self . assertIn ( 'HTTP_AUTHORIZATION' , response . headers ) #NEWLINE# self . assertEqual ( response . headers . get ( 'HTTP_AUTHORIZATION' ) , 'Token {0}' . format ( session . sid ) ) #NEWLINE# environ . pop ( 'MONGOREST_SETTINGS_MODULE' )