diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2020-05-15 04:21:10 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2020-05-15 04:21:10 +0100 |
commit | ea841400f543fa4139adca926fefdd8565c227d2 (patch) | |
tree | fa5869d6a108ccd7f8955e1978bb02f276e12803 /test/test_routing.py | |
parent | ce4a2bbd05f42d258f9bf7880060a604ac1a866e (diff) | |
download | unit-ea841400f543fa4139adca926fefdd8565c227d2.tar.gz unit-ea841400f543fa4139adca926fefdd8565c227d2.tar.bz2 |
Tests: added test for encoding in the "pass" option.
Diffstat (limited to 'test/test_routing.py')
-rw-r--r-- | test/test_routing.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/test_routing.py b/test/test_routing.py index 5c4de519..3cf4009c 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -181,6 +181,61 @@ class TestRouting(TestApplicationProto): self.assertEqual(self.get(url='/blah')['status'], 200, '/blah') self.assertEqual(self.get(url='/BLAH')['status'], 404, '/BLAH') + def test_routes_pass_encode(self): + def check_pass(path, name): + self.assertIn( + 'success', + self.conf( + { + "listeners": { + "*:7080": {"pass": "applications/" + path} + }, + "applications": { + name: { + "type": "python", + "processes": {"spare": 0}, + "path": self.current_dir + '/python/empty', + "working_directory": self.current_dir + + '/python/empty', + "module": "wsgi", + } + }, + } + ), + ) + + self.assertEqual(self.get()['status'], 200) + + check_pass("%25", "%") + check_pass("blah%2Fblah", "blah/blah") + check_pass("%2Fblah%2F%2Fblah%2F", "/blah//blah/") + check_pass("%20blah%252Fblah%7E", " blah%2Fblah~") + + def check_pass_error(path, name): + self.assertIn( + 'error', + self.conf( + { + "listeners": { + "*:7080": {"pass": "applications/" + path} + }, + "applications": { + name: { + "type": "python", + "processes": {"spare": 0}, + "path": self.current_dir + '/python/empty', + "working_directory": self.current_dir + + '/python/empty', + "module": "wsgi", + } + }, + } + ), + ) + + check_pass_error("%", "%") + check_pass_error("%1", "%1") + def test_routes_absent(self): self.conf( { |