aws-sdk-core 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (417) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.simplecov +6 -0
  4. data/.travis.yml +12 -0
  5. data/.yardopts +11 -0
  6. data/Gemfile +26 -0
  7. data/LICENSE.txt +12 -0
  8. data/README.md +169 -0
  9. data/Rakefile +15 -0
  10. data/apis/AutoScaling-2011-01-01.json +1852 -0
  11. data/apis/CloudFormation-2010-05-15.json +981 -0
  12. data/apis/CloudFront-2012-05-05.json +3861 -0
  13. data/apis/CloudFront-2013-05-12.json +4593 -0
  14. data/apis/CloudFront-2013-08-26.json +4849 -0
  15. data/apis/CloudSearch-2011-02-01.json +2080 -0
  16. data/apis/CloudWatch-2010-08-01.json +1206 -0
  17. data/apis/DataPipeline-2012-10-29.json +901 -0
  18. data/apis/DirectConnect-2012-10-25.json +825 -0
  19. data/apis/DynamoDB-2011-12-05.json +2857 -0
  20. data/apis/DynamoDB-2012-08-10.json +3127 -0
  21. data/apis/EC2-2013-06-15.json +13600 -0
  22. data/apis/EC2-2013-10-01.json +14574 -0
  23. data/apis/EMR-2009-03-31.json +957 -0
  24. data/apis/ElastiCache-2012-11-15.json +2921 -0
  25. data/apis/ElastiCache-2013-06-15.json +3586 -0
  26. data/apis/ElasticBeanstalk-2010-12-01.json +2225 -0
  27. data/apis/ElasticLoadBalancing-2012-06-01.json +1215 -0
  28. data/apis/ElasticTranscoder-2012-09-25.json +3692 -0
  29. data/apis/Glacier-2012-06-01.json +1058 -0
  30. data/apis/IAM-2010-05-08.json +2863 -0
  31. data/apis/ImportExport-2010-06-01.json +328 -0
  32. data/apis/OpsWorks-2013-02-18.json +3546 -0
  33. data/apis/RDS-2013-01-10.json +6772 -0
  34. data/apis/RDS-2013-02-12.json +7151 -0
  35. data/apis/RDS-2013-05-15.json +7809 -0
  36. data/apis/Redshift-2012-12-01.json +4180 -0
  37. data/apis/Route53-2012-12-12.json +1018 -0
  38. data/apis/S3-2006-03-01.json +3787 -0
  39. data/apis/SDB-2009-04-15.json +539 -0
  40. data/apis/SES-2010-12-01.json +678 -0
  41. data/apis/SNS-2010-03-31.json +870 -0
  42. data/apis/SQS-2012-11-05.json +798 -0
  43. data/apis/STS-2011-06-15.json +352 -0
  44. data/apis/SWF-2012-01-25.json +5451 -0
  45. data/apis/StorageGateway-2012-06-30.json +1696 -0
  46. data/apis/Support-2013-04-15.json +794 -0
  47. data/apis/configuration/endpoints.json +1337 -0
  48. data/apis/source/autoscaling-2011-01-01.json +3215 -0
  49. data/apis/source/autoscaling-2011-01-01.paginators.json +52 -0
  50. data/apis/source/cloudformation-2010-05-15.json +1260 -0
  51. data/apis/source/cloudformation-2010-05-15.paginators.json +24 -0
  52. data/apis/source/cloudfront-2012-05-05.json +6588 -0
  53. data/apis/source/cloudfront-2012-05-05.paginators.json +28 -0
  54. data/apis/source/cloudfront-2013-05-12.json +7614 -0
  55. data/apis/source/cloudfront-2013-05-12.paginators.json +28 -0
  56. data/apis/source/cloudfront-2013-08-26.json +8016 -0
  57. data/apis/source/cloudfront-2013-08-26.paginators.json +28 -0
  58. data/apis/source/cloudsearch-2011-02-01.json +3585 -0
  59. data/apis/source/cloudsearch-2011-02-01.paginators.json +13 -0
  60. data/apis/source/datapipeline-2012-10-29.json +2144 -0
  61. data/apis/source/datapipeline-2012-10-29.paginators.json +25 -0
  62. data/apis/source/directconnect-2012-10-25.json +1271 -0
  63. data/apis/source/directconnect-2012-10-25.paginators.json +16 -0
  64. data/apis/source/dynamodb-2011-12-05.json +4380 -0
  65. data/apis/source/dynamodb-2011-12-05.paginators.json +24 -0
  66. data/apis/source/dynamodb-2012-08-10.json +4839 -0
  67. data/apis/source/dynamodb-2012-08-10.paginators.json +24 -0
  68. data/apis/source/ec2-2013-02-01.json +18820 -0
  69. data/apis/source/ec2-2013-02-01.paginators.json +115 -0
  70. data/apis/source/ec2-2013-06-15.json +18820 -0
  71. data/apis/source/ec2-2013-06-15.paginators.json +115 -0
  72. data/apis/source/ec2-2013-10-01.json +19885 -0
  73. data/apis/source/ec2-2013-10-01.paginators.json +115 -0
  74. data/apis/source/elasticache-2012-11-15.json +4403 -0
  75. data/apis/source/elasticache-2012-11-15.paginators.json +64 -0
  76. data/apis/source/elasticache-2013-06-15.json +5421 -0
  77. data/apis/source/elasticache-2013-06-15.paginators.json +64 -0
  78. data/apis/source/elasticbeanstalk-2010-12-01.json +3151 -0
  79. data/apis/source/elasticbeanstalk-2010-12-01.paginators.json +25 -0
  80. data/apis/source/elasticloadbalancing-2012-06-01.json +2041 -0
  81. data/apis/source/elasticloadbalancing-2012-06-01.paginators.json +18 -0
  82. data/apis/source/elasticmapreduce-2009-03-31.json +1478 -0
  83. data/apis/source/elasticmapreduce-2009-03-31.paginators.json +7 -0
  84. data/apis/source/elastictranscoder-2012-09-25.json +6148 -0
  85. data/apis/source/elastictranscoder-2012-09-25.paginators.json +20 -0
  86. data/apis/source/email-2010-12-01.json +892 -0
  87. data/apis/source/email-2010-12-01.paginators.json +13 -0
  88. data/apis/source/glacier-2012-06-01.json +3147 -0
  89. data/apis/source/glacier-2012-06-01.paginators.json +28 -0
  90. data/apis/source/iam-2010-05-08.json +5857 -0
  91. data/apis/source/iam-2010-05-08.paginators.json +116 -0
  92. data/apis/source/importexport-2010-06-01.json +876 -0
  93. data/apis/source/importexport-2010-06-01.paginators.json +10 -0
  94. data/apis/source/monitoring-2010-08-01.json +1910 -0
  95. data/apis/source/monitoring-2010-08-01.paginators.json +24 -0
  96. data/apis/source/opsworks-2013-02-18.json +5848 -0
  97. data/apis/source/opsworks-2013-02-18.paginators.json +46 -0
  98. data/apis/source/rds-2013-01-10.json +9283 -0
  99. data/apis/source/rds-2013-01-10.paginators.json +105 -0
  100. data/apis/source/rds-2013-02-12.json +9777 -0
  101. data/apis/source/rds-2013-02-12.paginators.json +105 -0
  102. data/apis/source/rds-2013-05-15.json +10618 -0
  103. data/apis/source/rds-2013-05-15.paginators.json +105 -0
  104. data/apis/source/redshift-2012-12-01.json +5742 -0
  105. data/apis/source/redshift-2012-12-01.paginators.json +74 -0
  106. data/apis/source/route53-2012-12-12.json +2067 -0
  107. data/apis/source/route53-2012-12-12.paginators.json +33 -0
  108. data/apis/source/s3-2006-03-01.json +4261 -0
  109. data/apis/source/s3-2006-03-01.paginators.json +46 -0
  110. data/apis/source/sdb-2009-04-15.json +1145 -0
  111. data/apis/source/sdb-2009-04-15.paginators.json +15 -0
  112. data/apis/source/sns-2010-03-31.json +2234 -0
  113. data/apis/source/sns-2010-03-31.paginators.json +19 -0
  114. data/apis/source/sqs-2012-11-05.json +1162 -0
  115. data/apis/source/sqs-2012-11-05.paginators.json +7 -0
  116. data/apis/source/storagegateway-2012-06-30.json +9487 -0
  117. data/apis/source/storagegateway-2012-06-30.paginators.json +28 -0
  118. data/apis/source/sts-2011-06-15.json +627 -0
  119. data/apis/source/support-2013-04-15.json +1261 -0
  120. data/apis/source/support-2013-04-15.paginators.json +31 -0
  121. data/apis/source/swf-2012-01-25.json +8744 -0
  122. data/apis/source/swf-2012-01-25.paginators.json +46 -0
  123. data/aws-sdk-core.gemspec +21 -0
  124. data/bin/aws.rb +156 -0
  125. data/doc-src/images/lastnode.png +0 -0
  126. data/doc-src/images/node.png +0 -0
  127. data/doc-src/images/vline.png +0 -0
  128. data/doc-src/plugins/apis.rb +205 -0
  129. data/doc-src/templates/default/fulldoc/html/css/common.css +90 -0
  130. data/doc-src/templates/default/fulldoc/html/js/tabs.js +21 -0
  131. data/doc-src/templates/default/fulldoc/html/setup.rb +61 -0
  132. data/doc-src/templates/default/layout/html/footer.erb +29 -0
  133. data/doc-src/templates/default/layout/html/setup.rb +3 -0
  134. data/features/autoscaling/client.feature +22 -0
  135. data/features/autoscaling/setup.rb +6 -0
  136. data/features/cloudformation/client.feature +18 -0
  137. data/features/cloudformation/setup.rb +6 -0
  138. data/features/cloudfront/client.feature +21 -0
  139. data/features/cloudfront/setup.rb +6 -0
  140. data/features/cloudsearch/client.feature +18 -0
  141. data/features/cloudsearch/setup.rb +6 -0
  142. data/features/cloudwatch/client.feature +21 -0
  143. data/features/cloudwatch/setup.rb +6 -0
  144. data/features/common/step_definitions.rb +65 -0
  145. data/features/datapipeline/client.feature +18 -0
  146. data/features/datapipeline/setup.rb +6 -0
  147. data/features/directconnect/client.feature +18 -0
  148. data/features/directconnect/setup.rb +6 -0
  149. data/features/dynamodb/client.feature +21 -0
  150. data/features/dynamodb/setup.rb +8 -0
  151. data/features/dynamodb/simplified.feature +32 -0
  152. data/features/dynamodb/step_definitions.rb +3 -0
  153. data/features/ec2/client.feature +21 -0
  154. data/features/ec2/setup.rb +6 -0
  155. data/features/ec2/step_definitions.rb +19 -0
  156. data/features/elasticache/client.feature +18 -0
  157. data/features/elasticache/setup.rb +6 -0
  158. data/features/elasticbeanstalk/client.feature +18 -0
  159. data/features/elasticbeanstalk/setup.rb +6 -0
  160. data/features/elasticloadbalancing/client.feature +18 -0
  161. data/features/elasticloadbalancing/setup.rb +6 -0
  162. data/features/elastictranscoder/client.feature +18 -0
  163. data/features/elastictranscoder/setup.rb +6 -0
  164. data/features/emr/client.feature +18 -0
  165. data/features/emr/setup.rb +6 -0
  166. data/features/env.rb +23 -0
  167. data/features/glacier/client.feature +28 -0
  168. data/features/glacier/setup.rb +16 -0
  169. data/features/glacier/step_definitions.rb +25 -0
  170. data/features/iam/client.feature +18 -0
  171. data/features/iam/setup.rb +6 -0
  172. data/features/importexport/client.feature +18 -0
  173. data/features/importexport/setup.rb +6 -0
  174. data/features/opsworks/client.feature +18 -0
  175. data/features/opsworks/setup.rb +6 -0
  176. data/features/rds/client.feature +18 -0
  177. data/features/rds/setup.rb +6 -0
  178. data/features/redshift/client.feature +18 -0
  179. data/features/redshift/setup.rb +6 -0
  180. data/features/route53/client.feature +18 -0
  181. data/features/route53/setup.rb +6 -0
  182. data/features/s3/buckets.feature +22 -0
  183. data/features/s3/objects.feature +18 -0
  184. data/features/s3/setup.rb +17 -0
  185. data/features/s3/step_definitions.rb +66 -0
  186. data/features/s3/test.png +0 -0
  187. data/features/sdb/client.feature +18 -0
  188. data/features/sdb/setup.rb +6 -0
  189. data/features/ses/client.feature +18 -0
  190. data/features/ses/setup.rb +6 -0
  191. data/features/sns/client.feature +18 -0
  192. data/features/sns/setup.rb +6 -0
  193. data/features/sqs/client.feature +23 -0
  194. data/features/sqs/setup.rb +10 -0
  195. data/features/sqs/step_definitions.rb +18 -0
  196. data/features/storagegateway/client.feature +18 -0
  197. data/features/storagegateway/setup.rb +6 -0
  198. data/features/sts/client.feature +18 -0
  199. data/features/sts/setup.rb +6 -0
  200. data/features/swf/client.feature +21 -0
  201. data/features/swf/setup.rb +6 -0
  202. data/integration-test-config.json.sample +3 -0
  203. data/lib/aws-sdk-core.rb +11 -0
  204. data/lib/aws.rb +175 -0
  205. data/lib/aws/api/base_translator.rb +72 -0
  206. data/lib/aws/api/doc_example.rb +116 -0
  207. data/lib/aws/api/documentor.rb +140 -0
  208. data/lib/aws/api/operation_translator.rb +77 -0
  209. data/lib/aws/api/service_namer.rb +40 -0
  210. data/lib/aws/api/service_translators/cloud_front.rb +19 -0
  211. data/lib/aws/api/service_translators/dynamo_db.rb +7 -0
  212. data/lib/aws/api/service_translators/glacier.rb +37 -0
  213. data/lib/aws/api/service_translators/import_export.rb +15 -0
  214. data/lib/aws/api/service_translators/route53.rb +23 -0
  215. data/lib/aws/api/service_translators/s3.rb +11 -0
  216. data/lib/aws/api/service_translators/sqs.rb +10 -0
  217. data/lib/aws/api/service_translators/swf.rb +7 -0
  218. data/lib/aws/api/shape_translator.rb +96 -0
  219. data/lib/aws/api/translator.rb +150 -0
  220. data/lib/aws/api/visitor.rb +32 -0
  221. data/lib/aws/credentials.rb +35 -0
  222. data/lib/aws/error_handler.rb +48 -0
  223. data/lib/aws/errors.rb +83 -0
  224. data/lib/aws/json/builder.rb +77 -0
  225. data/lib/aws/json/error_parser.rb +20 -0
  226. data/lib/aws/json/parser.rb +67 -0
  227. data/lib/aws/json/serializer.rb +15 -0
  228. data/lib/aws/plugins/credentials.rb +48 -0
  229. data/lib/aws/plugins/dynamodb_extended_retries.rb +22 -0
  230. data/lib/aws/plugins/glacier_api_version.rb +19 -0
  231. data/lib/aws/plugins/glacier_checksums.rb +100 -0
  232. data/lib/aws/plugins/global_configuration.rb +79 -0
  233. data/lib/aws/plugins/json_protocol.rb +30 -0
  234. data/lib/aws/plugins/json_rpc_headers.rb +34 -0
  235. data/lib/aws/plugins/query_protocol.rb +11 -0
  236. data/lib/aws/plugins/regional_endpoint.rb +37 -0
  237. data/lib/aws/plugins/retry_errors.rb +149 -0
  238. data/lib/aws/plugins/s3_bucket_dns.rb +78 -0
  239. data/lib/aws/plugins/s3_complete_multipart_upload_fix.rb +38 -0
  240. data/lib/aws/plugins/s3_get_bucket_location_fix.rb +21 -0
  241. data/lib/aws/plugins/s3_md5s.rb +61 -0
  242. data/lib/aws/plugins/s3_redirects.rb +38 -0
  243. data/lib/aws/plugins/s3_regional_endpoint.rb +19 -0
  244. data/lib/aws/plugins/s3_signer.rb +9 -0
  245. data/lib/aws/plugins/signature_v2.rb +9 -0
  246. data/lib/aws/plugins/signature_v3.rb +9 -0
  247. data/lib/aws/plugins/signature_v4.rb +29 -0
  248. data/lib/aws/plugins/sqs_queue_urls.rb +33 -0
  249. data/lib/aws/plugins/swf_read_timeouts.rb +23 -0
  250. data/lib/aws/plugins/user_agent.rb +32 -0
  251. data/lib/aws/plugins/xml_protocol.rb +11 -0
  252. data/lib/aws/query/builder.rb +102 -0
  253. data/lib/aws/query/param.rb +43 -0
  254. data/lib/aws/query/param_list.rb +91 -0
  255. data/lib/aws/query/serializer.rb +24 -0
  256. data/lib/aws/request_handler.rb +39 -0
  257. data/lib/aws/response_handler.rb +38 -0
  258. data/lib/aws/service.rb +237 -0
  259. data/lib/aws/signers/base.rb +29 -0
  260. data/lib/aws/signers/handler.rb +18 -0
  261. data/lib/aws/signers/s3.rb +162 -0
  262. data/lib/aws/signers/v2.rb +48 -0
  263. data/lib/aws/signers/v3.rb +34 -0
  264. data/lib/aws/signers/v4.rb +142 -0
  265. data/lib/aws/structure.rb +38 -0
  266. data/lib/aws/timestamp_formatter.rb +16 -0
  267. data/lib/aws/util.rb +38 -0
  268. data/lib/aws/version.rb +3 -0
  269. data/lib/aws/xml/builder.rb +134 -0
  270. data/lib/aws/xml/error_parser.rb +24 -0
  271. data/lib/aws/xml/parser.rb +147 -0
  272. data/lib/aws/xml/serializer.rb +16 -0
  273. data/spec/aws/credentials_spec.rb +39 -0
  274. data/spec/aws/iam_spec.rb +17 -0
  275. data/spec/aws/json/builder_spec.rb +183 -0
  276. data/spec/aws/json/parser_spec.rb +238 -0
  277. data/spec/aws/operations_spec.rb +145 -0
  278. data/spec/aws/plugins/credentials_spec.rb +76 -0
  279. data/spec/aws/plugins/global_configuration_spec.rb +56 -0
  280. data/spec/aws/plugins/region_endpoint_spec.rb +77 -0
  281. data/spec/aws/plugins/retry_errors_spec.rb +253 -0
  282. data/spec/aws/query/builder_spec.rb +361 -0
  283. data/spec/aws/query/param_list_spec.rb +80 -0
  284. data/spec/aws/query/param_spec.rb +59 -0
  285. data/spec/aws/service_spec.rb +247 -0
  286. data/spec/aws/signers/v4_spec.rb +141 -0
  287. data/spec/aws/structure_spec.rb +103 -0
  288. data/spec/aws/xml/builder_spec.rb +404 -0
  289. data/spec/aws/xml/parser_spec.rb +716 -0
  290. data/spec/aws_spec.rb +89 -0
  291. data/spec/fixtures/api/swf.json +100 -0
  292. data/spec/fixtures/operations/cloudfront/list_distributions.yml +195 -0
  293. data/spec/fixtures/operations/cloudfront/max_items.yml +12 -0
  294. data/spec/fixtures/operations/dynamodb/error_parsing.yml +13 -0
  295. data/spec/fixtures/operations/glacier/error_parsing.yml +10 -0
  296. data/spec/fixtures/operations/glacier/list_vaults.yml +24 -0
  297. data/spec/fixtures/operations/iam/result_wrapped_elements.yml +31 -0
  298. data/spec/fixtures/operations/s3/304_response.yml +12 -0
  299. data/spec/fixtures/operations/s3/400_response.yml +12 -0
  300. data/spec/fixtures/operations/s3/403_response.yml +12 -0
  301. data/spec/fixtures/operations/s3/404_response.yml +12 -0
  302. data/spec/fixtures/operations/s3/comlete_multipart_upload_error.yml +18 -0
  303. data/spec/fixtures/operations/s3/create_bucket_with_location_constraint.yml +25 -0
  304. data/spec/fixtures/operations/s3/create_bucket_without_location_constraint.yml +9 -0
  305. data/spec/fixtures/operations/s3/delete_objects.yml +54 -0
  306. data/spec/fixtures/operations/s3/error_parsing.yml +17 -0
  307. data/spec/fixtures/operations/s3/get_bucket_location.yml +17 -0
  308. data/spec/fixtures/operations/s3/get_bucket_location_classic.yml +17 -0
  309. data/spec/fixtures/operations/s3/head_bucket_with_dns_incompatible_name.yml +12 -0
  310. data/spec/fixtures/operations/s3/head_object.yml +50 -0
  311. data/spec/fixtures/operations/s3/list_buckets.yml +41 -0
  312. data/spec/fixtures/operations/s3/md5_checksum_disabled.yml +10 -0
  313. data/spec/fixtures/operations/s3/md5_checksum_enabled.yml +8 -0
  314. data/spec/fixtures/operations/swf/list_domains.yml +20 -0
  315. data/spec/spec_helper.rb +55 -0
  316. data/tasks/apis.rake +51 -0
  317. data/tasks/docs.rake +59 -0
  318. data/tasks/test.rake +39 -0
  319. data/vendor/seahorse/.gitignore +5 -0
  320. data/vendor/seahorse/.simplecov +4 -0
  321. data/vendor/seahorse/.yardopts +10 -0
  322. data/vendor/seahorse/Gemfile +20 -0
  323. data/vendor/seahorse/LICENSE.txt +12 -0
  324. data/vendor/seahorse/README.md +129 -0
  325. data/vendor/seahorse/Rakefile +7 -0
  326. data/vendor/seahorse/ca-bundle.crt +3554 -0
  327. data/vendor/seahorse/lib/seahorse.rb +6 -0
  328. data/vendor/seahorse/lib/seahorse/client.rb +61 -0
  329. data/vendor/seahorse/lib/seahorse/client/base.rb +239 -0
  330. data/vendor/seahorse/lib/seahorse/client/block_io.rb +39 -0
  331. data/vendor/seahorse/lib/seahorse/client/configuration.rb +197 -0
  332. data/vendor/seahorse/lib/seahorse/client/handler.rb +26 -0
  333. data/vendor/seahorse/lib/seahorse/client/handler_builder.rb +49 -0
  334. data/vendor/seahorse/lib/seahorse/client/handler_list.rb +250 -0
  335. data/vendor/seahorse/lib/seahorse/client/http/endpoint.rb +95 -0
  336. data/vendor/seahorse/lib/seahorse/client/http/headers.rb +94 -0
  337. data/vendor/seahorse/lib/seahorse/client/http/plain_string_io.rb +11 -0
  338. data/vendor/seahorse/lib/seahorse/client/http/request.rb +78 -0
  339. data/vendor/seahorse/lib/seahorse/client/http/response.rb +45 -0
  340. data/vendor/seahorse/lib/seahorse/client/logging/formatter.rb +319 -0
  341. data/vendor/seahorse/lib/seahorse/client/logging/handler.rb +35 -0
  342. data/vendor/seahorse/lib/seahorse/client/net_http/connection_pool.rb +339 -0
  343. data/vendor/seahorse/lib/seahorse/client/net_http/handler.rb +109 -0
  344. data/vendor/seahorse/lib/seahorse/client/param_converter.rb +202 -0
  345. data/vendor/seahorse/lib/seahorse/client/param_validator.rb +139 -0
  346. data/vendor/seahorse/lib/seahorse/client/plugin.rb +80 -0
  347. data/vendor/seahorse/lib/seahorse/client/plugin_list.rb +142 -0
  348. data/vendor/seahorse/lib/seahorse/client/plugins/api.rb +11 -0
  349. data/vendor/seahorse/lib/seahorse/client/plugins/content_length.rb +22 -0
  350. data/vendor/seahorse/lib/seahorse/client/plugins/endpoint.rb +36 -0
  351. data/vendor/seahorse/lib/seahorse/client/plugins/json_simple.rb +34 -0
  352. data/vendor/seahorse/lib/seahorse/client/plugins/logging.rb +37 -0
  353. data/vendor/seahorse/lib/seahorse/client/plugins/net_http.rb +26 -0
  354. data/vendor/seahorse/lib/seahorse/client/plugins/operation_methods.rb +48 -0
  355. data/vendor/seahorse/lib/seahorse/client/plugins/param_conversion.rb +29 -0
  356. data/vendor/seahorse/lib/seahorse/client/plugins/param_validation.rb +30 -0
  357. data/vendor/seahorse/lib/seahorse/client/plugins/raise_response_errors.rb +29 -0
  358. data/vendor/seahorse/lib/seahorse/client/plugins/restful_bindings.rb +205 -0
  359. data/vendor/seahorse/lib/seahorse/client/request.rb +62 -0
  360. data/vendor/seahorse/lib/seahorse/client/request_context.rb +68 -0
  361. data/vendor/seahorse/lib/seahorse/client/response.rb +106 -0
  362. data/vendor/seahorse/lib/seahorse/client/xml/builder.rb +92 -0
  363. data/vendor/seahorse/lib/seahorse/model.rb +38 -0
  364. data/vendor/seahorse/lib/seahorse/model/api.rb +39 -0
  365. data/vendor/seahorse/lib/seahorse/model/node.rb +102 -0
  366. data/vendor/seahorse/lib/seahorse/model/operation.rb +32 -0
  367. data/vendor/seahorse/lib/seahorse/model/operation_input.rb +30 -0
  368. data/vendor/seahorse/lib/seahorse/model/operations.rb +59 -0
  369. data/vendor/seahorse/lib/seahorse/model/property.rb +141 -0
  370. data/vendor/seahorse/lib/seahorse/model/shapes/shape.rb +229 -0
  371. data/vendor/seahorse/lib/seahorse/model/types.rb +8 -0
  372. data/vendor/seahorse/lib/seahorse/version.rb +3 -0
  373. data/vendor/seahorse/seahorse.gemspec +20 -0
  374. data/vendor/seahorse/spec/fixtures/plugin.rb +4 -0
  375. data/vendor/seahorse/spec/seahorse/client/base_spec.rb +308 -0
  376. data/vendor/seahorse/spec/seahorse/client/configuration_spec.rb +118 -0
  377. data/vendor/seahorse/spec/seahorse/client/handler_builder_spec.rb +159 -0
  378. data/vendor/seahorse/spec/seahorse/client/handler_list_spec.rb +243 -0
  379. data/vendor/seahorse/spec/seahorse/client/handler_spec.rb +40 -0
  380. data/vendor/seahorse/spec/seahorse/client/http/endpoint_spec.rb +168 -0
  381. data/vendor/seahorse/spec/seahorse/client/http/headers_spec.rb +213 -0
  382. data/vendor/seahorse/spec/seahorse/client/http/plain_string_io_spec.rb +23 -0
  383. data/vendor/seahorse/spec/seahorse/client/http/request_spec.rb +142 -0
  384. data/vendor/seahorse/spec/seahorse/client/http/response_spec.rb +77 -0
  385. data/vendor/seahorse/spec/seahorse/client/logging/formatter_spec.rb +197 -0
  386. data/vendor/seahorse/spec/seahorse/client/logging/handler_spec.rb +63 -0
  387. data/vendor/seahorse/spec/seahorse/client/net_http/connection_pool_spec.rb +10 -0
  388. data/vendor/seahorse/spec/seahorse/client/net_http/handler_spec.rb +232 -0
  389. data/vendor/seahorse/spec/seahorse/client/param_converter_spec.rb +318 -0
  390. data/vendor/seahorse/spec/seahorse/client/param_validator_spec.rb +271 -0
  391. data/vendor/seahorse/spec/seahorse/client/plugin_list_spec.rb +166 -0
  392. data/vendor/seahorse/spec/seahorse/client/plugin_spec.rb +118 -0
  393. data/vendor/seahorse/spec/seahorse/client/plugins/content_length_spec.rb +19 -0
  394. data/vendor/seahorse/spec/seahorse/client/plugins/endpoint_spec.rb +43 -0
  395. data/vendor/seahorse/spec/seahorse/client/plugins/logging_spec.rb +46 -0
  396. data/vendor/seahorse/spec/seahorse/client/plugins/net_http_spec.rb +71 -0
  397. data/vendor/seahorse/spec/seahorse/client/plugins/operation_methods_spec.rb +74 -0
  398. data/vendor/seahorse/spec/seahorse/client/plugins/restful_bindings/uri_path_builder_spec.rb +91 -0
  399. data/vendor/seahorse/spec/seahorse/client/request_context_spec.rb +105 -0
  400. data/vendor/seahorse/spec/seahorse/client/request_spec.rb +102 -0
  401. data/vendor/seahorse/spec/seahorse/client/response_spec.rb +171 -0
  402. data/vendor/seahorse/spec/seahorse/client/xml/builder/xml_doc_spec.rb +142 -0
  403. data/vendor/seahorse/spec/seahorse/client/xml/builder_spec.rb +10 -0
  404. data/vendor/seahorse/spec/seahorse/client_spec.rb +13 -0
  405. data/vendor/seahorse/spec/seahorse/model/api_spec.rb +72 -0
  406. data/vendor/seahorse/spec/seahorse/model/node_spec.rb +114 -0
  407. data/vendor/seahorse/spec/seahorse/model/operation_input_spec.rb +53 -0
  408. data/vendor/seahorse/spec/seahorse/model/operation_spec.rb +48 -0
  409. data/vendor/seahorse/spec/seahorse/model/operations_spec.rb +64 -0
  410. data/vendor/seahorse/spec/seahorse/model/property_spec.rb +136 -0
  411. data/vendor/seahorse/spec/seahorse/model/shapes/shape_spec.rb +105 -0
  412. data/vendor/seahorse/spec/seahorse/version_spec.rb +11 -0
  413. data/vendor/seahorse/spec/spec_helper.rb +34 -0
  414. data/vendor/seahorse/tasks/ca_bundle.rake +23 -0
  415. data/vendor/seahorse/tasks/docs.rake +11 -0
  416. data/vendor/seahorse/tasks/test.rake +26 -0
  417. metadata +614 -0
@@ -0,0 +1,716 @@
1
+ require 'spec_helper'
2
+ require 'time'
3
+
4
+ module Aws
5
+ module Xml
6
+ describe Parser do
7
+
8
+ let(:rules) {{
9
+ 'type' => 'output',
10
+ 'members' => {},
11
+ }}
12
+
13
+ let(:shape) { Seahorse::Model::Shapes::Shape.from_hash(rules) }
14
+
15
+ def parse(xml)
16
+ Parser.new.parse(shape, xml).to_hash
17
+ end
18
+
19
+ it 'returns an empty hash when the XML is empty' do
20
+ expect(parse('<xml/>')).to eq({})
21
+ end
22
+
23
+ it 'ignores xml namespaces on the root element' do
24
+ expect(parse('<xml xmlns="http://xmlns.com"/>')).to eq({})
25
+ end
26
+
27
+ it 'ignores xml elements when the rules are empty' do
28
+ rules['members'] = {}
29
+ expect(parse('<xml><foo>bar</foo></xml>')).to eq({})
30
+ end
31
+
32
+ it 'returns an instance of Struct' do
33
+ expect(Parser.parse(shape, '<xml/>')).to be_kind_of(Aws::Structure)
34
+ end
35
+
36
+ describe 'structures' do
37
+
38
+ it 'parses structure members' do
39
+ rules['members'] = {
40
+ 'first' => { 'type' => 'string' },
41
+ 'last' => { 'type' => 'string' }
42
+ }
43
+ xml = <<-XML
44
+ <xml>
45
+ <first>abc</first>
46
+ <last>xyz</last>
47
+ </xml>
48
+ XML
49
+ expect(parse(xml)).to eq(first: 'abc', last: 'xyz')
50
+ end
51
+
52
+ it 'parses members using their serialized name' do
53
+ rules['members'] = {
54
+ 'first' => { 'type' => 'string', 'serialized_name' => 'FirstName' },
55
+ 'last' => { 'type' => 'string', 'serialized_name' => 'LastName' }
56
+ }
57
+ xml = <<-XML
58
+ <xml>
59
+ <FirstName>John</FirstName>
60
+ <LastName>Doe</LastName>
61
+ </xml>
62
+ XML
63
+ expect(parse(xml)).to eq(first: 'John', last: 'Doe')
64
+ end
65
+
66
+ it 'parses structures of structures' do
67
+ rules['members'] = {
68
+ 'config' => {
69
+ 'type' => 'structure',
70
+ 'members' => {
71
+ 'state' => { 'type' => 'string' }
72
+ }
73
+ },
74
+ 'name' => { 'type' => 'string' }
75
+ }
76
+ xml = <<-XML
77
+ <xml>
78
+ <config>
79
+ <state>on</state>
80
+ </config>
81
+ <name>abc</name>
82
+ </xml>
83
+ XML
84
+ expect(parse(xml)).to eq(config: { state: 'on' }, name: 'abc')
85
+ end
86
+
87
+ end
88
+
89
+ describe 'non-flattened lists' do
90
+
91
+ it 'returns missing lists as []' do
92
+ rules['members'] = {
93
+ 'items' => {
94
+ 'type' => 'list',
95
+ 'members' => { 'type' => 'string' }
96
+ }
97
+ }
98
+ xml = "<xml/>"
99
+ expect(parse(xml)[:items]).to eq([])
100
+ end
101
+
102
+ it 'returns empty list elements as []' do
103
+ rules['members'] = {
104
+ 'items' => {
105
+ 'type' => 'list',
106
+ 'members' => { 'type' => 'string' }
107
+ }
108
+ }
109
+ xml = "<xml><items/></xml>"
110
+ expect(parse(xml)[:items]).to eq([])
111
+ end
112
+
113
+ it 'converts lists of strings into arrays of strings' do
114
+ rules['members'] = {
115
+ 'items' => {
116
+ 'type' => 'list',
117
+ 'members' => { 'type' => 'string' }
118
+ }
119
+ }
120
+ xml = <<-XML
121
+ <xml>
122
+ <items>
123
+ <member>abc</member>
124
+ <member>mno</member>
125
+ <member>xyz</member>
126
+ </items>
127
+ </xml>
128
+ XML
129
+ expect(parse(xml)[:items]).to eq(%w(abc mno xyz))
130
+ end
131
+
132
+ it 'accepts lists of single elements' do
133
+ rules['members'] = {
134
+ 'items' => {
135
+ 'type' => 'list',
136
+ 'members' => {
137
+ 'type' => 'structure',
138
+ 'members' => {
139
+ 'enabled' => { 'type' => 'boolean' }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ xml = <<-XML
145
+ <xml>
146
+ <items>
147
+ <member>
148
+ <enabled>true</enabled>
149
+ </member>
150
+ </items>
151
+ </xml>
152
+ XML
153
+ expect(parse(xml)[:items]).to eq([{ enabled: true }])
154
+ end
155
+
156
+ it 'observes the list member serialization name when present' do
157
+ rules['members'] = {
158
+ 'items' => {
159
+ 'type' => 'list',
160
+ 'members' => { 'type' => 'string', 'serialized_name' => 'item' }
161
+ }
162
+ }
163
+ xml = <<-XML
164
+ <xml>
165
+ <items>
166
+ <item>abc</item>
167
+ <item>mno</item>
168
+ <item>xyz</item>
169
+ </items>
170
+ </xml>
171
+ XML
172
+ expect(parse(xml)[:items]).to eq(%w(abc mno xyz))
173
+ end
174
+
175
+ it 'can parse lists of complex types' do
176
+ rules['members'] = {
177
+ 'items' => {
178
+ 'type' => 'list',
179
+ 'members' => {
180
+ 'type' => 'structure',
181
+ 'serialized_name' => 'item',
182
+ 'members' => { 'name' => { 'type' => 'string' } }
183
+ }
184
+ }
185
+ }
186
+ xml = <<-XML
187
+ <xml>
188
+ <items>
189
+ <item><name>abc</name></item>
190
+ <item><name>mno</name></item>
191
+ <item><name>xyz</name></item>
192
+ </items>
193
+ </xml>
194
+ XML
195
+ expect(parse(xml)[:items]).to eq([
196
+ { name: 'abc' },
197
+ { name: 'mno' },
198
+ { name: 'xyz' }
199
+ ])
200
+ end
201
+
202
+ end
203
+
204
+ describe 'flattened lists' do
205
+
206
+ it 'returns missing lists as []' do
207
+ rules['members'] = {
208
+ 'items' => {
209
+ 'type' => 'flat_list',
210
+ 'members' => { 'type' => 'string' }
211
+ }
212
+ }
213
+ xml = "<xml/>"
214
+ expect(parse(xml)[:items]).to eq([])
215
+ end
216
+
217
+ it 'returns empty list elements as []' do
218
+ rules['members'] = {
219
+ 'items' => {
220
+ 'type' => 'flat_list',
221
+ 'members' => { 'type' => 'string' }
222
+ }
223
+ }
224
+ xml = "<xml><items/></xml>"
225
+ expect(parse(xml)[:items]).to eq([])
226
+ end
227
+
228
+ it 'converts lists of strings into arrays of strings' do
229
+ rules['members'] = {
230
+ 'items' => {
231
+ 'type' => 'flat_list',
232
+ 'members' => { 'type' => 'string' }
233
+ }
234
+ }
235
+ xml = <<-XML
236
+ <xml>
237
+ <items>abc</items>
238
+ <items>mno</items>
239
+ <items>xyz</items>
240
+ </xml>
241
+ XML
242
+ expect(parse(xml)[:items]).to eq(%w(abc mno xyz))
243
+ end
244
+
245
+ it 'accepts lists of a single element' do
246
+ rules['members'] = {
247
+ 'items' => {
248
+ 'type' => 'flat_list',
249
+ 'members' => { 'type' => 'string' }
250
+ }
251
+ }
252
+ xml = <<-XML
253
+ <xml>
254
+ <items>abc</items>
255
+ </xml>
256
+ XML
257
+ expect(parse(xml)[:items]).to eq(['abc'])
258
+ end
259
+
260
+ it 'observes the list serialization name when present' do
261
+ rules['members'] = {
262
+ 'items' => {
263
+ 'type' => 'flat_list',
264
+ 'members' => { 'type' => 'string', 'serialized_name' => 'item' }
265
+ }
266
+ }
267
+ xml = <<-XML
268
+ <xml>
269
+ <item>abc</item>
270
+ <item>mno</item>
271
+ <item>xyz</item>
272
+ </xml>
273
+ XML
274
+ expect(parse(xml)[:items]).to eq(%w(abc mno xyz))
275
+ end
276
+
277
+ it 'can parse lists of complex types' do
278
+ rules['members'] = {
279
+ 'people' => {
280
+ 'type' => 'flat_list',
281
+ 'serialized_name' => 'Person',
282
+ 'members' => {
283
+ 'type' => 'structure',
284
+ 'members' => {
285
+ 'name' => { 'type' => 'string', 'serialized_name' => 'Name' }
286
+ }
287
+ }
288
+ }
289
+ }
290
+ xml = <<-XML
291
+ <xml>
292
+ <Person><Name>abc</Name></Person>
293
+ <Person><Name>mno</Name></Person>
294
+ <Person><Name>xyz</Name></Person>
295
+ </xml>
296
+ XML
297
+ expect(parse(xml)[:people]).to eq([
298
+ { name: 'abc' },
299
+ { name: 'mno' },
300
+ { name: 'xyz' }
301
+ ])
302
+ end
303
+
304
+ end
305
+
306
+ describe 'non-flattened maps' do
307
+
308
+ it 'returns missing maps as {}' do
309
+ rules['members'] = {
310
+ 'attributes' => {
311
+ 'type' => 'map',
312
+ 'keys' => { 'type' => 'string' },
313
+ 'members' => { 'type' => 'string' }
314
+ }
315
+ }
316
+ xml = "<xml/>"
317
+ expect(parse(xml)[:attributes]).to eq({})
318
+ end
319
+
320
+ it 'returns empty maps as {}' do
321
+ rules['members'] = {
322
+ 'attributes' => {
323
+ 'type' => 'map',
324
+ 'keys' => { 'type' => 'string' },
325
+ 'members' => { 'type' => 'string' }
326
+ }
327
+ }
328
+ xml = "<xml><attributes/></xml>"
329
+ expect(parse(xml)[:attributes]).to eq({})
330
+ end
331
+
332
+ it 'expects entry, key and value tags by default' do
333
+ rules['members'] = {
334
+ 'attributes' => {
335
+ 'type' => 'map',
336
+ 'keys' => { 'type' => 'string' },
337
+ 'members' => { 'type' => 'string' }
338
+ }
339
+ }
340
+ xml = <<-XML
341
+ <xml>
342
+ <attributes>
343
+ <entry>
344
+ <key>Color</key>
345
+ <value>red</value>
346
+ </entry>
347
+ <entry>
348
+ <key>Size</key>
349
+ <value>large</value>
350
+ </entry>
351
+ </attributes>
352
+ </xml>
353
+ XML
354
+ expect(parse(xml)[:attributes]).to eq({
355
+ 'Color' => 'red',
356
+ 'Size' => 'large'
357
+ })
358
+ end
359
+
360
+ it 'accepts maps with a single entry' do
361
+ rules['members'] = {
362
+ 'attributes' => {
363
+ 'type' => 'map',
364
+ 'keys' => { 'type' => 'string' },
365
+ 'members' => { 'type' => 'string' }
366
+ }
367
+ }
368
+ xml = <<-XML
369
+ <xml>
370
+ <attributes>
371
+ <entry>
372
+ <key>Color</key>
373
+ <value>red</value>
374
+ </entry>
375
+ </attributes>
376
+ </xml>
377
+ XML
378
+ expect(parse(xml)[:attributes]).to eq('Color' => 'red')
379
+ end
380
+
381
+ it 'accepts alternate key and value names' do
382
+ rules['members'] = {
383
+ 'attributes' => {
384
+ 'type' => 'map',
385
+ 'keys' => { 'type' => 'string', 'serialized_name' => 'attr' },
386
+ 'members' => { 'type' => 'string', 'serialized_name' => 'val' }
387
+ }
388
+ }
389
+ xml = <<-XML
390
+ <xml>
391
+ <attributes>
392
+ <entry>
393
+ <attr>hue</attr>
394
+ <val>red</val>
395
+ </entry>
396
+ <entry>
397
+ <attr>size</attr>
398
+ <val>med</val>
399
+ </entry>
400
+ </attributes>
401
+ </xml>
402
+ XML
403
+ expect(parse(xml)[:attributes]).to eq('hue' => 'red', 'size' => 'med')
404
+ end
405
+
406
+ end
407
+
408
+ describe 'flattened maps' do
409
+
410
+ it 'returns missing maps as {}' do
411
+ rules['members'] = {
412
+ 'attributes' => {
413
+ 'type' => 'flat_map',
414
+ 'keys' => { 'type' => 'string' },
415
+ 'members' => { 'type' => 'string' }
416
+ }
417
+ }
418
+ xml = "<xml/>"
419
+ expect(parse(xml)[:attributes]).to eq({})
420
+ end
421
+
422
+ it 'returns empty maps as {}' do
423
+ rules['members'] = {
424
+ 'attributes' => {
425
+ 'type' => 'flat_map',
426
+ 'keys' => { 'type' => 'string' },
427
+ 'members' => { 'type' => 'string' }
428
+ }
429
+ }
430
+ xml = "<xml><attributes/></xml>"
431
+ expect(parse(xml)[:attributes]).to eq({})
432
+ end
433
+
434
+ it 'expects key and value tags by default' do
435
+ rules['members'] = {
436
+ 'attributes' => {
437
+ 'type' => 'flat_map',
438
+ 'keys' => { 'type' => 'string' },
439
+ 'members' => { 'type' => 'string' }
440
+ }
441
+ }
442
+ xml = <<-XML
443
+ <xml>
444
+ <attributes>
445
+ <key>Color</key>
446
+ <value>red</value>
447
+ </attributes>
448
+ <attributes>
449
+ <key>Size</key>
450
+ <value>large</value>
451
+ </attributes>
452
+ </xml>
453
+ XML
454
+ expect(parse(xml)[:attributes]).to eq({
455
+ 'Color' => 'red',
456
+ 'Size' => 'large'
457
+ })
458
+ end
459
+
460
+ it 'accepts maps with a single entry' do
461
+ rules['members'] = {
462
+ 'attributes' => {
463
+ 'type' => 'flat_map',
464
+ 'keys' => { 'type' => 'string' },
465
+ 'members' => { 'type' => 'string' }
466
+ }
467
+ }
468
+ xml = <<-XML
469
+ <xml>
470
+ <attributes>
471
+ <key>Color</key>
472
+ <value>red</value>
473
+ </attributes>
474
+ </xml>
475
+ XML
476
+ expect(parse(xml)[:attributes]).to eq('Color' => 'red')
477
+ end
478
+
479
+ it 'accepts alternate key and value names' do
480
+ rules['members'] = {
481
+ 'attributes' => {
482
+ 'type' => 'flat_map',
483
+ 'keys' => { 'type' => 'string', 'serialized_name' => 'attr' },
484
+ 'members' => { 'type' => 'string', 'serialized_name' => 'val' }
485
+ }
486
+ }
487
+ xml = <<-XML
488
+ <xml>
489
+ <attributes>
490
+ <attr>hue</attr>
491
+ <val>red</val>
492
+ </attributes>
493
+ <attributes>
494
+ <attr>size</attr>
495
+ <val>med</val>
496
+ </attributes>
497
+ </xml>
498
+ XML
499
+ expect(parse(xml)[:attributes]).to eq('hue' => 'red', 'size' => 'med')
500
+ end
501
+
502
+ end
503
+
504
+ describe 'booleans' do
505
+
506
+ before(:each) do
507
+ rules['members'] = { 'enabled' => { 'type' => 'boolean' } }
508
+ end
509
+
510
+ it 'converts boolean true values' do
511
+ xml = "<xml><enabled>true</enabled></xml>"
512
+ expect(parse(xml)).to eq(enabled: true)
513
+ end
514
+
515
+ it 'converts boolean false values' do
516
+ xml = "<xml><enabled>false</enabled></xml>"
517
+ expect(parse(xml)).to eq(enabled: false)
518
+ end
519
+
520
+ it 'does not apply a boolean true/false value when not present' do
521
+ xml = "<xml/>"
522
+ expect(parse(xml)).to eq({})
523
+ end
524
+
525
+ end
526
+
527
+ describe 'timestamps' do
528
+
529
+ before(:each) do
530
+ rules['members'] = {
531
+ 'created_at' => {
532
+ 'type' => 'timestamp',
533
+ 'serialized_name' => 'CreatedAt',
534
+ }
535
+ }
536
+ end
537
+
538
+ it 'returns an empty element as nil' do
539
+ xml = "<xml><CreatedAt/></xml>"
540
+ expect(parse(xml)[:created_at]).to be(nil)
541
+ end
542
+
543
+ it 'can parse unix timestamps' do
544
+ timestamp = 1349908100
545
+ time = Time.at(timestamp)
546
+ xml = "<xml><CreatedAt>#{timestamp}</CreatedAt></xml>"
547
+ data = parse(xml)
548
+ expect(data[:created_at]).to be_a(Time)
549
+ expect(data[:created_at]).to eq(time)
550
+ end
551
+
552
+ it 'understands basic iso8601 strings' do
553
+ timestamp = '2012-09-10T15:47:10.001Z'
554
+ time = Time.parse(timestamp).to_time.utc
555
+ xml = "<xml><CreatedAt>#{timestamp}</CreatedAt></xml>"
556
+ data = parse(xml)
557
+ expect(data[:created_at]).to be_a(Time)
558
+ expect(data[:created_at]).to eq(time)
559
+ end
560
+
561
+ it 'understands basic rfc822 strings' do
562
+ timestamp = 'Wed, 10 Oct 2012 15:59:55 UTC'
563
+ time = Time.parse(timestamp).to_time.utc
564
+ xml = "<xml><CreatedAt>#{timestamp}</CreatedAt></xml>"
565
+ data = parse(xml)
566
+ expect(data[:created_at]).to be_a(Time)
567
+ expect(data[:created_at]).to eq(time)
568
+ end
569
+
570
+ it 'throws an error when unable to determine the format' do
571
+ timestamp = 'bad-date-format'
572
+ xml = "<xml><CreatedAt>#{timestamp}</CreatedAt></xml>"
573
+ expect {
574
+ parse(xml)
575
+ }.to raise_error("unhandled timestamp format `#{timestamp}'")
576
+ end
577
+
578
+ end
579
+
580
+ describe 'integers' do
581
+
582
+ before(:each) do
583
+ rules['members'] = { 'count' => { 'type' => 'integer' } }
584
+ end
585
+
586
+ it 'parses integer elements' do
587
+ xml = "<xml><count>123</count></xml>"
588
+ expect(parse(xml)[:count]).to eq(123)
589
+ end
590
+
591
+ it 'returns empty elements as nil' do
592
+ xml = "<xml><count/></xml>"
593
+ expect(parse(xml)[:count]).to eq(nil)
594
+ end
595
+
596
+ end
597
+
598
+ describe 'floats' do
599
+
600
+ before(:each) do
601
+ rules['members'] = { 'price' => { 'type' => 'float' } }
602
+ end
603
+
604
+ it 'parses float elements' do
605
+ xml = "<xml><price>12.34</price></xml>"
606
+ expect(parse(xml)[:price]).to eq(12.34)
607
+ end
608
+
609
+ it 'returns empty elements as nil' do
610
+ xml = "<xml><price/></xml>"
611
+ expect(parse(xml)[:price]).to eq(nil)
612
+ end
613
+
614
+ end
615
+
616
+ describe 'strings' do
617
+
618
+ it 'returns nil for empty elements' do
619
+ rules['members'] = {
620
+ 'data' => { 'type' => 'string' }
621
+ }
622
+ xml = "<xml><data/></xml>"
623
+ expect(parse(xml)[:data]).to be(nil)
624
+ end
625
+
626
+ it 'base64 decodes strings when encoding attribute is present' do
627
+ rules['members'] = {
628
+ 'encoded' => { 'type' => 'string' },
629
+ 'not_encoded' => { 'type' => 'string' },
630
+ 'nested' => {
631
+ 'type' => 'structure',
632
+ 'members' => {
633
+ 'encoded' => { 'type' => 'string' }
634
+ }
635
+ }
636
+ }
637
+ xml = <<-XML.strip
638
+ <xml>
639
+ <encoded encoding="base64">#{Base64.encode64('a')}</encoded>
640
+ <not_encoded abc="yxz">mno</not_encoded>
641
+ <nested>
642
+ <encoded encoding="base64">#{Base64.encode64('b')}</encoded>
643
+ </nested>
644
+ </xml>
645
+ XML
646
+ parsed = parse(xml)
647
+ expect(parsed[:encoded]).to eq('a')
648
+ expect(parsed[:nested][:encoded]).to eq('b')
649
+ expect(parsed[:not_encoded]).to eq('mno')
650
+ end
651
+
652
+ end
653
+
654
+ describe 'blobs' do
655
+
656
+ it 'returns nil for empty elements' do
657
+ rules['members'] = {
658
+ 'data' => { 'type' => 'blob' }
659
+ }
660
+ xml = "<xml><data/></xml>"
661
+ expect(parse(xml)[:data]).to be(nil)
662
+ end
663
+
664
+ it 'base64 decodes blob elements' do
665
+ rules['members'] = {
666
+ 'data' => { 'type' => 'blob' }
667
+ }
668
+ xml = "<xml><data>aGVsbG8=</data></xml>"
669
+ expect(parse(xml)).to eq(data: 'hello')
670
+ end
671
+
672
+ end
673
+
674
+ describe 'xml attributes' do
675
+
676
+ it 'omits attributes that are not members' do
677
+ rules['members'] = {
678
+ 'config' => {
679
+ 'type' => 'structure',
680
+ 'members' => {
681
+ 'state' => { 'type' => 'string' }
682
+ }
683
+ }
684
+ }
685
+ xml = "<xml><config foo='bar'><state>on</state></config></xml>"
686
+ expect(parse(xml)).to eq(config: { state: 'on' })
687
+ end
688
+
689
+ it 'merges xml attributes that are members' do
690
+ rules['members'] = {
691
+ 'config' => {
692
+ 'type' => 'structure',
693
+ 'members' => {
694
+ 'state' => { 'type' => 'string' },
695
+ 'foo' => { 'type' => 'string' }
696
+ }
697
+ }
698
+ }
699
+ xml = "<xml><config foo='bar'><state>on</state></config></xml>"
700
+ expect(parse(xml)).to eq(config: { state: 'on', foo: 'bar' })
701
+ end
702
+
703
+ end
704
+
705
+ describe 'parsing errors' do
706
+
707
+ it 'does not trap xml parsing errors' do
708
+ xml = '<xml'
709
+ expect { parse(xml) }.to raise_error
710
+ end
711
+
712
+ end
713
+
714
+ end
715
+ end
716
+ end