Skip to content

Commit

Permalink
oidc credentials provider allow use default value ("defaultSessionNam…
Browse files Browse the repository at this point in the history
…e") as RoleSessionName
  • Loading branch information
mozillazg authored and yndu13 committed Feb 6, 2023
1 parent 3bee676 commit 268a44a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions credentials/oidc_credential_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (p *oidcCredentialsProvider) resolve() (*Config, error) {
RoleArn: tea.String(roleArn),
OIDCProviderArn: tea.String(oidcProviderArn),
OIDCTokenFilePath: tea.String(oidcTokenFilePath),
RoleSessionName: tea.String("defaultSessionName"),
}
roleSessionName, ok := os.LookupEnv(ENVRoleSessionName)
if ok {
Expand Down
9 changes: 9 additions & 0 deletions credentials/oidc_credential_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ func TestOidcCredentialsProvider(t *testing.T) {
os.Setenv(ENVRoleArn, "roleArn")
os.Setenv(ENVOIDCProviderArn, "oidcProviderArn")
os.Setenv(ENVOIDCTokenFile, "oidcTokenFilePath")
os.Unsetenv(ENVRoleSessionName)
c, err = p.resolve()
assert.Nil(t, err)
assert.Equal(t, "roleArn", tea.StringValue(c.RoleArn))
assert.Equal(t, "oidcProviderArn", tea.StringValue(c.OIDCProviderArn))
assert.Equal(t, "oidcTokenFilePath", tea.StringValue(c.OIDCTokenFilePath))
assert.Equal(t, "defaultSessionName", tea.StringValue(c.RoleSessionName))
assert.Equal(t, "oidc_role_arn", tea.StringValue(c.Type))

os.Setenv(ENVRoleSessionName, "roleSessionName")
c, err = p.resolve()
assert.Nil(t, err)
Expand Down

0 comments on commit 268a44a

Please sign in to comment.