From 3f513f434fbe44810ea2352d4ffc7d4d702b3e12 Mon Sep 17 00:00:00 2001 From: Valentin Bartenev Date: Wed, 7 Oct 2020 20:06:30 +0300 Subject: Router: fixed "not empty" pattern matching. The "!" pattern should be opposite to "", i.e. match only non-empty values. But after 3c00af54b937 it was equal to "!*", which is wrong. --- test/test_routing.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/test_routing.py') diff --git a/test/test_routing.py b/test/test_routing.py index 734825ef..32a7fbc8 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -118,6 +118,9 @@ class TestRouting(TestApplicationProto): def test_routes_match_negative(self): self.route_match({"uri": "!"}) + assert self.get()['status'] == 200 + + self.route_match({"uri": "!*"}) assert self.get()['status'] == 404 self.route_match({"uri": "!/"}) @@ -1187,6 +1190,18 @@ class TestRouting(TestApplicationProto): assert self.get(url='/?foo=barxx&x%=%')['status'] == 404 def test_routes_match_arguments_negative(self): + self.route_match({"arguments": {"foo": "!"}}) + assert self.get(url='/?bar')['status'] == 404 + assert self.get(url='/?foo')['status'] == 404 + assert self.get(url='/?foo=')['status'] == 404 + assert self.get(url='/?foo=%25')['status'] == 200 + + self.route_match({"arguments": {"foo": "!*"}}) + assert self.get(url='/?bar')['status'] == 404 + assert self.get(url='/?foo')['status'] == 404 + assert self.get(url='/?foo=')['status'] == 404 + assert self.get(url='/?foo=blah')['status'] == 404 + self.route_match({"arguments": {"foo": "!%25"}}) assert self.get(url='/?foo=blah')['status'] == 200 assert self.get(url='/?foo=%')['status'] == 404 -- cgit