forked from jarias/stormpath-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_keys_test.go
64 lines (41 loc) · 1.18 KB
/
api_keys_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
package stormpath
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetAPIKey(t *testing.T) {
t.Parallel()
application := createTestApplication()
defer application.Purge()
account := createTestAccount(application)
apiKey, _ := account.CreateAPIKey()
k, err := GetAPIKey(apiKey.Href, MakeAPIKeyCriteria())
assert.NoError(t, err)
assert.Equal(t, apiKey, k)
}
func TestDeleteAPIKey(t *testing.T) {
t.Parallel()
application := createTestApplication()
defer application.Purge()
account := createTestAccount(application)
apiKey, _ := account.CreateAPIKey()
err := apiKey.Delete()
assert.NoError(t, err)
k, err := GetAPIKey(apiKey.Href, MakeAPIKeyCriteria())
assert.Error(t, err)
assert.Nil(t, k)
assert.Equal(t, http.StatusNotFound, err.(Error).Status)
}
func TestUpdateAPIKey(t *testing.T) {
t.Parallel()
application := createTestApplication()
defer application.Purge()
account := createTestAccount(application)
apiKey, _ := account.CreateAPIKey()
apiKey.Status = Disabled
err := apiKey.Update()
assert.NoError(t, err)
updatedAPIKey, _ := GetAPIKey(apiKey.Href, MakeAPIKeyCriteria())
assert.Equal(t, Disabled, updatedAPIKey.Status)
}