From 21c8b1ed6be1141d07c90eb46b3a4b0ba16ad004 Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Mon, 28 Oct 2024 11:28:38 +0100 Subject: [PATCH] [tests] Using `predicates` instead of `matches` Signed-off-by: dd di cesare --- tests/auth.rs | 45 ++++++++++++++++------------------------- tests/multi.rs | 45 ++++++++++++++++------------------------- tests/remote_address.rs | 8 ++------ 3 files changed, 36 insertions(+), 62 deletions(-) diff --git a/tests/auth.rs b/tests/auth.rs index c10184f7..730bc2c3 100644 --- a/tests/auth.rs +++ b/tests/auth.rs @@ -18,22 +18,11 @@ const CONFIG: &str = r#"{ "name": "some-name", "routeRuleConditions": { "hostnames": ["*.toystore.com", "example.com"], - "matches": [ - { - "selector": "request.url_path", - "operator": "startswith", - "value": "/admin/toy" - }, - { - "selector": "request.host", - "operator": "eq", - "value": "cars.toystore.com" - }, - { - "selector": "request.method", - "operator": "eq", - "value": "POST" - }] + "predicates" : [ + "request.url_path.startsWith('/admin/toy')", + "request.host == 'cars.toystore.com'", + "request.method == 'POST'" + ] }, "actions": [ { @@ -189,12 +178,12 @@ fn it_auths() { 10, 220, 1, 10, 25, 10, 23, 10, 21, 18, 15, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 52, 53, 48, 48, 48, 24, 200, 223, 2, 18, 23, 10, 21, 10, 19, 18, 14, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 56, 48, 48, 48, 24, 192, 62, 34, 141, 1, 10, 0, 18, - 136, 1, 18, 3, 71, 69, 84, 26, 30, 10, 10, 58, 97, 117, 116, 104, 111, 114, 105, - 116, 121, 18, 16, 97, 98, 105, 95, 116, 101, 115, 116, 95, 104, 97, 114, 110, 101, - 115, 115, 26, 14, 10, 7, 58, 109, 101, 116, 104, 111, 100, 18, 3, 71, 69, 84, 26, - 38, 10, 5, 58, 112, 97, 116, 104, 18, 29, 47, 100, 101, 102, 97, 117, 108, 116, 47, - 114, 101, 113, 117, 101, 115, 116, 47, 104, 101, 97, 100, 101, 114, 115, 47, 112, - 97, 116, 104, 34, 10, 47, 97, 100, 109, 105, 110, 47, 116, 111, 121, 42, 17, 99, + 136, 1, 18, 3, 71, 69, 84, 26, 38, 10, 5, 58, 112, 97, 116, 104, 18, 29, 47, 100, + 101, 102, 97, 117, 108, 116, 47, 114, 101, 113, 117, 101, 115, 116, 47, 104, 101, + 97, 100, 101, 114, 115, 47, 112, 97, 116, 104, 26, 14, 10, 7, 58, 109, 101, 116, + 104, 111, 100, 18, 3, 71, 69, 84, 26, 30, 10, 10, 58, 97, 117, 116, 104, 111, 114, + 105, 116, 121, 18, 16, 97, 98, 105, 95, 116, 101, 115, 116, 95, 104, 97, 114, 110, + 101, 115, 115, 34, 10, 47, 97, 100, 109, 105, 110, 47, 116, 111, 121, 42, 17, 99, 97, 114, 115, 46, 116, 111, 121, 115, 116, 111, 114, 101, 46, 99, 111, 109, 50, 4, 104, 116, 116, 112, 82, 4, 72, 84, 84, 80, 82, 20, 10, 4, 104, 111, 115, 116, 18, 12, 97, 117, 116, 104, 99, 111, 110, 102, 105, 103, 45, 65, 90, 0, @@ -385,12 +374,12 @@ fn it_denies() { 10, 220, 1, 10, 25, 10, 23, 10, 21, 18, 15, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 52, 53, 48, 48, 48, 24, 200, 223, 2, 18, 23, 10, 21, 10, 19, 18, 14, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 56, 48, 48, 48, 24, 192, 62, 34, 141, 1, 10, 0, 18, - 136, 1, 18, 3, 71, 69, 84, 26, 30, 10, 10, 58, 97, 117, 116, 104, 111, 114, 105, - 116, 121, 18, 16, 97, 98, 105, 95, 116, 101, 115, 116, 95, 104, 97, 114, 110, 101, - 115, 115, 26, 14, 10, 7, 58, 109, 101, 116, 104, 111, 100, 18, 3, 71, 69, 84, 26, - 38, 10, 5, 58, 112, 97, 116, 104, 18, 29, 47, 100, 101, 102, 97, 117, 108, 116, 47, - 114, 101, 113, 117, 101, 115, 116, 47, 104, 101, 97, 100, 101, 114, 115, 47, 112, - 97, 116, 104, 34, 10, 47, 97, 100, 109, 105, 110, 47, 116, 111, 121, 42, 17, 99, + 136, 1, 18, 3, 71, 69, 84, 26, 38, 10, 5, 58, 112, 97, 116, 104, 18, 29, 47, 100, + 101, 102, 97, 117, 108, 116, 47, 114, 101, 113, 117, 101, 115, 116, 47, 104, 101, + 97, 100, 101, 114, 115, 47, 112, 97, 116, 104, 26, 14, 10, 7, 58, 109, 101, 116, + 104, 111, 100, 18, 3, 71, 69, 84, 26, 30, 10, 10, 58, 97, 117, 116, 104, 111, 114, + 105, 116, 121, 18, 16, 97, 98, 105, 95, 116, 101, 115, 116, 95, 104, 97, 114, 110, + 101, 115, 115, 34, 10, 47, 97, 100, 109, 105, 110, 47, 116, 111, 121, 42, 17, 99, 97, 114, 115, 46, 116, 111, 121, 115, 116, 111, 114, 101, 46, 99, 111, 109, 50, 4, 104, 116, 116, 112, 82, 4, 72, 84, 84, 80, 82, 20, 10, 4, 104, 111, 115, 116, 18, 12, 97, 117, 116, 104, 99, 111, 110, 102, 105, 103, 45, 65, 90, 0, diff --git a/tests/multi.rs b/tests/multi.rs index df419437..5d9bc125 100644 --- a/tests/multi.rs +++ b/tests/multi.rs @@ -25,22 +25,11 @@ const CONFIG: &str = r#"{ "name": "some-name", "routeRuleConditions": { "hostnames": ["*.toystore.com", "example.com"], - "matches": [ - { - "selector": "request.url_path", - "operator": "startswith", - "value": "/admin/toy" - }, - { - "selector": "request.host", - "operator": "eq", - "value": "cars.toystore.com" - }, - { - "selector": "request.method", - "operator": "eq", - "value": "POST" - }] + "predicates" : [ + "request.url_path.startsWith('/admin/toy')", + "request.host == 'cars.toystore.com'", + "request.method == 'POST'" + ] }, "actions": [ { @@ -207,12 +196,12 @@ fn it_performs_authenticated_rate_limiting() { 10, 220, 1, 10, 25, 10, 23, 10, 21, 18, 15, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 52, 53, 48, 48, 48, 24, 200, 223, 2, 18, 23, 10, 21, 10, 19, 18, 14, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 56, 48, 48, 48, 24, 192, 62, 34, 141, 1, 10, 0, 18, - 136, 1, 18, 3, 71, 69, 84, 26, 30, 10, 10, 58, 97, 117, 116, 104, 111, 114, 105, - 116, 121, 18, 16, 97, 98, 105, 95, 116, 101, 115, 116, 95, 104, 97, 114, 110, 101, - 115, 115, 26, 14, 10, 7, 58, 109, 101, 116, 104, 111, 100, 18, 3, 71, 69, 84, 26, - 38, 10, 5, 58, 112, 97, 116, 104, 18, 29, 47, 100, 101, 102, 97, 117, 108, 116, 47, - 114, 101, 113, 117, 101, 115, 116, 47, 104, 101, 97, 100, 101, 114, 115, 47, 112, - 97, 116, 104, 34, 10, 47, 97, 100, 109, 105, 110, 47, 116, 111, 121, 42, 17, 99, + 136, 1, 18, 3, 71, 69, 84, 26, 38, 10, 5, 58, 112, 97, 116, 104, 18, 29, 47, 100, + 101, 102, 97, 117, 108, 116, 47, 114, 101, 113, 117, 101, 115, 116, 47, 104, 101, + 97, 100, 101, 114, 115, 47, 112, 97, 116, 104, 26, 14, 10, 7, 58, 109, 101, 116, + 104, 111, 100, 18, 3, 71, 69, 84, 26, 30, 10, 10, 58, 97, 117, 116, 104, 111, 114, + 105, 116, 121, 18, 16, 97, 98, 105, 95, 116, 101, 115, 116, 95, 104, 97, 114, 110, + 101, 115, 115, 34, 10, 47, 97, 100, 109, 105, 110, 47, 116, 111, 121, 42, 17, 99, 97, 114, 115, 46, 116, 111, 121, 115, 116, 111, 114, 101, 46, 99, 111, 109, 50, 4, 104, 116, 116, 112, 82, 4, 72, 84, 84, 80, 82, 20, 10, 4, 104, 111, 115, 116, 18, 12, 97, 117, 116, 104, 99, 111, 110, 102, 105, 103, 45, 65, 90, 0, @@ -420,12 +409,12 @@ fn unauthenticated_does_not_ratelimit() { 10, 220, 1, 10, 25, 10, 23, 10, 21, 18, 15, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 52, 53, 48, 48, 48, 24, 200, 223, 2, 18, 23, 10, 21, 10, 19, 18, 14, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 56, 48, 48, 48, 24, 192, 62, 34, 141, 1, 10, 0, 18, - 136, 1, 18, 3, 71, 69, 84, 26, 30, 10, 10, 58, 97, 117, 116, 104, 111, 114, 105, - 116, 121, 18, 16, 97, 98, 105, 95, 116, 101, 115, 116, 95, 104, 97, 114, 110, 101, - 115, 115, 26, 14, 10, 7, 58, 109, 101, 116, 104, 111, 100, 18, 3, 71, 69, 84, 26, - 38, 10, 5, 58, 112, 97, 116, 104, 18, 29, 47, 100, 101, 102, 97, 117, 108, 116, 47, - 114, 101, 113, 117, 101, 115, 116, 47, 104, 101, 97, 100, 101, 114, 115, 47, 112, - 97, 116, 104, 34, 10, 47, 97, 100, 109, 105, 110, 47, 116, 111, 121, 42, 17, 99, + 136, 1, 18, 3, 71, 69, 84, 26, 38, 10, 5, 58, 112, 97, 116, 104, 18, 29, 47, 100, + 101, 102, 97, 117, 108, 116, 47, 114, 101, 113, 117, 101, 115, 116, 47, 104, 101, + 97, 100, 101, 114, 115, 47, 112, 97, 116, 104, 26, 14, 10, 7, 58, 109, 101, 116, + 104, 111, 100, 18, 3, 71, 69, 84, 26, 30, 10, 10, 58, 97, 117, 116, 104, 111, 114, + 105, 116, 121, 18, 16, 97, 98, 105, 95, 116, 101, 115, 116, 95, 104, 97, 114, 110, + 101, 115, 115, 34, 10, 47, 97, 100, 109, 105, 110, 47, 116, 111, 121, 42, 17, 99, 97, 114, 115, 46, 116, 111, 121, 115, 116, 111, 114, 101, 46, 99, 111, 109, 50, 4, 104, 116, 116, 112, 82, 4, 72, 84, 84, 80, 82, 20, 10, 4, 104, 111, 115, 116, 18, 12, 97, 117, 116, 104, 99, 111, 110, 102, 105, 103, 45, 65, 90, 0, diff --git a/tests/remote_address.rs b/tests/remote_address.rs index 5ffdc5c0..c89a53d4 100644 --- a/tests/remote_address.rs +++ b/tests/remote_address.rs @@ -35,12 +35,8 @@ fn it_limits_based_on_source_address() { "name": "some-name", "routeRuleConditions": { "hostnames": ["*.example.com"], - "matches": [ - { - "selector": "source.remote_address", - "operator": "neq", - "value": "50.0.0.1" - } + "predicates" : [ + "source.remote_address != '50.0.0.1'" ] }, "actions": [