@@ -6,10 +6,11 @@ package openstack
66
77import (
88 "context"
9- "github.com/drone/autoscaler"
10- "github.com/h2non/gock"
119 "os"
1210 "testing"
11+
12+ "github.com/drone/autoscaler"
13+ "github.com/h2non/gock"
1314)
1415
1516func TestCreate (t * testing.T ) {
@@ -31,6 +32,21 @@ func TestCreate(t *testing.T) {
3132 SetHeader ("X-Subject-Token" , authToken ).
3233 BodyString (string (tokenResp1 ))
3334
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+
3450 fipResp1 := helperLoad (t , "fipresp1.json" )
3551 gock .New ("http://ops.my.cloud" ).
3652 Post ("/compute/v2.1/os-floating-ips" ).
@@ -113,6 +129,7 @@ func TestAuthFail(t *testing.T) {
113129 if err != nil {
114130 t .Error ("Unable to set OS_PASSWORD" )
115131 }
132+
116133 authResp1 := helperLoad (t , "authresp1.json" )
117134 gock .New ("http://ops.my.cloud" ).
118135 Get ("/identity" ).
@@ -160,13 +177,20 @@ func TestCreateFail(t *testing.T) {
160177 SetHeader ("X-Subject-Token" , authToken ).
161178 BodyString (string (tokenResp1 ))
162179
163- fipResp1 := helperLoad (t , "fipresp1 .json" )
180+ authResp2 := helperLoad (t , "authresp1 .json" )
164181 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 ).
168184 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 ))
170194
171195 imageListResp := helperLoad (t , "imagelistresp1.json" )
172196 gock .New ("http://ops.my.cloud" ).
@@ -240,7 +264,7 @@ func testInstance(instance *autoscaler.Instance) func(t *testing.T) {
240264 if want , got := instance .Address , "172.24.4.5" ; got != want {
241265 t .Errorf ("Want instance IP %q, got %q" , want , got )
242266 }
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 {
244268 t .Errorf ("Want instance ID %q, got %q" , want , got )
245269 }
246270 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) {
255279 if want , got := instance .Region , "RegionOne" ; got != want {
256280 t .Errorf ("Want instance Region %q, got %q" , want , got )
257281 }
258- if want , got := instance .Size , "m1.small " ; got != want {
282+ if want , got := instance .Size , "29e3cce3-d771-4220-80fe-3edf0e8dd466 " ; got != want {
259283 t .Errorf ("Want instance Size %q, got %q" , want , got )
260284 }
261285 }
0 commit comments