<s> """<STR_LIT>""" <EOL> from tests import strict_eq <EOL> from werkzeug . datastructures import ResponseCacheControl <EOL> from werkzeug . http import parse_cache_control_header <EOL> from werkzeug . test import create_environ , Client <EOL> from werkzeug . wrappers import Request , Response <EOL> from werkzeug . contrib import fixers <EOL> from werkzeug . utils import redirect <EOL> @ Request . application <EOL> def path_check_app ( request ) : <EOL> return Response ( '<STR_LIT>' % ( <EOL> request . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> request . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ) ) <EOL> class TestServerFixer ( object ) : <EOL> def test_cgi_root_fix ( self ) : <EOL> app = fixers . CGIRootFix ( path_check_app ) <EOL> response = Response . from_app ( <EOL> app , <EOL> dict ( create_environ ( ) , <EOL> SCRIPT_NAME = '<STR_LIT>' , <EOL> PATH_INFO = '<STR_LIT>' , <EOL> SERVER_SOFTWARE = '<STR_LIT>' ) ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> def test_cgi_root_fix_custom_app_root ( self ) : <EOL> app = fixers . CGIRootFix ( path_check_app , app_root = '<STR_LIT>' ) <EOL> response = Response . from_app ( <EOL> app , <EOL> dict ( create_environ ( ) , <EOL> SCRIPT_NAME = '<STR_LIT>' , <EOL> PATH_INFO = '<STR_LIT>' ) ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> def test_path_info_from_request_uri_fix ( self ) : <EOL> app = fixers . PathInfoFromRequestUriFix ( path_check_app ) <EOL> for key in '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' : <EOL> env = dict ( create_environ ( ) , SCRIPT_NAME = '<STR_LIT>' , PATH_INFO = '<STR_LIT>' ) <EOL> env [ key ] = '<STR_LIT>' <EOL> response = Response . from_app ( app , env ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> def test_proxy_fix ( self ) : <EOL> @ Request . application <EOL> def app ( request ) : <EOL> return Response ( '<STR_LIT>' % ( <EOL> request . remote_addr , <EOL> request . environ [ '<STR_LIT>' ] <EOL> ) ) <EOL> app = fixers . ProxyFix ( app , num_proxies = <NUM_LIT:2> ) <EOL> environ = dict ( <EOL> create_environ ( ) , <EOL> HTTP_X_FORWARDED_PROTO = "<STR_LIT>" , <EOL> HTTP_X_FORWARDED_HOST = '<STR_LIT>' , <EOL> HTTP_X_FORWARDED_FOR = '<STR_LIT>' , <EOL> REMOTE_ADDR = '<STR_LIT:127.0.0.1>' , <EOL> HTTP_HOST = '<STR_LIT>' <EOL> ) <EOL> response = Response . from_app ( app , environ ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> redirect_app = redirect ( '<STR_LIT>' ) <EOL> response = Response . from_app ( redirect_app , environ ) <EOL> wsgi_headers = response . get_wsgi_headers ( environ ) <EOL> assert wsgi_headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_proxy_fix_weird_enum ( self ) : <EOL> @ fixers . ProxyFix <EOL> @ Request . application <EOL> def app ( request ) : <EOL> return Response ( request . remote_addr ) <EOL> environ = dict ( <EOL> create_environ ( ) , <EOL> HTTP_X_FORWARDED_FOR = '<STR_LIT:U+002C>' , <EOL> REMOTE_ADDR = '<STR_LIT:127.0.0.1>' , <EOL> ) <EOL> response = Response . from_app ( app , environ ) <EOL> strict_eq ( response . get_data ( ) , b'<STR_LIT:127.0.0.1>' ) <EOL> def test_header_rewriter_fix ( self ) : <EOL> @ Request . application <EOL> def application ( request ) : <EOL> return Response ( "<STR_LIT>" , headers = [ <EOL> ( '<STR_LIT>' , '<STR_LIT:bar>' ) <EOL> ] ) <EOL> application = fixers . HeaderRewriterFix ( application , ( '<STR_LIT>' , ) , ( ( '<STR_LIT>' , '<STR_LIT>' ) , ) ) <EOL> response = Response . from_app ( application , create_environ ( ) ) <EOL> assert response . headers [ '<STR_LIT:Content-Type>' ] == '<STR_LIT>' <EOL> assert '<STR_LIT>' not in response . headers <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> class TestBrowserFixer ( object ) : <EOL> def test_ie_fixes ( self ) : <EOL> @ fixers . InternetExplorerFix <EOL> @ Request . application <EOL> def application ( request ) : <EOL> response = Response ( '<STR_LIT>' , mimetype = '<STR_LIT>' ) <EOL> response . headers [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> response . headers [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> return response <EOL> c = Client ( application , Response ) <EOL> response = c . get ( '<STR_LIT:/>' , headers = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ] ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> assert '<STR_LIT>' not in response . headers <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> c = Client ( application , Response ) <EOL> response = c . get ( '<STR_LIT:/>' ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> assert '<STR_LIT>' in response . headers <EOL> cc = ResponseCacheControl ( ) <EOL> cc . no_cache = True <EOL> @ fixers . InternetExplorerFix <EOL> @ Request . application <EOL> def application ( request ) : <EOL> response = Response ( '<STR_LIT>' , mimetype = '<STR_LIT>' ) <EOL> response . headers [ '<STR_LIT>' ] = '<STR_LIT:U+002CU+0020>' . join ( pragma ) <EOL> response . headers [ '<STR_LIT>' ] = cc . to_header ( ) <EOL> response . headers [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> return response <EOL> pragma = ( '<STR_LIT>' , ) <EOL> c = Client ( application , Response ) <EOL> response = c . get ( '<STR_LIT:/>' , headers = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ] ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> assert '<STR_LIT>' not in response . headers <EOL> assert '<STR_LIT>' not in response . headers <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> pragma = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> cc . proxy_revalidate = True <EOL> response = c . get ( '<STR_LIT:/>' , headers = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ] ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> response = c . get ( '<STR_LIT:/>' ) <EOL> assert response . get_data ( ) == b'<STR_LIT>' <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> cc = parse_cache_control_header ( response . headers [ '<STR_LIT>' ] , <EOL> cls = ResponseCacheControl ) <EOL> assert cc . no_cache <EOL> assert cc . proxy_revalidate <EOL> assert response . headers [ '<STR_LIT>' ] == '<STR_LIT>' </s>
