From 02659b1ee3b041d1f4046ac440ea6755455230a1 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Wed, 20 Jul 2022 19:05:29 +0100 Subject: [PATCH] Tests: added tests for translating $dollar into a literal $. If you need to specify a $ in a URI you can now use '$dollar' or '${dollar}'. Added some tests for the above to test_variables.py setting a Location string. --- test/test_variables.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test_variables.py b/test/test_variables.py index ccd0839b..2ddfdc0a 100644 --- a/test/test_variables.py +++ b/test/test_variables.py @@ -114,6 +114,27 @@ class TestVariables(TestApplicationProto): check_user_agent('', 404) check_user_agent('no', 404) + def test_variables_dollar(self): + assert 'success' in self.conf( + { + "listeners": {"*:7080": {"pass": "routes"}}, + "routes": [{"action": {"return": 301}}], + } + ) + + def check_dollar(location, expect): + assert 'success' in self.conf( + '"' + location + '"', + 'routes/0/action/location', + ) + assert self.get()['headers']['Location'] == expect + + check_dollar( + 'https://${host}${uri}path${dollar}dollar', + 'https://localhost/path$dollar', + ) + check_dollar('path$dollar${dollar}', 'path$$') + def test_variables_many(self): self.conf_routes("\"routes$uri$method\"") assert self.get(url='/5')['status'] == 206, 'many'