-
Notifications
You must be signed in to change notification settings - Fork 2
/
arn_test.go
55 lines (51 loc) · 1.39 KB
/
arn_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
50
51
52
53
54
55
package vault_plugin_auth_tencentcloud
import (
"testing"
)
func TestParseRoleArn(t *testing.T) {
// qcs::cam::uin/100021543***:roleName/****
arn := "qcs::cam::uin/1000215438890:roleName/elk"
result, err := parseARN(arn)
if err != nil {
t.Fatal(err)
}
if result.Uin != "1000215438890" {
t.Fatalf("got %s but expected %s", result.Uin, "1000215438890")
}
if result.Type != arnRoleType {
t.Fatalf("got %d but expected %d", result.Type, arnRoleType)
}
if result.RoleName != "elk" {
t.Fatalf("got %s but wanted %s", result.RoleName, "elk")
}
if result.RoleId != "" {
t.Fatalf("got %s but wanted %s", result.RoleId, "")
}
}
func TestParseAssumedRoleArn(t *testing.T) {
// qcs::sts:1000262***:assumed-role/461168601842741***
arn := "qcs::sts:1000215438890:assumed-role/4611686018427418890"
result, err := parseARN(arn)
if err != nil {
panic(err)
}
if result.Uin != "1000215438890" {
t.Fatalf("got %s but expected %s", result.Uin, "1000215438890")
}
if result.Type != arnAssumedRoleType {
t.Fatalf("got %d but expected %d", result.Type, arnAssumedRoleType)
}
if result.RoleName != "" {
t.Fatalf("got %s but wanted %s", result.RoleName, "")
}
if result.RoleId != "4611686018427418890" {
t.Fatalf("got %s but wanted %s", result.RoleId, "4611686018427418890")
}
}
func TestParseEmpty(t *testing.T) {
arn := ""
_, err := parseARN(arn)
if err == nil {
t.Fatal("expected an err")
}
}