blob: 4429f3bf0de7baa1575c5713060fc90e0b60a91f [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Jon Perritta065da12015-02-06 10:20:16 -07002
3import (
4 "fmt"
5 "net/http"
6 "testing"
7 "time"
8
Jon Perritt27249f42016-02-18 10:35:59 -06009 "github.com/gophercloud/gophercloud"
Krzysztof Szukiełojć24a29ce2017-05-07 14:24:02 +020010 "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/orchestration/v1/stackresources"
11 th "gerrit.mcp.mirantis.net/debian/gophercloud.git/testhelper"
12 fake "gerrit.mcp.mirantis.net/debian/gophercloud.git/testhelper/client"
Jon Perritta065da12015-02-06 10:20:16 -070013)
14
Jon Perrittbba201b2015-02-08 21:12:38 -070015// FindExpected represents the expected object from a Find request.
jrperritt3d966162016-06-06 14:08:54 -050016var FindExpected = []stackresources.Resource{
17 {
Jon Perritta065da12015-02-06 10:20:16 -070018 Name: "hello_world",
19 Links: []gophercloud.Link{
jrperritt3d966162016-06-06 14:08:54 -050020 {
Jon Perritta065da12015-02-06 10:20:16 -070021 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world",
22 Rel: "self",
23 },
jrperritt3d966162016-06-06 14:08:54 -050024 {
Jon Perritta065da12015-02-06 10:20:16 -070025 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b",
26 Rel: "stack",
27 },
28 },
29 LogicalID: "hello_world",
30 StatusReason: "state changed",
jrperritt98d01622017-01-12 14:24:42 -060031 UpdatedTime: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC),
32 CreationTime: time.Date(2015, 2, 5, 21, 33, 10, 0, time.UTC),
Jon Perritta065da12015-02-06 10:20:16 -070033 RequiredBy: []interface{}{},
34 Status: "CREATE_IN_PROGRESS",
35 PhysicalID: "49181cd6-169a-4130-9455-31185bbfc5bf",
36 Type: "OS::Nova::Server",
Pratik Mallya827c03e2015-09-17 00:10:47 -050037 Attributes: map[string]interface{}{"SXSW": "atx"},
38 Description: "Some resource",
Jon Perritta065da12015-02-06 10:20:16 -070039 },
40}
41
Jon Perrittbba201b2015-02-08 21:12:38 -070042// FindOutput represents the response body from a Find request.
Jon Perritta065da12015-02-06 10:20:16 -070043const FindOutput = `
44{
45 "resources": [
46 {
Pratik Mallya827c03e2015-09-17 00:10:47 -050047 "description": "Some resource",
48 "attributes": {"SXSW": "atx"},
Jon Perritta065da12015-02-06 10:20:16 -070049 "resource_name": "hello_world",
50 "links": [
51 {
52 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world",
53 "rel": "self"
54 },
55 {
56 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b",
57 "rel": "stack"
58 }
59 ],
60 "logical_resource_id": "hello_world",
61 "resource_status_reason": "state changed",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -050062 "updated_time": "2015-02-05T21:33:11",
Pratik Mallya827c03e2015-09-17 00:10:47 -050063 "creation_time": "2015-02-05T21:33:10",
Jon Perritta065da12015-02-06 10:20:16 -070064 "required_by": [],
65 "resource_status": "CREATE_IN_PROGRESS",
66 "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf",
67 "resource_type": "OS::Nova::Server"
68 }
69 ]
70}`
71
72// HandleFindSuccessfully creates an HTTP handler at `/stacks/hello_world/resources`
73// on the test handler mux that responds with a `Find` response.
74func HandleFindSuccessfully(t *testing.T, output string) {
75 th.Mux.HandleFunc("/stacks/hello_world/resources", func(w http.ResponseWriter, r *http.Request) {
76 th.TestMethod(t, r, "GET")
77 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
78 th.TestHeader(t, r, "Accept", "application/json")
79
80 w.Header().Set("Content-Type", "application/json")
81 w.WriteHeader(http.StatusOK)
82 fmt.Fprintf(w, output)
83 })
84}
85
Jon Perrittbba201b2015-02-08 21:12:38 -070086// ListExpected represents the expected object from a List request.
jrperritt3d966162016-06-06 14:08:54 -050087var ListExpected = []stackresources.Resource{
88 {
Jon Perritta065da12015-02-06 10:20:16 -070089 Name: "hello_world",
90 Links: []gophercloud.Link{
jrperritt3d966162016-06-06 14:08:54 -050091 {
Jon Perritta065da12015-02-06 10:20:16 -070092 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world",
93 Rel: "self",
94 },
jrperritt3d966162016-06-06 14:08:54 -050095 {
Jon Perritta065da12015-02-06 10:20:16 -070096 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b",
97 Rel: "stack",
98 },
99 },
100 LogicalID: "hello_world",
101 StatusReason: "state changed",
jrperritt98d01622017-01-12 14:24:42 -0600102 UpdatedTime: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC),
103 CreationTime: time.Date(2015, 2, 5, 21, 33, 10, 0, time.UTC),
Jon Perritta065da12015-02-06 10:20:16 -0700104 RequiredBy: []interface{}{},
105 Status: "CREATE_IN_PROGRESS",
106 PhysicalID: "49181cd6-169a-4130-9455-31185bbfc5bf",
107 Type: "OS::Nova::Server",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500108 Attributes: map[string]interface{}{"SXSW": "atx"},
109 Description: "Some resource",
Jon Perritta065da12015-02-06 10:20:16 -0700110 },
111}
112
Jon Perrittbba201b2015-02-08 21:12:38 -0700113// ListOutput represents the response body from a List request.
Jon Perritta065da12015-02-06 10:20:16 -0700114const ListOutput = `{
115 "resources": [
116 {
117 "resource_name": "hello_world",
118 "links": [
119 {
120 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world",
121 "rel": "self"
122 },
123 {
124 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b",
125 "rel": "stack"
126 }
127 ],
128 "logical_resource_id": "hello_world",
129 "resource_status_reason": "state changed",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500130 "updated_time": "2015-02-05T21:33:11",
Jon Perritta065da12015-02-06 10:20:16 -0700131 "required_by": [],
132 "resource_status": "CREATE_IN_PROGRESS",
133 "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500134 "creation_time": "2015-02-05T21:33:10",
135 "resource_type": "OS::Nova::Server",
136 "attributes": {"SXSW": "atx"},
137 "description": "Some resource"
Jon Perritta065da12015-02-06 10:20:16 -0700138 }
139]
140}`
141
142// HandleListSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources`
143// on the test handler mux that responds with a `List` response.
144func HandleListSuccessfully(t *testing.T, output string) {
145 th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources", func(w http.ResponseWriter, r *http.Request) {
146 th.TestMethod(t, r, "GET")
147 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
148 th.TestHeader(t, r, "Accept", "application/json")
149
150 w.Header().Set("Content-Type", "application/json")
151 r.ParseForm()
152 marker := r.Form.Get("marker")
153 switch marker {
154 case "":
155 fmt.Fprintf(w, output)
Jon Perritt64f594d2015-02-08 21:24:33 -0700156 case "49181cd6-169a-4130-9455-31185bbfc5bf":
157 fmt.Fprintf(w, `{"resources":[]}`)
Jon Perritta065da12015-02-06 10:20:16 -0700158 default:
159 t.Fatalf("Unexpected marker: [%s]", marker)
160 }
161 })
162}
163
Jon Perrittbba201b2015-02-08 21:12:38 -0700164// GetExpected represents the expected object from a Get request.
jrperritt3d966162016-06-06 14:08:54 -0500165var GetExpected = &stackresources.Resource{
Jon Perritta065da12015-02-06 10:20:16 -0700166 Name: "wordpress_instance",
167 Links: []gophercloud.Link{
jrperritt3d966162016-06-06 14:08:54 -0500168 {
Jon Perritta065da12015-02-06 10:20:16 -0700169 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance",
170 Rel: "self",
171 },
jrperritt3d966162016-06-06 14:08:54 -0500172 {
Jon Perritta065da12015-02-06 10:20:16 -0700173 Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e",
174 Rel: "stack",
175 },
176 },
177 LogicalID: "wordpress_instance",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500178 Attributes: map[string]interface{}{"SXSW": "atx"},
Jon Perritta065da12015-02-06 10:20:16 -0700179 StatusReason: "state changed",
jrperritt98d01622017-01-12 14:24:42 -0600180 UpdatedTime: time.Date(2014, 12, 10, 18, 34, 35, 0, time.UTC),
Jon Perritta065da12015-02-06 10:20:16 -0700181 RequiredBy: []interface{}{},
182 Status: "CREATE_COMPLETE",
183 PhysicalID: "00e3a2fe-c65d-403c-9483-4db9930dd194",
184 Type: "OS::Nova::Server",
185}
186
Jon Perrittbba201b2015-02-08 21:12:38 -0700187// GetOutput represents the response body from a Get request.
Jon Perritta065da12015-02-06 10:20:16 -0700188const GetOutput = `
189{
190 "resource": {
Pratik Mallya827c03e2015-09-17 00:10:47 -0500191 "description": "Some resource",
192 "attributes": {"SXSW": "atx"},
Jon Perritta065da12015-02-06 10:20:16 -0700193 "resource_name": "wordpress_instance",
194 "description": "",
195 "links": [
196 {
197 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance",
198 "rel": "self"
199 },
200 {
201 "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e",
202 "rel": "stack"
203 }
204 ],
205 "logical_resource_id": "wordpress_instance",
206 "resource_status": "CREATE_COMPLETE",
Pratik Mallyae1b6cbb2015-09-09 14:24:14 -0500207 "updated_time": "2014-12-10T18:34:35",
Jon Perritta065da12015-02-06 10:20:16 -0700208 "required_by": [],
209 "resource_status_reason": "state changed",
210 "physical_resource_id": "00e3a2fe-c65d-403c-9483-4db9930dd194",
211 "resource_type": "OS::Nova::Server"
212 }
213}`
214
215// HandleGetSuccessfully creates an HTTP handler at `/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance`
216// on the test handler mux that responds with a `Get` response.
217func HandleGetSuccessfully(t *testing.T, output string) {
218 th.Mux.HandleFunc("/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance", func(w http.ResponseWriter, r *http.Request) {
219 th.TestMethod(t, r, "GET")
220 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
221 th.TestHeader(t, r, "Accept", "application/json")
222
223 w.Header().Set("Content-Type", "application/json")
224 w.WriteHeader(http.StatusOK)
225 fmt.Fprintf(w, output)
226 })
227}
228
Jon Perrittbba201b2015-02-08 21:12:38 -0700229// MetadataExpected represents the expected object from a Metadata request.
Jon Perritta065da12015-02-06 10:20:16 -0700230var MetadataExpected = map[string]string{
231 "number": "7",
232 "animal": "auk",
233}
234
Jon Perrittbba201b2015-02-08 21:12:38 -0700235// MetadataOutput represents the response body from a Metadata request.
Jon Perritta065da12015-02-06 10:20:16 -0700236const MetadataOutput = `
237{
238 "metadata": {
239 "number": "7",
240 "animal": "auk"
241 }
242}`
243
244// HandleMetadataSuccessfully creates an HTTP handler at `/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance/metadata`
245// on the test handler mux that responds with a `Metadata` response.
246func HandleMetadataSuccessfully(t *testing.T, output string) {
247 th.Mux.HandleFunc("/stacks/teststack/0b1771bd-9336-4f2b-ae86-a80f971faf1e/resources/wordpress_instance/metadata", func(w http.ResponseWriter, r *http.Request) {
248 th.TestMethod(t, r, "GET")
249 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
250 th.TestHeader(t, r, "Accept", "application/json")
251
252 w.Header().Set("Content-Type", "application/json")
253 w.WriteHeader(http.StatusOK)
254 fmt.Fprintf(w, output)
255 })
256}
257
Jon Perrittbba201b2015-02-08 21:12:38 -0700258// ListTypesExpected represents the expected object from a ListTypes request.
jrperritt3d966162016-06-06 14:08:54 -0500259var ListTypesExpected = stackresources.ResourceTypes{
Jon Perritta065da12015-02-06 10:20:16 -0700260 "OS::Nova::Server",
261 "OS::Heat::RandomString",
262 "OS::Swift::Container",
263 "OS::Trove::Instance",
264 "OS::Nova::FloatingIPAssociation",
265 "OS::Cinder::VolumeAttachment",
266 "OS::Nova::FloatingIP",
267 "OS::Nova::KeyPair",
268}
269
Pratik Mallya827c03e2015-09-17 00:10:47 -0500270// same as above, but sorted
jrperritt3d966162016-06-06 14:08:54 -0500271var SortedListTypesExpected = stackresources.ResourceTypes{
Pratik Mallya827c03e2015-09-17 00:10:47 -0500272 "OS::Cinder::VolumeAttachment",
273 "OS::Heat::RandomString",
274 "OS::Nova::FloatingIP",
275 "OS::Nova::FloatingIPAssociation",
276 "OS::Nova::KeyPair",
277 "OS::Nova::Server",
278 "OS::Swift::Container",
279 "OS::Trove::Instance",
280}
281
Jon Perrittbba201b2015-02-08 21:12:38 -0700282// ListTypesOutput represents the response body from a ListTypes request.
Jon Perritta065da12015-02-06 10:20:16 -0700283const ListTypesOutput = `
284{
285 "resource_types": [
286 "OS::Nova::Server",
287 "OS::Heat::RandomString",
288 "OS::Swift::Container",
289 "OS::Trove::Instance",
290 "OS::Nova::FloatingIPAssociation",
291 "OS::Cinder::VolumeAttachment",
292 "OS::Nova::FloatingIP",
293 "OS::Nova::KeyPair"
294 ]
295}`
296
297// HandleListTypesSuccessfully creates an HTTP handler at `/resource_types`
298// on the test handler mux that responds with a `ListTypes` response.
299func HandleListTypesSuccessfully(t *testing.T, output string) {
300 th.Mux.HandleFunc("/resource_types", func(w http.ResponseWriter, r *http.Request) {
301 th.TestMethod(t, r, "GET")
302 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
303 th.TestHeader(t, r, "Accept", "application/json")
304
305 w.Header().Set("Content-Type", "application/json")
306 w.WriteHeader(http.StatusOK)
307 fmt.Fprintf(w, output)
308 })
309}
Jon Perritt1d4aca02015-02-06 12:29:16 -0700310
Jon Perrittbba201b2015-02-08 21:12:38 -0700311// GetSchemaExpected represents the expected object from a Schema request.
jrperritt3d966162016-06-06 14:08:54 -0500312var GetSchemaExpected = &stackresources.TypeSchema{
Jon Perritt1d4aca02015-02-06 12:29:16 -0700313 Attributes: map[string]interface{}{
314 "an_attribute": map[string]interface{}{
315 "description": "An attribute description .",
316 },
317 },
318 Properties: map[string]interface{}{
319 "a_property": map[string]interface{}{
320 "update_allowed": false,
321 "required": true,
322 "type": "string",
323 "description": "A resource description.",
324 },
325 },
326 ResourceType: "OS::Heat::AResourceName",
Pratik Mallya827c03e2015-09-17 00:10:47 -0500327 SupportStatus: map[string]interface{}{
328 "message": "A status message",
329 "status": "SUPPORTED",
330 "version": "2014.1",
331 },
Jon Perritt1d4aca02015-02-06 12:29:16 -0700332}
333
Jon Perrittbba201b2015-02-08 21:12:38 -0700334// GetSchemaOutput represents the response body from a Schema request.
Jon Perritt1d4aca02015-02-06 12:29:16 -0700335const GetSchemaOutput = `
336{
337 "attributes": {
338 "an_attribute": {
339 "description": "An attribute description ."
340 }
341 },
342 "properties": {
343 "a_property": {
344 "update_allowed": false,
345 "required": true,
346 "type": "string",
347 "description": "A resource description."
348 }
349 },
Pratik Mallya827c03e2015-09-17 00:10:47 -0500350 "resource_type": "OS::Heat::AResourceName",
351 "support_status": {
352 "message": "A status message",
353 "status": "SUPPORTED",
354 "version": "2014.1"
355 }
Jon Perritt1d4aca02015-02-06 12:29:16 -0700356}`
357
358// HandleGetSchemaSuccessfully creates an HTTP handler at `/resource_types/OS::Heat::AResourceName`
359// on the test handler mux that responds with a `Schema` response.
360func HandleGetSchemaSuccessfully(t *testing.T, output string) {
361 th.Mux.HandleFunc("/resource_types/OS::Heat::AResourceName", func(w http.ResponseWriter, r *http.Request) {
362 th.TestMethod(t, r, "GET")
363 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
364 th.TestHeader(t, r, "Accept", "application/json")
365
366 w.Header().Set("Content-Type", "application/json")
367 w.WriteHeader(http.StatusOK)
368 fmt.Fprintf(w, output)
369 })
370}
371
Jon Perrittbba201b2015-02-08 21:12:38 -0700372// GetTemplateExpected represents the expected object from a Template request.
Pratik Mallya827c03e2015-09-17 00:10:47 -0500373var 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 -0700374
Jon Perrittbba201b2015-02-08 21:12:38 -0700375// GetTemplateOutput represents the response body from a Template request.
Jon Perritt1d4aca02015-02-06 12:29:16 -0700376const GetTemplateOutput = `
377{
Jon Perrittb1e303a2015-02-06 22:15:44 -0700378 "HeatTemplateFormatVersion": "2012-12-12",
Jon Perritt1d4aca02015-02-06 12:29:16 -0700379 "Outputs": {
Jon Perrittb1e303a2015-02-06 22:15:44 -0700380 "private_key": {
381 "Description": "The private key if it has been saved.",
382 "Value": "{\"Fn::GetAtt\": [\"KeyPair\", \"private_key\"]}"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700383 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700384 "public_key": {
385 "Description": "The public key.",
386 "Value": "{\"Fn::GetAtt\": [\"KeyPair\", \"public_key\"]}"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700387 }
388 },
Jon Perritt1d4aca02015-02-06 12:29:16 -0700389 "Parameters": {
Jon Perritt1d4aca02015-02-06 12:29:16 -0700390 "name": {
Jon Perrittb1e303a2015-02-06 22:15:44 -0700391 "Description": "The name of the key pair.",
392 "Type": "String"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700393 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700394 "public_key": {
395 "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.",
396 "Type": "String"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700397 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700398 "save_private_key": {
Jon Perritt1d4aca02015-02-06 12:29:16 -0700399 "AllowedValues": [
Jon Perrittb1e303a2015-02-06 22:15:44 -0700400 "True",
401 "true",
402 "False",
403 "false"
404 ],
405 "Default": false,
406 "Description": "True if the system should remember a generated private key; False otherwise.",
407 "Type": "String"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700408 }
409 },
410 "Resources": {
Jon Perrittb1e303a2015-02-06 22:15:44 -0700411 "KeyPair": {
Jon Perritt1d4aca02015-02-06 12:29:16 -0700412 "Properties": {
Jon Perritt1d4aca02015-02-06 12:29:16 -0700413 "name": {
414 "Ref": "name"
415 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700416 "public_key": {
417 "Ref": "public_key"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700418 },
Jon Perrittb1e303a2015-02-06 22:15:44 -0700419 "save_private_key": {
420 "Ref": "save_private_key"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700421 }
Jon Perrittb1e303a2015-02-06 22:15:44 -0700422 },
423 "Type": "OS::Nova::KeyPair"
Jon Perritt1d4aca02015-02-06 12:29:16 -0700424 }
425 }
426}`
Jon Perrittb1e303a2015-02-06 22:15:44 -0700427
428// HandleGetTemplateSuccessfully creates an HTTP handler at `/resource_types/OS::Heat::AResourceName/template`
429// on the test handler mux that responds with a `Template` response.
430func HandleGetTemplateSuccessfully(t *testing.T, output string) {
431 th.Mux.HandleFunc("/resource_types/OS::Heat::AResourceName/template", func(w http.ResponseWriter, r *http.Request) {
432 th.TestMethod(t, r, "GET")
433 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
434 th.TestHeader(t, r, "Accept", "application/json")
435
436 w.Header().Set("Content-Type", "application/json")
437 w.WriteHeader(http.StatusOK)
438 fmt.Fprintf(w, output)
439 })
440}