Fixed up some confusion between AWS_TOKEN and AWS_PROFILE. Also allowing testing when AWS_PROFILE is set without AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID.
This commit is contained in:
parent
63514d28e7
commit
dd77bf68da
|
@ -483,7 +483,7 @@ func unsetEnv(t *testing.T) func() {
|
||||||
t.Fatalf("Error unsetting env var AWS_SESSION_TOKEN: %s", err)
|
t.Fatalf("Error unsetting env var AWS_SESSION_TOKEN: %s", err)
|
||||||
}
|
}
|
||||||
if err := os.Unsetenv("AWS_PROFILE"); err != nil {
|
if err := os.Unsetenv("AWS_PROFILE"); err != nil {
|
||||||
t.Fatalf("Error unsetting env var AWS_TOKEN: %s", err)
|
t.Fatalf("Error unsetting env var AWS_PROFILE: %s", err)
|
||||||
}
|
}
|
||||||
if err := os.Unsetenv("AWS_SHARED_CREDENTIALS_FILE"); err != nil {
|
if err := os.Unsetenv("AWS_SHARED_CREDENTIALS_FILE"); err != nil {
|
||||||
t.Fatalf("Error unsetting env var AWS_SHARED_CREDENTIALS_FILE: %s", err)
|
t.Fatalf("Error unsetting env var AWS_SHARED_CREDENTIALS_FILE: %s", err)
|
||||||
|
@ -635,7 +635,7 @@ func getEnv() *currentEnv {
|
||||||
Key: os.Getenv("AWS_ACCESS_KEY_ID"),
|
Key: os.Getenv("AWS_ACCESS_KEY_ID"),
|
||||||
Secret: os.Getenv("AWS_SECRET_ACCESS_KEY"),
|
Secret: os.Getenv("AWS_SECRET_ACCESS_KEY"),
|
||||||
Token: os.Getenv("AWS_SESSION_TOKEN"),
|
Token: os.Getenv("AWS_SESSION_TOKEN"),
|
||||||
Profile: os.Getenv("AWS_TOKEN"),
|
Profile: os.Getenv("AWS_PROFILE"),
|
||||||
CredsFilename: os.Getenv("AWS_SHARED_CREDENTIALS_FILE"),
|
CredsFilename: os.Getenv("AWS_SHARED_CREDENTIALS_FILE"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,14 @@ func TestProvider_impl(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccPreCheck(t *testing.T) {
|
func testAccPreCheck(t *testing.T) {
|
||||||
|
if v := os.Getenv("AWS_PROFILE"); v == "" {
|
||||||
if v := os.Getenv("AWS_ACCESS_KEY_ID"); v == "" {
|
if v := os.Getenv("AWS_ACCESS_KEY_ID"); v == "" {
|
||||||
t.Fatal("AWS_ACCESS_KEY_ID must be set for acceptance tests")
|
t.Fatal("AWS_ACCESS_KEY_ID must be set for acceptance tests")
|
||||||
}
|
}
|
||||||
if v := os.Getenv("AWS_SECRET_ACCESS_KEY"); v == "" {
|
if v := os.Getenv("AWS_SECRET_ACCESS_KEY"); v == "" {
|
||||||
t.Fatal("AWS_SECRET_ACCESS_KEY must be set for acceptance tests")
|
t.Fatal("AWS_SECRET_ACCESS_KEY must be set for acceptance tests")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if v := os.Getenv("AWS_DEFAULT_REGION"); v == "" {
|
if v := os.Getenv("AWS_DEFAULT_REGION"); v == "" {
|
||||||
log.Println("[INFO] Test: Using us-west-2 as test region")
|
log.Println("[INFO] Test: Using us-west-2 as test region")
|
||||||
os.Setenv("AWS_DEFAULT_REGION", "us-west-2")
|
os.Setenv("AWS_DEFAULT_REGION", "us-west-2")
|
||||||
|
|
Loading…
Reference in New Issue