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
/
stormpath_suite_test.go
135 lines (108 loc) · 7.6 KB
/
stormpath_suite_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
129
130
131
132
133
134
135
package stormpath
import (
"io/ioutil"
"log"
"os"
"strings"
"testing"
uuid "github.com/nu7hatch/gouuid"
)
var (
tenant *Tenant
)
const (
string256 = "5mmsUvVLGAfBphgbkWoNjsPVLafEUaqJFKSKbHJkDsuWFOUTq2q3SRQSbSnT7J9hGyDCBtsACTTgreSKIRtRci1lywp0g2J474tmnfCEHaSItpFFtWvkOr4IJgmZ0ZYacnzWF4JJjC6KZAOmAOIG0AwUxJ22TTEnkBToWrzvTEunuwXBZfWcyQKToEsj1QCeHNJ7OOfQYClELLxjAvSVEQSRYJta72LZICRPsoTl4aMYRbgD92l83vmCCHma4qOk"
string4001 = "a9j5ko04xuMRmj2mP2Ex2Ue7DtZ62UDPKxPtQvRvqPxVNPxsylszp0RIpyMDeKuMB7AMoU4mWbrjEsVR5JGe64ZqzuHlEKcBSJ8Ci5H2LsZ1Le2JbDWKIQjGLTHaKgC0Ecu3Xe8RpMLo72YbKYESQ2YBzOKczDphPi7iovGrxGx5uoyw0Zh5XfBMTLZlXmSfpzB2jhNpyCHBUhlFittJ21Ff8GSV5eTE8EtnjpwvseirWBQjwOa9I6sqfQUMuKJwTqt69vtZa0YGN81aDtylqF1vqIjWLp9WmNnpD5r17xHez0nmjT0I7zaMGsyvmSXpPHyLipLw9kKsp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EerVFbXbLgQhS4kRYwbY87huNFI7aJsyuhOcz9g6hDK3Z3b5A1BmND8qfpPrlAnmaPtWN0hNxecDQbBUFNBKotvF1WQ49YYL7oPprO5WDp40Z0PAp7GPyfTx6NCWl99fsHlqFHHD8FToW7ZsIG0n4SfQO67GnT93ir8VIjeGlLLwGu5Hrcb1j3RMlOrWFw3bO7mVfV45aY2SFeWWwuZurUm5JyTEVG3WES7FaO1rRsw0H9jlxWE1Ey1hJivMEtounUMW2bnDsYPHEyNoWxD6GwSCelHVJioSvIcgU3IFxbN9AtFFXabWU7qqcCIx6L3knzmgM0ByUse4sR0F2e09xGT757zhayvP"
)
var isSetup = false
func TestMain(m *testing.M) {
setup()
cleanApps()
r := m.Run()
cleanApps()
os.Exit(r)
}
func cleanApps() {
//Clean any leftover apps
applications, _ := tenant.GetApplications(MakeApplicationsCriteria().Limit(100))
for _, application := range applications.Items {
if strings.Contains("go-sdk-app", application.Name) {
application.Purge()
}
}
}
func setup() {
if !isSetup {
isSetup = true
//Disable logs
Logger = log.New(ioutil.Discard, "", 0)
var err error
clientConfig, err := LoadConfiguration()
if err != nil {
panic(err)
}
Init(clientConfig, nil)
GetClient().Cache = nil
tenant, err = CurrentTenant()
if err != nil {
panic(err)
}
}
}
func randomName() string {
uuid, _ := uuid.NewV4()
return uuid.String()
}
func newTestApplication() *Application {
return &Application{Name: "go-sdk-app-" + randomName()}
}
func newTestGroup() *Group {
return &Group{Name: "go-sdk-group-" + randomName()}
}
func newTestDirectory() *Directory {
return &Directory{Name: "go-sdk-directory-" + randomName()}
}
func newTestAccount() *Account {
name := "go-sdk-" + randomName()
email := name + "@test.org"
return NewAccount(email, "1234567z!A89", email, "givenName", "surname")
}
func newTestOrganization() *Organization {
return NewOrganization("go-sdk-org-"+randomName(), "go-sdk-org-"+randomName())
}
func createTestApplication(t *testing.T) *Application {
application := newTestApplication()
e := CreateApplication(application)
failOnError(e, t)
return application
}
func createTestOrganization(t *testing.T) *Organization {
organization := newTestOrganization()
e := tenant.CreateOrganization(organization)
failOnError(e, t)
return organization
}
func createTestAccount(application *Application, t *testing.T) *Account {
account := newTestAccount()
e := application.RegisterAccount(account)
failOnError(e, t)
return account
}
func createTestGroup(application *Application, t *testing.T) *Group {
group := newTestGroup()
e := application.CreateGroup(group)
failOnError(e, t)
return group
}
func createTestDirectory(t *testing.T) *Directory {
directory := newTestDirectory()
e := CreateDirectory(directory)
failOnError(e, t)
return directory
}
func failOnError(e error, t *testing.T) {
if e != nil {
t.Fatal(e)
}
}