Skip to content

Commit

Permalink
[smithy-rs] Filter test inputs for presigning header exclusion propte…
Browse files Browse the repository at this point in the history
…st (#2986)

## Motivation and Context
During our internal build, the `aws-sigv4` crate failed on a proptest as
follows:
```
Diff < left / right > :
<content-length;content-type;host
>content-length;content-type

.
minimal failing input: excluded_headers = [
    "host",
]
        successes: 74
        local rejects: 0
        global rejects: 0
', aws-sigv4/src/http_request/canonical_request.rs:838:5

failures:
    http_request::canonical_request::tests::presigning_header_exclusion_with_explicit_exclusion_list_specified
```
This says that `excluded_headers` should not contain `host`.

To address it, this PR will filter out test inputs from proptest that
contain `content-length`, `content-type`, or `host` (all of which appear
in the expected value for the test at line 886 in the new revision).

## Testing
No new tests have been added, relied on the existing tests in CI

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
ysaito1001 authored and aws-sdk-rust-ci committed Sep 19, 2023
1 parent fd4f730 commit d0505ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 17 additions & 4 deletions sdk/aws-sigv4/src/http_request/canonical_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,24 @@ mod tests {
);
}

fn valid_input(input: &Vec<String>) -> bool {
[
"content-length".to_owned(),
"content-type".to_owned(),
"host".to_owned(),
]
.iter()
.all(|element| !input.contains(&element))
}

proptest! {
#[test]
fn presigning_header_exclusion_with_explicit_exclusion_list_specified(
excluded_headers in prop::collection::vec("[a-z]{1,20}", 1..10),
) {
#[test]
fn presigning_header_exclusion_with_explicit_exclusion_list_specified(
excluded_headers in prop::collection::vec("[a-z]{1,20}", 1..10).prop_filter(
"`excluded_headers` should pass the `valid_input` check",
valid_input,
)
) {
let mut request_builder = http::Request::builder()
.uri("https://some-endpoint.some-region.amazonaws.com")
.header("content-type", "application/xml")
Expand Down
4 changes: 2 additions & 2 deletions versions.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
smithy_rs_revision = 'cf95f4803aaad77197b3ce3a39570f85408bfd2a'
smithy_rs_revision = 'f982b40edb378ea54a697b1163490ad0096f2d88'
aws_doc_sdk_examples_revision = '577a55916047897a0ef2e2aac1e855dccc3614f9'

[manual_interventions]
Expand Down Expand Up @@ -2152,7 +2152,7 @@ source_hash = 'a2dad573276654e47f5d3befb3f570f66f569d39c19dda0e468b7d2acb9cc020'
[crates.aws-sigv4]
category = 'AwsRuntime'
version = '0.56.1'
source_hash = 'eac6c9c7b6dba8797de55acdba79dbf18b5ee91fb7d5e54cda289dd0ac346221'
source_hash = '03be96a75a27326060a77544c0072d31e78df71d7b54c04e7cbec7e7df536172'

[crates.aws-smithy-async]
category = 'SmithyRuntime'
Expand Down

0 comments on commit d0505ea

Please sign in to comment.