github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/rds/v3/securities/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 "github.com/huaweicloud/golangsdk" 9 "github.com/huaweicloud/golangsdk/openstack/rds/v3/securities" 10 th "github.com/huaweicloud/golangsdk/testhelper" 11 "github.com/huaweicloud/golangsdk/testhelper/client" 12 ) 13 14 const ( 15 expectedEnableSSLResponse = `{}` 16 17 expectedUpdateResponse = ` 18 { 19 "workflowId": "e982d9d7-d96f-4d25-a591-b6be03c93081" 20 } 21 ` 22 ) 23 24 var ( 25 sslOpts = securities.SSLOpts{ 26 SSLEnable: golangsdk.Enabled, 27 } 28 29 portOpts = securities.PortOpts{ 30 Port: 3309, 31 } 32 33 secGroupOpts = securities.SecGroupOpts{ 34 SecurityGroupId: "71aa11f4-7d6f-479c-b1b4-123f31412e21", 35 } 36 37 expectedGetResponseData = &securities.WorkFlow{ 38 WorkflowId: "e982d9d7-d96f-4d25-a591-b6be03c93081", 39 } 40 ) 41 42 func handleV2DatabaseSSLUpdate(t *testing.T) { 43 th.Mux.HandleFunc("/instances/fda30974248d449e9dbdce8ae65d5ba0in01/ssl", 44 func(w http.ResponseWriter, r *http.Request) { 45 th.TestMethod(t, r, "PUT") 46 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 47 w.Header().Add("Content-Type", "application/json") 48 w.WriteHeader(http.StatusOK) 49 _, _ = fmt.Fprint(w, expectedUpdateResponse) 50 }) 51 } 52 53 func handleV2DatabasePortUpdate(t *testing.T) { 54 th.Mux.HandleFunc("/instances/fda30974248d449e9dbdce8ae65d5ba0in01/port", 55 func(w http.ResponseWriter, r *http.Request) { 56 th.TestMethod(t, r, "PUT") 57 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 58 w.Header().Add("Content-Type", "application/json") 59 w.WriteHeader(http.StatusOK) 60 _, _ = fmt.Fprint(w, expectedUpdateResponse) 61 }) 62 } 63 64 func handleV2SecurityGroupUpdate(t *testing.T) { 65 th.Mux.HandleFunc("/instances/fda30974248d449e9dbdce8ae65d5ba0in01/security-group", 66 func(w http.ResponseWriter, r *http.Request) { 67 th.TestMethod(t, r, "PUT") 68 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 69 w.Header().Add("Content-Type", "application/json") 70 w.WriteHeader(http.StatusOK) 71 _, _ = fmt.Fprint(w, expectedUpdateResponse) 72 }) 73 }