summaryrefslogtreecommitdiffhomepage
path: root/test/test_routing.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2021-05-24 04:33:42 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2021-05-24 04:33:42 +0100
commitd6439002371d0bc73183c9d3d28df4f62ce0b972 (patch)
tree52dae430abdde798589a7aa7944e7c79b69b5fbe /test/test_routing.py
parent539551c89f4028ed70e5881400fc9151af3d12e8 (diff)
downloadunit-d6439002371d0bc73183c9d3d28df4f62ce0b972.tar.gz
unit-d6439002371d0bc73183c9d3d28df4f62ce0b972.tar.bz2
Tests: minor fixes.
Diffstat (limited to 'test/test_routing.py')
-rw-r--r--test/test_routing.py90
1 files changed, 19 insertions, 71 deletions
diff --git a/test/test_routing.py b/test/test_routing.py
index 7392c1ab..eaa0a134 100644
--- a/test/test_routing.py
+++ b/test/test_routing.py
@@ -1041,83 +1041,31 @@ class TestRouting(TestApplicationProto):
}
)
+ def check_headers(hds):
+ hds = dict({"Host": "localhost", "Connection": "close"}, **hds)
+ assert (
+ self.get(headers=hds)['status'] == 200
+ ), 'headers array match'
+
+ def check_headers_404(hds):
+ hds = dict({"Host": "localhost", "Connection": "close"}, **hds)
+ assert (
+ self.get(headers=hds)['status'] == 404
+ ), 'headers array no match'
+
assert self.get()['status'] == 404, 'match headers array'
- assert (
- self.get(
- headers={
- "Host": "localhost",
- "x-header1": "foo123",
- "Connection": "close",
- }
- )['status']
- == 200
- ), 'match headers array 2'
- assert (
- self.get(
- headers={
- "Host": "localhost",
- "x-header2": "bar",
- "Connection": "close",
- }
- )['status']
- == 200
- ), 'match headers array 3'
- assert (
- self.get(
- headers={
- "Host": "localhost",
- "x-header3": "bar",
- "Connection": "close",
- }
- )['status']
- == 200
- ), 'match headers array 4'
- assert (
- self.get(
- headers={
- "Host": "localhost",
- "x-header1": "bar",
- "Connection": "close",
- }
- )['status']
- == 404
- ), 'match headers array 5'
- assert (
- self.get(
- headers={
- "Host": "localhost",
- "x-header1": "bar",
- "x-header4": "foo",
- "Connection": "close",
- }
- )['status']
- == 200
- ), 'match headers array 6'
+ check_headers({"x-header1": "foo123"})
+ check_headers({"x-header2": "bar"})
+ check_headers({"x-header3": "bar"})
+ check_headers_404({"x-header1": "bar"})
+ check_headers({"x-header1": "bar", "x-header4": "foo"})
assert 'success' in self.conf_delete(
'routes/0/match/headers/1'
), 'match headers array configure 2'
- assert (
- self.get(
- headers={
- "Host": "localhost",
- "x-header2": "bar",
- "Connection": "close",
- }
- )['status']
- == 404
- ), 'match headers array 7'
- assert (
- self.get(
- headers={
- "Host": "localhost",
- "x-header3": "foo",
- "Connection": "close",
- }
- )['status']
- == 200
- ), 'match headers array 8'
+ check_headers_404({"x-header2": "bar"})
+ check_headers({"x-header3": "foo"})
def test_routes_match_arguments(self):
self.route_match({"arguments": {"foo": "bar"}})