-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcred_test.go
49 lines (45 loc) · 1.13 KB
/
cred_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package aws
import (
"github.com/aws/aws-sdk-go/service/iam"
"github.com/stretchr/testify/assert"
"github.com/viant/endly"
"github.com/viant/toolbox"
"github.com/viant/scy/cred/secret"
"os"
"path"
"testing"
)
func Test_GetAWSCredentialConfig(t *testing.T) {
if !toolbox.FileExists(path.Join(os.Getenv("HOME"), ".secret/aws.json")) {
return
}
secretService := secret.New("", false)
cred, err := secretService.GetCredentials("aws")
if !assert.Nil(t, err) {
return
}
awsCred, err := GetAWSCredentialConfig(cred)
if !assert.Nil(t, err) {
return
}
assert.NotNil(t, awsCred)
assert.NotNil(t, cred.AccountID)
}
func Test_GetClient(t *testing.T) {
if !toolbox.FileExists(path.Join(os.Getenv("HOME"), ".secret/aws.json")) {
return
}
manager := endly.New()
context := manager.NewContext(nil)
var key = struct{}{}
_, err := InitCredentials(context, map[string]interface{}{
"Credentials": "aws",
}, key)
assert.Nil(t, err)
client := &iam.IAM{}
err = GetClient(context, iam.New, &client)
assert.Nil(t, err)
output, err := client.ListUsers(&iam.ListUsersInput{})
assert.Nil(t, err)
assert.True(t, len(output.Users) > 0)
}