Skip to content

Commit

Permalink
aws/session: Add Assume role for credential process from aws shared c…
Browse files Browse the repository at this point in the history
…onfig (#2674)

Add support for assuming role using credential process from the shared config file. Also updated SDK's environment testing and added SDK's CI testing with Windows.
  • Loading branch information
skotambkar committed Jul 10, 2019
1 parent 7503c91 commit 5402768
Show file tree
Hide file tree
Showing 28 changed files with 399 additions and 235 deletions.
27 changes: 19 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,38 @@ go:
matrix:
allow_failures:
- go: tip
- os: windows
exclude:
# OSX 1.6.4 is not present in travis.
# https://github.com/travis-ci/travis-ci/issues/10309
- go: 1.6.x
os: osx
include:
- os: windows
go: 1.12.x
- os: linux
go: 1.5.x
# Use Go 1.5's vendoring experiment for 1.5 tests.
env: GO15VENDOREXPERIMENT=1

before_install:
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install make; fi

script:
- if [ $TRAVIS_GO_VERSION == "1.10.x" ] ||
[ $TRAVIS_GO_VERSION == "1.11.x" ] ||
[ $TRAVIS_GO_VERSION == "1.12.x" ] ||
[ $TRAVIS_GO_VERSION == "tip" ]; then
make get-deps;
make ci-test;
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then
make get-deps;
make unit-no-verify;
else
make get-deps-tests;
make unit-old-go-race-cover;
if [ $TRAVIS_GO_VERSION == "1.10.x" ] ||
[ $TRAVIS_GO_VERSION == "1.11.x" ] ||
[ $TRAVIS_GO_VERSION == "1.12.x" ] ||
[ $TRAVIS_GO_VERSION == "tip" ]; then
make get-deps;
make ci-test;
else
make get-deps-tests;
make unit-old-go-race-cover;
fi
fi

branches:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ cleanup-models:
###################
# Unit/CI Testing #
###################

unit-no-verify:
@echo "go test SDK and vendor packages with no linting"
go test -count=1 -tags ${UNIT_TEST_TAGS} ${SDK_ALL_PKGS}

unit: verify
@echo "go test SDK and vendor packages"
go test -count=1 -tags ${UNIT_TEST_TAGS} ${SDK_ALL_PKGS}
Expand Down
14 changes: 8 additions & 6 deletions aws/corehandlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
"time"
Expand All @@ -18,12 +17,13 @@ import (
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/awstesting"
"github.com/aws/aws-sdk-go/awstesting/unit"
"github.com/aws/aws-sdk-go/internal/sdktesting"
"github.com/aws/aws-sdk-go/service/s3"
)

func TestValidateEndpointHandler(t *testing.T) {
os.Clearenv()

restoreEnvFn := sdktesting.StashEnv()
defer restoreEnvFn()
svc := awstesting.NewClient(aws.NewConfig().WithRegion("us-west-2"))
svc.Handlers.Clear()
svc.Handlers.Validate.PushBackNamed(corehandlers.ValidateEndpointHandler)
Expand All @@ -37,8 +37,8 @@ func TestValidateEndpointHandler(t *testing.T) {
}

func TestValidateEndpointHandlerErrorRegion(t *testing.T) {
os.Clearenv()

restoreEnvFn := sdktesting.StashEnv()
defer restoreEnvFn()
svc := awstesting.NewClient()
svc.Handlers.Clear()
svc.Handlers.Validate.PushBackNamed(corehandlers.ValidateEndpointHandler)
Expand Down Expand Up @@ -69,7 +69,9 @@ func (m *mockCredsProvider) IsExpired() bool {
}

func TestAfterRetryRefreshCreds(t *testing.T) {
os.Clearenv()
restoreEnvFn := sdktesting.StashEnv()
defer restoreEnvFn()

credProvider := &mockCredsProvider{}

svc := awstesting.NewClient(&aws.Config{
Expand Down
3 changes: 2 additions & 1 deletion aws/corehandlers/user_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/internal/sdktesting"
)

func TestAddHostExecEnvUserAgentHander(t *testing.T) {
Expand All @@ -19,7 +20,7 @@ func TestAddHostExecEnvUserAgentHander(t *testing.T) {
}

for i, c := range cases {
os.Clearenv()
sdktesting.StashEnv()
os.Setenv(execEnvVar, c.ExecEnv)

req := &request.Request{
Expand Down
21 changes: 16 additions & 5 deletions aws/credentials/env_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package credentials
import (
"os"
"testing"

"github.com/aws/aws-sdk-go/internal/sdktesting"
)

func TestEnvProviderRetrieve(t *testing.T) {
os.Clearenv()
restoreEnvFn := sdktesting.StashEnv()
defer restoreEnvFn()
os.Setenv("AWS_ACCESS_KEY_ID", "access")
os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
os.Setenv("AWS_SESSION_TOKEN", "token")
Expand All @@ -29,7 +32,9 @@ func TestEnvProviderRetrieve(t *testing.T) {
}

func TestEnvProviderIsExpired(t *testing.T) {
os.Clearenv()
restoreEnvFn := sdktesting.StashEnv()
defer restoreEnvFn()

os.Setenv("AWS_ACCESS_KEY_ID", "access")
os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")
os.Setenv("AWS_SESSION_TOKEN", "token")
Expand All @@ -51,7 +56,9 @@ func TestEnvProviderIsExpired(t *testing.T) {
}

func TestEnvProviderNoAccessKeyID(t *testing.T) {
os.Clearenv()
restoreEnvFn := sdktesting.StashEnv()
defer restoreEnvFn()

os.Setenv("AWS_SECRET_ACCESS_KEY", "secret")

e := EnvProvider{}
Expand All @@ -62,7 +69,9 @@ func TestEnvProviderNoAccessKeyID(t *testing.T) {
}

func TestEnvProviderNoSecretAccessKey(t *testing.T) {
os.Clearenv()
restoreEnvFn := sdktesting.StashEnv()
defer restoreEnvFn()

os.Setenv("AWS_ACCESS_KEY_ID", "access")

e := EnvProvider{}
Expand All @@ -73,7 +82,9 @@ func TestEnvProviderNoSecretAccessKey(t *testing.T) {
}

func TestEnvProviderAlternateNames(t *testing.T) {
os.Clearenv()
restoreEnvFn := sdktesting.StashEnv()
defer restoreEnvFn()

os.Setenv("AWS_ACCESS_KEY", "access")
os.Setenv("AWS_SECRET_KEY", "secret")

Expand Down
Loading

0 comments on commit 5402768

Please sign in to comment.