github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/sharedfilesystems/v2/shares/testing/fixtures_test.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 th "github.com/vnpaycloud-console/gophercloud/v2/testhelper" 9 fake "github.com/vnpaycloud-console/gophercloud/v2/testhelper/client" 10 ) 11 12 const ( 13 shareEndpoint = "/shares" 14 shareID = "011d21e2-fbc3-4e4a-9993-9ea223f73264" 15 ) 16 17 var createRequest = `{ 18 "share": { 19 "name": "my_test_share", 20 "size": 1, 21 "share_proto": "NFS", 22 "scheduler_hints": { 23 "same_host": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef", 24 "different_host": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef" 25 } 26 } 27 }` 28 29 var createResponse = `{ 30 "share": { 31 "name": "my_test_share", 32 "share_proto": "NFS", 33 "size": 1, 34 "status": null, 35 "share_server_id": null, 36 "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", 37 "share_type": "25747776-08e5-494f-ab40-a64b9d20d8f7", 38 "share_type_name": "default", 39 "availability_zone": null, 40 "created_at": "2015-09-18T10:25:24.533287", 41 "export_location": null, 42 "links": [ 43 { 44 "href": "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264", 45 "rel": "self" 46 }, 47 { 48 "href": "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264", 49 "rel": "bookmark" 50 } 51 ], 52 "share_network_id": null, 53 "export_locations": [], 54 "host": null, 55 "access_rules_status": "active", 56 "has_replicas": false, 57 "replication_type": null, 58 "task_state": null, 59 "snapshot_support": true, 60 "create_share_from_snapshot_support": true, 61 "consistency_group_id": "9397c191-8427-4661-a2e8-b23820dc01d4", 62 "source_cgsnapshot_member_id": null, 63 "volume_type": "default", 64 "snapshot_id": null, 65 "is_public": true, 66 "metadata": { 67 "project": "my_app", 68 "aim": "doc", 69 "__affinity_same_host": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef", 70 "__affinity_different_host": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef" 71 }, 72 "id": "011d21e2-fbc3-4e4a-9993-9ea223f73264", 73 "description": "My custom share London" 74 } 75 }` 76 77 // MockCreateResponse creates a mock response 78 func MockCreateResponse(t *testing.T) { 79 th.Mux.HandleFunc(shareEndpoint, func(w http.ResponseWriter, r *http.Request) { 80 th.TestMethod(t, r, "POST") 81 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 82 th.TestHeader(t, r, "Content-Type", "application/json") 83 th.TestHeader(t, r, "Accept", "application/json") 84 th.TestJSONRequest(t, r, createRequest) 85 w.Header().Add("Content-Type", "application/json") 86 w.WriteHeader(http.StatusOK) 87 fmt.Fprint(w, createResponse) 88 }) 89 } 90 91 // MockDeleteResponse creates a mock delete response 92 func MockDeleteResponse(t *testing.T) { 93 th.Mux.HandleFunc(shareEndpoint+"/"+shareID, func(w http.ResponseWriter, r *http.Request) { 94 th.TestMethod(t, r, "DELETE") 95 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 96 w.WriteHeader(http.StatusAccepted) 97 }) 98 } 99 100 var updateRequest = `{ 101 "share": { 102 "display_name": "my_new_test_share", 103 "display_description": "", 104 "is_public": false 105 } 106 }` 107 108 var updateResponse = ` 109 { 110 "share": { 111 "links": [ 112 { 113 "href": "http://172.18.198.54:8786/v2/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264", 114 "rel": "self" 115 }, 116 { 117 "href": "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264", 118 "rel": "bookmark" 119 } 120 ], 121 "availability_zone": "nova", 122 "share_network_id": "713df749-aac0-4a54-af52-10f6c991e80c", 123 "export_locations": [], 124 "share_server_id": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef", 125 "share_group_id": null, 126 "snapshot_id": null, 127 "id": "011d21e2-fbc3-4e4a-9993-9ea223f73264", 128 "size": 1, 129 "share_type": "25747776-08e5-494f-ab40-a64b9d20d8f7", 130 "share_type_name": "default", 131 "export_location": null, 132 "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", 133 "metadata": { 134 "project": "my_app", 135 "aim": "doc" 136 }, 137 "status": "error", 138 "description": "", 139 "host": "manila2@generic1#GENERIC1", 140 "task_state": null, 141 "is_public": false, 142 "snapshot_support": true, 143 "create_share_from_snapshot_support": true, 144 "name": "my_new_test_share", 145 "created_at": "2015-09-18T10:25:24.000000", 146 "share_proto": "NFS", 147 "volume_type": "default" 148 } 149 } 150 ` 151 152 func MockUpdateResponse(t *testing.T) { 153 th.Mux.HandleFunc(shareEndpoint+"/"+shareID, func(w http.ResponseWriter, r *http.Request) { 154 th.TestMethod(t, r, "PUT") 155 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 156 th.TestHeader(t, r, "Content-Type", "application/json") 157 th.TestHeader(t, r, "Accept", "application/json") 158 th.TestJSONRequest(t, r, updateRequest) 159 w.Header().Add("Content-Type", "application/json") 160 w.WriteHeader(http.StatusOK) 161 fmt.Fprint(w, updateResponse) 162 }) 163 } 164 165 var getResponse = `{ 166 "share": { 167 "links": [ 168 { 169 "href": "http://172.18.198.54:8786/v2/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264", 170 "rel": "self" 171 }, 172 { 173 "href": "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264", 174 "rel": "bookmark" 175 } 176 ], 177 "availability_zone": "nova", 178 "share_network_id": "713df749-aac0-4a54-af52-10f6c991e80c", 179 "share_server_id": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef", 180 "snapshot_id": null, 181 "id": "011d21e2-fbc3-4e4a-9993-9ea223f73264", 182 "size": 1, 183 "share_type": "25747776-08e5-494f-ab40-a64b9d20d8f7", 184 "share_type_name": "default", 185 "consistency_group_id": "9397c191-8427-4661-a2e8-b23820dc01d4", 186 "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", 187 "metadata": { 188 "project": "my_app", 189 "aim": "doc" 190 }, 191 "status": "available", 192 "description": "My custom share London", 193 "host": "manila2@generic1#GENERIC1", 194 "has_replicas": false, 195 "replication_type": null, 196 "task_state": null, 197 "is_public": true, 198 "snapshot_support": true, 199 "create_share_from_snapshot_support": true, 200 "name": "my_test_share", 201 "created_at": "2015-09-18T10:25:24.000000", 202 "share_proto": "NFS", 203 "volume_type": "default", 204 "source_cgsnapshot_member_id": null 205 } 206 }` 207 208 // MockGetResponse creates a mock get response 209 func MockGetResponse(t *testing.T) { 210 th.Mux.HandleFunc(shareEndpoint+"/"+shareID, func(w http.ResponseWriter, r *http.Request) { 211 th.TestMethod(t, r, "GET") 212 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 213 w.WriteHeader(http.StatusOK) 214 fmt.Fprint(w, getResponse) 215 }) 216 } 217 218 var listDetailResponse = `{ 219 "shares": [ 220 { 221 "links": [ 222 { 223 "href": "http://172.18.198.54:8786/v2/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264", 224 "rel": "self" 225 }, 226 { 227 "href": "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/011d21e2-fbc3-4e4a-9993-9ea223f73264", 228 "rel": "bookmark" 229 } 230 ], 231 "availability_zone": "nova", 232 "share_network_id": "713df749-aac0-4a54-af52-10f6c991e80c", 233 "share_server_id": "e268f4aa-d571-43dd-9ab3-f49ad06ffaef", 234 "snapshot_id": null, 235 "id": "011d21e2-fbc3-4e4a-9993-9ea223f73264", 236 "size": 1, 237 "share_type": "25747776-08e5-494f-ab40-a64b9d20d8f7", 238 "share_type_name": "default", 239 "consistency_group_id": "9397c191-8427-4661-a2e8-b23820dc01d4", 240 "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", 241 "metadata": { 242 "project": "my_app", 243 "aim": "doc" 244 }, 245 "status": "available", 246 "description": "My custom share London", 247 "host": "manila2@generic1#GENERIC1", 248 "has_replicas": false, 249 "replication_type": null, 250 "task_state": null, 251 "is_public": true, 252 "snapshot_support": true, 253 "create_share_from_snapshot_support": true, 254 "name": "my_test_share", 255 "created_at": "2015-09-18T10:25:24.000000", 256 "share_proto": "NFS", 257 "volume_type": "default", 258 "source_cgsnapshot_member_id": null 259 } 260 ] 261 }` 262 263 var listDetailEmptyResponse = `{"shares": []}` 264 265 // MockListDetailResponse creates a mock detailed-list response 266 func MockListDetailResponse(t *testing.T) { 267 th.Mux.HandleFunc(shareEndpoint+"/detail", func(w http.ResponseWriter, r *http.Request) { 268 th.TestMethod(t, r, "GET") 269 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 270 271 w.Header().Add("Content-Type", "application/json") 272 w.WriteHeader(http.StatusOK) 273 274 if err := r.ParseForm(); err != nil { 275 t.Errorf("Failed to parse request form %v", err) 276 } 277 marker := r.Form.Get("offset") 278 279 switch marker { 280 case "": 281 fmt.Fprint(w, listDetailResponse) 282 default: 283 fmt.Fprint(w, listDetailEmptyResponse) 284 } 285 }) 286 } 287 288 var listExportLocationsResponse = `{ 289 "export_locations": [ 290 { 291 "path": "127.0.0.1:/var/lib/manila/mnt/share-9a922036-ad26-4d27-b955-7a1e285fa74d", 292 "share_instance_id": "011d21e2-fbc3-4e4a-9993-9ea223f73264", 293 "is_admin_only": false, 294 "id": "80ed63fc-83bc-4afc-b881-da4a345ac83d", 295 "preferred": false 296 } 297 ] 298 }` 299 300 // MockListExportLocationsResponse creates a mock get export locations response 301 func MockListExportLocationsResponse(t *testing.T) { 302 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/export_locations", func(w http.ResponseWriter, r *http.Request) { 303 th.TestMethod(t, r, "GET") 304 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 305 w.Header().Add("Content-Type", "application/json") 306 w.WriteHeader(http.StatusOK) 307 fmt.Fprint(w, listExportLocationsResponse) 308 }) 309 } 310 311 var getExportLocationResponse = `{ 312 "export_location": { 313 "path": "127.0.0.1:/var/lib/manila/mnt/share-9a922036-ad26-4d27-b955-7a1e285fa74d", 314 "share_instance_id": "011d21e2-fbc3-4e4a-9993-9ea223f73264", 315 "is_admin_only": false, 316 "id": "80ed63fc-83bc-4afc-b881-da4a345ac83d", 317 "preferred": false 318 } 319 }` 320 321 // MockGetExportLocationResponse creates a mock get export location response 322 func MockGetExportLocationResponse(t *testing.T) { 323 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/export_locations/80ed63fc-83bc-4afc-b881-da4a345ac83d", func(w http.ResponseWriter, r *http.Request) { 324 th.TestMethod(t, r, "GET") 325 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 326 w.Header().Add("Content-Type", "application/json") 327 w.WriteHeader(http.StatusOK) 328 fmt.Fprint(w, getExportLocationResponse) 329 }) 330 } 331 332 var grantAccessRequest = `{ 333 "allow_access": { 334 "access_type": "ip", 335 "access_to": "0.0.0.0/0", 336 "access_level": "rw" 337 } 338 }` 339 340 var grantAccessResponse = `{ 341 "access": { 342 "share_id": "011d21e2-fbc3-4e4a-9993-9ea223f73264", 343 "access_type": "ip", 344 "access_to": "0.0.0.0/0", 345 "access_key": "", 346 "access_level": "rw", 347 "state": "new", 348 "id": "a2f226a5-cee8-430b-8a03-78a59bd84ee8" 349 } 350 }` 351 352 // MockGrantAccessResponse creates a mock grant access response 353 func MockGrantAccessResponse(t *testing.T) { 354 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 355 th.TestMethod(t, r, "POST") 356 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 357 th.TestHeader(t, r, "Content-Type", "application/json") 358 th.TestHeader(t, r, "Accept", "application/json") 359 th.TestJSONRequest(t, r, grantAccessRequest) 360 w.Header().Add("Content-Type", "application/json") 361 w.WriteHeader(http.StatusOK) 362 fmt.Fprint(w, grantAccessResponse) 363 }) 364 } 365 366 var revokeAccessRequest = `{ 367 "deny_access": { 368 "access_id": "a2f226a5-cee8-430b-8a03-78a59bd84ee8" 369 } 370 }` 371 372 // MockRevokeAccessResponse creates a mock revoke access response 373 func MockRevokeAccessResponse(t *testing.T) { 374 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 375 th.TestMethod(t, r, "POST") 376 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 377 th.TestHeader(t, r, "Content-Type", "application/json") 378 th.TestHeader(t, r, "Accept", "application/json") 379 th.TestJSONRequest(t, r, revokeAccessRequest) 380 w.Header().Add("Content-Type", "application/json") 381 w.WriteHeader(http.StatusAccepted) 382 }) 383 } 384 385 var listAccessRightsRequest = `{ 386 "access_list": null 387 }` 388 389 var listAccessRightsResponse = `{ 390 "access_list": [ 391 { 392 "share_id": "011d21e2-fbc3-4e4a-9993-9ea223f73264", 393 "access_type": "ip", 394 "access_to": "0.0.0.0/0", 395 "access_key": "", 396 "access_level": "rw", 397 "state": "new", 398 "id": "a2f226a5-cee8-430b-8a03-78a59bd84ee8" 399 } 400 ] 401 }` 402 403 // MockListAccessRightsResponse creates a mock list access response 404 func MockListAccessRightsResponse(t *testing.T) { 405 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 406 th.TestMethod(t, r, "POST") 407 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 408 th.TestHeader(t, r, "Content-Type", "application/json") 409 th.TestHeader(t, r, "Accept", "application/json") 410 th.TestJSONRequest(t, r, listAccessRightsRequest) 411 w.Header().Add("Content-Type", "application/json") 412 w.WriteHeader(http.StatusOK) 413 fmt.Fprint(w, listAccessRightsResponse) 414 }) 415 } 416 417 var extendRequest = `{ 418 "extend": { 419 "new_size": 2 420 } 421 }` 422 423 // MockExtendResponse creates a mock extend share response 424 func MockExtendResponse(t *testing.T) { 425 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 426 th.TestMethod(t, r, "POST") 427 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 428 th.TestHeader(t, r, "Content-Type", "application/json") 429 th.TestHeader(t, r, "Accept", "application/json") 430 th.TestJSONRequest(t, r, extendRequest) 431 w.Header().Add("Content-Type", "application/json") 432 w.WriteHeader(http.StatusAccepted) 433 }) 434 } 435 436 var shrinkRequest = `{ 437 "shrink": { 438 "new_size": 1 439 } 440 }` 441 442 // MockShrinkResponse creates a mock shrink share response 443 func MockShrinkResponse(t *testing.T) { 444 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 445 th.TestMethod(t, r, "POST") 446 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 447 th.TestHeader(t, r, "Content-Type", "application/json") 448 th.TestHeader(t, r, "Accept", "application/json") 449 th.TestJSONRequest(t, r, shrinkRequest) 450 w.Header().Add("Content-Type", "application/json") 451 w.WriteHeader(http.StatusAccepted) 452 }) 453 } 454 455 var getMetadataResponse = `{ 456 "metadata": { 457 "foo": "bar" 458 } 459 }` 460 461 // MockGetMetadataResponse creates a mock get metadata response 462 func MockGetMetadataResponse(t *testing.T) { 463 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/metadata", func(w http.ResponseWriter, r *http.Request) { 464 th.TestMethod(t, r, "GET") 465 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 466 th.TestHeader(t, r, "Accept", "application/json") 467 w.Header().Add("Content-Type", "application/json") 468 w.WriteHeader(http.StatusOK) 469 fmt.Fprint(w, getMetadataResponse) 470 }) 471 } 472 473 var getMetadatumResponse = `{ 474 "meta": { 475 "foo": "bar" 476 } 477 }` 478 479 // MockGetMetadatumResponse creates a mock get metadatum response 480 func MockGetMetadatumResponse(t *testing.T, key string) { 481 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/metadata/"+key, func(w http.ResponseWriter, r *http.Request) { 482 th.TestMethod(t, r, "GET") 483 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 484 th.TestHeader(t, r, "Accept", "application/json") 485 w.Header().Add("Content-Type", "application/json") 486 w.WriteHeader(http.StatusOK) 487 fmt.Fprint(w, getMetadatumResponse) 488 }) 489 } 490 491 var setMetadataRequest = `{ 492 "metadata": { 493 "foo": "bar" 494 } 495 }` 496 497 var setMetadataResponse = `{ 498 "metadata": { 499 "foo": "bar" 500 } 501 }` 502 503 // MockSetMetadataResponse creates a mock set metadata response 504 func MockSetMetadataResponse(t *testing.T) { 505 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/metadata", func(w http.ResponseWriter, r *http.Request) { 506 th.TestMethod(t, r, "POST") 507 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 508 th.TestHeader(t, r, "Content-Type", "application/json") 509 th.TestHeader(t, r, "Accept", "application/json") 510 th.TestJSONRequest(t, r, setMetadataRequest) 511 w.Header().Add("Content-Type", "application/json") 512 w.WriteHeader(http.StatusOK) 513 fmt.Fprint(w, setMetadataResponse) 514 }) 515 } 516 517 var updateMetadataRequest = `{ 518 "metadata": { 519 "foo": "bar" 520 } 521 }` 522 523 var updateMetadataResponse = `{ 524 "metadata": { 525 "foo": "bar" 526 } 527 }` 528 529 // MockUpdateMetadataResponse creates a mock update metadata response 530 func MockUpdateMetadataResponse(t *testing.T) { 531 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/metadata", func(w http.ResponseWriter, r *http.Request) { 532 th.TestMethod(t, r, "POST") 533 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 534 th.TestHeader(t, r, "Content-Type", "application/json") 535 th.TestHeader(t, r, "Accept", "application/json") 536 th.TestJSONRequest(t, r, updateMetadataRequest) 537 w.Header().Add("Content-Type", "application/json") 538 w.WriteHeader(http.StatusOK) 539 fmt.Fprint(w, updateMetadataResponse) 540 }) 541 } 542 543 // MockDeleteMetadatumResponse creates a mock unset metadata response 544 func MockDeleteMetadatumResponse(t *testing.T, key string) { 545 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/metadata/"+key, func(w http.ResponseWriter, r *http.Request) { 546 th.TestMethod(t, r, "DELETE") 547 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 548 w.WriteHeader(http.StatusOK) 549 }) 550 } 551 552 var revertRequest = `{ 553 "revert": { 554 "snapshot_id": "ddeac769-9742-497f-b985-5bcfa94a3fd6" 555 } 556 }` 557 558 // MockRevertResponse creates a mock revert share response 559 func MockRevertResponse(t *testing.T) { 560 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 561 th.TestMethod(t, r, "POST") 562 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 563 th.TestHeader(t, r, "Content-Type", "application/json") 564 th.TestHeader(t, r, "Accept", "application/json") 565 th.TestJSONRequest(t, r, revertRequest) 566 w.Header().Add("Content-Type", "application/json") 567 w.WriteHeader(http.StatusAccepted) 568 }) 569 } 570 571 var resetStatusRequest = `{ 572 "reset_status": { 573 "status": "error" 574 } 575 }` 576 577 // MockResetStatusResponse creates a mock reset status share response 578 func MockResetStatusResponse(t *testing.T) { 579 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 580 th.TestMethod(t, r, "POST") 581 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 582 th.TestHeader(t, r, "Content-Type", "application/json") 583 th.TestHeader(t, r, "Accept", "application/json") 584 th.TestJSONRequest(t, r, resetStatusRequest) 585 w.Header().Add("Content-Type", "application/json") 586 w.WriteHeader(http.StatusAccepted) 587 }) 588 } 589 590 var forceDeleteRequest = `{ 591 "force_delete": null 592 }` 593 594 // MockForceDeleteResponse creates a mock force delete share response 595 func MockForceDeleteResponse(t *testing.T) { 596 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 597 th.TestMethod(t, r, "POST") 598 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 599 th.TestHeader(t, r, "Content-Type", "application/json") 600 th.TestHeader(t, r, "Accept", "application/json") 601 th.TestJSONRequest(t, r, forceDeleteRequest) 602 w.Header().Add("Content-Type", "application/json") 603 w.WriteHeader(http.StatusAccepted) 604 }) 605 } 606 607 var unmanageRequest = `{ 608 "unmanage": null 609 }` 610 611 // MockUnmanageResponse creates a mock unmanage share response 612 func MockUnmanageResponse(t *testing.T) { 613 th.Mux.HandleFunc(shareEndpoint+"/"+shareID+"/action", func(w http.ResponseWriter, r *http.Request) { 614 th.TestMethod(t, r, "POST") 615 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 616 th.TestHeader(t, r, "Content-Type", "application/json") 617 th.TestHeader(t, r, "Accept", "application/json") 618 th.TestJSONRequest(t, r, unmanageRequest) 619 w.Header().Add("Content-Type", "application/json") 620 w.WriteHeader(http.StatusAccepted) 621 }) 622 }