Unverified Commit 0642b3b8 authored by Landon James's avatar Landon James Committed by GitHub
Browse files

Merge `feature/credential-features` branch to main (#4240)

## 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 -->
Merging the feature branch containing work from the below two PRs:
* https://github.com/smithy-lang/smithy-rs/pull/4238
* https://github.com/smithy-lang/smithy-rs/pull/4224




## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] For changes to the AWS SDK, generated SDK code, or SDK runtime
crates, I have created a changelog entry Markdown file in the
`.changelog` directory, specifying "aws-sdk-rust" in the `applies_to`
key.

----

_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: default avatarAWS SDK Rust Bot <97246200+aws-sdk-rust-ci@users.noreply.github.com>
parent 2229fb1f
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
---
applies_to:
  - aws-sdk-rust
authors:
  - landonxjames
references:
  - smithy-rs#4238
breaking: false
new_feature: true
bug_fix: false
---
Add user-agent feature tracking for credential providers in `aws-config`.
+5 −5
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"

[[package]]
name = "aws-credential-types"
version = "1.2.4"
version = "1.2.5"
dependencies = [
 "async-trait",
 "aws-smithy-async",
@@ -143,7 +143,7 @@ dependencies = [

[[package]]
name = "aws-runtime"
version = "1.5.9"
version = "1.5.10"
dependencies = [
 "arbitrary",
 "aws-credential-types",
@@ -231,7 +231,7 @@ dependencies = [

[[package]]
name = "aws-smithy-checksums"
version = "0.63.5"
version = "0.63.6"
dependencies = [
 "aws-smithy-http",
 "aws-smithy-types",
@@ -319,7 +319,7 @@ dependencies = [

[[package]]
name = "aws-smithy-runtime"
version = "1.8.5"
version = "1.8.6"
dependencies = [
 "aws-smithy-async",
 "aws-smithy-http",
@@ -341,7 +341,7 @@ dependencies = [

[[package]]
name = "aws-smithy-runtime-api"
version = "1.8.5"
version = "1.8.6"
dependencies = [
 "aws-smithy-async",
 "aws-smithy-types",
+5 −5
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"

[[package]]
name = "aws-config"
version = "1.8.3"
version = "1.8.4"
dependencies = [
 "aws-credential-types",
 "aws-runtime",
@@ -84,7 +84,7 @@ dependencies = [

[[package]]
name = "aws-credential-types"
version = "1.2.4"
version = "1.2.5"
dependencies = [
 "aws-smithy-async",
 "aws-smithy-runtime-api",
@@ -117,7 +117,7 @@ dependencies = [

[[package]]
name = "aws-runtime"
version = "1.5.9"
version = "1.5.10"
dependencies = [
 "aws-credential-types",
 "aws-sigv4",
@@ -318,7 +318,7 @@ dependencies = [

[[package]]
name = "aws-smithy-runtime"
version = "1.8.5"
version = "1.8.6"
dependencies = [
 "aws-smithy-async",
 "aws-smithy-http",
@@ -341,7 +341,7 @@ dependencies = [

[[package]]
name = "aws-smithy-runtime-api"
version = "1.8.5"
version = "1.8.6"
dependencies = [
 "aws-smithy-async",
 "aws-smithy-types",
+2 −2
Original line number Diff line number Diff line
[package]
name = "aws-config"
version = "1.8.3"
version = "1.8.4"
authors = [
    "AWS Rust SDK Team <aws-sdk-rust@amazon.com>",
    "Russell Cohen <rcoh@amazon.com>",
@@ -61,8 +61,8 @@ aws-sdk-ssooidc = { path = "../../sdk/build/aws-sdk/sdk/ssooidc", default-featur

[dev-dependencies]
aws-smithy-async = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-async", features = ["rt-tokio", "test-util"] }
aws-smithy-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime", features = ["client", "test-util"] }
aws-smithy-http-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-http-client", features = ["default-client", "test-util"] }
aws-smithy-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime", features = ["client", "test-util"] }
aws-smithy-runtime-api = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["test-util"] }
futures-util = { version = "0.3.29", default-features = false }
tracing-test = "0.2.4"
+26 −4
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
use crate::json_credentials::{json_parse_loop, InvalidJsonCredentials};
use crate::sensitive_command::CommandWithSensitiveArgs;
use aws_credential_types::attributes::AccountId;
use aws_credential_types::credential_feature::AwsCredentialFeature;
use aws_credential_types::provider::{self, error::CredentialsError, future, ProvideCredentials};
use aws_credential_types::Credentials;
use aws_smithy_json::deserialize::Token;
@@ -122,14 +123,19 @@ impl CredentialProcessProvider {
            ))
        })?;

        parse_credential_process_json_credentials(output, self.profile_account_id.as_ref()).map_err(
            |invalid| {
        parse_credential_process_json_credentials(output, self.profile_account_id.as_ref())
            .map(|mut creds| {
                creds
                    .get_property_mut_or_default::<Vec<AwsCredentialFeature>>()
                    .push(AwsCredentialFeature::CredentialsProcess);
                creds
            })
            .map_err(|invalid| {
                CredentialsError::provider_error(format!(
                "Error retrieving credentials from external process, could not parse response: {}",
                invalid
            ))
            },
        )
            })
    }
}

@@ -264,6 +270,7 @@ fn parse_expiration(expiration: impl AsRef<str>) -> Result<SystemTime, InvalidJs
mod test {
    use crate::credential_process::CredentialProcessProvider;
    use crate::sensitive_command::CommandWithSensitiveArgs;
    use aws_credential_types::credential_feature::AwsCredentialFeature;
    use aws_credential_types::provider::ProvideCredentials;
    use std::time::{Duration, SystemTime};
    use time::format_description::well_known::Rfc3339;
@@ -339,4 +346,19 @@ mod test {
        let creds = provider.provide_credentials().await.unwrap();
        assert_eq!("111122223333", creds.account_id().unwrap().as_str());
    }

    #[tokio::test]
    async fn credential_feature() {
        let provider = CredentialProcessProvider::builder()
            .command(CommandWithSensitiveArgs::new(String::from(
                r#"echo '{ "Version": 1, "AccessKeyId": "ASIARTESTID", "SecretAccessKey": "TESTSECRETKEY", "AccountId": "111122223333" }'"#,
            )))
            .account_id("012345678901")
            .build();
        let creds = provider.provide_credentials().await.unwrap();
        assert_eq!(
            &vec![AwsCredentialFeature::CredentialsProcess],
            creds.get_property::<Vec<AwsCredentialFeature>>().unwrap()
        );
    }
}
Loading