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