-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathiam_sessions_test.go
69 lines (55 loc) · 1.29 KB
/
iam_sessions_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package alks
import (
"github.com/Cox-Automotive/alks-go/testutils"
"testing"
. "github.com/motain/gocheck"
)
func Test(t *testing.T) {
TestingT(t)
}
type S struct {
client *Client
}
var _ = Suite(&S{})
var testServer = testutil.NewHTTPServer()
func (s *S) SetUpSuite(c *C) {
testServer.Start()
var err error
s.client, err = NewClient("http://localhost:4200", "brian", "pass", "012345678910/ALKSAdmin - awstest123", "Admin")
if err != nil {
panic(err)
}
}
func (s *S) TearDownTest(c *C) {
testServer.Flush()
}
func (s *S) Test_CreateIamSession(c *C) {
testServer.Response(200, nil, getIamLoginRoleResponse)
testServer.Response(202, nil, iamResponse)
resp, err := s.client.CreateIamSession()
_ = testServer.WaitRequest()
_ = testServer.WaitRequest()
c.Assert(err, IsNil)
c.Assert(resp.AccessKey, Equals, "thisismykey")
c.Assert(resp.SecretKey, Equals, "thisismysecret")
c.Assert(resp.SessionToken, Equals, "thisismysession")
}
var iamResponse = `
{
"accessKey": "thisismykey",
"secretKey": "thisismysecret",
"sessionToken": "thisismysession"
}
`
var getIamLoginRoleResponse = `
{
"requestId": "abcd1234",
"statusMessage": "Success",
"loginRole": {
"account": "012345678910/ALKSAdmin",
"role": "Admin",
"iamKeyActive": true,
"maxKeyDuration": 36
}
}
`