Keith Byrne | bda4859 | 2016-03-23 11:37:08 +0000 | [diff] [blame] | 1 | // +build fixtures |
| 2 | |
Jamie Hannaford | fba65af | 2014-11-03 10:32:37 +0100 | [diff] [blame] | 3 | package lbs |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 4 | |
| 5 | import ( |
| 6 | "fmt" |
| 7 | "net/http" |
Jamie Hannaford | 5f95e6a | 2014-10-31 16:13:44 +0100 | [diff] [blame] | 8 | "strconv" |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 9 | "testing" |
| 10 | |
| 11 | th "github.com/rackspace/gophercloud/testhelper" |
| 12 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 13 | ) |
| 14 | |
| 15 | func mockListLBResponse(t *testing.T) { |
| 16 | th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) { |
| 17 | th.TestMethod(t, r, "GET") |
| 18 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 19 | |
| 20 | w.Header().Add("Content-Type", "application/json") |
| 21 | w.WriteHeader(http.StatusOK) |
| 22 | |
| 23 | fmt.Fprintf(w, ` |
| 24 | { |
Jamie Hannaford | 4d398ff | 2014-11-14 11:03:00 +0100 | [diff] [blame] | 25 | "loadBalancers":[ |
| 26 | { |
| 27 | "name":"lb-site1", |
| 28 | "id":71, |
| 29 | "protocol":"HTTP", |
| 30 | "port":80, |
| 31 | "algorithm":"RANDOM", |
| 32 | "status":"ACTIVE", |
| 33 | "nodeCount":3, |
| 34 | "virtualIps":[ |
| 35 | { |
| 36 | "id":403, |
| 37 | "address":"206.55.130.1", |
| 38 | "type":"PUBLIC", |
| 39 | "ipVersion":"IPV4" |
| 40 | } |
| 41 | ], |
| 42 | "created":{ |
| 43 | "time":"2010-11-30T03:23:42Z" |
| 44 | }, |
| 45 | "updated":{ |
| 46 | "time":"2010-11-30T03:23:44Z" |
| 47 | } |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 48 | }, |
Jamie Hannaford | 4d398ff | 2014-11-14 11:03:00 +0100 | [diff] [blame] | 49 | { |
| 50 | "name":"lb-site2", |
| 51 | "id":72, |
| 52 | "created":{ |
| 53 | "time":"2011-11-30T03:23:42Z" |
| 54 | }, |
| 55 | "updated":{ |
| 56 | "time":"2011-11-30T03:23:44Z" |
| 57 | } |
| 58 | }, |
| 59 | { |
| 60 | "name":"lb-site3", |
| 61 | "id":73, |
| 62 | "created":{ |
| 63 | "time":"2012-11-30T03:23:42Z" |
| 64 | }, |
| 65 | "updated":{ |
| 66 | "time":"2012-11-30T03:23:44Z" |
| 67 | } |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 68 | } |
Jamie Hannaford | 4d398ff | 2014-11-14 11:03:00 +0100 | [diff] [blame] | 69 | ] |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 70 | } |
Jamie Hannaford | 4d398ff | 2014-11-14 11:03:00 +0100 | [diff] [blame] | 71 | `) |
Jamie Hannaford | 186d4e2 | 2014-10-31 12:26:11 +0100 | [diff] [blame] | 72 | }) |
| 73 | } |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 74 | |
| 75 | func mockCreateLBResponse(t *testing.T) { |
| 76 | th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) { |
| 77 | th.TestMethod(t, r, "POST") |
| 78 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 79 | |
| 80 | th.TestJSONRequest(t, r, ` |
| 81 | { |
| 82 | "loadBalancer": { |
| 83 | "name": "a-new-loadbalancer", |
| 84 | "port": 80, |
| 85 | "protocol": "HTTP", |
| 86 | "virtualIps": [ |
| 87 | { |
| 88 | "id": 2341 |
| 89 | }, |
| 90 | { |
| 91 | "id": 900001 |
| 92 | } |
| 93 | ], |
| 94 | "nodes": [ |
| 95 | { |
| 96 | "address": "10.1.1.1", |
| 97 | "port": 80, |
| 98 | "condition": "ENABLED" |
| 99 | } |
| 100 | ] |
| 101 | } |
| 102 | } |
| 103 | `) |
| 104 | |
| 105 | w.Header().Add("Content-Type", "application/json") |
Jamie Hannaford | 2592f1f | 2014-11-06 11:10:38 +0100 | [diff] [blame] | 106 | w.WriteHeader(http.StatusAccepted) |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 107 | |
| 108 | fmt.Fprintf(w, ` |
| 109 | { |
| 110 | "loadBalancer": { |
| 111 | "name": "a-new-loadbalancer", |
| 112 | "id": 144, |
| 113 | "protocol": "HTTP", |
| 114 | "halfClosed": false, |
| 115 | "port": 83, |
| 116 | "algorithm": "RANDOM", |
| 117 | "status": "BUILD", |
| 118 | "timeout": 30, |
| 119 | "cluster": { |
| 120 | "name": "ztm-n01.staging1.lbaas.rackspace.net" |
| 121 | }, |
| 122 | "nodes": [ |
| 123 | { |
| 124 | "address": "10.1.1.1", |
| 125 | "id": 653, |
| 126 | "port": 80, |
| 127 | "status": "ONLINE", |
| 128 | "condition": "ENABLED", |
| 129 | "weight": 1 |
| 130 | } |
| 131 | ], |
| 132 | "virtualIps": [ |
| 133 | { |
| 134 | "address": "206.10.10.210", |
| 135 | "id": 39, |
| 136 | "type": "PUBLIC", |
| 137 | "ipVersion": "IPV4" |
| 138 | }, |
| 139 | { |
| 140 | "address": "2001:4801:79f1:0002:711b:be4c:0000:0021", |
| 141 | "id": 900001, |
| 142 | "type": "PUBLIC", |
| 143 | "ipVersion": "IPV6" |
| 144 | } |
| 145 | ], |
| 146 | "created": { |
Jamie Hannaford | 4d398ff | 2014-11-14 11:03:00 +0100 | [diff] [blame] | 147 | "time": "2010-11-30T03:23:42Z" |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 148 | }, |
| 149 | "updated": { |
Jamie Hannaford | 4d398ff | 2014-11-14 11:03:00 +0100 | [diff] [blame] | 150 | "time": "2010-11-30T03:23:44Z" |
Jamie Hannaford | e09b682 | 2014-10-31 15:33:57 +0100 | [diff] [blame] | 151 | }, |
| 152 | "connectionLogging": { |
| 153 | "enabled": false |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | `) |
| 158 | }) |
| 159 | } |
Jamie Hannaford | 1c26033 | 2014-10-31 15:57:22 +0100 | [diff] [blame] | 160 | |
Jamie Hannaford | 5f95e6a | 2014-10-31 16:13:44 +0100 | [diff] [blame] | 161 | func mockBatchDeleteLBResponse(t *testing.T, ids []int) { |
Jamie Hannaford | 1c26033 | 2014-10-31 15:57:22 +0100 | [diff] [blame] | 162 | th.Mux.HandleFunc("/loadbalancers", func(w http.ResponseWriter, r *http.Request) { |
| 163 | th.TestMethod(t, r, "DELETE") |
| 164 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
Jamie Hannaford | 5f95e6a | 2014-10-31 16:13:44 +0100 | [diff] [blame] | 165 | |
| 166 | r.ParseForm() |
| 167 | |
| 168 | for k, v := range ids { |
| 169 | fids := r.Form["id"] |
| 170 | th.AssertEquals(t, strconv.Itoa(v), fids[k]) |
| 171 | } |
| 172 | |
| 173 | w.WriteHeader(http.StatusAccepted) |
| 174 | }) |
| 175 | } |
| 176 | |
| 177 | func mockDeleteLBResponse(t *testing.T, id int) { |
| 178 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) { |
| 179 | th.TestMethod(t, r, "DELETE") |
| 180 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
Jamie Hannaford | 1c26033 | 2014-10-31 15:57:22 +0100 | [diff] [blame] | 181 | w.WriteHeader(http.StatusAccepted) |
| 182 | }) |
| 183 | } |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 184 | |
| 185 | func mockGetLBResponse(t *testing.T, id int) { |
| 186 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) { |
| 187 | th.TestMethod(t, r, "GET") |
| 188 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 189 | |
| 190 | w.Header().Add("Content-Type", "application/json") |
| 191 | w.WriteHeader(http.StatusOK) |
| 192 | |
| 193 | fmt.Fprintf(w, ` |
| 194 | { |
| 195 | "loadBalancer": { |
| 196 | "id": 2000, |
| 197 | "name": "sample-loadbalancer", |
| 198 | "protocol": "HTTP", |
| 199 | "port": 80, |
| 200 | "algorithm": "RANDOM", |
| 201 | "status": "ACTIVE", |
| 202 | "timeout": 30, |
| 203 | "connectionLogging": { |
| 204 | "enabled": true |
| 205 | }, |
| 206 | "virtualIps": [ |
| 207 | { |
| 208 | "id": 1000, |
| 209 | "address": "206.10.10.210", |
| 210 | "type": "PUBLIC", |
| 211 | "ipVersion": "IPV4" |
| 212 | } |
| 213 | ], |
| 214 | "nodes": [ |
| 215 | { |
| 216 | "id": 1041, |
| 217 | "address": "10.1.1.1", |
| 218 | "port": 80, |
| 219 | "condition": "ENABLED", |
| 220 | "status": "ONLINE" |
| 221 | }, |
| 222 | { |
| 223 | "id": 1411, |
| 224 | "address": "10.1.1.2", |
| 225 | "port": 80, |
| 226 | "condition": "ENABLED", |
| 227 | "status": "ONLINE" |
| 228 | } |
| 229 | ], |
| 230 | "sessionPersistence": { |
| 231 | "persistenceType": "HTTP_COOKIE" |
| 232 | }, |
| 233 | "connectionThrottle": { |
Jamie Hannaford | cfe2f28 | 2014-11-07 15:11:21 +0100 | [diff] [blame] | 234 | "maxConnections": 100 |
Jamie Hannaford | 07c0696 | 2014-10-31 16:42:03 +0100 | [diff] [blame] | 235 | }, |
| 236 | "cluster": { |
| 237 | "name": "c1.dfw1" |
| 238 | }, |
| 239 | "created": { |
| 240 | "time": "2010-11-30T03:23:42Z" |
| 241 | }, |
| 242 | "updated": { |
| 243 | "time": "2010-11-30T03:23:44Z" |
| 244 | }, |
| 245 | "sourceAddresses": { |
| 246 | "ipv6Public": "2001:4801:79f1:1::1/64", |
| 247 | "ipv4Servicenet": "10.0.0.0", |
| 248 | "ipv4Public": "10.12.99.28" |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | `) |
| 253 | }) |
| 254 | } |
Jamie Hannaford | 76fcc83 | 2014-10-31 16:56:50 +0100 | [diff] [blame] | 255 | |
| 256 | func mockUpdateLBResponse(t *testing.T, id int) { |
| 257 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id), func(w http.ResponseWriter, r *http.Request) { |
| 258 | th.TestMethod(t, r, "PUT") |
| 259 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 260 | |
| 261 | th.TestJSONRequest(t, r, ` |
| 262 | { |
| 263 | "loadBalancer": { |
| 264 | "name": "a-new-loadbalancer", |
| 265 | "protocol": "TCP", |
| 266 | "halfClosed": true, |
| 267 | "algorithm": "RANDOM", |
| 268 | "port": 8080, |
| 269 | "timeout": 100, |
| 270 | "httpsRedirect": false |
| 271 | } |
| 272 | } |
| 273 | `) |
| 274 | |
Jamie Hannaford | 2592f1f | 2014-11-06 11:10:38 +0100 | [diff] [blame] | 275 | w.WriteHeader(http.StatusAccepted) |
Jamie Hannaford | 76fcc83 | 2014-10-31 16:56:50 +0100 | [diff] [blame] | 276 | }) |
| 277 | } |
Jamie Hannaford | 4ab9aea | 2014-11-04 14:38:06 +0100 | [diff] [blame] | 278 | |
| 279 | func mockListProtocolsResponse(t *testing.T) { |
| 280 | th.Mux.HandleFunc("/loadbalancers/protocols", func(w http.ResponseWriter, r *http.Request) { |
| 281 | th.TestMethod(t, r, "GET") |
| 282 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 283 | |
| 284 | w.Header().Add("Content-Type", "application/json") |
| 285 | w.WriteHeader(http.StatusOK) |
| 286 | |
| 287 | fmt.Fprintf(w, ` |
| 288 | { |
| 289 | "protocols": [ |
| 290 | { |
| 291 | "name": "DNS_TCP", |
| 292 | "port": 53 |
| 293 | }, |
| 294 | { |
| 295 | "name": "DNS_UDP", |
| 296 | "port": 53 |
| 297 | }, |
| 298 | { |
| 299 | "name": "FTP", |
| 300 | "port": 21 |
| 301 | }, |
| 302 | { |
| 303 | "name": "HTTP", |
| 304 | "port": 80 |
| 305 | }, |
| 306 | { |
| 307 | "name": "HTTPS", |
| 308 | "port": 443 |
| 309 | }, |
| 310 | { |
| 311 | "name": "IMAPS", |
| 312 | "port": 993 |
| 313 | }, |
| 314 | { |
| 315 | "name": "IMAPv4", |
| 316 | "port": 143 |
| 317 | }, |
| 318 | { |
| 319 | "name": "LDAP", |
| 320 | "port": 389 |
| 321 | }, |
| 322 | { |
| 323 | "name": "LDAPS", |
| 324 | "port": 636 |
| 325 | }, |
| 326 | { |
| 327 | "name": "MYSQL", |
| 328 | "port": 3306 |
| 329 | }, |
| 330 | { |
| 331 | "name": "POP3", |
| 332 | "port": 110 |
| 333 | }, |
| 334 | { |
| 335 | "name": "POP3S", |
| 336 | "port": 995 |
| 337 | }, |
| 338 | { |
| 339 | "name": "SMTP", |
| 340 | "port": 25 |
| 341 | }, |
| 342 | { |
| 343 | "name": "TCP", |
| 344 | "port": 0 |
| 345 | }, |
| 346 | { |
| 347 | "name": "TCP_CLIENT_FIRST", |
| 348 | "port": 0 |
| 349 | }, |
| 350 | { |
| 351 | "name": "UDP", |
| 352 | "port": 0 |
| 353 | }, |
| 354 | { |
| 355 | "name": "UDP_STREAM", |
| 356 | "port": 0 |
| 357 | }, |
| 358 | { |
| 359 | "name": "SFTP", |
| 360 | "port": 22 |
| 361 | }, |
| 362 | { |
| 363 | "name": "TCP_STREAM", |
| 364 | "port": 0 |
| 365 | } |
| 366 | ] |
| 367 | } |
| 368 | `) |
| 369 | }) |
| 370 | } |
Jamie Hannaford | 4633628 | 2014-11-04 14:48:20 +0100 | [diff] [blame] | 371 | |
| 372 | func mockListAlgorithmsResponse(t *testing.T) { |
| 373 | th.Mux.HandleFunc("/loadbalancers/algorithms", func(w http.ResponseWriter, r *http.Request) { |
| 374 | th.TestMethod(t, r, "GET") |
| 375 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 376 | |
| 377 | w.Header().Add("Content-Type", "application/json") |
| 378 | w.WriteHeader(http.StatusOK) |
| 379 | |
| 380 | fmt.Fprintf(w, ` |
| 381 | { |
| 382 | "algorithms": [ |
| 383 | { |
| 384 | "name": "LEAST_CONNECTIONS" |
| 385 | }, |
| 386 | { |
| 387 | "name": "RANDOM" |
| 388 | }, |
| 389 | { |
| 390 | "name": "ROUND_ROBIN" |
| 391 | }, |
| 392 | { |
| 393 | "name": "WEIGHTED_LEAST_CONNECTIONS" |
| 394 | }, |
| 395 | { |
| 396 | "name": "WEIGHTED_ROUND_ROBIN" |
| 397 | } |
| 398 | ] |
| 399 | } |
| 400 | `) |
| 401 | }) |
| 402 | } |
Jamie Hannaford | d78bb35 | 2014-11-07 16:36:09 +0100 | [diff] [blame] | 403 | |
| 404 | func mockGetLoggingResponse(t *testing.T, id int) { |
| 405 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) { |
| 406 | th.TestMethod(t, r, "GET") |
| 407 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 408 | |
| 409 | w.Header().Add("Content-Type", "application/json") |
| 410 | w.WriteHeader(http.StatusOK) |
| 411 | |
| 412 | fmt.Fprintf(w, ` |
| 413 | { |
| 414 | "connectionLogging": { |
| 415 | "enabled": true |
| 416 | } |
| 417 | } |
| 418 | `) |
| 419 | }) |
| 420 | } |
| 421 | |
| 422 | func mockEnableLoggingResponse(t *testing.T, id int) { |
| 423 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) { |
| 424 | th.TestMethod(t, r, "PUT") |
| 425 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 426 | |
| 427 | th.TestJSONRequest(t, r, ` |
| 428 | { |
| 429 | "connectionLogging":{ |
| 430 | "enabled":true |
| 431 | } |
| 432 | } |
| 433 | `) |
| 434 | |
Jamie Hannaford | a307e04 | 2014-11-10 15:42:07 +0100 | [diff] [blame] | 435 | w.WriteHeader(http.StatusAccepted) |
Jamie Hannaford | d78bb35 | 2014-11-07 16:36:09 +0100 | [diff] [blame] | 436 | }) |
| 437 | } |
| 438 | |
| 439 | func mockDisableLoggingResponse(t *testing.T, id int) { |
| 440 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/connectionlogging", func(w http.ResponseWriter, r *http.Request) { |
| 441 | th.TestMethod(t, r, "PUT") |
| 442 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 443 | |
| 444 | th.TestJSONRequest(t, r, ` |
| 445 | { |
| 446 | "connectionLogging":{ |
| 447 | "enabled":false |
| 448 | } |
| 449 | } |
| 450 | `) |
| 451 | |
Jamie Hannaford | a307e04 | 2014-11-10 15:42:07 +0100 | [diff] [blame] | 452 | w.WriteHeader(http.StatusAccepted) |
Jamie Hannaford | d78bb35 | 2014-11-07 16:36:09 +0100 | [diff] [blame] | 453 | }) |
| 454 | } |
Jamie Hannaford | da45b42 | 2014-11-10 11:00:38 +0100 | [diff] [blame] | 455 | |
| 456 | func mockGetErrorPageResponse(t *testing.T, id int) { |
| 457 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) { |
| 458 | th.TestMethod(t, r, "GET") |
| 459 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 460 | |
| 461 | w.Header().Add("Content-Type", "application/json") |
| 462 | w.WriteHeader(http.StatusOK) |
| 463 | |
| 464 | fmt.Fprintf(w, ` |
| 465 | { |
| 466 | "errorpage": { |
| 467 | "content": "<html>DEFAULT ERROR PAGE</html>" |
| 468 | } |
| 469 | } |
| 470 | `) |
| 471 | }) |
| 472 | } |
| 473 | |
| 474 | func mockSetErrorPageResponse(t *testing.T, id int) { |
| 475 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) { |
| 476 | th.TestMethod(t, r, "PUT") |
| 477 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 478 | |
| 479 | th.TestJSONRequest(t, r, ` |
| 480 | { |
| 481 | "errorpage": { |
| 482 | "content": "<html>New error page</html>" |
| 483 | } |
| 484 | } |
| 485 | `) |
| 486 | |
| 487 | w.WriteHeader(http.StatusOK) |
| 488 | |
| 489 | fmt.Fprintf(w, ` |
| 490 | { |
| 491 | "errorpage": { |
| 492 | "content": "<html>New error page</html>" |
| 493 | } |
| 494 | } |
| 495 | `) |
| 496 | }) |
| 497 | } |
| 498 | |
| 499 | func mockDeleteErrorPageResponse(t *testing.T, id int) { |
| 500 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/errorpage", func(w http.ResponseWriter, r *http.Request) { |
| 501 | th.TestMethod(t, r, "DELETE") |
| 502 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 503 | w.WriteHeader(http.StatusOK) |
| 504 | }) |
| 505 | } |
Jamie Hannaford | 3da6528 | 2014-11-10 11:36:16 +0100 | [diff] [blame] | 506 | |
| 507 | func mockGetStatsResponse(t *testing.T, id int) { |
| 508 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/stats", func(w http.ResponseWriter, r *http.Request) { |
| 509 | th.TestMethod(t, r, "GET") |
| 510 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 511 | |
| 512 | w.Header().Add("Content-Type", "application/json") |
| 513 | w.WriteHeader(http.StatusOK) |
| 514 | |
| 515 | fmt.Fprintf(w, ` |
| 516 | { |
| 517 | "connectTimeOut": 10, |
| 518 | "connectError": 20, |
| 519 | "connectFailure": 30, |
| 520 | "dataTimedOut": 40, |
| 521 | "keepAliveTimedOut": 50, |
| 522 | "maxConn": 60, |
| 523 | "currentConn": 40, |
| 524 | "connectTimeOutSsl": 10, |
| 525 | "connectErrorSsl": 20, |
| 526 | "connectFailureSsl": 30, |
| 527 | "dataTimedOutSsl": 40, |
| 528 | "keepAliveTimedOutSsl": 50, |
| 529 | "maxConnSsl": 60, |
| 530 | "currentConnSsl": 40 |
| 531 | } |
| 532 | `) |
| 533 | }) |
| 534 | } |
Jamie Hannaford | 20b7588 | 2014-11-10 13:39:51 +0100 | [diff] [blame] | 535 | |
| 536 | func mockGetCachingResponse(t *testing.T, id int) { |
| 537 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) { |
| 538 | th.TestMethod(t, r, "GET") |
| 539 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 540 | |
| 541 | w.Header().Add("Content-Type", "application/json") |
| 542 | w.WriteHeader(http.StatusOK) |
| 543 | |
| 544 | fmt.Fprintf(w, ` |
| 545 | { |
| 546 | "contentCaching": { |
| 547 | "enabled": true |
| 548 | } |
| 549 | } |
| 550 | `) |
| 551 | }) |
| 552 | } |
| 553 | |
| 554 | func mockEnableCachingResponse(t *testing.T, id int) { |
| 555 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) { |
| 556 | th.TestMethod(t, r, "PUT") |
| 557 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 558 | |
| 559 | th.TestJSONRequest(t, r, ` |
| 560 | { |
| 561 | "contentCaching":{ |
| 562 | "enabled":true |
| 563 | } |
| 564 | } |
| 565 | `) |
| 566 | |
Jamie Hannaford | a307e04 | 2014-11-10 15:42:07 +0100 | [diff] [blame] | 567 | w.WriteHeader(http.StatusAccepted) |
Jamie Hannaford | 20b7588 | 2014-11-10 13:39:51 +0100 | [diff] [blame] | 568 | }) |
| 569 | } |
| 570 | |
| 571 | func mockDisableCachingResponse(t *testing.T, id int) { |
| 572 | th.Mux.HandleFunc("/loadbalancers/"+strconv.Itoa(id)+"/contentcaching", func(w http.ResponseWriter, r *http.Request) { |
| 573 | th.TestMethod(t, r, "PUT") |
| 574 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 575 | |
| 576 | th.TestJSONRequest(t, r, ` |
| 577 | { |
| 578 | "contentCaching":{ |
| 579 | "enabled":false |
| 580 | } |
| 581 | } |
| 582 | `) |
| 583 | |
Jamie Hannaford | a307e04 | 2014-11-10 15:42:07 +0100 | [diff] [blame] | 584 | w.WriteHeader(http.StatusAccepted) |
Jamie Hannaford | 20b7588 | 2014-11-10 13:39:51 +0100 | [diff] [blame] | 585 | }) |
| 586 | } |