blob: 885fdf659a7f9248692c35a1b3b41af62d6ab3cc [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Jon Perrittfd53bba2014-10-03 00:41:22 -05002
3import (
4 "fmt"
5 "net/http"
6 "testing"
7
Jon Perritt27249f42016-02-18 10:35:59 -06008 th "github.com/gophercloud/gophercloud/testhelper"
9 "github.com/gophercloud/gophercloud/testhelper/client"
Jon Perrittfd53bba2014-10-03 00:41:22 -050010)
11
jrperritt3d966162016-06-06 14:08:54 -050012func MockListResponse(t *testing.T) {
Jon Perrittfd53bba2014-10-03 00:41:22 -050013 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
14 th.TestMethod(t, r, "GET")
Ash Wilsonff899c12014-10-22 09:14:30 -040015 th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
Jon Perrittfd53bba2014-10-03 00:41:22 -050016
17 w.Header().Add("Content-Type", "application/json")
18 w.WriteHeader(http.StatusOK)
19
20 fmt.Fprintf(w, `{
21 "versions": [
22 {
23 "status": "CURRENT",
24 "updated": "2012-01-04T11:33:21Z",
25 "id": "v1.0",
26 "links": [
27 {
28 "href": "http://23.253.228.211:8776/v1/",
29 "rel": "self"
30 }
31 ]
32 },
33 {
34 "status": "CURRENT",
35 "updated": "2012-11-21T11:33:21Z",
36 "id": "v2.0",
37 "links": [
38 {
39 "href": "http://23.253.228.211:8776/v2/",
40 "rel": "self"
41 }
42 ]
43 }
44 ]
45 }`)
46 })
Jon Perrittfd53bba2014-10-03 00:41:22 -050047}
48
jrperritt3d966162016-06-06 14:08:54 -050049func MockGetResponse(t *testing.T) {
Jon Perrittfd53bba2014-10-03 00:41:22 -050050 th.Mux.HandleFunc("/v1/", func(w http.ResponseWriter, r *http.Request) {
51 th.TestMethod(t, r, "GET")
Ash Wilsonff899c12014-10-22 09:14:30 -040052 th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
Jon Perrittfd53bba2014-10-03 00:41:22 -050053
54 w.Header().Add("Content-Type", "application/json")
55 w.WriteHeader(http.StatusOK)
56
57 fmt.Fprintf(w, `{
58 "version": {
59 "status": "CURRENT",
60 "updated": "2012-01-04T11:33:21Z",
61 "media-types": [
62 {
63 "base": "application/xml",
64 "type": "application/vnd.openstack.volume+xml;version=1"
65 },
66 {
67 "base": "application/json",
68 "type": "application/vnd.openstack.volume+json;version=1"
69 }
70 ],
71 "id": "v1.0",
72 "links": [
73 {
74 "href": "http://23.253.228.211:8776/v1/",
75 "rel": "self"
76 },
77 {
78 "href": "http://jorgew.github.com/block-storage-api/content/os-block-storage-1.0.pdf",
79 "type": "application/pdf",
80 "rel": "describedby"
81 },
82 {
83 "href": "http://docs.rackspacecloud.com/servers/api/v1.1/application.wadl",
84 "type": "application/vnd.sun.wadl+xml",
85 "rel": "describedby"
86 }
87 ]
88 }
89 }`)
90 })
Jon Perrittfd53bba2014-10-03 00:41:22 -050091}