vagrant-unbundled 1.8.4.2 → 1.8.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (281) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +52 -0
  4. data/Gemfile.lock +9 -7
  5. data/RELEASE.md +37 -14
  6. data/lib/vagrant/action/builtin/box_add.rb +3 -1
  7. data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +5 -0
  8. data/lib/vagrant/box_collection.rb +2 -1
  9. data/lib/vagrant/bundler.rb +36 -1
  10. data/lib/vagrant/errors.rb +16 -8
  11. data/lib/vagrant/plugin/state_file.rb +8 -1
  12. data/lib/vagrant/util/platform.rb +1 -1
  13. data/plugins/guests/arch/cap/change_host_name.rb +13 -10
  14. data/plugins/guests/arch/cap/configure_networks.rb +11 -8
  15. data/plugins/guests/arch/cap/nfs.rb +35 -0
  16. data/plugins/guests/arch/cap/rsync.rb +16 -0
  17. data/plugins/guests/arch/cap/smb.rb +17 -0
  18. data/plugins/guests/arch/plugin.rb +28 -3
  19. data/plugins/guests/atomic/cap/change_host_name.rb +13 -10
  20. data/plugins/guests/atomic/plugin.rb +3 -3
  21. data/plugins/guests/{netbsd → bsd}/cap/halt.rb +2 -2
  22. data/plugins/guests/bsd/cap/nfs.rb +49 -0
  23. data/plugins/guests/bsd/cap/public_key.rb +65 -0
  24. data/plugins/guests/bsd/cap/virtualbox.rb +16 -0
  25. data/plugins/guests/bsd/guest.rb +9 -0
  26. data/plugins/guests/bsd/plugin.rb +40 -0
  27. data/plugins/guests/coreos/cap/change_host_name.rb +1 -1
  28. data/plugins/guests/coreos/plugin.rb +4 -4
  29. data/plugins/guests/darwin/cap/change_host_name.rb +4 -1
  30. data/plugins/guests/darwin/cap/configure_networks.rb +12 -5
  31. data/plugins/guests/darwin/cap/halt.rb +3 -1
  32. data/plugins/guests/darwin/cap/rsync.rb +7 -4
  33. data/plugins/guests/darwin/plugin.rb +13 -28
  34. data/plugins/guests/debian/cap/change_host_name.rb +14 -15
  35. data/plugins/guests/debian/cap/configure_networks.rb +2 -6
  36. data/plugins/guests/debian/cap/{nfs_client.rb → nfs.rb} +2 -1
  37. data/plugins/guests/debian/cap/rsync.rb +5 -6
  38. data/plugins/guests/debian/plugin.rb +8 -8
  39. data/plugins/guests/esxi/cap/mount_nfs_folder.rb +2 -2
  40. data/plugins/guests/esxi/plugin.rb +6 -6
  41. data/plugins/guests/fedora/cap/flavor.rb +1 -1
  42. data/plugins/guests/fedora/plugin.rb +2 -17
  43. data/plugins/guests/freebsd/cap/change_host_name.rb +2 -3
  44. data/plugins/guests/freebsd/cap/rsync.rb +7 -4
  45. data/plugins/guests/freebsd/plugin.rb +9 -29
  46. data/plugins/guests/funtoo/plugin.rb +3 -8
  47. data/plugins/guests/gentoo/cap/change_host_name.rb +21 -6
  48. data/plugins/guests/gentoo/cap/configure_networks.rb +35 -26
  49. data/plugins/guests/gentoo/plugin.rb +4 -4
  50. data/plugins/guests/linux/cap/choose_addressable_ip_addr.rb +2 -3
  51. data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +31 -45
  52. data/plugins/guests/linux/cap/network_interfaces.rb +20 -0
  53. data/plugins/guests/linux/cap/nfs.rb +57 -0
  54. data/plugins/guests/linux/cap/public_key.rb +65 -0
  55. data/plugins/guests/linux/cap/rsync.rb +7 -4
  56. data/plugins/guests/linux/plugin.rb +30 -25
  57. data/plugins/guests/mint/plugin.rb +1 -1
  58. data/plugins/guests/netbsd/plugin.rb +10 -30
  59. data/plugins/guests/nixos/plugin.rb +5 -5
  60. data/plugins/guests/omnios/cap/change_host_name.rb +1 -1
  61. data/plugins/guests/omnios/plugin.rb +4 -4
  62. data/plugins/guests/openbsd/cap/change_host_name.rb +21 -3
  63. data/plugins/guests/openbsd/plugin.rb +10 -30
  64. data/plugins/guests/photon/cap/change_host_name.rb +1 -1
  65. data/plugins/guests/photon/plugin.rb +4 -4
  66. data/plugins/guests/pld/cap/change_host_name.rb +1 -1
  67. data/plugins/guests/pld/plugin.rb +4 -4
  68. data/plugins/guests/redhat/cap/change_host_name.rb +4 -3
  69. data/plugins/guests/redhat/cap/configure_networks.rb +1 -24
  70. data/plugins/guests/redhat/plugin.rb +7 -7
  71. data/plugins/guests/slackware/cap/change_host_name.rb +1 -1
  72. data/plugins/guests/slackware/cap/configure_networks.rb +1 -5
  73. data/plugins/guests/slackware/plugin.rb +3 -3
  74. data/plugins/guests/smartos/plugin.rb +12 -12
  75. data/plugins/guests/solaris/plugin.rb +14 -14
  76. data/plugins/guests/solaris11/plugin.rb +12 -12
  77. data/plugins/guests/suse/cap/change_host_name.rb +1 -1
  78. data/plugins/guests/suse/cap/configure_networks.rb +1 -5
  79. data/plugins/guests/suse/plugin.rb +8 -8
  80. data/plugins/guests/tinycore/cap/mount_nfs.rb +2 -2
  81. data/plugins/guests/tinycore/plugin.rb +7 -7
  82. data/plugins/guests/trisquel/plugin.rb +1 -1
  83. data/plugins/guests/ubuntu/guest.rb +1 -1
  84. data/plugins/guests/ubuntu/plugin.rb +1 -6
  85. data/plugins/guests/windows/plugin.rb +2 -2
  86. data/plugins/kernel_v2/config/vm.rb +8 -1
  87. data/plugins/providers/hyperv/scripts/get_vm_status.ps1 +25 -5
  88. data/plugins/providers/virtualbox/driver/meta.rb +1 -0
  89. data/plugins/providers/virtualbox/driver/version_5_1.rb +734 -0
  90. data/plugins/providers/virtualbox/plugin.rb +1 -0
  91. data/plugins/synced_folders/nfs/synced_folder.rb +10 -2
  92. data/plugins/synced_folders/rsync/helper.rb +11 -4
  93. data/scripts/{bintray_upload.sh → sign.sh} +0 -0
  94. data/templates/guests/arch/network_static.erb +3 -3
  95. data/templates/guests/arch/network_static6.erb +8 -0
  96. data/templates/guests/freebsd/network_static6.erb +6 -0
  97. data/templates/guests/funtoo/network_static6.erb +9 -0
  98. data/templates/guests/gentoo/network_dhcp.erb +1 -1
  99. data/templates/guests/gentoo/network_static.erb +4 -4
  100. data/templates/guests/gentoo/network_static6.erb +7 -0
  101. data/templates/guests/redhat/network_dhcp.erb +1 -1
  102. data/templates/guests/redhat/network_static.erb +4 -1
  103. data/templates/guests/{fedora → redhat}/network_static6.erb +5 -2
  104. data/templates/locales/en.yml +40 -6
  105. data/test/unit/plugins/guests/arch/cap/change_host_name_test.rb +6 -6
  106. data/test/unit/plugins/guests/arch/cap/configure_networks_test.rb +20 -15
  107. data/test/unit/plugins/guests/arch/cap/rsync_test.rb +30 -0
  108. data/test/unit/plugins/guests/arch/cap/smb_test.rb +38 -0
  109. data/test/unit/plugins/guests/atomic/cap/change_host_name_test.rb +9 -8
  110. data/test/unit/plugins/guests/{freebsd → bsd}/cap/halt_test.rb +11 -10
  111. data/test/unit/plugins/guests/{freebsd → bsd}/cap/insert_public_key_test.rb +7 -6
  112. data/test/unit/plugins/guests/bsd/cap/nfs_test.rb +68 -0
  113. data/test/unit/plugins/guests/coreos/cap/change_host_name_test.rb +5 -5
  114. data/test/unit/plugins/guests/darwin/cap/change_host_name_test.rb +5 -5
  115. data/test/unit/plugins/guests/darwin/cap/halt_test.rb +36 -0
  116. data/test/unit/plugins/guests/debian/cap/change_host_name_test.rb +3 -5
  117. data/test/unit/plugins/guests/debian/cap/configure_networks_test.rb +13 -9
  118. data/test/unit/plugins/guests/debian/cap/rsync_test.rb +3 -11
  119. data/test/unit/plugins/guests/freebsd/cap/change_host_name_test.rb +2 -2
  120. data/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb +16 -3
  121. data/test/unit/plugins/guests/omnios/cap/change_host_name_test.rb +2 -2
  122. data/test/unit/plugins/guests/photon/cap/change_host_name_test.rb +2 -2
  123. data/test/unit/plugins/guests/pld/cap/change_host_name_test.rb +2 -2
  124. data/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb +4 -3
  125. data/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb +17 -33
  126. data/test/unit/plugins/guests/slackware/cap/change_host_name_test.rb +2 -2
  127. data/test/unit/plugins/guests/slackware/cap/configure_networks_test.rb +8 -4
  128. data/test/unit/plugins/guests/suse/cap/change_host_name_test.rb +2 -2
  129. data/test/unit/plugins/guests/suse/cap/configure_networks_test.rb +13 -16
  130. data/test/unit/plugins/kernel_v2/config/vm_test.rb +10 -2
  131. data/test/unit/templates/guests/arch/network_static_test.rb +4 -2
  132. data/test/unit/templates/guests/gentoo/network_dhcp_test.rb +2 -2
  133. data/test/unit/templates/guests/gentoo/network_static_test.rb +10 -10
  134. data/test/unit/templates/guests/redhat/network_dhcp_test.rb +2 -2
  135. data/test/unit/templates/guests/redhat/network_static_test.rb +9 -9
  136. data/vagrant.gemspec +3 -3
  137. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/CHANGELOG.md +1 -0
  138. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/CONTRIBUTING.md +38 -0
  139. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/LICENSE.txt +22 -0
  140. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/README.md +297 -0
  141. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/bin/listen +12 -0
  142. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/base.rb +141 -0
  143. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/bsd.rb +106 -0
  144. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/config.rb +26 -0
  145. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/darwin.rb +92 -0
  146. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/linux.rb +106 -0
  147. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/polling.rb +37 -0
  148. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/windows.rb +98 -0
  149. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter.rb +45 -0
  150. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/backend.rb +38 -0
  151. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/change.rb +76 -0
  152. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/cli.rb +65 -0
  153. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/directory.rb +87 -0
  154. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/config.rb +55 -0
  155. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/loop.rb +117 -0
  156. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/processor.rb +122 -0
  157. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/queue.rb +55 -0
  158. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/file.rb +80 -0
  159. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/fsm.rb +132 -0
  160. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/internals/thread_pool.rb +29 -0
  161. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/listener/config.rb +41 -0
  162. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/listener.rb +133 -0
  163. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/logger.rb +32 -0
  164. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/options.rb +23 -0
  165. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/queue_optimizer.rb +132 -0
  166. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record/entry.rb +64 -0
  167. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record/symlink_detector.rb +39 -0
  168. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record.rb +118 -0
  169. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb +48 -0
  170. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/silencer.rb +97 -0
  171. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/version.rb +3 -0
  172. data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen.rb +57 -0
  173. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.gitignore +8 -0
  174. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rspec +2 -0
  175. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rubocop-disables.yml +384 -0
  176. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rubocop.yml +3 -0
  177. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.travis.yml +43 -0
  178. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/AUTHORS +98 -0
  179. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/Gemfile +11 -0
  180. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/LICENSE +21 -0
  181. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/README.md +667 -0
  182. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/Rakefile +132 -0
  183. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/bin/restclient +92 -0
  184. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/history.md +310 -0
  185. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/rest-client.rb +2 -0
  186. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/rest_client.rb +2 -0
  187. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb +226 -0
  188. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/exceptions.rb +244 -0
  189. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/params_array.rb +72 -0
  190. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/payload.rb +209 -0
  191. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/platform.rb +49 -0
  192. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/raw_response.rb +38 -0
  193. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/request.rb +904 -0
  194. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/resource.rb +168 -0
  195. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/response.rb +80 -0
  196. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/utils.rb +235 -0
  197. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/version.rb +8 -0
  198. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/windows/root_certs.rb +105 -0
  199. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/windows.rb +8 -0
  200. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient.rb +184 -0
  201. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/rest-client.gemspec +31 -0
  202. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/rest-client.windows.gemspec +19 -0
  203. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/helpers.rb +22 -0
  204. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/_lib.rb +1 -0
  205. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/244b5494.0 +19 -0
  206. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/81b9768f.0 +19 -0
  207. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/README +8 -0
  208. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/digicert.crt +19 -0
  209. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/415660c1.0 +14 -0
  210. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/7651b327.0 +14 -0
  211. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/README +8 -0
  212. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/verisign.crt +14 -0
  213. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/certs/digicert.crt +19 -0
  214. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/certs/verisign.crt +14 -0
  215. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/httpbin_spec.rb +86 -0
  216. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/integration_spec.rb +125 -0
  217. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/request_spec.rb +127 -0
  218. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/spec_helper.rb +29 -0
  219. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/_lib.rb +1 -0
  220. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/abstract_response_spec.rb +145 -0
  221. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/exceptions_spec.rb +108 -0
  222. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/master_shake.jpg +0 -0
  223. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/params_array_spec.rb +36 -0
  224. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/payload_spec.rb +263 -0
  225. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/raw_response_spec.rb +18 -0
  226. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/request2_spec.rb +54 -0
  227. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/request_spec.rb +1265 -0
  228. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/resource_spec.rb +130 -0
  229. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/response_spec.rb +241 -0
  230. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/restclient_spec.rb +79 -0
  231. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/utils_spec.rb +147 -0
  232. data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/windows/root_certs_spec.rb +22 -0
  233. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.gitignore +10 -0
  234. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.rspec +3 -0
  235. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.rubocop.yml +3 -0
  236. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.travis.yml +11 -0
  237. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/LICENSE.txt +21 -0
  238. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/README.md +151 -0
  239. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/logger.rb +16 -0
  240. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/quiet.rb +3 -0
  241. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/ruby_version.rb +58 -0
  242. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/travis/ruby_version.rb +59 -0
  243. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/travis.rb +58 -0
  244. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/version.rb +3 -0
  245. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/warning.rb +97 -0
  246. data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep.rb +2 -0
  247. data/vendor/bundle/ruby/2.3.0/specifications/listen-3.1.5.gemspec +44 -0
  248. data/vendor/bundle/ruby/2.3.0/specifications/rest-client-2.0.0.gemspec +60 -0
  249. data/vendor/bundle/ruby/2.3.0/specifications/ruby_dep-1.4.0.gemspec +34 -0
  250. data/version.txt +1 -1
  251. metadata +147 -44
  252. data/plugins/guests/darwin/cap/insert_public_key.rb +0 -33
  253. data/plugins/guests/darwin/cap/mount_nfs_folder.rb +0 -37
  254. data/plugins/guests/darwin/cap/remove_public_key.rb +0 -21
  255. data/plugins/guests/fedora/cap/change_host_name.rb +0 -29
  256. data/plugins/guests/fedora/cap/configure_networks.rb +0 -135
  257. data/plugins/guests/fedora/cap/network_scripts_dir.rb +0 -15
  258. data/plugins/guests/freebsd/cap/halt.rb +0 -16
  259. data/plugins/guests/freebsd/cap/insert_public_key.rb +0 -34
  260. data/plugins/guests/freebsd/cap/mount_nfs_folder.rb +0 -24
  261. data/plugins/guests/freebsd/cap/remove_public_key.rb +0 -21
  262. data/plugins/guests/funtoo/cap/change_host_name.rb +0 -17
  263. data/plugins/guests/linux/cap/insert_public_key.rb +0 -31
  264. data/plugins/guests/linux/cap/mount_nfs.rb +0 -50
  265. data/plugins/guests/linux/cap/nfs_client.rb +0 -11
  266. data/plugins/guests/linux/cap/remove_public_key.rb +0 -24
  267. data/plugins/guests/netbsd/cap/insert_public_key.rb +0 -21
  268. data/plugins/guests/netbsd/cap/mount_nfs_folder.rb +0 -17
  269. data/plugins/guests/netbsd/cap/remove_public_key.rb +0 -21
  270. data/plugins/guests/openbsd/cap/halt.rb +0 -16
  271. data/plugins/guests/openbsd/cap/insert_public_key.rb +0 -21
  272. data/plugins/guests/openbsd/cap/mount_nfs_folder.rb +0 -14
  273. data/plugins/guests/openbsd/cap/remove_public_key.rb +0 -21
  274. data/plugins/guests/ubuntu/cap/change_host_name.rb +0 -52
  275. data/templates/guests/fedora/network_dhcp.erb +0 -6
  276. data/templates/guests/fedora/network_static.erb +0 -16
  277. data/test/unit/plugins/guests/freebsd/cap/mount_nfs_folder_test.rb +0 -53
  278. data/test/unit/plugins/guests/ubuntu/cap/change_host_name_test.rb +0 -42
  279. data/test/unit/templates/guests/fedora/network_dhcp_test.rb +0 -21
  280. data/test/unit/templates/guests/fedora/network_static6_test.rb +0 -25
  281. data/test/unit/templates/guests/fedora/network_static_test.rb +0 -71
@@ -0,0 +1 @@
1
+ require_relative '../spec_helper'
@@ -0,0 +1,145 @@
1
+ require_relative '_lib'
2
+
3
+ describe RestClient::AbstractResponse, :include_helpers do
4
+
5
+ class MyAbstractResponse
6
+
7
+ include RestClient::AbstractResponse
8
+
9
+ attr_accessor :size
10
+
11
+ def initialize net_http_res, request
12
+ @net_http_res = net_http_res
13
+ @request = request
14
+ end
15
+
16
+ end
17
+
18
+ before do
19
+ @net_http_res = double('net http response')
20
+ @request = request_double(url: 'http://example.com', method: 'get')
21
+ @response = MyAbstractResponse.new(@net_http_res, @request)
22
+ end
23
+
24
+ it "fetches the numeric response code" do
25
+ expect(@net_http_res).to receive(:code).and_return('200')
26
+ expect(@response.code).to eq 200
27
+ end
28
+
29
+ it "has a nice description" do
30
+ expect(@net_http_res).to receive(:to_hash).and_return({'Content-Type' => ['application/pdf']})
31
+ expect(@net_http_res).to receive(:code).and_return('200')
32
+ expect(@response.description).to eq "200 OK | application/pdf bytes\n"
33
+ end
34
+
35
+ describe '.beautify_headers' do
36
+ it "beautifies the headers by turning the keys to symbols" do
37
+ h = RestClient::AbstractResponse.beautify_headers('content-type' => [ 'x' ])
38
+ expect(h.keys.first).to eq :content_type
39
+ end
40
+
41
+ it "beautifies the headers by turning the values to strings instead of one-element arrays" do
42
+ h = RestClient::AbstractResponse.beautify_headers('x' => [ 'text/html' ] )
43
+ expect(h.values.first).to eq 'text/html'
44
+ end
45
+
46
+ it 'joins multiple header values by comma' do
47
+ expect(RestClient::AbstractResponse.beautify_headers(
48
+ {'My-Header' => ['one', 'two']}
49
+ )).to eq({:my_header => 'one, two'})
50
+ end
51
+
52
+ it 'leaves set-cookie headers as array' do
53
+ expect(RestClient::AbstractResponse.beautify_headers(
54
+ {'Set-Cookie' => ['cookie1=foo', 'cookie2=bar']}
55
+ )).to eq({:set_cookie => ['cookie1=foo', 'cookie2=bar']})
56
+ end
57
+ end
58
+
59
+ it "fetches the headers" do
60
+ expect(@net_http_res).to receive(:to_hash).and_return('content-type' => [ 'text/html' ])
61
+ expect(@response.headers).to eq({ :content_type => 'text/html' })
62
+ end
63
+
64
+ it "extracts cookies from response headers" do
65
+ expect(@net_http_res).to receive(:to_hash).and_return('set-cookie' => ['session_id=1; path=/'])
66
+ expect(@response.cookies).to eq({ 'session_id' => '1' })
67
+ end
68
+
69
+ it "extract strange cookies" do
70
+ expect(@net_http_res).to receive(:to_hash).and_return('set-cookie' => ['session_id=ZJ/HQVH6YE+rVkTpn0zvTQ==; path=/'])
71
+ expect(@response.headers).to eq({:set_cookie => ['session_id=ZJ/HQVH6YE+rVkTpn0zvTQ==; path=/']})
72
+ expect(@response.cookies).to eq({ 'session_id' => 'ZJ/HQVH6YE+rVkTpn0zvTQ==' })
73
+ end
74
+
75
+ it "doesn't escape cookies" do
76
+ expect(@net_http_res).to receive(:to_hash).and_return('set-cookie' => ['session_id=BAh7BzoNYXBwX25hbWUiEGFwcGxpY2F0aW9uOgpsb2dpbiIKYWRtaW4%3D%0A--08114ba654f17c04d20dcc5228ec672508f738ca; path=/'])
77
+ expect(@response.cookies).to eq({ 'session_id' => 'BAh7BzoNYXBwX25hbWUiEGFwcGxpY2F0aW9uOgpsb2dpbiIKYWRtaW4%3D%0A--08114ba654f17c04d20dcc5228ec672508f738ca' })
78
+ end
79
+
80
+ describe '.cookie_jar' do
81
+ it 'extracts cookies into cookie jar' do
82
+ expect(@net_http_res).to receive(:to_hash).and_return('set-cookie' => ['session_id=1; path=/'])
83
+ expect(@response.cookie_jar).to be_a HTTP::CookieJar
84
+
85
+ cookie = @response.cookie_jar.cookies.first
86
+ expect(cookie.domain).to eq 'example.com'
87
+ expect(cookie.name).to eq 'session_id'
88
+ expect(cookie.value).to eq '1'
89
+ expect(cookie.path).to eq '/'
90
+ end
91
+
92
+ it 'handles cookies when URI scheme is implicit' do
93
+ net_http_res = double('net http response')
94
+ expect(net_http_res).to receive(:to_hash).and_return('set-cookie' => ['session_id=1; path=/'])
95
+ request = double(url: 'example.com', uri: URI.parse('http://example.com'),
96
+ method: 'get', cookie_jar: HTTP::CookieJar.new)
97
+ response = MyAbstractResponse.new(net_http_res, request)
98
+ expect(response.cookie_jar).to be_a HTTP::CookieJar
99
+
100
+ cookie = response.cookie_jar.cookies.first
101
+ expect(cookie.domain).to eq 'example.com'
102
+ expect(cookie.name).to eq 'session_id'
103
+ expect(cookie.value).to eq '1'
104
+ expect(cookie.path).to eq '/'
105
+ end
106
+ end
107
+
108
+ it "can access the net http result directly" do
109
+ expect(@response.net_http_res).to eq @net_http_res
110
+ end
111
+
112
+ describe "#return!" do
113
+ it "should return the response itself on 200-codes" do
114
+ expect(@net_http_res).to receive(:code).and_return('200')
115
+ expect(@response.return!).to be_equal(@response)
116
+ end
117
+
118
+ it "should raise RequestFailed on unknown codes" do
119
+ expect(@net_http_res).to receive(:code).and_return('1000')
120
+ expect { @response.return! }.to raise_error RestClient::RequestFailed
121
+ end
122
+
123
+ it "should raise an error on a redirection after non-GET/HEAD requests" do
124
+ expect(@net_http_res).to receive(:code).and_return('301')
125
+ expect(@request).to receive(:method).and_return('put')
126
+ expect(@response).not_to receive(:follow_redirection)
127
+ expect { @response.return! }.to raise_error RestClient::RequestFailed
128
+ end
129
+
130
+ it "should follow 302 redirect" do
131
+ expect(@net_http_res).to receive(:code).and_return('302')
132
+ expect(@response).to receive(:check_max_redirects).and_return('fake-check')
133
+ expect(@response).to receive(:follow_redirection).and_return('fake-redirection')
134
+ expect(@response.return!).to eq 'fake-redirection'
135
+ end
136
+
137
+ it "should gracefully handle 302 redirect with no location header" do
138
+ @net_http_res = response_double(code: 302, location: nil)
139
+ @request = request_double()
140
+ @response = MyAbstractResponse.new(@net_http_res, @request)
141
+ expect(@response).to receive(:check_max_redirects).and_return('fake-check')
142
+ expect { @response.return! }.to raise_error RestClient::Found
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,108 @@
1
+ require_relative '_lib'
2
+
3
+ describe RestClient::Exception do
4
+ it "returns a 'message' equal to the class name if the message is not set, because 'message' should not be nil" do
5
+ e = RestClient::Exception.new
6
+ expect(e.message).to eq "RestClient::Exception"
7
+ end
8
+
9
+ it "returns the 'message' that was set" do
10
+ e = RestClient::Exception.new
11
+ message = "An explicitly set message"
12
+ e.message = message
13
+ expect(e.message).to eq message
14
+ end
15
+
16
+ it "sets the exception message to ErrorMessage" do
17
+ expect(RestClient::ResourceNotFound.new.message).to eq 'Not Found'
18
+ end
19
+
20
+ it "contains exceptions in RestClient" do
21
+ expect(RestClient::Unauthorized.new).to be_a_kind_of(RestClient::Exception)
22
+ expect(RestClient::ServerBrokeConnection.new).to be_a_kind_of(RestClient::Exception)
23
+ end
24
+ end
25
+
26
+ describe RestClient::ServerBrokeConnection do
27
+ it "should have a default message of 'Server broke connection'" do
28
+ e = RestClient::ServerBrokeConnection.new
29
+ expect(e.message).to eq 'Server broke connection'
30
+ end
31
+ end
32
+
33
+ describe RestClient::RequestFailed do
34
+ before do
35
+ @response = double('HTTP Response', :code => '502')
36
+ end
37
+
38
+ it "stores the http response on the exception" do
39
+ response = "response"
40
+ begin
41
+ raise RestClient::RequestFailed, response
42
+ rescue RestClient::RequestFailed => e
43
+ expect(e.response).to eq response
44
+ end
45
+ end
46
+
47
+ it "http_code convenience method for fetching the code as an integer" do
48
+ expect(RestClient::RequestFailed.new(@response).http_code).to eq 502
49
+ end
50
+
51
+ it "http_body convenience method for fetching the body (decoding when necessary)" do
52
+ expect(RestClient::RequestFailed.new(@response).http_code).to eq 502
53
+ expect(RestClient::RequestFailed.new(@response).message).to eq 'HTTP status code 502'
54
+ end
55
+
56
+ it "shows the status code in the message" do
57
+ expect(RestClient::RequestFailed.new(@response).to_s).to match(/502/)
58
+ end
59
+ end
60
+
61
+ describe RestClient::ResourceNotFound do
62
+ it "also has the http response attached" do
63
+ response = "response"
64
+ begin
65
+ raise RestClient::ResourceNotFound, response
66
+ rescue RestClient::ResourceNotFound => e
67
+ expect(e.response).to eq response
68
+ end
69
+ end
70
+
71
+ it 'stores the body on the response of the exception' do
72
+ body = "body"
73
+ stub_request(:get, "www.example.com").to_return(:body => body, :status => 404)
74
+ begin
75
+ RestClient.get "www.example.com"
76
+ raise
77
+ rescue RestClient::ResourceNotFound => e
78
+ expect(e.response.body).to eq body
79
+ end
80
+ end
81
+ end
82
+
83
+ describe "backwards compatibility" do
84
+ it 'aliases RestClient::NotFound as ResourceNotFound' do
85
+ expect(RestClient::ResourceNotFound).to eq RestClient::NotFound
86
+ end
87
+
88
+ it 'aliases old names for HTTP 413, 414, 416' do
89
+ expect(RestClient::RequestEntityTooLarge).to eq RestClient::PayloadTooLarge
90
+ expect(RestClient::RequestURITooLong).to eq RestClient::URITooLong
91
+ expect(RestClient::RequestedRangeNotSatisfiable).to eq RestClient::RangeNotSatisfiable
92
+ end
93
+
94
+ it 'subclasses NotFound from RequestFailed, ExceptionWithResponse' do
95
+ expect(RestClient::NotFound).to be < RestClient::RequestFailed
96
+ expect(RestClient::NotFound).to be < RestClient::ExceptionWithResponse
97
+ end
98
+
99
+ it 'subclasses timeout from RestClient::RequestTimeout, RequestFailed, EWR' do
100
+ expect(RestClient::Exceptions::OpenTimeout).to be < RestClient::Exceptions::Timeout
101
+ expect(RestClient::Exceptions::ReadTimeout).to be < RestClient::Exceptions::Timeout
102
+
103
+ expect(RestClient::Exceptions::Timeout).to be < RestClient::RequestTimeout
104
+ expect(RestClient::Exceptions::Timeout).to be < RestClient::RequestFailed
105
+ expect(RestClient::Exceptions::Timeout).to be < RestClient::ExceptionWithResponse
106
+ end
107
+
108
+ end
@@ -0,0 +1,36 @@
1
+ require_relative '_lib'
2
+
3
+ describe RestClient::ParamsArray do
4
+
5
+ describe '.new' do
6
+ it 'accepts various types of containers' do
7
+ as_array = [[:foo, 123], [:foo, 456], [:bar, 789], [:empty, nil]]
8
+ [
9
+ [[:foo, 123], [:foo, 456], [:bar, 789], [:empty, nil]],
10
+ [{foo: 123}, {foo: 456}, {bar: 789}, {empty: nil}],
11
+ [{foo: 123}, {foo: 456}, {bar: 789}, {empty: nil}],
12
+ [{foo: 123}, [:foo, 456], {bar: 789}, {empty: nil}],
13
+ [{foo: 123}, [:foo, 456], {bar: 789}, [:empty]],
14
+ ].each do |input|
15
+ expect(RestClient::ParamsArray.new(input).to_a).to eq as_array
16
+ end
17
+
18
+ expect(RestClient::ParamsArray.new([]).to_a).to eq []
19
+ expect(RestClient::ParamsArray.new([]).empty?).to eq true
20
+ end
21
+
22
+ it 'rejects various invalid input' do
23
+ expect {
24
+ RestClient::ParamsArray.new([[]])
25
+ }.to raise_error(IndexError)
26
+
27
+ expect {
28
+ RestClient::ParamsArray.new([[1,2,3]])
29
+ }.to raise_error(ArgumentError)
30
+
31
+ expect {
32
+ RestClient::ParamsArray.new([1,2,3])
33
+ }.to raise_error(NoMethodError)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,263 @@
1
+ # encoding: binary
2
+
3
+ require_relative '_lib'
4
+
5
+ describe RestClient::Payload do
6
+ context "Base Payload" do
7
+ it "should reset stream after to_s" do
8
+ payload = RestClient::Payload::Base.new('foobar')
9
+ expect(payload.to_s).to eq 'foobar'
10
+ expect(payload.to_s).to eq 'foobar'
11
+ end
12
+ end
13
+
14
+ context "A regular Payload" do
15
+ it "should use standard enctype as default content-type" do
16
+ expect(RestClient::Payload::UrlEncoded.new({}).headers['Content-Type']).
17
+ to eq 'application/x-www-form-urlencoded'
18
+ end
19
+
20
+ it "should form properly encoded params" do
21
+ expect(RestClient::Payload::UrlEncoded.new({:foo => 'bar'}).to_s).
22
+ to eq "foo=bar"
23
+ expect(["foo=bar&baz=qux", "baz=qux&foo=bar"]).to include(
24
+ RestClient::Payload::UrlEncoded.new({:foo => 'bar', :baz => 'qux'}).to_s)
25
+ end
26
+
27
+ it "should escape parameters" do
28
+ expect(RestClient::Payload::UrlEncoded.new({'foo + bar' => 'baz'}).to_s).
29
+ to eq "foo+%2B+bar=baz"
30
+ end
31
+
32
+ it "should properly handle hashes as parameter" do
33
+ expect(RestClient::Payload::UrlEncoded.new({:foo => {:bar => 'baz'}}).to_s).
34
+ to eq "foo[bar]=baz"
35
+ expect(RestClient::Payload::UrlEncoded.new({:foo => {:bar => {:baz => 'qux'}}}).to_s).
36
+ to eq "foo[bar][baz]=qux"
37
+ end
38
+
39
+ it "should handle many attributes inside a hash" do
40
+ parameters = RestClient::Payload::UrlEncoded.new({:foo => {:bar => 'baz', :baz => 'qux'}}).to_s
41
+ expect(parameters).to eq 'foo[bar]=baz&foo[baz]=qux'
42
+ end
43
+
44
+ it "should handle attributes inside an array inside an hash" do
45
+ parameters = RestClient::Payload::UrlEncoded.new({"foo" => [{"bar" => 'baz'}, {"bar" => 'qux'}]}).to_s
46
+ expect(parameters).to eq 'foo[][bar]=baz&foo[][bar]=qux'
47
+ end
48
+
49
+ it "should handle arrays inside a hash inside a hash" do
50
+ parameters = RestClient::Payload::UrlEncoded.new({"foo" => {'even' => [0, 2], 'odd' => [1, 3]}}).to_s
51
+ expect(parameters).to eq 'foo[even][]=0&foo[even][]=2&foo[odd][]=1&foo[odd][]=3'
52
+ end
53
+
54
+ it "should form properly use symbols as parameters" do
55
+ expect(RestClient::Payload::UrlEncoded.new({:foo => :bar}).to_s).
56
+ to eq "foo=bar"
57
+ expect(RestClient::Payload::UrlEncoded.new({:foo => {:bar => :baz}}).to_s).
58
+ to eq "foo[bar]=baz"
59
+ end
60
+
61
+ it "should properly handle arrays as repeated parameters" do
62
+ expect(RestClient::Payload::UrlEncoded.new({:foo => ['bar']}).to_s).
63
+ to eq "foo[]=bar"
64
+ expect(RestClient::Payload::UrlEncoded.new({:foo => ['bar', 'baz']}).to_s).
65
+ to eq "foo[]=bar&foo[]=baz"
66
+ end
67
+
68
+ it 'should not close if stream already closed' do
69
+ p = RestClient::Payload::UrlEncoded.new({'foo ' => 'bar'})
70
+ 3.times {p.close}
71
+ end
72
+
73
+ end
74
+
75
+ context "A multipart Payload" do
76
+ it "should use standard enctype as default content-type" do
77
+ m = RestClient::Payload::Multipart.new({})
78
+ allow(m).to receive(:boundary).and_return(123)
79
+ expect(m.headers['Content-Type']).to eq 'multipart/form-data; boundary=123'
80
+ end
81
+
82
+ it 'should not error on close if stream already closed' do
83
+ m = RestClient::Payload::Multipart.new(:file => File.new(File.join(File.dirname(File.expand_path(__FILE__)), 'master_shake.jpg')))
84
+ 3.times {m.close}
85
+ end
86
+
87
+ it "should form properly separated multipart data" do
88
+ m = RestClient::Payload::Multipart.new([[:bar, "baz"], [:foo, "bar"]])
89
+ expect(m.to_s).to eq <<-EOS
90
+ --#{m.boundary}\r
91
+ Content-Disposition: form-data; name="bar"\r
92
+ \r
93
+ baz\r
94
+ --#{m.boundary}\r
95
+ Content-Disposition: form-data; name="foo"\r
96
+ \r
97
+ bar\r
98
+ --#{m.boundary}--\r
99
+ EOS
100
+ end
101
+
102
+ it "should not escape parameters names" do
103
+ m = RestClient::Payload::Multipart.new([["bar ", "baz"]])
104
+ expect(m.to_s).to eq <<-EOS
105
+ --#{m.boundary}\r
106
+ Content-Disposition: form-data; name="bar "\r
107
+ \r
108
+ baz\r
109
+ --#{m.boundary}--\r
110
+ EOS
111
+ end
112
+
113
+ it "should form properly separated multipart data" do
114
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
115
+ m = RestClient::Payload::Multipart.new({:foo => f})
116
+ expect(m.to_s).to eq <<-EOS
117
+ --#{m.boundary}\r
118
+ Content-Disposition: form-data; name="foo"; filename="master_shake.jpg"\r
119
+ Content-Type: image/jpeg\r
120
+ \r
121
+ #{File.open(f.path, 'rb'){|bin| bin.read}}\r
122
+ --#{m.boundary}--\r
123
+ EOS
124
+ end
125
+
126
+ it "should ignore the name attribute when it's not set" do
127
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
128
+ m = RestClient::Payload::Multipart.new({nil => f})
129
+ expect(m.to_s).to eq <<-EOS
130
+ --#{m.boundary}\r
131
+ Content-Disposition: form-data; filename="master_shake.jpg"\r
132
+ Content-Type: image/jpeg\r
133
+ \r
134
+ #{File.open(f.path, 'rb'){|bin| bin.read}}\r
135
+ --#{m.boundary}--\r
136
+ EOS
137
+ end
138
+
139
+ it "should detect optional (original) content type and filename" do
140
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
141
+ f.instance_eval "def content_type; 'text/plain'; end"
142
+ f.instance_eval "def original_filename; 'foo.txt'; end"
143
+ m = RestClient::Payload::Multipart.new({:foo => f})
144
+ expect(m.to_s).to eq <<-EOS
145
+ --#{m.boundary}\r
146
+ Content-Disposition: form-data; name="foo"; filename="foo.txt"\r
147
+ Content-Type: text/plain\r
148
+ \r
149
+ #{File.open(f.path, 'rb'){|bin| bin.read}}\r
150
+ --#{m.boundary}--\r
151
+ EOS
152
+ end
153
+
154
+ it "should handle hash in hash parameters" do
155
+ m = RestClient::Payload::Multipart.new({:bar => {:baz => "foo"}})
156
+ expect(m.to_s).to eq <<-EOS
157
+ --#{m.boundary}\r
158
+ Content-Disposition: form-data; name="bar[baz]"\r
159
+ \r
160
+ foo\r
161
+ --#{m.boundary}--\r
162
+ EOS
163
+
164
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
165
+ f.instance_eval "def content_type; 'text/plain'; end"
166
+ f.instance_eval "def original_filename; 'foo.txt'; end"
167
+ m = RestClient::Payload::Multipart.new({:foo => {:bar => f}})
168
+ expect(m.to_s).to eq <<-EOS
169
+ --#{m.boundary}\r
170
+ Content-Disposition: form-data; name="foo[bar]"; filename="foo.txt"\r
171
+ Content-Type: text/plain\r
172
+ \r
173
+ #{File.open(f.path, 'rb'){|bin| bin.read}}\r
174
+ --#{m.boundary}--\r
175
+ EOS
176
+ end
177
+
178
+ it 'should correctly format hex boundary' do
179
+ allow(SecureRandom).to receive(:base64).with(12).and_return('TGs89+ttw/xna6TV')
180
+ f = File.new(File.dirname(__FILE__) + '/master_shake.jpg')
181
+ m = RestClient::Payload::Multipart.new({:foo => f})
182
+ expect(m.boundary).to eq('-' * 4 + 'RubyFormBoundary' + 'TGs89AttwBxna6TV')
183
+ end
184
+
185
+ end
186
+
187
+ context "streamed payloads" do
188
+ it "should properly determine the size of file payloads" do
189
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
190
+ payload = RestClient::Payload.generate(f)
191
+ expect(payload.size).to eq 76_988
192
+ expect(payload.length).to eq 76_988
193
+ end
194
+
195
+ it "should properly determine the size of other kinds of streaming payloads" do
196
+ s = StringIO.new 'foo'
197
+ payload = RestClient::Payload.generate(s)
198
+ expect(payload.size).to eq 3
199
+ expect(payload.length).to eq 3
200
+
201
+ begin
202
+ f = Tempfile.new "rest-client"
203
+ f.write 'foo bar'
204
+
205
+ payload = RestClient::Payload.generate(f)
206
+ expect(payload.size).to eq 7
207
+ expect(payload.length).to eq 7
208
+ ensure
209
+ f.close
210
+ end
211
+ end
212
+ end
213
+
214
+ context "Payload generation" do
215
+ it "should recognize standard urlencoded params" do
216
+ expect(RestClient::Payload.generate({"foo" => 'bar'})).to be_kind_of(RestClient::Payload::UrlEncoded)
217
+ end
218
+
219
+ it "should recognize multipart params" do
220
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
221
+ expect(RestClient::Payload.generate({"foo" => f})).to be_kind_of(RestClient::Payload::Multipart)
222
+ end
223
+
224
+ it "should be multipart if forced" do
225
+ expect(RestClient::Payload.generate({"foo" => "bar", :multipart => true})).to be_kind_of(RestClient::Payload::Multipart)
226
+ end
227
+
228
+ it "should handle deeply nested multipart" do
229
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
230
+ params = {foo: RestClient::ParamsArray.new({nested: f})}
231
+ expect(RestClient::Payload.generate(params)).to be_kind_of(RestClient::Payload::Multipart)
232
+ end
233
+
234
+
235
+ it "should return data if no of the above" do
236
+ expect(RestClient::Payload.generate("data")).to be_kind_of(RestClient::Payload::Base)
237
+ end
238
+
239
+ it "should recognize nested multipart payloads in hashes" do
240
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
241
+ expect(RestClient::Payload.generate({"foo" => {"file" => f}})).to be_kind_of(RestClient::Payload::Multipart)
242
+ end
243
+
244
+ it "should recognize nested multipart payloads in arrays" do
245
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
246
+ expect(RestClient::Payload.generate({"foo" => [f]})).to be_kind_of(RestClient::Payload::Multipart)
247
+ end
248
+
249
+ it "should recognize file payloads that can be streamed" do
250
+ f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
251
+ expect(RestClient::Payload.generate(f)).to be_kind_of(RestClient::Payload::Streamed)
252
+ end
253
+
254
+ it "should recognize other payloads that can be streamed" do
255
+ expect(RestClient::Payload.generate(StringIO.new('foo'))).to be_kind_of(RestClient::Payload::Streamed)
256
+ end
257
+
258
+ # hashery gem introduces Hash#read convenience method. Existence of #read method used to determine of content is streameable :/
259
+ it "shouldn't treat hashes as streameable" do
260
+ expect(RestClient::Payload.generate({"foo" => 'bar'})).to be_kind_of(RestClient::Payload::UrlEncoded)
261
+ end
262
+ end
263
+ end