github.com/gophercloud/gophercloud@v1.11.0/openstack/sharedfilesystems/v2/shareaccessrules/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 shareAccessRulesEndpoint = "/share-access-rules" 14 shareAccessRuleID = "507bf114-36f2-4f56-8cf4-857985ca87c1" 15 shareID = "fb213952-2352-41b4-ad7b-2c4c69d13eef" 16 ) 17 18 var getResponse = `{ 19 "access": { 20 "access_level": "rw", 21 "state": "error", 22 "id": "507bf114-36f2-4f56-8cf4-857985ca87c1", 23 "share_id": "fb213952-2352-41b4-ad7b-2c4c69d13eef", 24 "access_type": "cert", 25 "access_to": "example.com", 26 "access_key": null, 27 "created_at": "2018-07-17T02:01:04.000000", 28 "updated_at": "2018-07-17T02:01:04.000000", 29 "metadata": { 30 "key1": "value1", 31 "key2": "value2" 32 } 33 } 34 }` 35 36 func MockGetResponse(t *testing.T) { 37 th.Mux.HandleFunc(shareAccessRulesEndpoint+"/"+shareAccessRuleID, func(w http.ResponseWriter, r *http.Request) { 38 th.TestMethod(t, r, "GET") 39 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 40 th.TestHeader(t, r, "Accept", "application/json") 41 w.Header().Add("Content-Type", "application/json") 42 w.WriteHeader(http.StatusOK) 43 fmt.Fprintf(w, getResponse) 44 }) 45 } 46 47 var listResponse = `{ 48 "access_list": [ 49 { 50 "access_level": "rw", 51 "state": "error", 52 "id": "507bf114-36f2-4f56-8cf4-857985ca87c1", 53 "access_type": "cert", 54 "access_to": "example.com", 55 "access_key": null, 56 "created_at": "2018-07-17T02:01:04.000000", 57 "updated_at": "2018-07-17T02:01:04.000000", 58 "metadata": { 59 "key1": "value1", 60 "key2": "value2" 61 } 62 }, 63 { 64 "access_level": "rw", 65 "state": "active", 66 "id": "a25b2df3-90bd-4add-afa6-5f0dbbd50452", 67 "access_type": "ip", 68 "access_to": "0.0.0.0/0", 69 "access_key": null, 70 "created_at": "2018-07-16T01:03:21.000000", 71 "updated_at": "2018-07-16T01:03:21.000000", 72 "metadata": { 73 "key3": "value3", 74 "key4": "value4" 75 } 76 } 77 ] 78 }`