From b7185e89e473865f474774b8a7592119b45e53d8 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Tue, 15 Dec 2009 10:47:05 -0800 Subject: [PATCH] Added test to ensure we don't repeat the mistake that led to Luke's bug, also made testhttpd call its superclass setup/teardown methods. --- AUTHORS | 1 + tests/wsgi_test.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/AUTHORS b/AUTHORS index d37ba07..7d4a356 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,6 +23,7 @@ Linden Lab Contributors Thanks To --------- +* Luke Tucker, bug report regarding wsgi + webob * Chuck Thier, reporting a bug in processes.py * Brantley Harris, reporting bug #4 * Taso Du Val, reproing an exception squelching bug, saving children's lives ;-) diff --git a/tests/wsgi_test.py b/tests/wsgi_test.py index 131072e..88b84ac 100644 --- a/tests/wsgi_test.py +++ b/tests/wsgi_test.py @@ -113,6 +113,7 @@ def read_http(sock): class TestHttpd(LimitedTestCase): mode = 'static' def setUp(self): + super(TestHttpd, self).setUp() self.logfile = StringIO() self.site = Site() listener = api.tcp_listener(('localhost', 0)) @@ -125,7 +126,9 @@ class TestHttpd(LimitedTestCase): log=self.logfile) def tearDown(self): + super(TestHttpd, self).tearDown() api.kill(self.killer) + api.sleep(0) def test_001_server(self): sock = api.connect_tcp( @@ -468,6 +471,26 @@ class TestHttpd(LimitedTestCase): self.assert_('5.6.7.8' not in self.logfile.getvalue()) self.assert_('127.0.0.1' in self.logfile.getvalue()) + def test_021_environ_clobbering(self): + def clobberin_time(environ, start_response): + for environ_var in ['wsgi.version', 'wsgi.url_scheme', + 'wsgi.input', 'wsgi.errors', 'wsgi.multithread', + 'wsgi.multiprocess', 'wsgi.run_once', 'REQUEST_METHOD', + 'SCRIPT_NAME', 'PATH_INFO', 'QUERY_STRING', 'CONTENT_TYPE', + 'CONTENT_LENGTH', 'SERVER_NAME', 'SERVER_PORT', + 'SERVER_PROTOCOL']: + environ[environ_var] = None + start_response('200 OK', [('Content-type', 'text/plain')]) + return [] + self.site.application = clobberin_time + sock = api.connect_tcp(('localhost', self.port)) + fd = sock.makeGreenFile() + fd.write('GET / HTTP/1.1\r\n' + 'Host: localhost\r\n' + 'Connection: close\r\n' + '\r\n\r\n') + self.assert_('200 OK' in fd.read()) + if __name__ == '__main__': main()