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
/
account_creation_policy_test.go
128 lines (87 loc) · 3.24 KB
/
account_creation_policy_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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package stormpath
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetVerificationEmailTemplatesPolicyNoExists(t *testing.T) {
t.Parallel()
policy := &AccountCreationPolicy{VerificationEmailTemplates: &EmailTemplates{}}
policy.VerificationEmailTemplates.Href = "https://api.stormpath.com/v1/accountCreationPolicies/xxxx/verificationEmailTemplates"
templates, err := policy.GetVerificationEmailTemplates()
assert.Error(t, err)
assert.Equal(t, 404, err.(Error).Status)
assert.Nil(t, templates)
}
func TestGetVerificationEmailTemplates(t *testing.T) {
t.Parallel()
directory := createTestDirectory(t)
defer directory.Delete()
policy, _ := directory.GetAccountCreationPolicy()
templates, err := policy.GetVerificationEmailTemplates()
assert.NoError(t, err)
assert.Len(t, templates.Items, 1)
}
func TestGetVerificationSuccessEmailTemplatesPolicyNoExists(t *testing.T) {
t.Parallel()
policy := &AccountCreationPolicy{VerificationSuccessEmailTemplates: &EmailTemplates{}}
policy.VerificationSuccessEmailTemplates.Href = "https://api.stormpath.com/v1/accountCreationPolicies/xxxx/verificationSuccessEmailTemplates"
templates, err := policy.GetVerificationSuccessEmailTemplates()
assert.Error(t, err)
assert.Equal(t, 404, err.(Error).Status)
assert.Nil(t, templates)
}
func TestGetVerificationSuccessEmailTemplates(t *testing.T) {
t.Parallel()
directory := createTestDirectory(t)
defer directory.Delete()
policy, _ := directory.GetAccountCreationPolicy()
templates, err := policy.GetVerificationSuccessEmailTemplates()
assert.NoError(t, err)
assert.Len(t, templates.Items, 1)
}
func TestGetWelcomeEmailTemplatesPolicyNoExists(t *testing.T) {
t.Parallel()
policy := &AccountCreationPolicy{WelcomeEmailTemplates: &EmailTemplates{}}
policy.WelcomeEmailTemplates.Href = "https://api.stormpath.com/v1/accountCreationPolicies/xxxx/welcomeEmailTemplates"
templates, err := policy.GetWelcomeEmailTemplates()
assert.Error(t, err)
assert.Equal(t, 404, err.(Error).Status)
assert.Nil(t, templates)
}
func TestGetWelcomeEmailTemplates(t *testing.T) {
t.Parallel()
directory := createTestDirectory(t)
defer directory.Delete()
policy, _ := directory.GetAccountCreationPolicy()
templates, err := policy.GetWelcomeEmailTemplates()
assert.NoError(t, err)
assert.Len(t, templates.Items, 1)
}
func TestUpdateAccountCreationPolicy(t *testing.T) {
t.Parallel()
directory := createTestDirectory(t)
defer directory.Delete()
policy, _ := directory.GetAccountCreationPolicy()
policy.VerificationEmailStatus = Enabled
err := policy.Update()
assert.NoError(t, err)
assert.Equal(t, Enabled, policy.VerificationEmailStatus)
}
func TestUpdateAccountCreationPolicyNoExists(t *testing.T) {
t.Parallel()
policy := AccountCreationPolicy{}
policy.Href = GetClient().ClientConfiguration.BaseURL + "accountCreationPolicies/XXXX"
err := policy.Update()
assert.Error(t, err)
assert.Equal(t, 404, err.(Error).Status)
}
func TestRefreshAccountCreationPolicy(t *testing.T) {
t.Parallel()
directory := createTestDirectory(t)
defer directory.Delete()
policy, _ := directory.GetAccountCreationPolicy()
policy.VerificationEmailStatus = Enabled
err := policy.Refresh()
assert.NoError(t, err)
assert.Equal(t, Disabled, policy.VerificationEmailStatus)
}