Skip to content

Commit

Permalink
refactor config setters
Browse files Browse the repository at this point in the history
  • Loading branch information
yndu13 committed Sep 14, 2024
1 parent 1d5d242 commit e3948a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions credentials/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ func (s *Config) SetSTSEndpoint(v string) *Config {
return s
}

func (s *Config) SetExternalId(v string) *Config {
s.ExternalId = &v
return s
}

// NewCredential return a credential according to the type in config.
// if config is nil, the function will use default provider chain to get credentials.
// please see README.md for detail.
Expand Down
9 changes: 9 additions & 0 deletions credentials/credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ func TestNewCredentialWithRAMRoleARN(t *testing.T) {
cred, err = NewCredential(config)
assert.Nil(t, err)
assert.NotNil(t, cred)

config.SetExternalId("externalId")
config.SetPolicy("policy")
config.SetRoleSessionExpiration(3600)
config.SetRoleSessionName("roleSessionName")
cred, err = NewCredential(config)
assert.Nil(t, err)
assert.NotNil(t, cred)

}

func TestNewCredentialWithBearerToken(t *testing.T) {
Expand Down

0 comments on commit e3948a9

Please sign in to comment.