@@ -6,10 +6,11 @@ package openstack
6
6
7
7
import (
8
8
"context"
9
- "github.com/drone/autoscaler"
10
- "github.com/h2non/gock"
11
9
"os"
12
10
"testing"
11
+
12
+ "github.com/drone/autoscaler"
13
+ "github.com/h2non/gock"
13
14
)
14
15
15
16
func TestCreate (t * testing.T ) {
@@ -31,6 +32,21 @@ func TestCreate(t *testing.T) {
31
32
SetHeader ("X-Subject-Token" , authToken ).
32
33
BodyString (string (tokenResp1 ))
33
34
35
+ authResp2 := helperLoad (t , "authresp1.json" )
36
+ gock .New ("http://ops.my.cloud" ).
37
+ Get ("/identity" ).
38
+ Reply (300 ).
39
+ SetHeader ("Content-Type" , "application/json" ).
40
+ BodyString (string (authResp2 ))
41
+
42
+ tokenResp2 := helperLoad (t , "tokenresp1.json" )
43
+ gock .New ("http://ops.my.cloud" ).
44
+ Post ("/identity/v3/auth/tokens" ).
45
+ Reply (201 ).
46
+ SetHeader ("Content-Type" , "application/json" ).
47
+ SetHeader ("X-Subject-Token" , authToken ).
48
+ BodyString (string (tokenResp2 ))
49
+
34
50
fipResp1 := helperLoad (t , "fipresp1.json" )
35
51
gock .New ("http://ops.my.cloud" ).
36
52
Post ("/compute/v2.1/os-floating-ips" ).
@@ -113,6 +129,7 @@ func TestAuthFail(t *testing.T) {
113
129
if err != nil {
114
130
t .Error ("Unable to set OS_PASSWORD" )
115
131
}
132
+
116
133
authResp1 := helperLoad (t , "authresp1.json" )
117
134
gock .New ("http://ops.my.cloud" ).
118
135
Get ("/identity" ).
@@ -160,13 +177,20 @@ func TestCreateFail(t *testing.T) {
160
177
SetHeader ("X-Subject-Token" , authToken ).
161
178
BodyString (string (tokenResp1 ))
162
179
163
- fipResp1 := helperLoad (t , "fipresp1 .json" )
180
+ authResp2 := helperLoad (t , "authresp1 .json" )
164
181
gock .New ("http://ops.my.cloud" ).
165
- Post ("/compute/v2.1/os-floating-ips" ).
166
- MatchHeader ("X-Auth-Token" , authToken ).
167
- Reply (200 ).
182
+ Get ("/identity" ).
183
+ Reply (300 ).
168
184
SetHeader ("Content-Type" , "application/json" ).
169
- BodyString (string (fipResp1 ))
185
+ BodyString (string (authResp2 ))
186
+
187
+ tokenResp2 := helperLoad (t , "tokenresp1.json" )
188
+ gock .New ("http://ops.my.cloud" ).
189
+ Post ("/identity/v3/auth/tokens" ).
190
+ Reply (201 ).
191
+ SetHeader ("Content-Type" , "application/json" ).
192
+ SetHeader ("X-Subject-Token" , authToken ).
193
+ BodyString (string (tokenResp2 ))
170
194
171
195
imageListResp := helperLoad (t , "imagelistresp1.json" )
172
196
gock .New ("http://ops.my.cloud" ).
@@ -240,7 +264,7 @@ func testInstance(instance *autoscaler.Instance) func(t *testing.T) {
240
264
if want , got := instance .Address , "172.24.4.5" ; got != want {
241
265
t .Errorf ("Want instance IP %q, got %q" , want , got )
242
266
}
243
- if want , got := instance .Image , "ubuntu-16.04-server-latest " ; got != want {
267
+ if want , got := instance .Image , "4ef19958-ee2d-44a7-a100-de0b8afdbc8e " ; got != want {
244
268
t .Errorf ("Want instance ID %q, got %q" , want , got )
245
269
}
246
270
if want , got := instance .ID , "56046f6d-3184-495b-938b-baa450db970d" ; got != want {
@@ -255,7 +279,7 @@ func testInstance(instance *autoscaler.Instance) func(t *testing.T) {
255
279
if want , got := instance .Region , "RegionOne" ; got != want {
256
280
t .Errorf ("Want instance Region %q, got %q" , want , got )
257
281
}
258
- if want , got := instance .Size , "m1.small " ; got != want {
282
+ if want , got := instance .Size , "29e3cce3-d771-4220-80fe-3edf0e8dd466 " ; got != want {
259
283
t .Errorf ("Want instance Size %q, got %q" , want , got )
260
284
}
261
285
}
0 commit comments