-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements IsCredentialsProvider for checking if a provider matches a…
… target provider type. (#1890)
- Loading branch information
Showing
10 changed files
with
195 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "1b61ec1c-e18c-4cdf-ae74-f8852ecbf877", | ||
"type": "bugfix", | ||
"description": "The SDK client has been updated to utilize the `aws.IsCredentialsProvider` function for determining if `aws.AnonymousCredentials` has been configured for the `CredentialProvider`.", | ||
"modules": [ | ||
"service/eventbridge", | ||
"service/s3" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "869890a0-30aa-4f8e-8ddd-5ef80b7a01df", | ||
"type": "feature", | ||
"description": "Adds `aws.IsCredentialsProvider` for inspecting `CredentialProvider` types when needing to determine if the underlying implementation type matches a target type. This resolves an issue where `CredentialsCache` could mask `AnonymousCredentials` providers, breaking downstream detection logic.", | ||
"modules": [ | ||
"." | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package aws | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
type anonymousNamedType AnonymousCredentials | ||
|
||
func (f anonymousNamedType) Retrieve(ctx context.Context) (Credentials, error) { | ||
return AnonymousCredentials(f).Retrieve(ctx) | ||
} | ||
|
||
func TestIsCredentialsProvider(t *testing.T) { | ||
tests := map[string]struct { | ||
provider CredentialsProvider | ||
target CredentialsProvider | ||
want bool | ||
}{ | ||
"same implementations": { | ||
provider: AnonymousCredentials{}, | ||
target: AnonymousCredentials{}, | ||
want: true, | ||
}, | ||
"same implementations, pointer target": { | ||
provider: AnonymousCredentials{}, | ||
target: &AnonymousCredentials{}, | ||
want: true, | ||
}, | ||
"same implementations, pointer provider": { | ||
provider: &AnonymousCredentials{}, | ||
target: AnonymousCredentials{}, | ||
want: true, | ||
}, | ||
"same implementations, both pointers": { | ||
provider: &AnonymousCredentials{}, | ||
target: &AnonymousCredentials{}, | ||
want: true, | ||
}, | ||
"different implementations, nil target": { | ||
provider: AnonymousCredentials{}, | ||
target: nil, | ||
want: false, | ||
}, | ||
"different implementations, nil provider": { | ||
provider: nil, | ||
target: AnonymousCredentials{}, | ||
want: false, | ||
}, | ||
"different implementations": { | ||
provider: AnonymousCredentials{}, | ||
target: &stubCredentialsProvider{}, | ||
want: false, | ||
}, | ||
"nil provider and target": { | ||
provider: nil, | ||
target: nil, | ||
want: true, | ||
}, | ||
"implements IsCredentialsProvider, match": { | ||
provider: NewCredentialsCache(AnonymousCredentials{}), | ||
target: AnonymousCredentials{}, | ||
want: true, | ||
}, | ||
"implements IsCredentialsProvider, no match": { | ||
provider: NewCredentialsCache(AnonymousCredentials{}), | ||
target: &stubCredentialsProvider{}, | ||
want: false, | ||
}, | ||
"named types aliasing underlying types": { | ||
provider: AnonymousCredentials{}, | ||
target: anonymousNamedType{}, | ||
want: false, | ||
}, | ||
} | ||
for name, tt := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
if got := IsCredentialsProvider(tt.provider, tt.target); got != tt.want { | ||
t.Errorf("IsCredentialsProvider() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.