This repository has been archived by the owner on Apr 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
group_membership_test.go
72 lines (48 loc) · 1.7 KB
/
group_membership_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
70
71
72
package stormpath
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetGroupMembershipAccount(t *testing.T) {
t.Parallel()
application := createTestApplication(t)
defer application.Purge()
group := createTestGroup(application, t)
defer group.Delete()
account := createTestAccount(application, t)
groupMembership, _ := account.AddToGroup(group)
a, err := groupMembership.GetAccount(MakeAccountCriteria())
assert.NoError(t, err)
assert.Equal(t, account.Href, a.Href)
assert.Equal(t, groupMembership.Account, a)
}
func TestGetGroupMembershipAccountNotFound(t *testing.T) {
t.Parallel()
gm := NewGroupMembership(client.ClientConfiguration.BaseURL+"/accounts/XXX", client.ClientConfiguration.BaseURL+"/groups/XXX")
account, err := gm.GetAccount(MakeAccountCriteria())
assert.Error(t, err)
assert.Nil(t, account)
assert.Equal(t, http.StatusNotFound, err.(Error).Status)
}
func TestGetGroupMembershipGroup(t *testing.T) {
t.Parallel()
application := createTestApplication(t)
defer application.Purge()
group := createTestGroup(application, t)
defer group.Delete()
account := createTestAccount(application, t)
groupMembership, _ := account.AddToGroup(group)
g, err := groupMembership.GetGroup(MakeGroupCriteria())
assert.NoError(t, err)
assert.Equal(t, group.Href, g.Href)
assert.Equal(t, groupMembership.Group, g)
}
func TestGetGroupMembershipGroupNotFound(t *testing.T) {
t.Parallel()
gm := NewGroupMembership(client.ClientConfiguration.BaseURL+"/accounts/XXX", client.ClientConfiguration.BaseURL+"/groups/XXX")
group, err := gm.GetGroup(MakeGroupCriteria())
assert.Error(t, err)
assert.Nil(t, group)
assert.Equal(t, http.StatusNotFound, err.(Error).Status)
}