From f9a3328a2510e7237b8bd8f35a57914f6a22bbd2 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Mon, 24 Dec 2018 20:35:18 +0300 Subject: Tests: more QUERY_STRING tests. --- test/test_python_application.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/test_python_application.py') diff --git a/test/test_python_application.py b/test/test_python_application.py index 667047bc..9c2c762d 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -53,6 +53,25 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.assertEqual(resp['headers']['Query-String'], 'var1=val1&var2=val2', 'Query-String header') + def test_python_application_query_string_empty(self): + self.load('query_string') + + resp = self.get(url='/?') + + self.assertEqual(resp['status'], 200, 'query string empty status') + self.assertEqual(resp['headers']['Query-String'], '', + 'query string empty') + + @unittest.expectedFailure + def test_python_application_query_string_absent(self): + self.load('query_string') + + resp = self.get() + + self.assertEqual(resp['status'], 200, 'query string absent status') + self.assertEqual(resp['headers']['Query-String'], '', + 'query string absent') + @unittest.expectedFailure def test_python_application_server_port(self): self.load('server_port') -- cgit From 59644130668c19522488932fbe894587e5616a94 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Tue, 25 Dec 2018 17:22:32 +0300 Subject: Tests: added delay to wait for error logging. --- test/test_python_application.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/test_python_application.py') diff --git a/test/test_python_application.py b/test/test_python_application.py index 9c2c762d..b28675f9 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -1,3 +1,4 @@ +import time import unittest import unit @@ -105,6 +106,8 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.stop() + time.sleep(0.2) + self.assertIsNotNone(self.search_in_log(r'RuntimeError'), 'ctx iter atexit') -- cgit From 955050aea3148595fde027319fd427369856ebc9 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Wed, 20 Feb 2019 20:28:29 +0300 Subject: Tests: skip sendmsg()/recvmsg() alerts for all tests. Currently, these alerts may appear in the log when any application exits. --- test/test_python_application.py | 8 -------- 1 file changed, 8 deletions(-) (limited to 'test/test_python_application.py') diff --git a/test/test_python_application.py b/test/test_python_application.py index b28675f9..d37af0c4 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -87,7 +87,6 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): '204 header transfer encoding') def test_python_application_ctx_iter_atexit(self): - self.skip_alerts.append(r'sendmsg.+failed') self.load('ctx_iter_atexit') resp = self.post(headers={ @@ -131,10 +130,6 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.assertEqual(resp['body'], '0123456789', 'keep-alive 2') def test_python_keepalive_reconfigure(self): - self.skip_alerts.extend([ - r'sendmsg.+failed', - r'recvmsg.+failed' - ]) self.load('mirror') body = '0123456789' @@ -183,7 +178,6 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): }, 'applications/mirror/processes'), 'reconfigure 3') def test_python_keepalive_reconfigure_2(self): - self.skip_alerts.append(r'sendmsg.+failed') self.load('mirror') body = '0123456789' @@ -217,7 +211,6 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.assertEqual(resp, {}, 'reconfigure 2 keep-alive 3') def test_python_keepalive_reconfigure_3(self): - self.skip_alerts.append(r'sendmsg.+failed') self.load('empty') (resp, sock) = self.http(b"""GET / HTTP/1.1 @@ -236,7 +229,6 @@ Connection: close self.assertEqual(resp['status'], 200, 'reconfigure 3') def test_python_atexit(self): - self.skip_alerts.append(r'sendmsg.+failed') self.load('atexit') self.get() -- cgit From 4de2c8b56719fce6b95b6f8a613b349590a3676f Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Wed, 27 Feb 2019 19:15:02 +0300 Subject: Tests: added "Host" and "Connetion" headers where necessary. Also minor header organizing. --- test/test_python_application.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'test/test_python_application.py') diff --git a/test/test_python_application.py b/test/test_python_application.py index d37af0c4..da5d3ba2 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -15,7 +15,8 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): resp = self.post(headers={ 'Host': 'localhost', 'Content-Type': 'text/html', - 'Custom-Header': 'blah' + 'Custom-Header': 'blah', + 'Connection': 'close' }, body=body) self.assertEqual(resp['status'], 200, 'status') @@ -31,6 +32,7 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): 'date header') self.assertDictEqual(headers, { + 'Connection': 'close', 'Content-Length': str(len(body)), 'Content-Type': 'text/html', 'Request-Method': 'POST', @@ -90,9 +92,9 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.load('ctx_iter_atexit') resp = self.post(headers={ + 'Host': 'localhost', 'Connection': 'close', - 'Content-Type': 'text/html', - 'Host': 'localhost' + 'Content-Type': 'text/html' }, body='0123456789') self.assertEqual(resp['status'], 200, 'ctx iter status') @@ -114,17 +116,17 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.load('mirror') (resp, sock) = self.post(headers={ + 'Host': 'localhost', 'Connection': 'keep-alive', - 'Content-Type': 'text/html', - 'Host': 'localhost' + 'Content-Type': 'text/html' }, start=True, body='0123456789' * 500) self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1') resp = self.post(headers={ + 'Host': 'localhost', 'Connection': 'close', - 'Content-Type': 'text/html', - 'Host': 'localhost' + 'Content-Type': 'text/html' }, sock=sock, body='0123456789') self.assertEqual(resp['body'], '0123456789', 'keep-alive 2') @@ -138,9 +140,9 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): for i in range(conns): (resp, sock) = self.post(headers={ + 'Host': 'localhost', 'Connection': 'keep-alive', - 'Content-Type': 'text/html', - 'Host': 'localhost' + 'Content-Type': 'text/html' }, start=True, body=body) self.assertEqual(resp['body'], body, 'keep-alive open') @@ -153,9 +155,9 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): for i in range(conns): (resp, sock) = self.post(headers={ + 'Host': 'localhost', 'Connection': 'keep-alive', - 'Content-Type': 'text/html', - 'Host': 'localhost' + 'Content-Type': 'text/html' }, start=True, sock=socks[i], body=body) self.assertEqual(resp['body'], body, 'keep-alive request') @@ -166,9 +168,9 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): for i in range(conns): resp = self.post(headers={ + 'Host': 'localhost', 'Connection': 'close', - 'Content-Type': 'text/html', - 'Host': 'localhost' + 'Content-Type': 'text/html' }, sock=socks[i], body=body) self.assertEqual(resp['body'], body, 'keep-alive close') @@ -183,9 +185,9 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): body = '0123456789' (resp, sock) = self.post(headers={ + 'Host': 'localhost', 'Connection': 'keep-alive', - 'Content-Type': 'text/html', - 'Host': 'localhost' + 'Content-Type': 'text/html' }, start=True, body=body) self.assertEqual(resp['body'], body, 'reconfigure 2 keep-alive 1') @@ -193,9 +195,9 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.load('empty') (resp, sock) = self.post(headers={ + 'Host': 'localhost', 'Connection': 'close', - 'Content-Type': 'text/html', - 'Host': 'localhost' + 'Content-Type': 'text/html' }, start=True, sock=sock, body=body) self.assertEqual(resp['status'], 200, 'reconfigure 2 keep-alive 2') -- cgit From a5dd0f8aa9b81921ff28c486a39fd46607dbdbd9 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Thu, 28 Feb 2019 20:20:41 +0300 Subject: Made QUERY_STRING mandatory. According to CGI/1.1 RFC 3875: The server MUST set this variable; if the Script-URI does not include a query component, the QUERY_STRING MUST be defined as an empty string (""). Python's PEP 333(3) allows omitting it in WSGI interface; PHP docs force no requirements; PSGI and Rack specifications require it even if empty. When nginx proxies requests over FastCGI, it always provides QUERY_STRING. and some PHP apps have been observed to fail if it is missing (see issue #201 on GitHub). A drawback of this change (besides a small overhead) is that there will be no easy way to tell a missing query string from an empty one (i.e. requests with or without the "?" character); yet, it's negligible compared to the possible benefits of wider application compatibility. This closes #226 issue on GitHub. --- test/test_python_application.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test/test_python_application.py') diff --git a/test/test_python_application.py b/test/test_python_application.py index da5d3ba2..a8631085 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -65,7 +65,6 @@ class TestUnitPythonApplication(unit.TestUnitApplicationPython): self.assertEqual(resp['headers']['Query-String'], '', 'query string empty') - @unittest.expectedFailure def test_python_application_query_string_absent(self): self.load('query_string') -- cgit