Skip to content

Commit

Permalink
style: more linter things and adjust for mocking client
Browse files Browse the repository at this point in the history
Signed-off-by: Samantha Coyle <[email protected]>
  • Loading branch information
sicoyle committed Nov 12, 2024
1 parent ce94dfe commit 30de3db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/authentication/aws/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type mockedSQS struct {
GetQueueURLFn func(ctx context.Context, input *sqs.GetQueueUrlInput) (*sqs.GetQueueUrlOutput, error)
}

func (m *mockedSQS) GetQueueURLWithContext(ctx context.Context, input *sqs.GetQueueUrlInput, opts ...request.Option) (*sqs.GetQueueUrlOutput, error) {
func (m *mockedSQS) GetQueueUrlWithContext(ctx context.Context, input *sqs.GetQueueUrlInput, opts ...request.Option) (*sqs.GetQueueUrlOutput, error) { //nolint:stylecheck
return m.GetQueueURLFn(ctx, input)
}

Expand Down
7 changes: 5 additions & 2 deletions common/authentication/aws/x509.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,17 @@ func (a *x509) createOrRefreshSession(ctx context.Context) (*session.Session, er
config = a.cfg.WithRegion(*a.region).WithHTTPClient(client).WithLogLevel(aws.LogOff)
}

// this is needed for testing purposes to mock the client,
// so code never sets the client, but tests do.
var rolesClient *rolesanywhere.RolesAnywhere
if a.rolesAnywhereClient == nil {
mySession = session.Must(session.NewSession(config))
rolesAnywhereClient := rolesanywhere.New(mySession, config)
// Set up signing function and handlers
if err := a.setSigningFunction(rolesAnywhereClient); err != nil {
return nil, err
}
a.rolesAnywhereClient = rolesAnywhereClient
rolesClient = rolesAnywhereClient
}

var (
Expand Down Expand Up @@ -498,7 +501,7 @@ func (a *x509) createOrRefreshSession(ctx context.Context) (*session.Session, er
}
}

output, err := a.rolesAnywhereClient.CreateSessionWithContext(ctx, &createSessionRequest)
output, err := rolesClient.CreateSessionWithContext(ctx, &createSessionRequest)
if err != nil {
return nil, fmt.Errorf("failed to create session using dapr app identity: %w", err)
}
Expand Down

0 comments on commit 30de3db

Please sign in to comment.