forked from jarias/stormpath-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectory_test.go
91 lines (72 loc) · 2.21 KB
/
directory_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package stormpath_test
import (
"encoding/json"
. "github.com/jarias/stormpath-sdk-go"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Directory", func() {
Describe("JSON", func() {
It("should marshal a minimum JSON with only the directory name", func() {
directory := NewDirectory("name")
jsonData, _ := json.Marshal(directory)
Expect(string(jsonData)).To(Equal("{\"name\":\"name\"}"))
})
})
Describe("Delete", func() {
It("should delete an existing directory", func() {
directory := newTestDirectory()
tenant.CreateDirectory(directory)
err := directory.Delete()
Expect(err).NotTo(HaveOccurred())
})
})
Describe("GetGroups", func() {
It("should retrive all directory groups", func() {
directory := newTestDirectory()
tenant.CreateDirectory(directory)
groups, err := directory.GetGroups(MakeGroupCriteria())
Expect(err).NotTo(HaveOccurred())
Expect(groups.Href).NotTo(BeEmpty())
Expect(groups.Offset).To(Equal(0))
Expect(groups.Limit).To(Equal(25))
Expect(groups.Items).To(BeEmpty())
directory.Delete()
})
})
Describe("GetAccounts", func() {
It("should retrieve all directory accounts", func() {
directory := newTestDirectory()
tenant.CreateDirectory(directory)
accounts, err := directory.GetAccounts(MakeAccountCriteria())
Expect(err).NotTo(HaveOccurred())
Expect(accounts.Href).NotTo(BeEmpty())
Expect(accounts.Offset).To(Equal(0))
Expect(accounts.Limit).To(Equal(25))
Expect(accounts.Items).To(BeEmpty())
directory.Delete()
})
})
Describe("CreateGroup", func() {
It("should create new group", func() {
directory := newTestDirectory()
tenant.CreateDirectory(directory)
group := NewGroup("new-group")
err := directory.CreateGroup(group)
Expect(err).NotTo(HaveOccurred())
Expect(group.Href).NotTo(BeEmpty())
directory.Delete()
})
})
Describe("RegisterAccount", func() {
It("should create a new accout for the group", func() {
directory := newTestDirectory()
tenant.CreateDirectory(directory)
account := newTestAccount()
err := directory.RegisterAccount(account)
Expect(err).NotTo(HaveOccurred())
Expect(account.Href).NotTo(BeEmpty())
directory.Delete()
})
})
})