From 31061c1239f90adf98176d99e4ff3c5d16f2de55 Mon Sep 17 00:00:00 2001 From: David Ortiz Date: Wed, 18 Jul 2018 17:04:09 +0200 Subject: [PATCH] t/apicast-policy-conditional: adapt to new config schema --- t/apicast-policy-conditional.t | 79 +++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/t/apicast-policy-conditional.t b/t/apicast-policy-conditional.t index e008fd1d4..4d84ce471 100644 --- a/t/apicast-policy-conditional.t +++ b/t/apicast-policy-conditional.t @@ -20,7 +20,17 @@ phases it runs, so we can use that to verify it was executed. { "name": "apicast.policy.conditional", "configuration": { - "condition": "request_path == \"/log\"", + "condition": { + "operations": [ + { + "left": "{{ uri }}", + "left_type": "liquid", + "op": "==", + "right": "/log", + "right_type": "plain" + } + ] + }, "policy_chain": [ { "name": "apicast.policy.phase_logger" @@ -61,7 +71,17 @@ phases it runs, so we can use that to verify that it was not executed. { "name": "apicast.policy.conditional", "configuration": { - "condition": "request_path == \"/log\"", + "condition": { + "operations": [ + { + "left": "{{ uri }}", + "left_type": "liquid", + "op": "==", + "right": "/log", + "right_type": "plain" + } + ] + }, "policy_chain": [ { "name": "apicast.policy.phase_logger" @@ -85,3 +105,58 @@ GET / HTTP/1.1 --- no_error_log [error] running phase: rewrite + +=== TEST 3: Combine several operations in the condition +--- configuration +{ + "services": [ + { + "id": 42, + "proxy": { + "policy_chain": [ + { + "name": "apicast.policy.conditional", + "configuration": { + "condition": { + "operations": [ + { + "left": "{{ uri }}", + "left_type": "liquid", + "op": "==", + "right": "/log", + "right_type": "plain" + }, + { + "left": "{{ service.id }}", + "left_type": "liquid", + "op": "==", + "right": "42", + "right_type": "plain" + } + ], + "combine_op": "and" + }, + "policy_chain": [ + { + "name": "apicast.policy.phase_logger" + } + ] + } + }, + { + "name": "apicast.policy.echo" + } + ] + } + } + ] +} +--- request +GET /log +--- response_body +GET /log HTTP/1.1 +--- error_code: 200 +--- no_error_log +[error] +--- error_log chomp +running phase: rewrite