Jamie Hannaford | 17d2f87 | 2014-11-24 12:20:33 +0100 | [diff] [blame^] | 1 | package defsecrules |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | |
| 8 | th "github.com/rackspace/gophercloud/testhelper" |
| 9 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 10 | ) |
| 11 | |
| 12 | const rootPath = "/os-security-group-default-rules" |
| 13 | |
| 14 | func mockListRulesResponse(t *testing.T) { |
| 15 | th.Mux.HandleFunc(rootPath, func(w http.ResponseWriter, r *http.Request) { |
| 16 | th.TestMethod(t, r, "GET") |
| 17 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 18 | |
| 19 | w.Header().Add("Content-Type", "application/json") |
| 20 | w.WriteHeader(http.StatusOK) |
| 21 | |
| 22 | fmt.Fprintf(w, ` |
| 23 | { |
| 24 | "security_group_default_rules": [ |
| 25 | { |
| 26 | "from_port": 80, |
| 27 | "id": "f9a97fcf-3a97-47b0-b76f-919136afb7ed", |
| 28 | "ip_protocol": "TCP", |
| 29 | "ip_range": { |
| 30 | "cidr": "10.10.10.0/24" |
| 31 | }, |
| 32 | "to_port": 80 |
| 33 | } |
| 34 | ] |
| 35 | } |
| 36 | `) |
| 37 | }) |
| 38 | } |