Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jdisanti-improve-miss…
Browse files Browse the repository at this point in the history
…ing-creds-error
  • Loading branch information
jdisanti committed Dec 2, 2023
2 parents e3cd04b + 75b4c35 commit 70bc54f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ references = ["aws-sdk-rust#975", "smithy-rs#3269"]
meta = { "breaking" = false, "tada" = true, "bug" = false }
author = "jdisanti"

[[aws-sdk-rust]]
message = """Add `test_credentials` to `ConfigLoader` in `aws_config`. This allows the following pattern during tests:
```rust
async fn main() {
let conf = aws_config::defaults(BehaviorVersion::latest())
.test_credentials()
.await;
}
```
This is designed for unit tests and using local mocks like DynamoDB Local and LocalStack with the SDK.
"""
meta = { "breaking" = false, "tada" = true, "bug" = false }
author = "rcoh"
references = ["smithy-rs#3279", "aws-sdk-rust#971"]

[[aws-sdk-rust]]
message = "Improve the error messages for when auth fails to select an auth scheme for a request."
references = ["aws-sdk-rust#979", "smithy-rs#3277"]
Expand Down
7 changes: 4 additions & 3 deletions aws/rust-runtime/aws-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ repository = "https://github.com/smithy-lang/smithy-rs"
behavior-version-latest = []
client-hyper = ["aws-smithy-runtime/connector-hyper-0-14-x"]
rustls = ["aws-smithy-runtime/tls-rustls", "client-hyper"]
allow-compilation = [] # our tests use `cargo test --all-features` and native-tls breaks CI
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-runtime/rt-tokio", "tokio/rt"]
sso = ["dep:aws-sdk-sso", "dep:aws-sdk-ssooidc", "dep:ring", "dep:hex", "dep:zeroize", "aws-smithy-runtime-api/http-auth"]
credentials-process = ["tokio/process"]

default = ["client-hyper", "rustls", "rt-tokio", "credentials-process", "sso"]

# deprecated: this feature does nothing
allow-compilation = []

[dependencies]
aws-credential-types = { path = "../../sdk/build/aws-sdk/sdk/aws-credential-types" }
aws-credential-types = { path = "../../sdk/build/aws-sdk/sdk/aws-credential-types", features = ["test-util"] }
aws-http = { path = "../../sdk/build/aws-sdk/sdk/aws-http" }
aws-sdk-sts = { path = "../../sdk/build/aws-sdk/sdk/sts", default-features = false }
aws-smithy-async = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-async" }
Expand Down Expand Up @@ -52,7 +54,6 @@ zeroize = { version = "1", optional = true }
aws-sdk-ssooidc = { path = "../../sdk/build/aws-sdk/sdk/ssooidc", default-features = false, optional = true }

[dev-dependencies]
aws-credential-types = { path = "../../sdk/build/aws-sdk/sdk/aws-credential-types", features = ["test-util"] }
aws-smithy-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime", features = ["client", "connector-hyper-0-14-x", "test-util"] }
aws-smithy-runtime-api = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["test-util"] }
futures-util = { version = "0.3.16", default-features = false }
Expand Down
10 changes: 10 additions & 0 deletions aws/rust-runtime/aws-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ mod loader {
use crate::profile::profile_file::ProfileFiles;
use crate::provider_config::ProviderConfig;
use aws_credential_types::provider::{ProvideCredentials, SharedCredentialsProvider};
use aws_credential_types::Credentials;
use aws_smithy_async::rt::sleep::{default_async_sleep, AsyncSleep, SharedAsyncSleep};
use aws_smithy_async::time::{SharedTimeSource, TimeSource};
use aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
Expand Down Expand Up @@ -458,6 +459,10 @@ mod loader {
/// anonymous auth for S3, calling operations in STS that don't require a signature,
/// or using token-based auth.
///
/// **Note**: For tests, e.g. with a service like DynamoDB Local, this is **not** what you
/// want. If credentials are disabled, requests cannot be signed. For these use cases, use
/// [`test_credentials`](Self::test_credentials).
///
/// # Examples
///
/// Turn off credentials in order to call a service without signing:
Expand All @@ -474,6 +479,11 @@ mod loader {
self
}

/// Set test credentials for use when signing requests
pub fn test_credentials(self) -> Self {
self.credentials_provider(Credentials::for_tests())
}

/// Override the name of the app used to build [`SdkConfig`](aws_types::SdkConfig).
///
/// This _optional_ name is used to identify the application in the user agent that
Expand Down
14 changes: 12 additions & 2 deletions tools/ci-scripts/check-aws-config
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,18 @@ cargo "+${RUST_NIGHTLY_VERSION:-nightly}" check-external-types --all-features --
echo "${C_YELLOW}## Checking for duplicate dependency versions in the normal dependency graph with all features enabled${C_RESET}"
cargo tree -d --edges normal --all-features

echo "${C_YELLOW}## Testing every combination of features${C_RESET}"
cargo hack test --feature-powerset --exclude-all-features --exclude-features native-tls
# the crate has `allow-compilation` which needs to be deprecated

echo "${C_YELLOW}## Checking every combination of features${C_RESET}"
cargo hack check --feature-powerset --exclude-all-features --exclude-features allow-compilation

echo "${C_YELLOW}## Testing each feature in isolation${C_RESET}"
# these features are missed by the following check because they are grouped
cargo hack test --each-feature --include-features rt-tokio,client-hyper,rustls --exclude-no-default-features

# This check will check other individual features and no-default-features
# grouping these features because they don't interact
cargo hack test --feature-powerset --exclude-all-features --exclude-features allow-compilation --group-features rt-tokio,client-hyper,rustls

echo "${C_YELLOW}## Checking the wasm32-unknown-unknown and wasm32-wasi targets${C_RESET}"
cargo check --target wasm32-unknown-unknown --no-default-features
Expand Down

0 comments on commit 70bc54f

Please sign in to comment.