3434 appinfo .URLMap (url = '/failure' , script = 'wsgi_test.nonexistent_function' ),
3535 appinfo .URLMap (url = '/env' , script = 'wsgi_test.dump_os_environ' ),
3636 appinfo .URLMap (url = '/setenv' , script = 'wsgi_test.add_to_os_environ' ),
37- appinfo .URLMap (url = '/wait' , script = 'wsgi_test.wait_on_global_event' )]
37+ appinfo .URLMap (url = '/wait' , script = 'wsgi_test.wait_on_global_event' ),
38+ appinfo .URLMap (url = '/favicon.ico' , static_files = 'test_statics/favicon.ico' ),
39+ appinfo .URLMap (url = '/faketype.ico' , static_files = 'test_statics/favicon.ico' ,
40+ mime_type = 'application/fake_type' ),
41+ appinfo .URLMap (url = '/wildcard_statics/(.*)' ,
42+ static_files = r'test_statics/\1' ),
43+ appinfo .URLMap (url = '/static_dir' ,
44+ static_dir = 'test_statics' ),
45+ ]
3846HELLO_STRING = 'Hello World!'
3947
4048FAKE_ENV_KEY = 'KEY'
@@ -118,6 +126,10 @@ def test_notfound(self):
118126 response = self .client .get ('/notfound' )
119127 self .assertEqual (response .status_code , 404 )
120128
129+ def test_health (self ):
130+ response = self .client .get ('/_ah/health' )
131+ self .assertEqual (response .status_code , 200 )
132+
121133 # Test PATH is present in env. If this breaks, each request is properly
122134 # wiping the environment but not properly reconstituting the frozen initial
123135 # state.
@@ -126,6 +138,39 @@ def test_basic_env(self):
126138 # Assumes PATH will be present in the env in all cases, including tests!
127139 self .assertIn ('PATH' , json .loads (response .data ))
128140
141+ def test_static_file (self ):
142+ response = self .client .get ('/favicon.ico' )
143+ self .assertEqual (response .status_code , 200 )
144+ with open ('test_statics/favicon.ico' ) as f :
145+ self .assertEqual (response .data , f .read ())
146+
147+ def test_static_file_mime_type (self ):
148+ response = self .client .get ('/faketype.ico' )
149+ self .assertEqual (response .status_code , 200 )
150+ with open ('test_statics/favicon.ico' ) as f :
151+ self .assertEqual (response .data , f .read ())
152+ self .assertEqual (response .mimetype , 'application/fake_type' )
153+
154+ def test_static_file_wildcard (self ):
155+ response = self .client .get ('/wildcard_statics/favicon.ico' )
156+ self .assertEqual (response .status_code , 200 )
157+ with open ('test_statics/favicon.ico' ) as f :
158+ self .assertEqual (response .data , f .read ())
159+
160+ def test_static_file_wildcard_404 (self ):
161+ response = self .client .get ('/wildcard_statics/no_file' )
162+ self .assertEqual (response .status_code , 404 )
163+
164+ def test_static_file_wildcard_directory_traversal (self ):
165+ response = self .client .get ('/wildcard_statics/../../setup.py' )
166+ self .assertEqual (response .status_code , 404 )
167+
168+ def test_static_dir (self ):
169+ response = self .client .get ('/static_dir/favicon.ico' )
170+ self .assertEqual (response .status_code , 200 )
171+ with open ('test_statics/favicon.ico' ) as f :
172+ self .assertEqual (response .data , f .read ())
173+
129174 def test_wsgi_vars_in_env (self ):
130175 response = self .client .get ('/env' )
131176 env = json .loads (response .data )
0 commit comments