From 08bf3f170aa861c2a8f3c07e812b6fef39eaf4f8 Mon Sep 17 00:00:00 2001 From: Adam Cattermole Date: Thu, 22 Aug 2024 14:08:40 +0100 Subject: [PATCH] Fix tests using header resolver Signed-off-by: Adam Cattermole --- tests/rate_limited.rs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/tests/rate_limited.rs b/tests/rate_limited.rs index 1578afa7..a351faa6 100644 --- a/tests/rate_limited.rs +++ b/tests/rate_limited.rs @@ -1,3 +1,4 @@ +use proxy_wasm::types::Status::NotFound; use proxy_wasm_test_framework::tester; use proxy_wasm_test_framework::types::{Action, BufferType, LogLevel, MapType, ReturnType}; use serial_test::serial; @@ -57,12 +58,6 @@ fn it_loads() { module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Debug), Some("#2 on_http_request_headers")) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) - .returning(None) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) - .returning(None) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) - .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) .returning(Some("cars.toystore.com")) .expect_log( @@ -161,14 +156,14 @@ fn it_limits() { module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Debug), Some("#2 on_http_request_headers")) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) + .returning(Some("cars.toystore.com")) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) .returning(None) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) - .returning(Some("cars.toystore.com")) .expect_get_property(Some(vec!["request", "url_path"])) .returning(Some("/admin/toy".as_bytes())) .expect_get_property(Some(vec!["request", "host"])) @@ -299,14 +294,14 @@ fn it_passes_additional_headers() { module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Debug), Some("#2 on_http_request_headers")) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) + .returning(Some("cars.toystore.com")) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) .returning(None) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) - .returning(Some("cars.toystore.com")) .expect_get_property(Some(vec!["request", "url_path"])) .returning(Some("/admin/toy".as_bytes())) .expect_get_property(Some(vec!["request", "host"])) @@ -431,14 +426,14 @@ fn it_rate_limits_with_empty_conditions() { module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Debug), Some("#2 on_http_request_headers")) + .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) + .returning(Some("a.com")) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) .returning(None) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) - .returning(Some("a.com")) .expect_log( Some(LogLevel::Debug), Some("#2 ratelimitpolicy selected some-name"), @@ -542,12 +537,6 @@ fn it_does_not_rate_limits_when_selector_does_not_exist_and_misses_default_value module .call_proxy_on_request_headers(http_context, 0, false) .expect_log(Some(LogLevel::Debug), Some("#2 on_http_request_headers")) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("traceparent")) - .returning(None) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("tracestate")) - .returning(None) - .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some("baggage")) - .returning(None) .expect_get_header_map_value(Some(MapType::HttpRequestHeaders), Some(":authority")) .returning(Some("a.com")) .expect_get_property(Some(vec!["unknown", "path"]))