Skip to content

Commit

Permalink
Fix tests using header resolver
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Cattermole <[email protected]>
  • Loading branch information
adam-cattermole committed Aug 22, 2024
1 parent 75ebb7a commit 08bf3f1
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions tests/rate_limited.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use proxy_wasm::types::Status::NotFound;

Check failure on line 1 in tests/rate_limited.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused import: `proxy_wasm::types::Status::NotFound`

Check warning on line 1 in tests/rate_limited.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused import: `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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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"]))
Expand Down Expand Up @@ -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"]))
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"]))
Expand Down

0 comments on commit 08bf3f1

Please sign in to comment.