diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2020-08-31 03:14:02 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2020-08-31 03:14:02 +0100 |
commit | df374057f7a42808d9482a8cac82111f24a104fa (patch) | |
tree | e3409b92c3aff18d661f6aba14b3e0d3766816af /test | |
parent | 70c2a4645efd62ad8219f5f7a992436d2930f6b7 (diff) | |
download | unit-df374057f7a42808d9482a8cac82111f24a104fa.tar.gz unit-df374057f7a42808d9482a8cac82111f24a104fa.tar.bz2 |
Tests: $host varaible test.
Also added few tests for $uri and minor style fixes.
Diffstat (limited to '')
-rw-r--r-- | test/test_variables.py | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/test/test_variables.py b/test/test_variables.py index 805c5144..fb481be5 100644 --- a/test/test_variables.py +++ b/test/test_variables.py @@ -16,10 +16,11 @@ class TestVariables(TestApplicationProto): "GET": [{"action": {"return": 201}}], "POST": [{"action": {"return": 202}}], "3": [{"action": {"return": 203}}], - "4": [{"action": {"return": 204}}], + "4*": [{"action": {"return": 204}}], "blahGET}": [{"action": {"return": 205}}], "5GET": [{"action": {"return": 206}}], "GETGET": [{"action": {"return": 207}}], + "localhost": [{"action": {"return": 208}}], }, }, ), @@ -27,10 +28,7 @@ class TestVariables(TestApplicationProto): ) def conf_routes(self, routes): - self.assertIn( - 'success', - self.conf(routes, 'listeners/*:7080/pass') - ) + self.assertIn('success', self.conf(routes, 'listeners/*:7080/pass')) def test_variables_method(self): self.assertEqual(self.get()['status'], 201, 'method GET') @@ -40,7 +38,26 @@ class TestVariables(TestApplicationProto): self.conf_routes("\"routes$uri\"") self.assertEqual(self.get(url='/3')['status'], 203, 'uri') - self.assertEqual(self.get(url='/4')['status'], 204, 'uri 2') + self.assertEqual(self.get(url='/4*')['status'], 204, 'uri 2') + self.assertEqual(self.get(url='/4%2A')['status'], 204, 'uri 3') + + def test_variables_host(self): + self.conf_routes("\"routes/$host\"") + + def check_host(host, status=208): + self.assertEqual( + self.get(headers={'Host': host, 'Connection': 'close'})[ + 'status' + ], + status, + ) + + check_host('localhost') + check_host('localhost.') + check_host('localhost:7080') + check_host('.localhost', 404) + check_host('www.localhost', 404) + check_host('localhost1', 404) def test_variables_many(self): self.conf_routes("\"routes$uri$method\"") @@ -69,7 +86,7 @@ class TestVariables(TestApplicationProto): self.assertEqual(self.post()['status'], 202) self.conf_routes("\"routes${uri}\"") - self.assertEqual(self.get(url='/4')['status'], 204) + self.assertEqual(self.get(url='/4*')['status'], 204) self.conf_routes("\"routes/blah$method}\"") self.assertEqual(self.get()['status'], 205) |