Commit Graph

7 Commits

Author SHA1 Message Date
Zelda Hessler 5f7113f506
Sourcing service config from the environment. (#3493)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
https://github.com/smithy-lang/smithy-rs/issues/2863
https://github.com/awslabs/aws-sdk-rust/issues/1060

## Description
<!--- Describe your changes in detail -->
This PR adds a new feature: the ability to source service-specific
config from the environment.
This is **only** supported when creating a service config from an
`SdkConfig`. I've posted [a
guide](https://github.com/smithy-lang/smithy-rs/discussions/3537) to our
discussions board.

[This also adds support for setting an endpoint URL in environment
config.](https://github.com/smithy-lang/smithy-rs/issues/2863)

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
I have written several tests ensuring config is extracted with the
correct precedence.

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: ysaito1001 <awsaito@amazon.com>
2024-04-01 14:50:31 +00:00
Zelda Hessler 2d931fa8dc
Fix the runtime versioner and update tool deps (#3503)
This issue was caused by a runtime crate referencing another runtime
crate with a version dependency instead of a path dependency. I've added
an error message that tells us how to fix this if it comes up again:

```txt
crate `aws-smithy-mocks-experimental` depends on crate `aws-smithy-types` crate by version instead of by path. Please update it to use path dependencies for all runtime crates.
```

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-03-22 18:10:07 +00:00
David Souther e858d3e262
Replace `enforce_order(bool)` with `enum RuleMode` (#3502)
RuleMode describes how rules will be interpreted.
- In RuleMode::MatchAny, the first matching rule will be applied, and
the rules will remain unchanged.
- In RuleMode::Sequential, the first matching rule will be applied, and
that rule will be removed from the list of rules.

Also adds a `make_client!` macro produces a Client configured with a
number of Rules and appropriate test default configuration.

## Motivation and Context
Working through improvements on experimental mocks after implementing
them in the Cloudwatch Logs example.

## Testing
Unit tests, doctests, 

## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-03-20 19:51:12 +00:00
Zelda Hessler 5b9d0c0fff
fix clippy lints from the future (#3438)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
Because the build pipeline is checking for these.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-02-26 15:30:51 +00:00
John DiSanti 59c73e4400
Include aws-smithy-mocks-experimental in the release (#3374)
We intend to include aws-smithy-mocks-experimental in the release, but
it needs to be added to the CrateSet to actually be published.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-01-18 03:26:00 +00:00
John DiSanti 2044a4820e
Set aws-smithy-mocks-experimental to 0.1 (#3372)
_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: Russell Cohen <rcoh@amazon.com>
2024-01-17 21:05:18 +00:00
Russell Cohen aae94aea55
Adds experimental mocks package. (#3308)
Publishing is disabled for this package currently.

## Motivation and Context
Testing is a huge pain. Currently. This method isn't ideal and can lack
accuracy in some cases but in quick and useful for many applications.

## Description
New mock package that allows code like this:
```rust
    let s3_404 = mock!(Client::get_object)
        .match_requests(|inp| {
            inp.bucket() == Some("test-bucket") && inp.key() != Some("correct-key")
        })
        .then_http_response(|| {
            http::Response::builder()
                .status(400)
                .body(SdkBody::from(S3_NO_SUCH_KEY))
                .unwrap()
                .try_into()
                .unwrap()
        });

    let s3_real_object = mock!(Client::get_object)
        .match_requests(|inp| {
            inp.bucket() == Some("test-bucket") && inp.key() == Some("correct-key")
        })
        .then_output(|| {
            GetObjectOutput::builder()
                .body(ByteStream::from_static(b"test-test-test"))
                .build()
        });

    let get_object_mocks = MockResponseInterceptor::new()
        .with_rule(&s3_404)
        .with_rule(&s3_real_object);

    let s3 = aws_sdk_s3::Client::from_conf(
        Config::builder()
            .with_test_defaults()
            .region(Region::new("us-east-1"))
            .interceptor(get_object_mocks)
            .build(),
    );
```

There is no binary level mocking and this is completely typesafe. IDE
inference works properly as well. The crimes that were committed were
small and self-contained.

## Testing
There is a unit test and it works.

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-01-11 20:02:28 +00:00