Skip to content

Commit

Permalink
fix(tests): correct structure of newsigv4 testdata
Browse files Browse the repository at this point in the history
The implicit expectation of the ConfigTest is that the underlying
credentials provider will come from the mockCredentials struct.
This change constructs the testdata config in such a way as to make
this happen. Needs refactoring to remove this implicit contract.
  • Loading branch information
tanuck committed Jan 15, 2025
1 parent df4c9c5 commit f197c07
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/PR-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ jobs:
run-test-case:
runs-on: ubuntu-22.04
if: false
needs: [changes, get-test-cases, build, create-test-ref]
strategy:
fail-fast: false
Expand Down
3 changes: 1 addition & 2 deletions extensions/newsigv4/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func TestLoadConfig(t *testing.T) {
STSRegion: "region",
},
SharedCredentialsWatcher: SharedCredentialsWatcher{
FileLocation: "/local/credentials/credentials",
ProfileName: "default",
ProfileName: "profile_name",
},
// Ensure creds are the same for load config test; tested in extension_test.go
credsProvider: cfg.(*Config).credsProvider,
Expand Down
4 changes: 4 additions & 0 deletions extensions/newsigv4/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/aws/aws-sdk-go-v2/aws"
sigv4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
awsconfig "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
"github.com/aws/aws-sdk-go-v2/service/sts"
Expand Down Expand Up @@ -156,6 +157,9 @@ func newSigv4Extension(cfg *Config, awsSDKInfo string, logger *zap.Logger) *sigv
func getCredsProviderFromConfig(cfg *Config) (*aws.CredentialsProvider, error) {
awscfg, err := awsconfig.LoadDefaultConfig(context.Background(),
awsconfig.WithRegion(cfg.AssumeRole.STSRegion),
awsconfig.WithHTTPClient(awshttp.NewBuildableClient().WithTransportOptions(func(transport *http.Transport) {
transport.DisableKeepAlives = true
})),
)
if err != nil {
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions extensions/newsigv4/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ newsigv4:
assume_role:
session_name: "role_session_name"
shared_credentials_watcher:
file_location: "/local/credentials/credentials"
profile_name: "default"
profile_name: "profile_name"
newsigv4/missing_credentials:
region: "region"
service: "service"

0 comments on commit f197c07

Please sign in to comment.