ehdou | b5066cd | 2016-11-10 22:15:42 +0200 | [diff] [blame^] | 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 | func MockCreateResponse(t *testing.T) { |
| 13 | th.Mux.HandleFunc("/security-services", func(w http.ResponseWriter, r *http.Request) { |
| 14 | th.TestMethod(t, r, "POST") |
| 15 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 16 | th.TestHeader(t, r, "Content-Type", "application/json") |
| 17 | th.TestHeader(t, r, "Accept", "application/json") |
| 18 | th.TestJSONRequest(t, r, ` |
| 19 | { |
| 20 | "security_service": { |
| 21 | "description": "Creating my first Security Service", |
| 22 | "dns_ip": "10.0.0.0/24", |
| 23 | "user": "demo", |
| 24 | "password": "***", |
| 25 | "type": "kerberos", |
| 26 | "name": "SecServ1" |
| 27 | } |
| 28 | }`) |
| 29 | |
| 30 | w.Header().Add("Content-Type", "application/json") |
| 31 | w.WriteHeader(http.StatusOK) |
| 32 | |
| 33 | fmt.Fprintf(w, ` |
| 34 | { |
| 35 | "security_service": { |
| 36 | "status": "new", |
| 37 | "domain": null, |
| 38 | "project_id": "16e1ab15c35a457e9c2b2aa189f544e1", |
| 39 | "name": "SecServ1", |
| 40 | "created_at": "2015-09-07T12:19:10.695211", |
| 41 | "updated_at": null, |
| 42 | "server": null, |
| 43 | "dns_ip": "10.0.0.0/24", |
| 44 | "user": "demo", |
| 45 | "password": "supersecret", |
| 46 | "type": "kerberos", |
| 47 | "id": "3c829734-0679-4c17-9637-801da48c0d5f", |
| 48 | "description": "Creating my first Security Service" |
| 49 | } |
| 50 | }`) |
| 51 | }) |
| 52 | } |