-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws/session: Add Assume role for credential process from aws profile #2674
Conversation
skotambkar
commented
Jun 28, 2019
- Enabled support to assume role using Credential Process from AWS Profile.
- Added and updated test files, configuration files accordingly.
How I’m lost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple suggestion.
Also need to make sure we test for windows.
awstesting/util.go
Outdated
os.Clearenv() | ||
// StashEnv stashes the current environment variables except variables listed in envToKeep | ||
// Returns an array of all environment values as key=val strings. | ||
func StashEnv(envToKeep ...string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest updating aws/credentials/processcreds
test, preserveImportantStashEnv
function to use this updated utility.
|
||
[cred_proc_arn_set] | ||
role_arn = assume_role_w_creds_proc_role_arn | ||
credential_process = echo "{\"Version\": 1, \"AccessKeyId\": \"accesskey\", \"SecretAccessKey\": \"secretkey\"}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will want to test this against windows to ensure tests work.
…hanges and added support for windows build on Travis
… bundle tests for travis - windows os
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, minor suggestions with how the environments are stashed between tests.
aws/corehandlers/handlers_test.go
Outdated
os.Clearenv() | ||
|
||
restoreEnvFn := sdktesting.StashEnv() | ||
restoreEnvFn() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is missing the defer
aws/corehandlers/handlers_test.go
Outdated
os.Clearenv() | ||
|
||
restoreEnvFn := sdktesting.StashEnv() | ||
restoreEnvFn() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing defer
aws/corehandlers/handlers_test.go
Outdated
@@ -69,7 +69,9 @@ func (m *mockCredsProvider) IsExpired() bool { | |||
} | |||
|
|||
func TestAfterRetryRefreshCreds(t *testing.T) { | |||
os.Clearenv() | |||
restoreEnvFn := sdktesting.StashEnv() | |||
restoreEnvFn() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing defer
aws/credentials/env_provider_test.go
Outdated
@@ -29,7 +31,8 @@ func TestEnvProviderRetrieve(t *testing.T) { | |||
} | |||
|
|||
func TestEnvProviderIsExpired(t *testing.T) { | |||
os.Clearenv() | |||
sdktesting.StashEnv() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these stashes also restore the env after the test runs?
"github.com/aws/aws-sdk-go/internal/shareddefaults" | ||
) | ||
|
||
func TestSharedCredentialsProvider(t *testing.T) { | ||
os.Clearenv() | ||
|
||
sdktesting.StashEnv() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these restore the stashed env after the test runs?
aws/request/request.go
Outdated
if netErr, ok := err.(*net.OpError); ok && netErr.Op == "dial" { | ||
return true | ||
} | ||
// If the error is temporary, we want to allow continuation of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, minor spacing/gofmt here
aws/request/request_retry_test.go
Outdated
} | ||
|
||
awsError := awserr.New("ErrorTestShouldRetry", "Test should retry when error received", &urlError) | ||
origError := awsError.OrigErr() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is awsError
needed in this test?
aws/request/request_test.go
Outdated
@@ -1101,6 +1101,11 @@ func TestRequestNoConnection(t *testing.T) { | |||
t.Fatal("expect error, but got none") | |||
} | |||
|
|||
t.Log(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, would be good to include prefix for this log statement.
aws/session/env_config_test.go
Outdated
@@ -76,8 +77,7 @@ func TestLoadEnvConfig_Creds(t *testing.T) { | |||
} | |||
|
|||
for _, c := range cases { | |||
os.Clearenv() | |||
|
|||
sdktesting.StashEnv() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these restore the env after test is done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding, t.Run
for this test with // +build go1.7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, minor issue with the t.Run
in test case.
aws/session/env_config_test.go
Outdated
for k, v := range c.Env { | ||
os.Setenv(k, v) | ||
} | ||
t.Run("", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the first param of t.Run
in this case should be the case index number. e.g.
for i, c := range cases {
t.Run(strconv.Itoa(i), func(t *testing.T) {
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or change the cases from a slice to map, and provide name for each test case.