blob: 952dc54d130302da9a1d12c3b0ccfd39dcdcf5f5 [file] [log] [blame]
Jon Perritta065da12015-02-06 10:20:16 -07001package stackresources
2
3import (
4 "fmt"
5 "net/http"
6 "testing"
7 "time"
8
9 "github.com/rackspace/gophercloud"
10 th "github.com/rackspace/gophercloud/testhelper"
11 fake "github.com/rackspace/gophercloud/testhelper/client"
12)
13
Jon Perrittbba201b2015-02-08 21:12:38 -070014// FindExpected represents the expected object from a Find request.
Jon Perritta065da12015-02-06 10:20:16 -070015var FindExpected = []Resource{
16 Resource{
17 Name: "hello_world",
18 Links: []gophercloud.Link{
19 gophercloud.Link{
20 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world",
21 Rel: "self",
22 },
23 gophercloud.Link{
24 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b",
25 Rel: "stack",
26 },
27 },
28 LogicalID: "hello_world",
29 StatusReason: "state changed",
30 UpdatedTime: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC),
Pratik Mallya827c03e2015-09-17 00:10:47 -050031 CreationTime: time.Date(2015, 2, 5, 21, 33, 10, 0, time.UTC),
Jon Perritta065da12015-02-06 10:20:16 -070032 RequiredBy: []interface{}{},
33 Status: "CREATE_IN_PROGRESS",
34 PhysicalID: "49181cd6-169a-4130-9455-31185bbfc5bf",
35 Type: "OS::Nova::Server",
Pratik Mallya827c03e2015-09-17 00:10:47 -050036 Attributes: map[string]interface{}{"SXSW": "atx"},
37 Description: "Some resource",
Jon Perritta065da12015-02-06 10:20:16 -070038 },
39}
40
Jon Perrittbba201b2015-02-08 21:12:38 -070041// FindOutput represents the response body from a Find request.
Jon Perritta065da12015-02-06 10:20:16 -070042const FindOutput = `
43{
44 "resources": [
45 {
Pratik Mallya827c03e2015-09-17 00:10:47 -050046 "description": "Some resource",
47 "attributes": {"SXSW": "atx"},
Jon Perritta065da12015-02-06 10:20:16 -070048 "resource_name": "hello_world",
49 "links": [
50 {
51 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world",
52 "rel": "self"
53 },
54 {
55 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b",
56 "rel": "stack"
57 }
58 ],
59 "logical_resource_id": "hello_world",
60 "resource_status_reason": "state changed",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -050061 "updated_time": "2015-02-05T21:33:11",
Pratik Mallya827c03e2015-09-17 00:10:47 -050062 "creation_time": "2015-02-05T21:33:10",
Jon Perritta065da12015-02-06 10:20:16 -070063 "required_by": [],
64 "resource_status": "CREATE_IN_PROGRESS",
65 "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf",
66 "resource_type": "OS::Nova::Server"
67 }
68 ]
69}`
70
71// HandleFindSuccessfully creates an HTTP handler at `/stacks/hello_world/resources`
72// on the test handler mux that responds with a `Find` response.
73func HandleFindSuccessfully(t *testing.T, output string) {
74 th.Mux.HandleFunc("/stacks/hello_world/resources", func(w http.ResponseWriter, r *http.Request) {
75 th.TestMethod(t, r, "GET")
76 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
77 th.TestHeader(t, r, "Accept", "application/json")
78
79 w.Header().Set("Content-Type", "application/json")
80 w.WriteHeader(http.StatusOK)
81 fmt.Fprintf(w, output)
82 })
83}
84
Jon Perrittbba201b2015-02-08 21:12:38 -070085// ListExpected represents the expected object from a List request.
Jon Perritta065da12015-02-06 10:20:16 -070086var ListExpected = []Resource{
87 Resource{
88 Name: "hello_world",
89 Links: []gophercloud.Link{
90 gophercloud.Link{
91 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world",
92 Rel: "self",
93 },
94 gophercloud.Link{
95 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b",
96 Rel: "stack",
97 },
98 },
99 LogicalID: "hello_world",
100 StatusReason: "state changed",
101 UpdatedTime: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC),
Pratik Mallya827c03e2015-09-17 00:10:47 -0500102 CreationTime: time.Date(2015, 2, 5, 21, 33, 10, 0, time.UTC),
Jon Perritta065da12015-02-06 10:20:16 -0700103 RequiredBy: []interface{}{},
104 Status: "CREATE_IN_PROGRESS",
105 PhysicalID: "49181cd6-169a-4130-9455-31185bbfc5bf",
106 Type: "OS::Nova::Server",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500107 Attributes: map[string]interface{}{"SXSW": "atx"},
108 Description: "Some resource",
Jon Perritta065da12015-02-06 10:20:16 -0700109 },
110}
111
Jon Perrittbba201b2015-02-08 21:12:38 -0700112// ListOutput represents the response body from a List request.
Jon Perritta065da12015-02-06 10:20:16 -0700113const ListOutput = `{
114 "resources": [
115 {
116 "resource_name": "hello_world",
117 "links": [
118 {
119 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world",
120 "rel": "self"
121 },
122 {
123 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b",
124 "rel": "stack"
125 }
126 ],
127 "logical_resource_id": "hello_world",
128 "resource_status_reason": "state changed",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500129 "updated_time": "2015-02-05T21:33:11",
Jon Perritta065da12015-02-06 10:20:16 -0700130 "required_by": [],
131 "resource_status": "CREATE_IN_PROGRESS",
132 "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500133 "creation_time": "2015-02-05T21:33:10",
134 "resource_type": "OS::Nova::Server",
135 "attributes": {"SXSW": "atx"},
136 "description": "Some resource"
Jon Perritta065da12015-02-06 10:20:16 -0700137 }
138]
139}`
140
141// HandleListSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources`
142// on the test handler mux that responds with a `List` response.
143func HandleListSuccessfully(t *testing.T, output string) {
144 th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources", func(w http.ResponseWriter, r *http.Request) {
145 th.TestMethod(t, r, "GET")
146 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
147 th.TestHeader(t, r, "Accept", "application/json")
148
149 w.Header().Set("Content-Type", "application/json")
150 r.ParseForm()
151 marker := r.Form.Get("marker")
152 switch marker {
153 case "":
154 fmt.Fprintf(w, output)
Jon Perritt64f594d2015-02-08 21:24:33 -0700155 case "49181cd6-169a-4130-9455-31185bbfc5bf":
156 fmt.Fprintf(w, `{"resources":[]}`)
Jon Perritta065da12015-02-06 10:20:16 -0700157 default:
158 t.Fatalf("Unexpected marker: [%s]", marker)
159 }
160 })
161}
162
Jon Perrittbba201b2015-02-08 21:12:38 -0700163// GetExpected represents the expected object from a Get request.
Jon Perritta065da12015-02-06 10:20:16 -0700164var GetExpected = &Resource{
165 Name: "wordpress_instance",
166 Links: []gophercloud.Link{
167 gophercloud.Link{
168 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance",
169 Rel: "self",
170 },
171 gophercloud.Link{
172 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e",
173 Rel: "stack",
174 },
175 },
176 LogicalID: "wordpress_instance",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500177 Attributes: map[string]interface{}{"SXSW": "atx"},
Jon Perritta065da12015-02-06 10:20:16 -0700178 StatusReason: "state changed",
179 UpdatedTime: time.Date(2014, 12, 10, 18, 34, 35, 0, time.UTC),
180 RequiredBy: []interface{}{},
181 Status: "CREATE_COMPLETE",
182 PhysicalID: "00e3a2fe-c65d-403c-9483-4db9930dd194",
183 Type: "OS::Nova::Server",
184}
185
Jon Perrittbba201b2015-02-08 21:12:38 -0700186// GetOutput represents the response body from a Get request.
Jon Perritta065da12015-02-06 10:20:16 -0700187const GetOutput = `
188{
189 "resource": {
Pratik Mallya827c03e2015-09-17 00:10:47 -0500190 "description": "Some resource",
191 "attributes": {"SXSW": "atx"},
Jon Perritta065da12015-02-06 10:20:16 -0700192 "resource_name": "wordpress_instance",
193 "description": "",
194 "links": [
195 {
196 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance",
197 "rel": "self"
198 },
199 {
200 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e",
201 "rel": "stack"
202 }
203 ],
204 "logical_resource_id": "wordpress_instance",
205 "resource_status": "CREATE_COMPLETE",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500206 "updated_time": "2014-12-10T18:34:35",
Jon Perritta065da12015-02-06 10:20:16 -0700207 "required_by": [],
208 "resource_status_reason": "state changed",
209 "physical_resource_id": "00e3a2fe-c65d-403c-9483-4db9930dd194",
210 "resource_type": "OS::Nova::Server"
211 }
212}`
213
214// HandleGetSuccessfully creates an HTTP handler at `/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance`
215// on the test handler mux that responds with a `Get` response.
216func HandleGetSuccessfully(t *testing.T, output string) {
217 th.Mux.HandleFunc("/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance", func(w http.ResponseWriter, r *http.Request) {
218 th.TestMethod(t, r, "GET")
219 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
220 th.TestHeader(t, r, "Accept", "application/json")
221
222 w.Header().Set("Content-Type", "application/json")
223 w.WriteHeader(http.StatusOK)
224 fmt.Fprintf(w, output)
225 })
226}
227
Jon Perrittbba201b2015-02-08 21:12:38 -0700228// MetadataExpected represents the expected object from a Metadata request.
Jon Perritta065da12015-02-06 10:20:16 -0700229var MetadataExpected = map[string]string{
230 "number": "7",
231 "animal": "auk",
232}
233
Jon Perrittbba201b2015-02-08 21:12:38 -0700234// MetadataOutput represents the response body from a Metadata request.
Jon Perritta065da12015-02-06 10:20:16 -0700235const MetadataOutput = `
236{
237 "metadata": {
238 "number": "7",
239 "animal": "auk"
240 }
241}`
242
243// HandleMetadataSuccessfully creates an HTTP handler at `/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance/metadata`
244// on the test handler mux that responds with a `Metadata` response.
245func HandleMetadataSuccessfully(t *testing.T, output string) {
246 th.Mux.HandleFunc("/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance/metadata", func(w http.ResponseWriter, r *http.Request) {
247 th.TestMethod(t, r, "GET")
248 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
249 th.TestHeader(t, r, "Accept", "application/json")
250
251 w.Header().Set("Content-Type", "application/json")
252 w.WriteHeader(http.StatusOK)
253 fmt.Fprintf(w, output)
254 })
255}
256
Jon Perrittbba201b2015-02-08 21:12:38 -0700257// ListTypesExpected represents the expected object from a ListTypes request.
Pratik Mallya3de347f2015-09-22 12:25:59 -0500258var ListTypesExpected = ResourceTypes{
Jon Perritta065da12015-02-06 10:20:16 -0700259 "OS::Nova::Server",
260 "OS::Heat::RandomString",
261 "OS::Swift::Container",
262 "OS::Trove::Instance",
263 "OS::Nova::FloatingIPAssociation",
264 "OS::Cinder::VolumeAttachment",
265 "OS::Nova::FloatingIP",
266 "OS::Nova::KeyPair",
267}
268
Pratik Mallya827c03e2015-09-17 00:10:47 -0500269// same as above, but sorted
Pratik Mallya3de347f2015-09-22 12:25:59 -0500270var SortedListTypesExpected = ResourceTypes{
Pratik Mallya827c03e2015-09-17 00:10:47 -0500271 "OS::Cinder::VolumeAttachment",
272 "OS::Heat::RandomString",
273 "OS::Nova::FloatingIP",
274 "OS::Nova::FloatingIPAssociation",
275 "OS::Nova::KeyPair",
276 "OS::Nova::Server",
277 "OS::Swift::Container",
278 "OS::Trove::Instance",
279}
280
Jon Perrittbba201b2015-02-08 21:12:38 -0700281// ListTypesOutput represents the response body from a ListTypes request.
Jon Perritta065da12015-02-06 10:20:16 -0700282const ListTypesOutput = `
283{
284 "resource_types": [
285 "OS::Nova::Server",
286 "OS::Heat::RandomString",
287 "OS::Swift::Container",
288 "OS::Trove::Instance",
289 "OS::Nova::FloatingIPAssociation",
290 "OS::Cinder::VolumeAttachment",
291 "OS::Nova::FloatingIP",
292 "OS::Nova::KeyPair"
293 ]
294}`
295
296// HandleListTypesSuccessfully creates an HTTP handler at `/resource_types`
297// on the test handler mux that responds with a `ListTypes` response.
298func HandleListTypesSuccessfully(t *testing.T, output string) {
299 th.Mux.HandleFunc("/resource_types", func(w http.ResponseWriter, r *http.Request) {
300 th.TestMethod(t, r, "GET")
301 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
302 th.TestHeader(t, r, "Accept", "application/json")
303
304 w.Header().Set("Content-Type", "application/json")
305 w.WriteHeader(http.StatusOK)
306 fmt.Fprintf(w, output)
307 })
308}
Jon Perritt1d4aca02015-02-06 12:29:16 -0700309
Jon Perrittbba201b2015-02-08 21:12:38 -0700310// GetSchemaExpected represents the expected object from a Schema request.
Jon Perritt1d4aca02015-02-06 12:29:16 -0700311var GetSchemaExpected = &TypeSchema{
312 Attributes: map[string]interface{}{
313 "an_attribute": map[string]interface{}{
314 "description": "An attribute description .",
315 },
316 },
317 Properties: map[string]interface{}{
318 "a_property": map[string]interface{}{
319 "update_allowed": false,
320 "required": true,
321 "type": "string",
322 "description": "A resource description.",
323 },
324 },
325 ResourceType: "OS::Heat::AResourceName",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500326 SupportStatus: map[string]interface{}{
327 "message": "A status message",
328 "status": "SUPPORTED",
329 "version": "2014.1",
330 },
Jon Perritt1d4aca02015-02-06 12:29:16 -0700331}
332
Jon Perrittbba201b2015-02-08 21:12:38 -0700333// GetSchemaOutput represents the response body from a Schema request.
Jon Perritt1d4aca02015-02-06 12:29:16 -0700334const GetSchemaOutput = `
335{
336 "attributes": {
337 "an_attribute": {
338 "description": "An attribute description ."
339 }
340 },
341 "properties": {
342 "a_property": {
343 "update_allowed": false,
344 "required": true,
345 "type": "string",
346 "description": "A resource description."
347 }
348 },
Pratik Mallya827c03e2015-09-17 00:10:47 -0500349 "resource_type": "OS::Heat::AResourceName",
350 "support_status": {
351 "message": "A status message",
352 "status": "SUPPORTED",
353 "version": "2014.1"
354 }
Jon Perritt1d4aca02015-02-06 12:29:16 -0700355}`
356
357// HandleGetSchemaSuccessfully creates an HTTP handler at `/resource_types/OS::Heat::AResourceName`
358// on the test handler mux that responds with a `Schema` response.
359func HandleGetSchemaSuccessfully(t *testing.T, output string) {
360 th.Mux.HandleFunc("/resource_types/OS::Heat::AResourceName", func(w http.ResponseWriter, r *http.Request) {
361 th.TestMethod(t, r, "GET")
362 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
363 th.TestHeader(t, r, "Accept", "application/json")
364
365 w.Header().Set("Content-Type", "application/json")
366 w.WriteHeader(http.StatusOK)
367 fmt.Fprintf(w, output)
368 })
369}
370
Jon Perrittbba201b2015-02-08 21:12:38 -0700371// GetTemplateExpected represents the expected object from a Template request.
Pratik Mallya827c03e2015-09-17 00:10:47 -0500372var GetTemplateExpected = "{\n \"HeatTemplateFormatVersion\": \"2012-12-12\",\n \"Outputs\": {\n \"private_key\": {\n \"Description\": \"The private key if it has been saved.\",\n \"Value\": \"{\\\"Fn::GetAtt\\\": [\\\"KeyPair\\\", \\\"private_key\\\"]}\"\n },\n \"public_key\": {\n \"Description\": \"The public key.\",\n \"Value\": \"{\\\"Fn::GetAtt\\\": [\\\"KeyPair\\\", \\\"public_key\\\"]}\"\n }\n },\n \"Parameters\": {\n \"name\": {\n \"Description\": \"The name of the key pair.\",\n \"Type\": \"String\"\n },\n \"public_key\": {\n \"Description\": \"The optional public key. This allows users to supply the public key from a pre-existing key pair. If not supplied, a new key pair will be generated.\",\n \"Type\": \"String\"\n },\n \"save_private_key\": {\n \"AllowedValues\": [\n \"True\",\n \"true\",\n \"False\",\n \"false\"\n ],\n \"Default\": false,\n \"Description\": \"True if the system should remember a generated private key; False otherwise.\",\n \"Type\": \"String\"\n }\n },\n \"Resources\": {\n \"KeyPair\": {\n \"Properties\": {\n \"name\": {\n \"Ref\": \"name\"\n },\n \"public_key\": {\n \"Ref\": \"public_key\"\n },\n \"save_private_key\": {\n \"Ref\": \"save_private_key\"\n }\n },\n \"Type\": \"OS::Nova::KeyPair\"\n }\n }\n}"
Jon Perrittb1e303a2015-02-06 22:15:44 -0700373
Jon Perrittbba201b2015-02-08 21:12:38 -0700374// GetTemplateOutput represents the response body from a Template request.
Jon Perritt1d4aca02015-02-06 12:29:16 -0700375const GetTemplateOutput = `
376{
Jon Perrittb1e303a2015-02-06 22:15:44 -0700377 "HeatTemplateFormatVersion": "2012-12-12",
Jon Perritt1d4aca02015-02-06 12:29:16 -0700378 "Outputs": {
Jon Perrittb1e303a2015-02-06 22:15:44 -0700379 "private_key": {
380 "Description": "The private key if it has been saved.",
381 "Value": "{\"Fn::GetAtt\": [\"KeyPair\", \"private_key\"]}"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700382 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700383 "public_key": {
384 "Description": "The public key.",
385 "Value": "{\"Fn::GetAtt\": [\"KeyPair\", \"public_key\"]}"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700386 }
387 },
Jon Perritt1d4aca02015-02-06 12:29:16 -0700388 "Parameters": {
Jon Perritt1d4aca02015-02-06 12:29:16 -0700389 "name": {
Jon Perrittb1e303a2015-02-06 22:15:44 -0700390 "Description": "The name of the key pair.",
391 "Type": "String"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700392 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700393 "public_key": {
394 "Description": "The optional public key. This allows users to supply the public key from a pre-existing key pair. If not supplied, a new key pair will be generated.",
395 "Type": "String"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700396 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700397 "save_private_key": {
Jon Perritt1d4aca02015-02-06 12:29:16 -0700398 "AllowedValues": [
Jon Perrittb1e303a2015-02-06 22:15:44 -0700399 "True",
400 "true",
401 "False",
402 "false"
403 ],
404 "Default": false,
405 "Description": "True if the system should remember a generated private key; False otherwise.",
406 "Type": "String"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700407 }
408 },
409 "Resources": {
Jon Perrittb1e303a2015-02-06 22:15:44 -0700410 "KeyPair": {
Jon Perritt1d4aca02015-02-06 12:29:16 -0700411 "Properties": {
Jon Perritt1d4aca02015-02-06 12:29:16 -0700412 "name": {
413 "Ref": "name"
414 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700415 "public_key": {
416 "Ref": "public_key"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700417 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700418 "save_private_key": {
419 "Ref": "save_private_key"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700420 }
Jon Perrittb1e303a2015-02-06 22:15:44 -0700421 },
422 "Type": "OS::Nova::KeyPair"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700423 }
424 }
425}`
Jon Perrittb1e303a2015-02-06 22:15:44 -0700426
427// HandleGetTemplateSuccessfully creates an HTTP handler at `/resource_types/OS::Heat::AResourceName/template`
428// on the test handler mux that responds with a `Template` response.
429func HandleGetTemplateSuccessfully(t *testing.T, output string) {
430 th.Mux.HandleFunc("/resource_types/OS::Heat::AResourceName/template", func(w http.ResponseWriter, r *http.Request) {
431 th.TestMethod(t, r, "GET")
432 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
433 th.TestHeader(t, r, "Accept", "application/json")
434
435 w.Header().Set("Content-Type", "application/json")
436 w.WriteHeader(http.StatusOK)
437 fmt.Fprintf(w, output)
438 })
439}