-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c32a32
commit eeb0e67
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/sts" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAWS_SessionV2(t *testing.T) { | ||
if ok, _ := strconv.ParseBool(os.Getenv("TEST_REMOTE_APIS")); !ok { | ||
t.Skip("Skipping remote API tests without TEST_REMOTE_APIS=true") | ||
} | ||
|
||
a := AWS{ | ||
Region: "eu-west-1", | ||
} | ||
|
||
cfg, err := a.SessionV2(context.Background()) | ||
require.NoError(t, err) | ||
|
||
client2 := sts.NewFromConfig(cfg) | ||
_, err = client2.GetCallerIdentity(context.Background(), &sts.GetCallerIdentityInput{}) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestAWS_SessionV2_Static(t *testing.T) { | ||
if ok, _ := strconv.ParseBool(os.Getenv("TEST_REMOTE_APIS")); !ok { | ||
t.Skip("Skipping remote API tests without TEST_REMOTE_APIS=true") | ||
} | ||
|
||
a := AWS{ | ||
Region: "eu-west-1", | ||
AccessKeyID: os.Getenv("TEST_AWS_ACCESS_KEY_ID"), | ||
AccessKeySecret: os.Getenv("TEST_AWS_SECRET_ACCESS_KEY"), | ||
} | ||
|
||
if a.AccessKeyID == "" { | ||
t.Fatal("TEST_AWS_ACCESS_KEY_ID not provided") | ||
} | ||
|
||
cfg, err := a.SessionV2(context.Background()) | ||
require.NoError(t, err) | ||
|
||
client2 := sts.NewFromConfig(cfg) | ||
_, err = client2.GetCallerIdentity(context.Background(), &sts.GetCallerIdentityInput{}) | ||
require.NoError(t, err) | ||
} |