Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #54

Merged
merged 7 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Rust
on:
push:
branches:
- '*'
- 'main'
pull_request:
branches:
- '*'
Expand All @@ -30,27 +30,6 @@ jobs:
with:
command: check
args: --release --target wasm32-unknown-unknown
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: wasm32-unknown-unknown
- uses: arduino/setup-protoc@v1
with:
version: '3.x'
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --target wasm32-unknown-unknown
- uses: actions-rs/cargo@v1
with:
command: test
fmt:
name: Rustfmt
runs-on: ubuntu-latest
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Tests

on:
push:
branches:
- 'main'
pull_request:
branches:
- '*'

jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: wasm32-unknown-unknown
- uses: arduino/setup-protoc@v1
with:
version: '3.x'
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --target wasm32-unknown-unknown
- uses: actions-rs/cargo@v1
with:
command: test
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/filter/http_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ impl HttpContext for Filter {
info!("on_http_request_headers #{}", self.context_id);

for header in TracingHeader::all() {
match self.get_http_request_header_bytes(header.as_str()) {
Some(value) => self.tracing_headers.push((header, value)),
None => (),
if let Some(value) = self.get_http_request_header_bytes(header.as_str()) {
self.tracing_headers.push((header, value))
}
}

match self
.config
.index
Expand Down
30 changes: 30 additions & 0 deletions tests/rate_limited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ fn it_loads() {
module
.call_proxy_on_request_headers(http_context, 0, false)
.expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2"))
.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 @@ -155,6 +161,12 @@ fn it_limits() {
module
.call_proxy_on_request_headers(http_context, 0, false)
.expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2"))
.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"]))
Expand Down Expand Up @@ -283,6 +295,12 @@ fn it_passes_additional_headers() {
module
.call_proxy_on_request_headers(http_context, 0, false)
.expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2"))
.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"]))
Expand Down Expand Up @@ -405,6 +423,12 @@ fn it_rate_limits_with_empty_conditions() {
module
.call_proxy_on_request_headers(http_context, 0, false)
.expect_log(Some(LogLevel::Info), Some("on_http_request_headers #2"))
.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_grpc_call(
Expand Down Expand Up @@ -506,6 +530,12 @@ 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::Info), Some("on_http_request_headers #2"))
.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
Loading