@@ -27,45 +27,36 @@ import (
27
27
)
28
28
29
29
var _ = Describe ("Test helper methods" , func () {
30
-
31
- Context ("Domain Creation and Deletion Integ Tests" , func () {
32
- var csClient * cloudstack.CloudStackClient
33
- ccPath := "../../cloud-config"
34
- var connectionErr error
35
- conf := cloud.Config {}
36
- if rawCfg , err := ini .Load ("../../cloud-config" ); err != nil {
37
- connectionErr = errors .Wrapf (err , "reading config at path %s:" , ccPath )
38
- } else if g := rawCfg .Section ("Global" ); len (g .Keys ()) == 0 {
39
- connectionErr = errors .New ("section Global not found" )
40
- } else if err = rawCfg .Section ("Global" ).StrictMapTo (& conf ); err != nil {
41
- connectionErr = errors .Wrapf (err , "parsing [Global] section from config at path %s:" , ccPath )
42
- }
43
-
44
- csClient = cloudstack .NewAsyncClient (conf .APIURL , conf .APIKey , conf .SecretKey , conf .VerifySSL )
45
-
46
- // Get the root domain's ID.
47
- rootDomainID , err , found := helpers .GetDomainByPath (csClient , "ROOT/" )
48
- Ω (err ).ShouldNot (HaveOccurred ())
49
- Ω (rootDomainID ).ShouldNot (BeEmpty ())
50
- Ω (found ).Should (BeTrue ())
51
-
52
- BeforeEach (func () {
53
- if connectionErr != nil { // Only do these tests if an actual ACS instance is available via cloud-config.
54
- Skip ("Could not connect to ACS instance." )
55
- }
56
- })
57
-
58
- AfterEach (func () {
59
- for _ , path := range []string {"ROOT/someNewDomain" , "ROOT/blah" } {
60
- // Delete any created domains.
61
- id , err , found := helpers .GetDomainByPath (csClient , path )
62
- Ω (err ).ShouldNot (HaveOccurred ())
63
- if found {
64
- Ω (helpers .DeleteDomain (csClient , id )).Should (Succeed ())
65
- }
30
+ var csClient * cloudstack.CloudStackClient
31
+ ccPath := "../../cloud-config"
32
+ conf := cloud.Config {}
33
+ if rawCfg , err := ini .Load ("../../cloud-config" ); err != nil {
34
+ Ω (errors .Wrapf (err , "reading config at path %s:" , ccPath )).ShouldNot (HaveOccurred ())
35
+ } else if g := rawCfg .Section ("Global" ); len (g .Keys ()) == 0 {
36
+ Ω (errors .New ("section Global not found" )).ShouldNot (HaveOccurred ())
37
+ } else if err = rawCfg .Section ("Global" ).StrictMapTo (& conf ); err != nil {
38
+ Ω (errors .Wrapf (err , "parsing [Global] section from config at path %s:" , ccPath )).ShouldNot (HaveOccurred ())
39
+ }
40
+ csClient = cloudstack .NewAsyncClient (conf .APIURL , conf .APIKey , conf .SecretKey , conf .VerifySSL )
41
+
42
+ // Get the root domain's ID.
43
+ rootDomainID , err , found := helpers .GetDomainByPath (csClient , "ROOT/" )
44
+ Ω (err ).ShouldNot (HaveOccurred ())
45
+ Ω (rootDomainID ).ShouldNot (BeEmpty ())
46
+ Ω (found ).Should (BeTrue ())
47
+
48
+ AfterEach (func () {
49
+ for _ , path := range []string {"ROOT/someNewDomain" , "ROOT/blah" } {
50
+ // Delete any created domains.
51
+ id , err , found := helpers .GetDomainByPath (csClient , path )
52
+ Ω (err ).ShouldNot (HaveOccurred ())
53
+ if found {
54
+ Ω (helpers .DeleteDomain (csClient , id )).Should (Succeed ())
66
55
}
67
- })
56
+ }
57
+ })
68
58
59
+ Context ("Domain Creation and Deletion." , func () {
69
60
It ("Can get the ROOT domain's ID." , func () {
70
61
id , err , found := helpers .GetDomainByPath (csClient , "ROOT/" )
71
62
Ω (err ).ShouldNot (HaveOccurred ())
@@ -88,7 +79,7 @@ var _ = Describe("Test helper methods", func() {
88
79
89
80
It ("Returns an appropriate error when the domain already exists." , func () {
90
81
someDomain := & cloud.Domain {Name : "blah" , Path : "blah" }
91
- Ω (helpers .GetOrCreateDomain (someDomain , csClient )).Should (Succeed ())
82
+ Ω (helpers .GetOrCreateDomain (csClient , someDomain )).Should (Succeed ())
92
83
Ω (someDomain .Name ).Should (Equal ("blah" ))
93
84
Ω (someDomain .Path ).Should (Equal ("ROOT/blah" ))
94
85
Ω (someDomain .ID ).ShouldNot (BeEmpty ())
@@ -99,23 +90,45 @@ var _ = Describe("Test helper methods", func() {
99
90
100
91
It ("Doesn't error if the domain already exists." , func () {
101
92
someDomain := & cloud.Domain {Name : "blah" , Path : "blah" }
102
- Ω (helpers .GetOrCreateDomain (someDomain , csClient )).Should (Succeed ())
93
+ Ω (helpers .GetOrCreateDomain (csClient , someDomain )).Should (Succeed ())
103
94
Ω (someDomain .Name ).Should (Equal ("blah" ))
104
95
Ω (someDomain .Path ).Should (Equal ("ROOT/blah" ))
105
96
Ω (someDomain .ID ).ShouldNot (BeEmpty ())
106
97
107
- Ω (helpers .GetOrCreateDomain (someDomain , csClient )).Should (Succeed ())
98
+ Ω (helpers .GetOrCreateDomain (csClient , someDomain )).Should (Succeed ())
108
99
Ω (someDomain .Name ).Should (Equal ("blah" ))
109
100
Ω (someDomain .Path ).Should (Equal ("ROOT/blah" ))
110
101
Ω (someDomain .ID ).ShouldNot (BeEmpty ())
111
102
})
112
103
113
104
It ("Can create a wholly new multi-level sub-domain path." , func () {
114
105
someDomain := & cloud.Domain {Name : "tooBlah" , Path : "ROOT/someNewDomain/tooBlah" }
115
- Ω (helpers .GetOrCreateDomain (someDomain , csClient )).Should (Succeed ())
106
+ Ω (helpers .GetOrCreateDomain (csClient , someDomain )).Should (Succeed ())
116
107
Ω (someDomain .Name ).Should (Equal ("tooBlah" ))
117
108
Ω (someDomain .Path ).Should (Equal ("ROOT/someNewDomain/tooBlah" ))
118
109
Ω (someDomain .ID ).ShouldNot (BeEmpty ())
119
110
})
120
111
})
112
+
113
+ Context ("Account Creation." , func () {
114
+ It ("Can create a new account in a new domain." , func () {
115
+ domain := cloud.Domain {Path : "ROOT/someNewDomain/tooBlah" }
116
+ account := cloud.Account {Name : "TempTestAccount" , Domain : domain }
117
+ Ω (helpers .GetOrCreateAccount (csClient , & account )).Should (Succeed ())
118
+ })
119
+ It ("Doesn't fail if the account already exists." , func () {
120
+ domain := cloud.Domain {Path : "ROOT/someNewDomain/tooBlah" }
121
+ account := cloud.Account {Name : "TempTestAccount" , Domain : domain }
122
+ Ω (helpers .GetOrCreateAccount (csClient , & account )).Should (Succeed ())
123
+ Ω (helpers .GetOrCreateAccount (csClient , & account )).Should (Succeed ())
124
+ })
125
+ })
126
+
127
+ // Context("User Creation w/Keys.", func() {
128
+ // It("Can create a new account in a new domain.", func() {
129
+ // domain := cloud.Domain{Path: "ROOT/someNewDomain/tooBlah"}
130
+ // account := cloud.Account{Name: "TempTestAccount", Domain: domain}
131
+ // Ω(helpers.GetOrCreateAccount(csClient, &account)).Should(Succeed())
132
+ // })
133
+ // })
121
134
})
0 commit comments