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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +52 -0
- data/Gemfile.lock +9 -7
- data/RELEASE.md +37 -14
- data/lib/vagrant/action/builtin/box_add.rb +3 -1
- data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +5 -0
- data/lib/vagrant/box_collection.rb +2 -1
- data/lib/vagrant/bundler.rb +36 -1
- data/lib/vagrant/errors.rb +16 -8
- data/lib/vagrant/plugin/state_file.rb +8 -1
- data/lib/vagrant/util/platform.rb +1 -1
- data/plugins/guests/arch/cap/change_host_name.rb +13 -10
- data/plugins/guests/arch/cap/configure_networks.rb +11 -8
- data/plugins/guests/arch/cap/nfs.rb +35 -0
- data/plugins/guests/arch/cap/rsync.rb +16 -0
- data/plugins/guests/arch/cap/smb.rb +17 -0
- data/plugins/guests/arch/plugin.rb +28 -3
- data/plugins/guests/atomic/cap/change_host_name.rb +13 -10
- data/plugins/guests/atomic/plugin.rb +3 -3
- data/plugins/guests/{netbsd → bsd}/cap/halt.rb +2 -2
- data/plugins/guests/bsd/cap/nfs.rb +49 -0
- data/plugins/guests/bsd/cap/public_key.rb +65 -0
- data/plugins/guests/bsd/cap/virtualbox.rb +16 -0
- data/plugins/guests/bsd/guest.rb +9 -0
- data/plugins/guests/bsd/plugin.rb +40 -0
- data/plugins/guests/coreos/cap/change_host_name.rb +1 -1
- data/plugins/guests/coreos/plugin.rb +4 -4
- data/plugins/guests/darwin/cap/change_host_name.rb +4 -1
- data/plugins/guests/darwin/cap/configure_networks.rb +12 -5
- data/plugins/guests/darwin/cap/halt.rb +3 -1
- data/plugins/guests/darwin/cap/rsync.rb +7 -4
- data/plugins/guests/darwin/plugin.rb +13 -28
- data/plugins/guests/debian/cap/change_host_name.rb +14 -15
- data/plugins/guests/debian/cap/configure_networks.rb +2 -6
- data/plugins/guests/debian/cap/{nfs_client.rb → nfs.rb} +2 -1
- data/plugins/guests/debian/cap/rsync.rb +5 -6
- data/plugins/guests/debian/plugin.rb +8 -8
- data/plugins/guests/esxi/cap/mount_nfs_folder.rb +2 -2
- data/plugins/guests/esxi/plugin.rb +6 -6
- data/plugins/guests/fedora/cap/flavor.rb +1 -1
- data/plugins/guests/fedora/plugin.rb +2 -17
- data/plugins/guests/freebsd/cap/change_host_name.rb +2 -3
- data/plugins/guests/freebsd/cap/rsync.rb +7 -4
- data/plugins/guests/freebsd/plugin.rb +9 -29
- data/plugins/guests/funtoo/plugin.rb +3 -8
- data/plugins/guests/gentoo/cap/change_host_name.rb +21 -6
- data/plugins/guests/gentoo/cap/configure_networks.rb +35 -26
- data/plugins/guests/gentoo/plugin.rb +4 -4
- data/plugins/guests/linux/cap/choose_addressable_ip_addr.rb +2 -3
- data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +31 -45
- data/plugins/guests/linux/cap/network_interfaces.rb +20 -0
- data/plugins/guests/linux/cap/nfs.rb +57 -0
- data/plugins/guests/linux/cap/public_key.rb +65 -0
- data/plugins/guests/linux/cap/rsync.rb +7 -4
- data/plugins/guests/linux/plugin.rb +30 -25
- data/plugins/guests/mint/plugin.rb +1 -1
- data/plugins/guests/netbsd/plugin.rb +10 -30
- data/plugins/guests/nixos/plugin.rb +5 -5
- data/plugins/guests/omnios/cap/change_host_name.rb +1 -1
- data/plugins/guests/omnios/plugin.rb +4 -4
- data/plugins/guests/openbsd/cap/change_host_name.rb +21 -3
- data/plugins/guests/openbsd/plugin.rb +10 -30
- data/plugins/guests/photon/cap/change_host_name.rb +1 -1
- data/plugins/guests/photon/plugin.rb +4 -4
- data/plugins/guests/pld/cap/change_host_name.rb +1 -1
- data/plugins/guests/pld/plugin.rb +4 -4
- data/plugins/guests/redhat/cap/change_host_name.rb +4 -3
- data/plugins/guests/redhat/cap/configure_networks.rb +1 -24
- data/plugins/guests/redhat/plugin.rb +7 -7
- data/plugins/guests/slackware/cap/change_host_name.rb +1 -1
- data/plugins/guests/slackware/cap/configure_networks.rb +1 -5
- data/plugins/guests/slackware/plugin.rb +3 -3
- data/plugins/guests/smartos/plugin.rb +12 -12
- data/plugins/guests/solaris/plugin.rb +14 -14
- data/plugins/guests/solaris11/plugin.rb +12 -12
- data/plugins/guests/suse/cap/change_host_name.rb +1 -1
- data/plugins/guests/suse/cap/configure_networks.rb +1 -5
- data/plugins/guests/suse/plugin.rb +8 -8
- data/plugins/guests/tinycore/cap/mount_nfs.rb +2 -2
- data/plugins/guests/tinycore/plugin.rb +7 -7
- data/plugins/guests/trisquel/plugin.rb +1 -1
- data/plugins/guests/ubuntu/guest.rb +1 -1
- data/plugins/guests/ubuntu/plugin.rb +1 -6
- data/plugins/guests/windows/plugin.rb +2 -2
- data/plugins/kernel_v2/config/vm.rb +8 -1
- data/plugins/providers/hyperv/scripts/get_vm_status.ps1 +25 -5
- data/plugins/providers/virtualbox/driver/meta.rb +1 -0
- data/plugins/providers/virtualbox/driver/version_5_1.rb +734 -0
- data/plugins/providers/virtualbox/plugin.rb +1 -0
- data/plugins/synced_folders/nfs/synced_folder.rb +10 -2
- data/plugins/synced_folders/rsync/helper.rb +11 -4
- data/scripts/{bintray_upload.sh → sign.sh} +0 -0
- data/templates/guests/arch/network_static.erb +3 -3
- data/templates/guests/arch/network_static6.erb +8 -0
- data/templates/guests/freebsd/network_static6.erb +6 -0
- data/templates/guests/funtoo/network_static6.erb +9 -0
- data/templates/guests/gentoo/network_dhcp.erb +1 -1
- data/templates/guests/gentoo/network_static.erb +4 -4
- data/templates/guests/gentoo/network_static6.erb +7 -0
- data/templates/guests/redhat/network_dhcp.erb +1 -1
- data/templates/guests/redhat/network_static.erb +4 -1
- data/templates/guests/{fedora → redhat}/network_static6.erb +5 -2
- data/templates/locales/en.yml +40 -6
- data/test/unit/plugins/guests/arch/cap/change_host_name_test.rb +6 -6
- data/test/unit/plugins/guests/arch/cap/configure_networks_test.rb +20 -15
- data/test/unit/plugins/guests/arch/cap/rsync_test.rb +30 -0
- data/test/unit/plugins/guests/arch/cap/smb_test.rb +38 -0
- data/test/unit/plugins/guests/atomic/cap/change_host_name_test.rb +9 -8
- data/test/unit/plugins/guests/{freebsd → bsd}/cap/halt_test.rb +11 -10
- data/test/unit/plugins/guests/{freebsd → bsd}/cap/insert_public_key_test.rb +7 -6
- data/test/unit/plugins/guests/bsd/cap/nfs_test.rb +68 -0
- data/test/unit/plugins/guests/coreos/cap/change_host_name_test.rb +5 -5
- data/test/unit/plugins/guests/darwin/cap/change_host_name_test.rb +5 -5
- data/test/unit/plugins/guests/darwin/cap/halt_test.rb +36 -0
- data/test/unit/plugins/guests/debian/cap/change_host_name_test.rb +3 -5
- data/test/unit/plugins/guests/debian/cap/configure_networks_test.rb +13 -9
- data/test/unit/plugins/guests/debian/cap/rsync_test.rb +3 -11
- data/test/unit/plugins/guests/freebsd/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb +16 -3
- data/test/unit/plugins/guests/omnios/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/photon/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/pld/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb +4 -3
- data/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb +17 -33
- data/test/unit/plugins/guests/slackware/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/slackware/cap/configure_networks_test.rb +8 -4
- data/test/unit/plugins/guests/suse/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/suse/cap/configure_networks_test.rb +13 -16
- data/test/unit/plugins/kernel_v2/config/vm_test.rb +10 -2
- data/test/unit/templates/guests/arch/network_static_test.rb +4 -2
- data/test/unit/templates/guests/gentoo/network_dhcp_test.rb +2 -2
- data/test/unit/templates/guests/gentoo/network_static_test.rb +10 -10
- data/test/unit/templates/guests/redhat/network_dhcp_test.rb +2 -2
- data/test/unit/templates/guests/redhat/network_static_test.rb +9 -9
- data/vagrant.gemspec +3 -3
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/CHANGELOG.md +1 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/CONTRIBUTING.md +38 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/README.md +297 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/bin/listen +12 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/base.rb +141 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/bsd.rb +106 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/config.rb +26 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/darwin.rb +92 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/linux.rb +106 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/polling.rb +37 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/windows.rb +98 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter.rb +45 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/backend.rb +38 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/change.rb +76 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/cli.rb +65 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/directory.rb +87 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/config.rb +55 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/loop.rb +117 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/processor.rb +122 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/queue.rb +55 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/file.rb +80 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/fsm.rb +132 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/internals/thread_pool.rb +29 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/listener/config.rb +41 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/listener.rb +133 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/logger.rb +32 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/options.rb +23 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/queue_optimizer.rb +132 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record/entry.rb +64 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record/symlink_detector.rb +39 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record.rb +118 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb +48 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/silencer.rb +97 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/version.rb +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen.rb +57 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.gitignore +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rspec +2 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rubocop-disables.yml +384 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rubocop.yml +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.travis.yml +43 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/AUTHORS +98 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/Gemfile +11 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/LICENSE +21 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/README.md +667 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/Rakefile +132 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/bin/restclient +92 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/history.md +310 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/rest-client.rb +2 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/rest_client.rb +2 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb +226 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/exceptions.rb +244 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/params_array.rb +72 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/payload.rb +209 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/platform.rb +49 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/raw_response.rb +38 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/request.rb +904 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/resource.rb +168 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/response.rb +80 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/utils.rb +235 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/version.rb +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/windows/root_certs.rb +105 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/windows.rb +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient.rb +184 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/rest-client.gemspec +31 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/rest-client.windows.gemspec +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/helpers.rb +22 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/_lib.rb +1 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/244b5494.0 +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/81b9768f.0 +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/README +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/digicert.crt +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/415660c1.0 +14 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/7651b327.0 +14 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/README +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/verisign.crt +14 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/certs/digicert.crt +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/certs/verisign.crt +14 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/httpbin_spec.rb +86 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/integration_spec.rb +125 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/request_spec.rb +127 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/spec_helper.rb +29 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/_lib.rb +1 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/abstract_response_spec.rb +145 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/exceptions_spec.rb +108 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/master_shake.jpg +0 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/params_array_spec.rb +36 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/payload_spec.rb +263 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/raw_response_spec.rb +18 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/request2_spec.rb +54 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/request_spec.rb +1265 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/resource_spec.rb +130 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/response_spec.rb +241 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/restclient_spec.rb +79 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/utils_spec.rb +147 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/windows/root_certs_spec.rb +22 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.gitignore +10 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.rspec +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.rubocop.yml +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.travis.yml +11 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/LICENSE.txt +21 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/README.md +151 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/logger.rb +16 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/quiet.rb +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/ruby_version.rb +58 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/travis/ruby_version.rb +59 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/travis.rb +58 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/version.rb +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/warning.rb +97 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep.rb +2 -0
- data/vendor/bundle/ruby/2.3.0/specifications/listen-3.1.5.gemspec +44 -0
- data/vendor/bundle/ruby/2.3.0/specifications/rest-client-2.0.0.gemspec +60 -0
- data/vendor/bundle/ruby/2.3.0/specifications/ruby_dep-1.4.0.gemspec +34 -0
- data/version.txt +1 -1
- metadata +147 -44
- data/plugins/guests/darwin/cap/insert_public_key.rb +0 -33
- data/plugins/guests/darwin/cap/mount_nfs_folder.rb +0 -37
- data/plugins/guests/darwin/cap/remove_public_key.rb +0 -21
- data/plugins/guests/fedora/cap/change_host_name.rb +0 -29
- data/plugins/guests/fedora/cap/configure_networks.rb +0 -135
- data/plugins/guests/fedora/cap/network_scripts_dir.rb +0 -15
- data/plugins/guests/freebsd/cap/halt.rb +0 -16
- data/plugins/guests/freebsd/cap/insert_public_key.rb +0 -34
- data/plugins/guests/freebsd/cap/mount_nfs_folder.rb +0 -24
- data/plugins/guests/freebsd/cap/remove_public_key.rb +0 -21
- data/plugins/guests/funtoo/cap/change_host_name.rb +0 -17
- data/plugins/guests/linux/cap/insert_public_key.rb +0 -31
- data/plugins/guests/linux/cap/mount_nfs.rb +0 -50
- data/plugins/guests/linux/cap/nfs_client.rb +0 -11
- data/plugins/guests/linux/cap/remove_public_key.rb +0 -24
- data/plugins/guests/netbsd/cap/insert_public_key.rb +0 -21
- data/plugins/guests/netbsd/cap/mount_nfs_folder.rb +0 -17
- data/plugins/guests/netbsd/cap/remove_public_key.rb +0 -21
- data/plugins/guests/openbsd/cap/halt.rb +0 -16
- data/plugins/guests/openbsd/cap/insert_public_key.rb +0 -21
- data/plugins/guests/openbsd/cap/mount_nfs_folder.rb +0 -14
- data/plugins/guests/openbsd/cap/remove_public_key.rb +0 -21
- data/plugins/guests/ubuntu/cap/change_host_name.rb +0 -52
- data/templates/guests/fedora/network_dhcp.erb +0 -6
- data/templates/guests/fedora/network_static.erb +0 -16
- data/test/unit/plugins/guests/freebsd/cap/mount_nfs_folder_test.rb +0 -53
- data/test/unit/plugins/guests/ubuntu/cap/change_host_name_test.rb +0 -42
- data/test/unit/templates/guests/fedora/network_dhcp_test.rb +0 -21
- data/test/unit/templates/guests/fedora/network_static6_test.rb +0 -25
- data/test/unit/templates/guests/fedora/network_static_test.rb +0 -71
@@ -0,0 +1,130 @@
|
|
1
|
+
require_relative '_lib'
|
2
|
+
|
3
|
+
describe RestClient::Resource do
|
4
|
+
before do
|
5
|
+
@resource = RestClient::Resource.new('http://some/resource', :user => 'jane', :password => 'mypass', :headers => {'X-Something' => '1'})
|
6
|
+
end
|
7
|
+
|
8
|
+
context "Resource delegation" do
|
9
|
+
it "GET" do
|
10
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
11
|
+
@resource.get
|
12
|
+
end
|
13
|
+
|
14
|
+
it "HEAD" do
|
15
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :head, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
16
|
+
@resource.head
|
17
|
+
end
|
18
|
+
|
19
|
+
it "POST" do
|
20
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :post, :url => 'http://some/resource', :payload => 'abc', :headers => {:content_type => 'image/jpg', 'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
21
|
+
@resource.post 'abc', :content_type => 'image/jpg'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "PUT" do
|
25
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :put, :url => 'http://some/resource', :payload => 'abc', :headers => {:content_type => 'image/jpg', 'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
26
|
+
@resource.put 'abc', :content_type => 'image/jpg'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "PATCH" do
|
30
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :patch, :url => 'http://some/resource', :payload => 'abc', :headers => {:content_type => 'image/jpg', 'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
31
|
+
@resource.patch 'abc', :content_type => 'image/jpg'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "DELETE" do
|
35
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :delete, :url => 'http://some/resource', :headers => {'X-Something' => '1'}, :user => 'jane', :password => 'mypass')
|
36
|
+
@resource.delete
|
37
|
+
end
|
38
|
+
|
39
|
+
it "overrides resource headers" do
|
40
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {'X-Something' => '2'}, :user => 'jane', :password => 'mypass')
|
41
|
+
@resource.get 'X-Something' => '2'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can instantiate with no user/password" do
|
46
|
+
@resource = RestClient::Resource.new('http://some/resource')
|
47
|
+
end
|
48
|
+
|
49
|
+
it "is backwards compatible with previous constructor" do
|
50
|
+
@resource = RestClient::Resource.new('http://some/resource', 'user', 'pass')
|
51
|
+
expect(@resource.user).to eq 'user'
|
52
|
+
expect(@resource.password).to eq 'pass'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "concatenates urls, inserting a slash when it needs one" do
|
56
|
+
expect(@resource.concat_urls('http://example.com', 'resource')).to eq 'http://example.com/resource'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "concatenates urls, using no slash if the first url ends with a slash" do
|
60
|
+
expect(@resource.concat_urls('http://example.com/', 'resource')).to eq 'http://example.com/resource'
|
61
|
+
end
|
62
|
+
|
63
|
+
it "concatenates urls, using no slash if the second url starts with a slash" do
|
64
|
+
expect(@resource.concat_urls('http://example.com', '/resource')).to eq 'http://example.com/resource'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "concatenates even non-string urls, :posts + 1 => 'posts/1'" do
|
68
|
+
expect(@resource.concat_urls(:posts, 1)).to eq 'posts/1'
|
69
|
+
end
|
70
|
+
|
71
|
+
it "offers subresources via []" do
|
72
|
+
parent = RestClient::Resource.new('http://example.com')
|
73
|
+
expect(parent['posts'].url).to eq 'http://example.com/posts'
|
74
|
+
end
|
75
|
+
|
76
|
+
it "transports options to subresources" do
|
77
|
+
parent = RestClient::Resource.new('http://example.com', :user => 'user', :password => 'password')
|
78
|
+
expect(parent['posts'].user).to eq 'user'
|
79
|
+
expect(parent['posts'].password).to eq 'password'
|
80
|
+
end
|
81
|
+
|
82
|
+
it "passes a given block to subresources" do
|
83
|
+
block = proc {|r| r}
|
84
|
+
parent = RestClient::Resource.new('http://example.com', &block)
|
85
|
+
expect(parent['posts'].block).to eq block
|
86
|
+
end
|
87
|
+
|
88
|
+
it "the block should be overrideable" do
|
89
|
+
block1 = proc {|r| r}
|
90
|
+
block2 = proc {|r| }
|
91
|
+
parent = RestClient::Resource.new('http://example.com', &block1)
|
92
|
+
# parent['posts', &block2].block.should eq block2 # ruby 1.9 syntax
|
93
|
+
expect(parent.send(:[], 'posts', &block2).block).to eq block2
|
94
|
+
expect(parent.send(:[], 'posts', &block2).block).not_to eq block1
|
95
|
+
end
|
96
|
+
|
97
|
+
it "the block should be overrideable in ruby 1.9 syntax" do
|
98
|
+
block1 = proc {|r| r}
|
99
|
+
block2 = ->(r) {}
|
100
|
+
|
101
|
+
parent = RestClient::Resource.new('http://example.com', &block1)
|
102
|
+
expect(parent['posts', &block2].block).to eq block2
|
103
|
+
expect(parent['posts', &block2].block).not_to eq block1
|
104
|
+
end
|
105
|
+
|
106
|
+
it "prints its url with to_s" do
|
107
|
+
expect(RestClient::Resource.new('x').to_s).to eq 'x'
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'block' do
|
111
|
+
it 'can use block when creating the resource' do
|
112
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
113
|
+
resource = RestClient::Resource.new('www.example.com') { |response, request| 'foo' }
|
114
|
+
expect(resource.get).to eq 'foo'
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'can use block when executing the resource' do
|
118
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
119
|
+
resource = RestClient::Resource.new('www.example.com')
|
120
|
+
expect(resource.get { |response, request| 'foo' }).to eq 'foo'
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'execution block override resource block' do
|
124
|
+
stub_request(:get, 'www.example.com').to_return(:body => '', :status => 404)
|
125
|
+
resource = RestClient::Resource.new('www.example.com') { |response, request| 'foo' }
|
126
|
+
expect(resource.get { |response, request| 'bar' }).to eq 'bar'
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
require_relative '_lib'
|
2
|
+
|
3
|
+
describe RestClient::Response, :include_helpers do
|
4
|
+
before do
|
5
|
+
@net_http_res = double('net http response', :to_hash => {"Status" => ["200 OK"]}, :code => 200)
|
6
|
+
@example_url = 'http://example.com'
|
7
|
+
@request = request_double(url: @example_url, method: 'get')
|
8
|
+
@response = RestClient::Response.create('abc', @net_http_res, @request)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "behaves like string" do
|
12
|
+
expect(@response.to_s).to eq 'abc'
|
13
|
+
expect(@response.to_str).to eq 'abc'
|
14
|
+
|
15
|
+
expect(@response).to receive(:warn)
|
16
|
+
expect(@response.to_i).to eq 0
|
17
|
+
end
|
18
|
+
|
19
|
+
it "accepts nil strings and sets it to empty for the case of HEAD" do
|
20
|
+
expect(RestClient::Response.create(nil, @net_http_res, @request).to_s).to eq ""
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'header processing' do
|
24
|
+
it "test headers and raw headers" do
|
25
|
+
expect(@response.raw_headers["Status"][0]).to eq "200 OK"
|
26
|
+
expect(@response.headers[:status]).to eq "200 OK"
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'handles multiple headers by joining with comma' do
|
30
|
+
@net_http_res = double('net http response', :to_hash => {'My-Header' => ['foo', 'bar']}, :code => 200)
|
31
|
+
@example_url = 'http://example.com'
|
32
|
+
@request = request_double(url: @example_url, method: 'get')
|
33
|
+
@response = RestClient::Response.create('abc', @net_http_res, @request)
|
34
|
+
|
35
|
+
expect(@response.raw_headers['My-Header']).to eq ['foo', 'bar']
|
36
|
+
expect(@response.headers[:my_header]).to eq 'foo, bar'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "cookie processing" do
|
41
|
+
it "should correctly deal with one Set-Cookie header with one cookie inside" do
|
42
|
+
header_val = "main_page=main_page_no_rewrite; path=/; expires=Sat, 10-Jan-2037 15:03:14 GMT".freeze
|
43
|
+
|
44
|
+
net_http_res = double('net http response', :to_hash => {"etag" => ["\"e1ac1a2df945942ef4cac8116366baad\""], "set-cookie" => [header_val]})
|
45
|
+
response = RestClient::Response.create('abc', net_http_res, @request)
|
46
|
+
expect(response.headers[:set_cookie]).to eq [header_val]
|
47
|
+
expect(response.cookies).to eq({ "main_page" => "main_page_no_rewrite" })
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should correctly deal with multiple cookies [multiple Set-Cookie headers]" do
|
51
|
+
net_http_res = double('net http response', :to_hash => {"etag" => ["\"e1ac1a2df945942ef4cac8116366baad\""], "set-cookie" => ["main_page=main_page_no_rewrite; path=/; expires=Sat, 10-Jan-2037 15:03:14 GMT", "remember_me=; path=/; expires=Sat, 10-Jan-2037 00:00:00 GMT", "user=somebody; path=/; expires=Sat, 10-Jan-2037 00:00:00 GMT"]})
|
52
|
+
response = RestClient::Response.create('abc', net_http_res, @request)
|
53
|
+
expect(response.headers[:set_cookie]).to eq ["main_page=main_page_no_rewrite; path=/; expires=Sat, 10-Jan-2037 15:03:14 GMT", "remember_me=; path=/; expires=Sat, 10-Jan-2037 00:00:00 GMT", "user=somebody; path=/; expires=Sat, 10-Jan-2037 00:00:00 GMT"]
|
54
|
+
expect(response.cookies).to eq({
|
55
|
+
"main_page" => "main_page_no_rewrite",
|
56
|
+
"remember_me" => "",
|
57
|
+
"user" => "somebody"
|
58
|
+
})
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should correctly deal with multiple cookies [one Set-Cookie header with multiple cookies]" do
|
62
|
+
net_http_res = double('net http response', :to_hash => {"etag" => ["\"e1ac1a2df945942ef4cac8116366baad\""], "set-cookie" => ["main_page=main_page_no_rewrite; path=/; expires=Sat, 10-Jan-2037 15:03:14 GMT, remember_me=; path=/; expires=Sat, 10-Jan-2037 00:00:00 GMT, user=somebody; path=/; expires=Sat, 10-Jan-2037 00:00:00 GMT"]})
|
63
|
+
response = RestClient::Response.create('abc', net_http_res, @request)
|
64
|
+
expect(response.cookies).to eq({
|
65
|
+
"main_page" => "main_page_no_rewrite",
|
66
|
+
"remember_me" => "",
|
67
|
+
"user" => "somebody"
|
68
|
+
})
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "exceptions processing" do
|
73
|
+
it "should return itself for normal codes" do
|
74
|
+
(200..206).each do |code|
|
75
|
+
net_http_res = response_double(:code => '200')
|
76
|
+
resp = RestClient::Response.create('abc', net_http_res, @request)
|
77
|
+
resp.return!
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should throw an exception for other codes" do
|
82
|
+
RestClient::Exceptions::EXCEPTIONS_MAP.each_pair do |code, exc|
|
83
|
+
unless (200..207).include? code
|
84
|
+
net_http_res = response_double(:code => code.to_i)
|
85
|
+
resp = RestClient::Response.create('abc', net_http_res, @request)
|
86
|
+
allow(@request).to receive(:max_redirects).and_return(5)
|
87
|
+
expect { resp.return! }.to raise_error(exc)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "redirection" do
|
95
|
+
|
96
|
+
it "follows a redirection when the request is a get" do
|
97
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
98
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
99
|
+
expect(RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body).to eq 'Foo'
|
100
|
+
end
|
101
|
+
|
102
|
+
it "keeps redirection history" do
|
103
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
104
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
105
|
+
r = RestClient::Request.execute(url: 'http://some/resource', method: :get)
|
106
|
+
expect(r.body).to eq 'Foo'
|
107
|
+
expect(r.history.length).to eq 1
|
108
|
+
expect(r.history.fetch(0)).to be_a(RestClient::Response)
|
109
|
+
expect(r.history.fetch(0).code).to be 301
|
110
|
+
end
|
111
|
+
|
112
|
+
it "follows a redirection and keep the parameters" do
|
113
|
+
stub_request(:get, 'http://some/resource').with(:headers => {'Accept' => 'application/json'}, :basic_auth => ['foo', 'bar']).to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
114
|
+
stub_request(:get, 'http://new/resource').with(:headers => {'Accept' => 'application/json'}, :basic_auth => ['foo', 'bar']).to_return(:body => 'Foo')
|
115
|
+
expect(RestClient::Request.execute(:url => 'http://some/resource', :method => :get, :user => 'foo', :password => 'bar', :headers => {:accept => :json}).body).to eq 'Foo'
|
116
|
+
end
|
117
|
+
|
118
|
+
it "follows a redirection and keep the cookies" do
|
119
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Set-Cookie' => 'Foo=Bar', 'Location' => 'http://some/new_resource', })
|
120
|
+
stub_request(:get, 'http://some/new_resource').with(:headers => {'Cookie' => 'Foo=Bar'}).to_return(:body => 'Qux')
|
121
|
+
expect(RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body).to eq 'Qux'
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'respects cookie domains on redirect' do
|
125
|
+
stub_request(:get, 'http://some.example.com/').to_return(:body => '', :status => 301,
|
126
|
+
:headers => {'Set-Cookie' => 'Foo=Bar', 'Location' => 'http://new.example.com/', })
|
127
|
+
stub_request(:get, 'http://new.example.com/').with(
|
128
|
+
:headers => {'Cookie' => 'passedthrough=1'}).to_return(:body => 'Qux')
|
129
|
+
|
130
|
+
expect(RestClient::Request.execute(:url => 'http://some.example.com/', :method => :get, cookies: [HTTP::Cookie.new('passedthrough', '1', domain: 'new.example.com', path: '/')]).body).to eq 'Qux'
|
131
|
+
end
|
132
|
+
|
133
|
+
it "doesn't follow a 301 when the request is a post" do
|
134
|
+
net_http_res = response_double(:code => 301)
|
135
|
+
|
136
|
+
response = RestClient::Response.create('abc', net_http_res,
|
137
|
+
request_double(method: 'post'))
|
138
|
+
expect {
|
139
|
+
response.return!
|
140
|
+
}.to raise_error(RestClient::MovedPermanently)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "doesn't follow a 302 when the request is a post" do
|
144
|
+
net_http_res = response_double(:code => 302)
|
145
|
+
response = RestClient::Response.create('abc', net_http_res,
|
146
|
+
request_double(method: 'post'))
|
147
|
+
expect {
|
148
|
+
response.return!
|
149
|
+
}.to raise_error(RestClient::Found)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "doesn't follow a 307 when the request is a post" do
|
153
|
+
net_http_res = response_double(:code => 307)
|
154
|
+
response = RestClient::Response.create('abc', net_http_res,
|
155
|
+
request_double(method: 'post'))
|
156
|
+
expect(response).not_to receive(:follow_redirection)
|
157
|
+
expect {
|
158
|
+
response.return!
|
159
|
+
}.to raise_error(RestClient::TemporaryRedirect)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "doesn't follow a redirection when the request is a put" do
|
163
|
+
net_http_res = response_double(:code => 301)
|
164
|
+
response = RestClient::Response.create('abc', net_http_res,
|
165
|
+
request_double(method: 'put'))
|
166
|
+
expect {
|
167
|
+
response.return!
|
168
|
+
}.to raise_error(RestClient::MovedPermanently)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "follows a redirection when the request is a post and result is a 303" do
|
172
|
+
stub_request(:put, 'http://some/resource').to_return(:body => '', :status => 303, :headers => {'Location' => 'http://new/resource'})
|
173
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
174
|
+
expect(RestClient::Request.execute(:url => 'http://some/resource', :method => :put).body).to eq 'Foo'
|
175
|
+
end
|
176
|
+
|
177
|
+
it "follows a redirection when the request is a head" do
|
178
|
+
stub_request(:head, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
179
|
+
stub_request(:head, 'http://new/resource').to_return(:body => 'Foo')
|
180
|
+
expect(RestClient::Request.execute(:url => 'http://some/resource', :method => :head).body).to eq 'Foo'
|
181
|
+
end
|
182
|
+
|
183
|
+
it "handles redirects with relative paths" do
|
184
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'index'})
|
185
|
+
stub_request(:get, 'http://some/index').to_return(:body => 'Foo')
|
186
|
+
expect(RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body).to eq 'Foo'
|
187
|
+
end
|
188
|
+
|
189
|
+
it "handles redirects with relative path and query string" do
|
190
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'index?q=1'})
|
191
|
+
stub_request(:get, 'http://some/index?q=1').to_return(:body => 'Foo')
|
192
|
+
expect(RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body).to eq 'Foo'
|
193
|
+
end
|
194
|
+
|
195
|
+
it "follow a redirection when the request is a get and the response is in the 30x range" do
|
196
|
+
stub_request(:get, 'http://some/resource').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://new/resource'})
|
197
|
+
stub_request(:get, 'http://new/resource').to_return(:body => 'Foo')
|
198
|
+
expect(RestClient::Request.execute(:url => 'http://some/resource', :method => :get).body).to eq 'Foo'
|
199
|
+
end
|
200
|
+
|
201
|
+
it "follows no more than 10 redirections before raising error" do
|
202
|
+
stub_request(:get, 'http://some/redirect-1').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
203
|
+
stub_request(:get, 'http://some/redirect-2').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
204
|
+
expect {
|
205
|
+
RestClient::Request.execute(url: 'http://some/redirect-1', method: :get)
|
206
|
+
}.to raise_error(RestClient::MovedPermanently) { |ex|
|
207
|
+
ex.response.history.each {|r| expect(r).to be_a(RestClient::Response) }
|
208
|
+
expect(ex.response.history.length).to eq 10
|
209
|
+
}
|
210
|
+
expect(WebMock).to have_requested(:get, 'http://some/redirect-2').times(10)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "follows no more than max_redirects redirections, if specified" do
|
214
|
+
stub_request(:get, 'http://some/redirect-1').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
215
|
+
stub_request(:get, 'http://some/redirect-2').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/redirect-2'})
|
216
|
+
expect {
|
217
|
+
RestClient::Request.execute(url: 'http://some/redirect-1', method: :get, max_redirects: 5)
|
218
|
+
}.to raise_error(RestClient::MovedPermanently) { |ex|
|
219
|
+
expect(ex.response.history.length).to eq 5
|
220
|
+
}
|
221
|
+
expect(WebMock).to have_requested(:get, 'http://some/redirect-2').times(5)
|
222
|
+
end
|
223
|
+
|
224
|
+
it "allows for manual following of redirects" do
|
225
|
+
stub_request(:get, 'http://some/redirect-1').to_return(:body => '', :status => 301, :headers => {'Location' => 'http://some/resource'})
|
226
|
+
stub_request(:get, 'http://some/resource').to_return(:body => 'Qux', :status => 200)
|
227
|
+
|
228
|
+
begin
|
229
|
+
RestClient::Request.execute(url: 'http://some/redirect-1', method: :get, max_redirects: 0)
|
230
|
+
rescue RestClient::MovedPermanently => err
|
231
|
+
resp = err.response.follow_redirection
|
232
|
+
else
|
233
|
+
raise 'notreached'
|
234
|
+
end
|
235
|
+
|
236
|
+
expect(resp.code).to eq 200
|
237
|
+
expect(resp.body).to eq 'Qux'
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative '_lib'
|
2
|
+
|
3
|
+
describe RestClient do
|
4
|
+
describe "API" do
|
5
|
+
it "GET" do
|
6
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {})
|
7
|
+
RestClient.get('http://some/resource')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "POST" do
|
11
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :post, :url => 'http://some/resource', :payload => 'payload', :headers => {})
|
12
|
+
RestClient.post('http://some/resource', 'payload')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "PUT" do
|
16
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :put, :url => 'http://some/resource', :payload => 'payload', :headers => {})
|
17
|
+
RestClient.put('http://some/resource', 'payload')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "PATCH" do
|
21
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :patch, :url => 'http://some/resource', :payload => 'payload', :headers => {})
|
22
|
+
RestClient.patch('http://some/resource', 'payload')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "DELETE" do
|
26
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :delete, :url => 'http://some/resource', :headers => {})
|
27
|
+
RestClient.delete('http://some/resource')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "HEAD" do
|
31
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :head, :url => 'http://some/resource', :headers => {})
|
32
|
+
RestClient.head('http://some/resource')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "OPTIONS" do
|
36
|
+
expect(RestClient::Request).to receive(:execute).with(:method => :options, :url => 'http://some/resource', :headers => {})
|
37
|
+
RestClient.options('http://some/resource')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "logging" do
|
42
|
+
after do
|
43
|
+
RestClient.log = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "uses << if the log is not a string" do
|
47
|
+
log = RestClient.log = []
|
48
|
+
expect(log).to receive(:<<).with('xyz')
|
49
|
+
RestClient.log << 'xyz'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "displays the log to stdout" do
|
53
|
+
RestClient.log = 'stdout'
|
54
|
+
expect(STDOUT).to receive(:puts).with('xyz')
|
55
|
+
RestClient.log << 'xyz'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "displays the log to stderr" do
|
59
|
+
RestClient.log = 'stderr'
|
60
|
+
expect(STDERR).to receive(:puts).with('xyz')
|
61
|
+
RestClient.log << 'xyz'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "append the log to the requested filename" do
|
65
|
+
RestClient.log = '/tmp/restclient.log'
|
66
|
+
f = double('file handle')
|
67
|
+
expect(File).to receive(:open).with('/tmp/restclient.log', 'a').and_yield(f)
|
68
|
+
expect(f).to receive(:puts).with('xyz')
|
69
|
+
RestClient.log << 'xyz'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'version' do
|
74
|
+
it 'has a version ~> 2.0.0.alpha' do
|
75
|
+
ver = Gem::Version.new(RestClient.version)
|
76
|
+
expect(Gem::Requirement.new('~> 2.0.0.alpha')).to be_satisfied_by(ver)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|