diff options
author | Andrei Belov <defan@nginx.com> | 2020-05-28 18:13:06 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-05-28 18:13:06 +0300 |
commit | 733c14e991d6b2d5bdae5202ae9f090d022bc956 (patch) | |
tree | 120562db5d30e5f4f51d001397f765f5cebab999 /test/test_proxy.py | |
parent | 6a8d4571d7fc89a951b4da80c39a93fcaa634406 (diff) | |
parent | 9d8e476c4e3695019b0a1fe3696d3411a8393de6 (diff) | |
download | unit-733c14e991d6b2d5bdae5202ae9f090d022bc956.tar.gz unit-733c14e991d6b2d5bdae5202ae9f090d022bc956.tar.bz2 |
Merged with the default branch.
Diffstat (limited to 'test/test_proxy.py')
-rw-r--r-- | test/test_proxy.py | 113 |
1 files changed, 31 insertions, 82 deletions
diff --git a/test/test_proxy.py b/test/test_proxy.py index 74bd0873..feec1ac4 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -1,12 +1,13 @@ import re -import time import socket +import time import unittest + from unit.applications.lang.python import TestApplicationPython class TestProxy(TestApplicationPython): - prerequisites = {'modules': ['python']} + prerequisites = {'modules': {'python': 'any'}} SERVER_PORT = 7999 @@ -521,88 +522,35 @@ Content-Length: 10 self.assertEqual(len(resp['body']), 10, 'body gt Content-Length 15') def test_proxy_invalid(self): - self.assertIn( - 'error', - self.conf([{"action": {"proxy": 'blah'}}], 'routes'), - 'proxy invalid', - ) - self.assertIn( - 'error', - self.conf([{"action": {"proxy": '/blah'}}], 'routes'), - 'proxy invalid 2', - ) - self.assertIn( - 'error', - self.conf([{"action": {"proxy": 'unix:/blah'}}], 'routes'), - 'proxy unix invalid 2', - ) - self.assertIn( - 'error', - self.conf([{"action": {"proxy": 'http://blah'}}], 'routes'), - 'proxy unix invalid 3', - ) - self.assertIn( - 'error', - self.conf([{"action": {"proxy": 'http://127.0.0.1'}}], 'routes'), - 'proxy ipv4 invalid', - ) - self.assertIn( - 'error', - self.conf([{"action": {"proxy": 'http://127.0.0.1:'}}], 'routes'), - 'proxy ipv4 invalid 2', - ) - self.assertIn( - 'error', - self.conf( - [{"action": {"proxy": 'http://127.0.0.1:blah'}}], 'routes' - ), - 'proxy ipv4 invalid 3', - ) - self.assertIn( - 'error', - self.conf( - [{"action": {"proxy": 'http://127.0.0.1:-1'}}], 'routes' - ), - 'proxy ipv4 invalid 4', - ) - self.assertIn( - 'error', - self.conf( - [{"action": {"proxy": 'http://127.0.0.1:7080b'}}], 'routes' - ), - 'proxy ipv4 invalid 5', - ) - self.assertIn( - 'error', - self.conf( - [{"action": {"proxy": 'http://[]'}}], 'routes' - ), - 'proxy ipv6 invalid', - ) - self.assertIn( - 'error', - self.conf( - [{"action": {"proxy": 'http://[]:7080'}}], 'routes' - ), - 'proxy ipv6 invalid 2', - ) - self.assertIn( - 'error', - self.conf( - [{"action": {"proxy": 'http://[:]:7080'}}], 'routes' - ), - 'proxy ipv6 invalid 3', - ) - self.assertIn( - 'error', - self.conf( - [{"action": {"proxy": 'http://[::7080'}}], 'routes' - ), - 'proxy ipv6 invalid 4', - ) + def check_proxy(proxy): + self.assertIn( + 'error', + self.conf([{"action": {"proxy": proxy}}], 'routes'), + 'proxy invalid', + ) + + check_proxy('blah') + check_proxy('/blah') + check_proxy('unix:/blah') + check_proxy('http://blah') + check_proxy('http://127.0.0.1') + check_proxy('http://127.0.0.1:') + check_proxy('http://127.0.0.1:blah') + check_proxy('http://127.0.0.1:-1') + check_proxy('http://127.0.0.1:7080b') + check_proxy('http://[]') + check_proxy('http://[]:7080') + check_proxy('http://[:]:7080') + check_proxy('http://[::7080') - @unittest.skip('not yet') def test_proxy_loop(self): + self.skip_alerts.extend( + [ + r'socket.*failed', + r'accept.*failed', + r'new connections are not accepted', + ] + ) self.conf( { "listeners": { @@ -625,6 +573,7 @@ Content-Length: 10 ) self.get_http10(no_recv=True) + self.get_http10(read_timeout=1) if __name__ == '__main__': TestProxy.main() |