diff -Nru vagrant-2.2.14+dfsg/bin/vagrant vagrant-2.2.19+dfsg/bin/vagrant --- vagrant-2.2.14+dfsg/bin/vagrant 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/bin/vagrant 2021-11-05 21:15:44.000000000 +0000 @@ -23,9 +23,9 @@ argv = argv.slice(0, idx) end +require_relative "../lib/vagrant/version" # Fast path the version of Vagrant if argv.include?("-v") || argv.include?("--version") - require_relative "../lib/vagrant/version" puts "Vagrant #{Vagrant::VERSION}" exit 0 end @@ -82,6 +82,29 @@ $stdout.sync = true $stderr.sync = true +# Before we start activate all our dependencies +# so we can provide correct resolutions later +builtin_specs = [] + +vagrant_spec = Gem::Specification.find_all_by_name("vagrant").detect do |spec| + spec.version == Gem::Version.new(Vagrant::VERSION) +end + +dep_activator = proc do |spec| + spec.runtime_dependencies.each do |dep| + gem(dep.name, *dep.requirement.as_list) + dep_spec = Gem::Specification.find_all_by_name(dep.name).detect(&:activated?) + if dep_spec + builtin_specs << dep_spec + dep_activator.call(dep_spec) + end + end +end + +if vagrant_spec + dep_activator.call(vagrant_spec) +end + env = nil begin require 'log4r' @@ -91,6 +114,9 @@ require 'vagrant/util/platform' require 'vagrant/util/experimental' + # Set our list of builtin specs + Vagrant::Bundler.instance.builtin_specs = builtin_specs + # Schedule the cleanup of things at_exit(&Vagrant::Bundler.instance.method(:deinit)) @@ -225,7 +251,7 @@ if env opts = { prefix: false } - env.ui.error e.message, opts if e.message + env.ui.error(e.message, **opts) if e.message env.ui.machine("error-exit", e.class.to_s, e.message.to_s) else $stderr.puts "Vagrant failed to initialize at a very early stage:\n\n" diff -Nru vagrant-2.2.14+dfsg/CHANGELOG.md vagrant-2.2.19+dfsg/CHANGELOG.md --- vagrant-2.2.14+dfsg/CHANGELOG.md 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/CHANGELOG.md 2021-11-05 21:15:44.000000000 +0000 @@ -1,8 +1,105 @@ +## 2.2.19 (November 5, 2021) + +IMPROVEMENTS: + +- guest/suse: Add fallback shutdown for versions without systemd [GH-12489] +- provider/virtualbox: Validate VirtualBox hostonly network range [GH-12564] + +BUG FIXES + +- guest/atomic: Update detection to prevent matching on non-atomic guests [GH-12575] +- guest/coreos: Fix configure network capability [GH-12575] +- guest/windows: Fix directory creation with rsync [GH-11880] +- host/windows: Properly handle spaces in path to SSH key [GH-12398] +- provisioner/chef: Update install checks [GH-12555] + +## 2.2.18 (July 27, 2021) + +BUG FIXES: + +- core: Fix of plugin manager kwargs [GH-12452] +- providers/docker: Pass in docker command opts as a map [GH-12449] +- providers/hyperv: Fix network address detection [GH-12472] + +## 2.2.17 (July 7, 2021) + +FEATURES: + +- guest/rocky: Add guest support for Rocky Linux [GH-12440] + +IMPROVEMENTS: + +- command/package: Add --info flag to package command [GH-12304] +- guest/debian: Retry network setup on debain [GH-12421] +- guest/suse: Use systemctl poweroff in the background instead of shutdown [GH-12439] +- guest/windows: Get powershell path in %WINDIR%/System32 [GH-12436] +- host/windows: Check Domain and Application Directory contexts for credentials when validating SMB creds [GH-12428] +- providers/hyper-v: Fix IP detection when multiple devices are attached [GH-12232] +- provisioner/ansible: Detects new versions of ansible-4.0.0+ [GH-12391] +- provisioner/ansible: Strip whitespace from ansible version [GH-12420] +- provisioner/salt: Always use upstream Salt bootstrap script on Windows [GH-12127] +- provisioner/salt: Use more conservative TLS settings to work on older .NET versions [GH-12413] +- provisioner/shell: Buffer output to display full lines [GH-12437] +- vagrant: Updates to support Ruby 3.0 [GH-12427] + +BUG FIXES: + +- command/cloud: Fix authentication middleware to prevent breaking local paths [GH-12419] +- communicator/ssh: Fix net-ssh patches for RSA signatures [GH-12415] +- core: Add box directly with authed urls [GH-12278] + +## 2.2.16 (April 29, 2021) + +IMPROVEMENTS: + +- guest/linux: Detect in process shutdown in reboot capability [GH-12302] +- util/powershell: Support `pwsh` executable in new versions of powershell [GH-12335] + +BUG FIXES: + +- communicator/ssh: Properly handle authentication with RSA keys [GH-12298] +- guest/fedora: Import guest detection module [GH-12275] +- guest/linux: Fix SMB folder mount name capability call [GH-12281] +- provider/docker: Properly handle updated buildkit build output [GH-12300] + +## 2.2.15 (March 30, 2021) + +IMPROVEMENTS: + +- command/cloud: Remove access token URL parameter by default [GH-12234] +- command/cloud: Add VAGRANT_SERVER_ACCESS_TOKEN_BY_URL to revert access token behavior [GH-12252] +- core: Bump vagrant_cloud dependency to 3.0.3 [GH-12200] +- core: Bump listen gem version and remove ruby_dep [GH-12148] +- core: Bump vagrant_cloud dependency to 3.0.4 [GH-12242] +- core/bundler: Update resolution handling when outside of installer and bundler [GH-12225] +- core/plugin: Provide friendlier error messages on install fail when possible [GH-12225] +- guest/openwrt: Add support for OpenWrt guests [GH-11791] +- guest/freebsd: FreeBSD updated ansible to py37-ansible [GH-12201] +- provider/virtualbox: Get default dhcp ip from a matching host ip [GH-12211] +- util/downloader: Prevent redirect notification for default store [GH-12235] + +BUG FIXES: + +- command/cloud: Automatically disable direct uploads when file is too large [GH-12250] +- core: Make shell script for loop shell agnostic [GH-12205] +- core: Raise error if downloading box metadata fails [GH-12189] +- core: Apply download options to metadata requests [GH-12177] +- core: Don't try to find "" by prefix in the machine index [GH-12188] +- core: Don't count not created machines as declined when destroying [GH-12186] +- core: Bump bcrypt_pbkdf version [GH-12216] +- core: Remove all space from checksums [GH-12168] +- core/bundler: Do not include default gems as pinned constraints [GH-12253] +- core/synced_folders: Extract os friendly mount name for vbox shared folders [GH-12184] +- guest/alpine: Check if interface exists before shutting it down [GH-12181] +- guest/nixos: Fix network config for recent NixOS releases [GH-12152] +- guest/fedora: Detect fedora using os-releases id [GH-12230] + ## 2.2.14 (November 20, 2020) IMPROVEMENTS: - host/windows: Update filesystem type matching on WSL2 [GH-12056] +- provisioner/salt: Modernize Salt bootstrap script [GH-12135] BUG FIXES: @@ -3363,6 +3460,10 @@ format, but this is _opt-in_. Old Vagrantfile format continues to be supported, as promised. To use the new features that will be introduced throughout the 1.x series, you'll have to upgrade at some point. + - The .vagrant file is no longer supported and has been replaced by + a .vagrant directory. Running vagrant will automatically upgrade + to the new style directory format, after which old versions of + Vagrant will not be able to see or control your VM. FEATURES: diff -Nru vagrant-2.2.14+dfsg/.ci/load-ci.sh vagrant-2.2.19+dfsg/.ci/load-ci.sh --- vagrant-2.2.14+dfsg/.ci/load-ci.sh 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.ci/load-ci.sh 2021-11-05 21:15:44.000000000 +0000 @@ -13,6 +13,36 @@ exit 1 fi + # Validate that we have the jq tool available + if ! command -v jq > /dev/null 2>&1; then + echo "⚠ ERROR: Missing required jq executable ⚠" + exit 1 + fi + + # If we have a role defined, assume it so we can get access to files + if [ "${AWS_ASSUME_ROLE_ARN}" != "" ] && [ "${AWS_SESSION_TOKEN}" = "" ]; then + if output="$(aws sts assume-role --role-arn "${AWS_ASSUME_ROLE_ARN}" --role-session-name "CI-initializer")"; then + export CORE_AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" + export CORE_AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" + id="$(printf '%s' "${output}" | jq -r .Credentials.AccessKeyId)" || failed=1 + key="$(printf '%s' "${output}" | jq -r .Credentials.SecretAccessKey)" || failed=1 + token="$(printf '%s' "${output}" | jq -r .Credentials.SessionToken)" || failed=1 + expire="$(printf '%s' "${output}" | jq -r .Credentials.Expiration)" || failed=1 + if [ "${failed}" = "1" ]; then + echo "🛑 ERROR: Failed to extract role credentials 🛑" + exit 1 + fi + export AWS_ACCESS_KEY_ID="${id}" + export AWS_SECRET_ACCESS_KEY="${key}" + export AWS_SESSION_TOKEN="${token}" + export AWS_SESSION_EXPIRATION="${expire}" + else + echo "⛔ ERROR: Failed to assume configured AWS role ⛔" + exit 1 + fi + fi + + # Create a local directory to stash our stuff in if ! mkdir -p "${ldir}"; then echo "⛔ ERROR: Failed to create utility file directory ⛔" diff -Nru vagrant-2.2.14+dfsg/.ci/spec/create-hosts.sh vagrant-2.2.19+dfsg/.ci/spec/create-hosts.sh --- vagrant-2.2.14+dfsg/.ci/spec/create-hosts.sh 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.ci/spec/create-hosts.sh 2021-11-05 21:15:44.000000000 +0000 @@ -39,7 +39,7 @@ echo "Creating vagrant spec guests..." wrap_stream packet-exec run -upload -- "vagrant up --no-provision --provider vmware_desktop" \ - "Vagrant Blackbox host creation command failed" + "Vagrant Acceptance host creation command failed" echo "Finished bringing up vagrant spec guests" diff -Nru vagrant-2.2.14+dfsg/.ci/spec/create-packet.sh vagrant-2.2.19+dfsg/.ci/spec/create-packet.sh --- vagrant-2.2.14+dfsg/.ci/spec/create-packet.sh 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.ci/spec/create-packet.sh 2021-11-05 21:15:44.000000000 +0000 @@ -1,5 +1,7 @@ #!/usr/bin/env bash +export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad2,dfw2,dfw1,ny5,ny7,ewr1,la4,lax1,lax2,tr2,ch3,ord1,ord4}" + csource="${BASH_SOURCE[0]}" while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done root="$( cd -P "$( dirname "$csource" )/../../" && pwd )" diff -Nru vagrant-2.2.14+dfsg/.ci/spec/run-test.sh vagrant-2.2.19+dfsg/.ci/spec/run-test.sh --- vagrant-2.2.14+dfsg/.ci/spec/run-test.sh 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.ci/spec/run-test.sh 2021-11-05 21:15:44.000000000 +0000 @@ -27,6 +27,6 @@ echo "Running vagrant spec tests..." # Need to make memory customizable for windows hosts wrap_stream packet-exec run "vagrant provision" \ - "Vagrant Blackbox testing command failed" + "Vagrant Acceptance testing command failed" echo "Finished vagrant spec tests" diff -Nru vagrant-2.2.14+dfsg/.ci/sync.sh vagrant-2.2.19+dfsg/.ci/sync.sh --- vagrant-2.2.14+dfsg/.ci/sync.sh 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.ci/sync.sh 2021-11-05 21:15:44.000000000 +0000 @@ -11,11 +11,14 @@ pushd "${root}" > "${output}" if [ "${repo_name}" = "vagrant" ]; then - remote_repository="hashicorp/vagrant-blackbox" + remote_repository="hashicorp/vagrant-acceptance" else fail "This repository is not configured to sync vagrant to mirror repository" fi +wrap git config pull.rebase false \ + "Failed to configure git pull strategy" + echo "Adding remote mirror repository '${remote_repository}'..." wrap git remote add mirror "https://${HASHIBOT_USERNAME}:${HASHIBOT_TOKEN}@github.com/${remote_repository}" \ "Failed to add mirror '${remote_repository}' for sync" diff -Nru vagrant-2.2.14+dfsg/.circleci/config.yml vagrant-2.2.19+dfsg/.circleci/config.yml --- vagrant-2.2.14+dfsg/.circleci/config.yml 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.circleci/config.yml 2021-11-05 21:15:44.000000000 +0000 @@ -24,7 +24,7 @@ fi algolia-index: docker: - - image: node:12 + - image: node:14 steps: - checkout - run: diff -Nru vagrant-2.2.14+dfsg/contrib/README.md vagrant-2.2.19+dfsg/contrib/README.md --- vagrant-2.2.14+dfsg/contrib/README.md 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/contrib/README.md 2021-11-05 21:15:44.000000000 +0000 @@ -14,4 +14,4 @@ starting machines. * `vim` - Contains a `.vim` file for enabling Ruby syntax highlighting for `Vagrantfile`s in `vim`. - * `zsh` - Contains a zsh script for improving autocompletion with zsh. +* `zsh` - Contains a zsh script for improving autocompletion with zsh. diff -Nru vagrant-2.2.14+dfsg/contrib/zsh/generate_zsh_completion.rb vagrant-2.2.19+dfsg/contrib/zsh/generate_zsh_completion.rb --- vagrant-2.2.14+dfsg/contrib/zsh/generate_zsh_completion.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/contrib/zsh/generate_zsh_completion.rb 2021-11-05 21:15:44.000000000 +0000 @@ -121,11 +121,11 @@ return commands, flags_def, case_string end -def format_script(root_command, subcommands, funciton_name) +def format_script(root_command, subcommands, function_name) top_level_commands, top_level_args, state_case = get_top_level_commands(root_command, subcommands) script = """ -function #{funciton_name} () { +function #{function_name} () { #{top_level_commands} diff -Nru vagrant-2.2.14+dfsg/debian/changelog vagrant-2.2.19+dfsg/debian/changelog --- vagrant-2.2.14+dfsg/debian/changelog 2021-05-29 22:43:54.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/changelog 2021-11-21 02:37:55.000000000 +0000 @@ -1,3 +1,27 @@ +vagrant (2.2.19+dfsg-1ubuntu1) jammy; urgency=medium + + * Merge from Debian unstable. Remaining changes: + - Drop integration-test DEP-8 test as it tries to download a vagrant + box from the internet. + + -- Logan Rosen Sat, 20 Nov 2021 21:37:55 -0500 + +vagrant (2.2.19+dfsg-1) unstable; urgency=medium + + * New upstream version 2.2.19+dfsg + - Passes tests against ruby3.0 with ruby-rspec >= 3.10 (Closes: #996529) + * debian/upstream/metadata: correct URLs + * debian/control: refresh build dependencies + * Bump Standards-Version to 4.6.0; no changes needed + * Refresh patches + * Refresh packaging files from dh-make-ruby + * debian/rules: replace whitelist/blacklist with include/exclude + * System-side installed plugins: cope with upstream changes + * autopkgtest: integration-test: add missing dependency on dnsmaq + * autopkgtest: integration-test: add missing dependency on sudo + + -- Antonio Terceiro Mon, 15 Nov 2021 09:10:33 -0300 + vagrant (2.2.14+dfsg-1ubuntu1) impish; urgency=medium * Merge from Debian unstable. Remaining changes: diff -Nru vagrant-2.2.14+dfsg/debian/control vagrant-2.2.19+dfsg/debian/control --- vagrant-2.2.14+dfsg/debian/control 2021-02-07 21:54:32.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/control 2021-11-15 16:27:24.000000000 +0000 @@ -6,28 +6,29 @@ Uploaders: Antonio Terceiro , Laurent Bigonville Build-Depends: bash-completion, - debhelper-compat (= 12), + debhelper-compat (= 13), curl, - gem2deb (>= 1), + gem2deb (>= 1.6), rake, ruby, - ruby-bcrypt-pbkdf (>= 1.0.0), - ruby-childprocess (>= 4.0.0), + ruby-bcrypt-pbkdf (>= 1.1), + ruby-childprocess (>= 4.1.0), ruby-ed25519 (>= 1.2.4), ruby-erubi, ruby-i18n (>= 1.8), - ruby-listen (>= 3.1.5), + ruby-listen (>= 3.6), ruby-log4r (>= 1.1.9), ruby-mime-types (>= 3.3), - ruby-net-scp (>= 1.2.0), + ruby-net-scp (>= 3.0.0), ruby-net-sftp (>= 3.0), ruby-net-ssh (>= 6.1.0), - ruby-rspec, + ruby-rspec (>= 3.10), ruby-rspec-its, - ruby-vagrant-cloud (>= 3.0), + ruby-rexml (>= 3.2), + ruby-vagrant-cloud (>= 3.0.5), ruby-webmock, ruby-zip (>= 2.0) -Standards-Version: 4.5.0 +Standards-Version: 4.6.0 Vcs-Git: https://salsa.debian.org/ruby-team/vagrant.git Vcs-Browser: https://salsa.debian.org/ruby-team/vagrant Homepage: https://www.vagrantup.com diff -Nru vagrant-2.2.14+dfsg/debian/patches/0001-bin-vagrant-silence-warning-about-installer.patch vagrant-2.2.19+dfsg/debian/patches/0001-bin-vagrant-silence-warning-about-installer.patch --- vagrant-2.2.14+dfsg/debian/patches/0001-bin-vagrant-silence-warning-about-installer.patch 2021-02-07 21:54:32.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/patches/0001-bin-vagrant-silence-warning-about-installer.patch 2021-11-15 16:27:24.000000000 +0000 @@ -7,10 +7,10 @@ 1 file changed, 5 deletions(-) diff --git a/bin/vagrant b/bin/vagrant -index ba7e400..077639f 100755 +index b539d34..571db19 100755 --- a/bin/vagrant +++ b/bin/vagrant -@@ -178,11 +178,6 @@ begin +@@ -204,11 +204,6 @@ begin end end diff -Nru vagrant-2.2.14+dfsg/debian/patches/0002-Use-a-private-temporary-dir.patch vagrant-2.2.19+dfsg/debian/patches/0002-Use-a-private-temporary-dir.patch --- vagrant-2.2.14+dfsg/debian/patches/0002-Use-a-private-temporary-dir.patch 2021-02-07 21:54:32.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/patches/0002-Use-a-private-temporary-dir.patch 2021-11-15 16:27:24.000000000 +0000 @@ -1,14 +1,16 @@ From: Antonio Terceiro Date: Wed, 22 Oct 2014 09:40:14 -0200 -Subject: Use a private temporary dir +Subject: Use a private temporary directory that is cleanup up on exit -Without this vagrant will clutter $TMPDIR with dozens of even hundreds +This avoids vagrant from cluttering $TMPDIR with dozens of even hundreds of temporary files (~4 per vagrant invocation). --- lib/vagrant/box.rb | 3 ++- lib/vagrant/util.rb | 1 + + lib/vagrant/util/caps.rb | 2 +- + lib/vagrant/util/platform.rb | 2 +- lib/vagrant/util/tempfile.rb | 39 +++++++++++++++++++++++++++++++++++++++ - 3 files changed, 42 insertions(+), 1 deletion(-) + 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 lib/vagrant/util/tempfile.rb diff --git a/lib/vagrant/box.rb b/lib/vagrant/box.rb @@ -33,17 +35,43 @@ url = @metadata_url diff --git a/lib/vagrant/util.rb b/lib/vagrant/util.rb -index f8be2ba..35662b5 100644 +index c135dac..5008858 100644 --- a/lib/vagrant/util.rb +++ b/lib/vagrant/util.rb -@@ -16,6 +16,7 @@ module Vagrant - autoload :SafeExec, 'vagrant/util/safe_exec' +@@ -46,6 +46,7 @@ module Vagrant autoload :SilenceWarnings, 'vagrant/util/silence_warnings' + autoload :SSH, 'vagrant/util/ssh' autoload :StackedProcRunner, 'vagrant/util/stacked_proc_runner' + autoload :Tempfile, 'vagrant/util/tempfile' autoload :StringBlockEditor, 'vagrant/util/string_block_editor' autoload :Subprocess, 'vagrant/util/subprocess' autoload :TemplateRenderer, 'vagrant/util/template_renderer' +diff --git a/lib/vagrant/util/caps.rb b/lib/vagrant/util/caps.rb +index 310add3..55afc49 100644 +--- a/lib/vagrant/util/caps.rb ++++ b/lib/vagrant/util/caps.rb +@@ -28,7 +28,7 @@ module Vagrant + + def ensure_output_iso(file_destination) + if file_destination.nil? +- tmpfile = Tempfile.new(["vagrant", ".iso"]) ++ tmpfile = Util::Tempfile.new(["vagrant", ".iso"]) + file_destination = Pathname.new(tmpfile.path) + tmpfile.close + tmpfile.unlink +diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb +index c8658e1..0421c70 100644 +--- a/lib/vagrant/util/platform.rb ++++ b/lib/vagrant/util/platform.rb +@@ -356,7 +356,7 @@ module Vagrant + + if wsl? + # Mark our filesystem with a temporary file having an unique name. +- marker = Tempfile.new(Time.now.to_i.to_s) ++ marker = Util::Tempfile.new(Time.now.to_i.to_s) + logger = Log4r::Logger.new("vagrant::util::platform::wsl") + + # Check for lxrun installation first diff --git a/lib/vagrant/util/tempfile.rb b/lib/vagrant/util/tempfile.rb new file mode 100644 index 0000000..0cbbb53 diff -Nru vagrant-2.2.14+dfsg/debian/patches/0004-Support-system-installed-plugins.patch vagrant-2.2.19+dfsg/debian/patches/0004-Support-system-installed-plugins.patch --- vagrant-2.2.14+dfsg/debian/patches/0004-Support-system-installed-plugins.patch 2021-02-07 21:54:32.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/patches/0004-Support-system-installed-plugins.patch 2021-11-15 16:27:24.000000000 +0000 @@ -16,12 +16,27 @@ } } --- + lib/vagrant/bundler.rb | 2 +- lib/vagrant/plugin/manager.rb | 4 ++-- lib/vagrant/plugin/state_file.rb | 22 +++++++++++++++++++++- - 2 files changed, 23 insertions(+), 3 deletions(-) + lib/vagrant/shared_helpers.rb | 8 ++++++++ + 4 files changed, 32 insertions(+), 4 deletions(-) +diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb +index eb2caab..f29b769 100644 +--- a/lib/vagrant/bundler.rb ++++ b/lib/vagrant/bundler.rb +@@ -660,7 +660,7 @@ module Vagrant + spec_dir = Gem::Specification.default_specifications_dir + end + directories = [spec_dir] +- if Vagrant.in_bundler? ++ if Vagrant.in_bundler? || Vagrant.in_debian_package? + Gem::Specification.find_all{true}.each do |spec| + list[spec.full_name] = spec + end diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb -index 9058e68..2772131 100644 +index b73f07f..a9e5f28 100644 --- a/lib/vagrant/plugin/manager.rb +++ b/lib/vagrant/plugin/manager.rb @@ -18,7 +18,7 @@ module Vagrant @@ -90,3 +105,22 @@ end protected +diff --git a/lib/vagrant/shared_helpers.rb b/lib/vagrant/shared_helpers.rb +index f14dbe0..54d90ae 100644 +--- a/lib/vagrant/shared_helpers.rb ++++ b/lib/vagrant/shared_helpers.rb +@@ -43,6 +43,14 @@ module Vagrant + !defined?(::Bundler).nil? + end + ++ # This returns a true/false if we are running from a Debian package ++ # ++ # @return [Boolean] ++ def self.in_debian_package? ++ # FIXME write a proper check if this ever goes upstream ++ true ++ end ++ + # Returns the path to the embedded directory of the Vagrant installer, + # if there is one (if we're running in an installer). + # diff -Nru vagrant-2.2.14+dfsg/debian/patches/0005-Relax-dependency-resolution.patch vagrant-2.2.19+dfsg/debian/patches/0005-Relax-dependency-resolution.patch --- vagrant-2.2.14+dfsg/debian/patches/0005-Relax-dependency-resolution.patch 2021-02-07 21:54:32.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/patches/0005-Relax-dependency-resolution.patch 2021-11-15 16:27:24.000000000 +0000 @@ -4,8 +4,8 @@ --- Gemfile | 6 ------ - vagrant.gemspec | 50 ++++++++++++++++++-------------------------------- - 2 files changed, 18 insertions(+), 38 deletions(-) + vagrant.gemspec | 46 +++++++++++++++++++--------------------------- + 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/Gemfile b/Gemfile index 565ca79..b4e2a20 100644 @@ -22,15 +22,15 @@ - gem 'vagrant-spec', git: "https://github.com/hashicorp/vagrant-spec.git", branch: :main -end diff --git a/vagrant.gemspec b/vagrant.gemspec -index a452e2b..e682c6c 100644 +index 992b48f..a715e77 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec -@@ -15,39 +15,25 @@ Gem::Specification.new do |s| - s.required_ruby_version = "~> 2.5", "< 2.8" +@@ -15,34 +15,26 @@ Gem::Specification.new do |s| + s.required_ruby_version = ">= 2.6", "< 3.1" s.required_rubygems_version = ">= 1.3.6" -- s.add_dependency "bcrypt_pbkdf", "~> 1.0.0" -- s.add_dependency "childprocess", "~> 4.0.0" +- s.add_dependency "bcrypt_pbkdf", "~> 1.1" +- s.add_dependency "childprocess", "~> 4.1.0" - s.add_dependency "ed25519", "~> 1.2.4" + ######################################################################## + # On Debian, it is not viable to lock down much of the dependencies because @@ -44,33 +44,28 @@ s.add_dependency "erubi" - s.add_dependency "hashicorp-checkpoint", "~> 0.1.5" - s.add_dependency "i18n", "~> 1.8" -- s.add_dependency "listen", "~> 3.1" +- s.add_dependency "listen", "~> 3.6" - s.add_dependency "log4r", "~> 1.1.9", "< 1.1.11" - s.add_dependency "mime-types", "~> 3.3" -- s.add_dependency "net-ssh", ">= 6.2.0.rc1", "< 7" +- s.add_dependency "net-ssh", ">= 6.1.0", "< 6.2" - s.add_dependency "net-sftp", "~> 3.0" -- s.add_dependency "net-scp", "~> 1.2.0" +- s.add_dependency "net-scp", "~> 3.0.0" - s.add_dependency "rb-kqueue", "~> 0.2.0" +- s.add_dependency "rexml", "~> 3.2" - s.add_dependency "rubyzip", "~> 2.0" -- s.add_dependency "vagrant_cloud", "~> 3.0.2" +- s.add_dependency "vagrant_cloud", "~> 3.0.5" - s.add_dependency "wdm", "~> 0.1.0" - s.add_dependency "winrm", ">= 2.3.4", "< 3.0" - s.add_dependency "winrm-elevated", ">= 1.2.1", "< 2.0" - s.add_dependency "winrm-fs", ">= 1.3.4", "< 2.0" - -- # NOTE: The ruby_dep gem is an implicit dependency from the listen gem. Later versions -- # of the ruby_dep gem impose an aggressive constraint on the required ruby version (>= 2.2.5). -- # Explicit constraint is defined to provide required dependency to listen without imposing -- # tighter restrictions on valid ruby versions -- s.add_dependency "ruby_dep", "<= 1.3.1" -- - # Constraint rake to properly handle deprecated method usage - # from within rspec -- s.add_development_dependency "rake", "~> 12.3.3" -- s.add_development_dependency "rspec", "~> 3.5.0" +- s.add_development_dependency "rake", "~> 13.0" +- s.add_development_dependency "rspec", "~> 3.10.0" - s.add_development_dependency "rspec-its", "~> 1.3.0" -- s.add_development_dependency "webmock", "~> 2.3.1" - s.add_development_dependency "fake_ftp", "~> 0.1.1" +- s.add_development_dependency "webrick", "~> 1.7.0" + s.add_dependency "i18n" + s.add_dependency "listen" + s.add_dependency "log4r" @@ -78,6 +73,7 @@ + s.add_dependency "net-ssh" + s.add_dependency "net-sftp" + s.add_dependency "net-scp" ++ s.add_dependency "rexml" + s.add_dependency "rubyzip" + s.add_dependency "vagrant_cloud" diff -Nru vagrant-2.2.14+dfsg/debian/patches/0005-Skip-tests-that-require-winrm.patch vagrant-2.2.19+dfsg/debian/patches/0005-Skip-tests-that-require-winrm.patch --- vagrant-2.2.14+dfsg/debian/patches/0005-Skip-tests-that-require-winrm.patch 2021-02-07 17:53:25.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/patches/0005-Skip-tests-that-require-winrm.patch 2021-11-15 16:27:24.000000000 +0000 @@ -8,10 +8,10 @@ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/unit/plugins/provisioners/ansible/provisioner_test.rb b/test/unit/plugins/provisioners/ansible/provisioner_test.rb -index 5d85272..1962d37 100644 +index 180f268..f3baf72 100644 --- a/test/unit/plugins/provisioners/ansible/provisioner_test.rb +++ b/test/unit/plugins/provisioners/ansible/provisioner_test.rb -@@ -670,7 +670,8 @@ VF +@@ -671,7 +671,8 @@ VF end end @@ -22,7 +22,7 @@ let(:iso_winrm_env) do env = isolated_environment diff --git a/test/unit/vagrant/machine_test.rb b/test/unit/vagrant/machine_test.rb -index 913dc5e..3f31d2d 100644 +index 8f42207..4e27e0a 100644 --- a/test/unit/vagrant/machine_test.rb +++ b/test/unit/vagrant/machine_test.rb @@ -114,7 +114,7 @@ describe Vagrant::Machine do @@ -34,7 +34,7 @@ config.vm.communicator = :winrm klass = Vagrant.plugin("2").manager.communicators[:winrm] -@@ -452,7 +452,7 @@ describe Vagrant::Machine do +@@ -451,7 +451,7 @@ describe Vagrant::Machine do to be_kind_of(VagrantPlugins::CommunicatorSSH::Communicator) end diff -Nru vagrant-2.2.14+dfsg/debian/patches/0006-tests-fix-tests-to-work-against-installed-package.patch vagrant-2.2.19+dfsg/debian/patches/0006-tests-fix-tests-to-work-against-installed-package.patch --- vagrant-2.2.14+dfsg/debian/patches/0006-tests-fix-tests-to-work-against-installed-package.patch 2021-02-07 17:53:25.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/patches/0006-tests-fix-tests-to-work-against-installed-package.patch 2021-11-15 16:27:24.000000000 +0000 @@ -10,7 +10,7 @@ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/unit/plugins/commands/init/command_test.rb b/test/unit/plugins/commands/init/command_test.rb -index 34da3cd..a60f45f 100644 +index 6bb86fa..6319a81 100644 --- a/test/unit/plugins/commands/init/command_test.rb +++ b/test/unit/plugins/commands/init/command_test.rb @@ -1,6 +1,8 @@ @@ -22,7 +22,7 @@ describe VagrantPlugins::CommandInit::Command do include_context "unit" include_context "command plugin helpers" -@@ -44,13 +46,13 @@ describe VagrantPlugins::CommandInit::Command do +@@ -43,13 +45,13 @@ describe VagrantPlugins::CommandInit::Command do end it "creates a custom Vagrantfile using an absolute template path" do @@ -38,7 +38,7 @@ contents = File.read(vagrantfile_path) expect(contents).to match(/config.vm.hostname = "vagrant.dev"/) end -@@ -72,7 +74,7 @@ describe VagrantPlugins::CommandInit::Command do +@@ -71,7 +73,7 @@ describe VagrantPlugins::CommandInit::Command do end it "ignores the -m option when using a provided template" do @@ -48,7 +48,7 @@ expect(contents).to match(/config.vm.hostname = "vagrant.dev"/) end diff --git a/test/unit/plugins/hosts/linux/cap/nfs_test.rb b/test/unit/plugins/hosts/linux/cap/nfs_test.rb -index b9ded2c..88c81ff 100644 +index ab94f74..40eec36 100644 --- a/test/unit/plugins/hosts/linux/cap/nfs_test.rb +++ b/test/unit/plugins/hosts/linux/cap/nfs_test.rb @@ -1,6 +1,6 @@ @@ -72,7 +72,7 @@ describe VagrantPlugins::HostVoid::Cap::NFS do diff --git a/test/unit/plugins/providers/virtualbox/synced_folder_test.rb b/test/unit/plugins/providers/virtualbox/synced_folder_test.rb -index 28e8d95..760b2a2 100644 +index 2e9b159..57b68a9 100644 --- a/test/unit/plugins/providers/virtualbox/synced_folder_test.rb +++ b/test/unit/plugins/providers/virtualbox/synced_folder_test.rb @@ -1,5 +1,5 @@ diff -Nru vagrant-2.2.14+dfsg/debian/rules vagrant-2.2.19+dfsg/debian/rules --- vagrant-2.2.14+dfsg/debian/rules 2021-02-07 21:54:32.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/rules 2021-11-15 16:27:24.000000000 +0000 @@ -1,9 +1,9 @@ #!/usr/bin/make -f -export DH_RUBY_GEM_INSTALL_WHITELIST_APPEND = version.txt -export DH_RUBY_GEM_INSTALL_BLACKLIST_APPEND = contrib/* scripts/* -export DH_RUBY = --gem-install export GEM2DEB_TEST_RUNNER = --check-dependencies +export DH_RUBY = --gem-install +export DH_RUBY_GEM_INSTALL_INCLUDE = version.txt +export DH_RUBY_GEM_INSTALL_EXCLUDE = contrib/* scripts/* %: dh $@ --buildsystem=ruby --with ruby --with bash_completion diff -Nru vagrant-2.2.14+dfsg/debian/upstream/metadata vagrant-2.2.19+dfsg/debian/upstream/metadata --- vagrant-2.2.14+dfsg/debian/upstream/metadata 2021-02-07 21:54:32.000000000 +0000 +++ vagrant-2.2.19+dfsg/debian/upstream/metadata 2021-11-15 16:27:24.000000000 +0000 @@ -1,7 +1,7 @@ --- Archive: GitHub -Bug-Database: https://www.vagrantup.com/issues -Bug-Submit: https://www.vagrantup.com/issues -Changelog: https://www.vagrantup.com/tags -Repository: https://www.vagrantup.com.git -Repository-Browse: https://www.vagrantup.com +Bug-Database: https://github.com/hashicorp/vagrant/issues +Bug-Submit: https://github.com/hashicorp/vagrant/issues/new +Changelog: https://github.com/hashicorp/vagrant/blob/main/CHANGELOG.md +Repository: https://github.com/hashicorp/vagrant.git +Repository-Browse: https://github.com/hashicorp/vagrant diff -Nru vagrant-2.2.14+dfsg/.github/CONTRIBUTING.md vagrant-2.2.19+dfsg/.github/CONTRIBUTING.md --- vagrant-2.2.14+dfsg/.github/CONTRIBUTING.md 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.github/CONTRIBUTING.md 2021-11-05 21:15:44.000000000 +0000 @@ -34,6 +34,8 @@ ### Setup a development installation of Vagrant +*A Vagrantfile is provided that should take care setting up a VM for running the rspec tests.* If you only need to run those tests and don't also want to run a development version of Vagrant from a host machine then it's recommended to use that. + There are a few prerequisites for setting up a development environment with Vagrant. Ensure you have the following installed on your machine: * git diff -Nru vagrant-2.2.14+dfsg/.github/workflows/build.yml vagrant-2.2.19+dfsg/.github/workflows/build.yml --- vagrant-2.2.14+dfsg/.github/workflows/build.yml 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.github/workflows/build.yml 2021-11-05 21:15:44.000000000 +0000 @@ -15,7 +15,7 @@ - name: Code Checkout uses: actions/checkout@v1 - name: Set Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: '2.6' - name: Build RubyGem @@ -32,6 +32,7 @@ ASSETS_SHORTTERM_PREFIX: est AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ASSUME_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} HASHIBOT_EMAIL: ${{ secrets.HASHIBOT_EMAIL }} HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }} HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }} diff -Nru vagrant-2.2.14+dfsg/.github/workflows/code.yml vagrant-2.2.19+dfsg/.github/workflows/code.yml --- vagrant-2.2.14+dfsg/.github/workflows/code.yml 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.github/workflows/code.yml 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ - 'spec-test-*' jobs: - sync-blackbox: + sync-acceptance: if: github.repository == 'hashicorp/vagrant' runs-on: ubuntu-18.04 steps: @@ -15,15 +15,16 @@ persist-credentials: false fetch-depth: 0 - name: Set Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: '2.6' - - name: Sync Blackbox Testing Repository + - name: Sync Acceptance Testing Repository run: ./.ci/sync.sh working-directory: ${{github.workspace}} env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ASSUME_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }} HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }} SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff -Nru vagrant-2.2.14+dfsg/.github/workflows/lock.yml vagrant-2.2.19+dfsg/.github/workflows/lock.yml --- vagrant-2.2.14+dfsg/.github/workflows/lock.yml 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/.github/workflows/lock.yml 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,23 @@ +name: 'Lock Threads' + +on: + schedule: + - cron: '50 1 * * *' + +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v2 + with: + github-token: ${{ github.token }} + issue-lock-comment: > + I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues. + + If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. + issue-lock-inactive-days: '30' + pr-lock-comment: > + I'm going to lock this pull request because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues. + + If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. + pr-lock-inactive-days: '30' diff -Nru vagrant-2.2.14+dfsg/.github/workflows/release.yml vagrant-2.2.19+dfsg/.github/workflows/release.yml --- vagrant-2.2.14+dfsg/.github/workflows/release.yml 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.github/workflows/release.yml 2021-11-05 21:15:44.000000000 +0000 @@ -15,7 +15,7 @@ - name: Code Checkout uses: actions/checkout@v1 - name: Set Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: '2.6' - name: Create Builders Release @@ -32,6 +32,7 @@ ASSETS_SHORTTERM_PREFIX: ${{ secrets.ASSETS_SHORTTERM_PREFIX }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ASSUME_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} HASHIBOT_EMAIL: ${{ secrets.HASHIBOT_EMAIL }} HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }} HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }} diff -Nru vagrant-2.2.14+dfsg/.github/workflows/spectesting.yml vagrant-2.2.19+dfsg/.github/workflows/spectesting.yml --- vagrant-2.2.14+dfsg/.github/workflows/spectesting.yml 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.github/workflows/spectesting.yml 2021-11-05 21:15:44.000000000 +0000 @@ -19,7 +19,6 @@ env: VAGRANT_CI_LOADER_BUCKET: ${{ secrets.VAGRANT_CI_LOADER_BUCKET }} - setup-hosts: if: github.repository == 'hashicorp/vagrant-acceptance' runs-on: self-hosted diff -Nru vagrant-2.2.14+dfsg/.github/workflows/testing.yml vagrant-2.2.19+dfsg/.github/workflows/testing.yml --- vagrant-2.2.14+dfsg/.github/workflows/testing.yml 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.github/workflows/testing.yml 2021-11-05 21:15:44.000000000 +0000 @@ -8,6 +8,10 @@ - 'lib/**' - 'plugins/**' - 'test/**' + - 'templates/**' + - 'Gemfile' + - 'vagrant.gemspec' + - 'Rakefile' pull_request: branches: - main @@ -16,19 +20,23 @@ - 'lib/**' - 'plugins/**' - 'test/**' + - 'Gemfile' + - 'templates/**' + - 'vagrant.gemspec' + - 'Rakefile' jobs: unit-tests: runs-on: ubuntu-18.04 strategy: matrix: - ruby: [ '2.5.x', '2.6.x', '2.7.x' ] + ruby: [ '2.6', '2.7', '3.0' ] name: Vagrant unit tests on Ruby ${{ matrix.ruby }} steps: - name: Code Checkout uses: actions/checkout@v1 - name: Setup Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{matrix.ruby}} architecture: 'x64' diff -Nru vagrant-2.2.14+dfsg/.hashibot.hcl vagrant-2.2.19+dfsg/.hashibot.hcl --- vagrant-2.2.14+dfsg/.hashibot.hcl 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/.hashibot.hcl 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -poll "closed_issue_locker" "locker" { - schedule = "0 50 1 * * *" - closed_for = "720h" # 30 days - max_issues = 500 - sleep_between_issues = "5s" - - no_comment_if_no_activity_for = "4320h" # 180 days - - message = <<-EOF - I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues. - - If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. - EOF -} diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/action/builtin/box_add.rb vagrant-2.2.19+dfsg/lib/vagrant/action/builtin/box_add.rb --- vagrant-2.2.14+dfsg/lib/vagrant/action/builtin/box_add.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/action/builtin/box_add.rb 2021-11-05 21:15:44.000000000 +0000 @@ -108,6 +108,14 @@ end end + is_error = is_metadata_results.find do |b| + b.is_a?(Errors::DownloaderError) + end + if is_error + raise Errors::BoxMetadataDownloadError, + message: is_error.extra_data[:message] + end + is_metadata = is_metadata_results.any? { |b| b === true } if is_metadata && url.length > 1 raise Errors::BoxAddMetadataMultiURL, @@ -118,7 +126,7 @@ url = [url.first, authed_urls.first] add_from_metadata(url, env, expanded) else - add_direct(url, env) + add_direct(authed_urls, env) end @app.call(env) @@ -538,11 +546,13 @@ !!(match.last.chomp =~ /application\/json/) end - def validate_checksum(checksum_type, checksum, path) + def validate_checksum(checksum_type, _checksum, path) + checksum = _checksum.strip() @logger.info("Validating checksum with #{checksum_type}") @logger.info("Expected checksum: #{checksum}") - actual = FileChecksum.new(path, checksum_type).checksum + _actual = FileChecksum.new(path, checksum_type).checksum + actual = _actual.strip() @logger.info("Actual checksum: #{actual}") if actual.casecmp(checksum) != 0 raise Errors::BoxChecksumMismatch, diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/action/builtin/box_check_outdated.rb vagrant-2.2.19+dfsg/lib/vagrant/action/builtin/box_check_outdated.rb --- vagrant-2.2.14+dfsg/lib/vagrant/action/builtin/box_check_outdated.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/action/builtin/box_check_outdated.rb 2021-11-05 21:15:44.000000000 +0000 @@ -46,7 +46,8 @@ client_cert: env[:client_cert] || machine.config.vm.box_download_client_cert, insecure: !env[:insecure].nil? ? - env[:insecure] : machine.config.vm.box_download_insecure + env[:insecure] : machine.config.vm.box_download_insecure, + box_extra_download_options: env[:box_extra_download_options] || machine.config.vm.box_extra_download_options, } env[:ui].output(I18n.t( diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/action/general/package.rb vagrant-2.2.19+dfsg/lib/vagrant/action/general/package.rb --- vagrant-2.2.14+dfsg/lib/vagrant/action/general/package.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/action/general/package.rb 2021-11-05 21:15:44.000000000 +0000 @@ -13,6 +13,7 @@ # # * package.output - The filename of the outputted package. # * package.include - An array of files to include in the package. + # * package.info - Path of desired info.json file to include # * package.directory - The directory which contains the contents to # compress into the package. # @@ -63,6 +64,7 @@ @app = app env["package.files"] ||= {} + env["package.info"] ||= "" env["package.output"] ||= "package.box" @fullpath = self.class.fullpath(env["package.output"]) @@ -77,11 +79,14 @@ raise Errors::PackageOutputDirectory if File.directory?(fullpath) + raise Errors::PackageInvalidInfo if invalid_info? + @app.call(env) @env[:ui].info I18n.t("vagrant.actions.general.package.compressing", fullpath: fullpath) copy_include_files + copy_info setup_private_key write_metadata_json compress @@ -137,6 +142,16 @@ raise Errors::PackageIncludeSymlink end + # This method copies the specified info.json file to the temporary directory + # so that it is accessible via the 'box list -i' command + def copy_info + info_path = Pathname.new(@env["package.info"]) + + if info_path.file? + FileUtils.cp(info_path, @env["package.directory"], preserve: true) + end + end + # Compress the exported file into a package def compress # Get the output path. We have to do this up here so that the @@ -216,6 +231,15 @@ f.puts %Q[end] end end + + # Check to see if package.info is a valid file and titled info.json + def invalid_info? + if @env["package.info"] != "" + info_path = Pathname.new(@env["package.info"]) + + return !info_path.file? || File.basename(info_path) != "info.json" + end + end end end end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/action.rb vagrant-2.2.19+dfsg/lib/vagrant/action.rb --- vagrant-2.2.14+dfsg/lib/vagrant/action.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/action.rb 2021-11-05 21:15:44.000000000 +0000 @@ -2,6 +2,7 @@ module Vagrant module Action + autoload :Builder, 'vagrant/action/builder' autoload :Hook, 'vagrant/action/hook' autoload :Runner, 'vagrant/action/runner' autoload :Warden, 'vagrant/action/warden' @@ -12,12 +13,13 @@ autoload :BoxAdd, "vagrant/action/builtin/box_add" autoload :BoxCheckOutdated, "vagrant/action/builtin/box_check_outdated" autoload :BoxRemove, "vagrant/action/builtin/box_remove" + autoload :BoxUpdate, "vagrant/action/builtin/box_update" autoload :Call, "vagrant/action/builtin/call" autoload :CleanupDisks, "vagrant/action/builtin/cleanup_disks" autoload :CloudInitSetup, "vagrant/action/builtin/cloud_init_setup" autoload :CloudInitWait, "vagrant/action/builtin/cloud_init_wait" - autoload :Confirm, "vagrant/action/builtin/confirm" autoload :ConfigValidate, "vagrant/action/builtin/config_validate" + autoload :Confirm, "vagrant/action/builtin/confirm" autoload :Delayed, "vagrant/action/builtin/delayed" autoload :DestroyConfirm, "vagrant/action/builtin/destroy_confirm" autoload :Disk, "vagrant/action/builtin/disk" @@ -31,14 +33,16 @@ autoload :IsState, "vagrant/action/builtin/is_state" autoload :Lock, "vagrant/action/builtin/lock" autoload :Message, "vagrant/action/builtin/message" + autoload :MixinProvisioners, "vagrant/action/builtin/mixin_provisioners" + autoload :MixinSyncedFolders, "vagrant/action/builtin/mixin_synced_folders" autoload :PrepareClone, "vagrant/action/builtin/prepare_clone" autoload :Provision, "vagrant/action/builtin/provision" autoload :ProvisionerCleanup, "vagrant/action/builtin/provisioner_cleanup" autoload :SetHostname, "vagrant/action/builtin/set_hostname" autoload :SSHExec, "vagrant/action/builtin/ssh_exec" autoload :SSHRun, "vagrant/action/builtin/ssh_run" - autoload :SyncedFolders, "vagrant/action/builtin/synced_folders" autoload :SyncedFolderCleanup, "vagrant/action/builtin/synced_folder_cleanup" + autoload :SyncedFolders, "vagrant/action/builtin/synced_folders" autoload :Trigger, "vagrant/action/builtin/trigger" autoload :WaitForCommunicator, "vagrant/action/builtin/wait_for_communicator" end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/bundler.rb vagrant-2.2.19+dfsg/lib/vagrant/bundler.rb --- vagrant-2.2.14+dfsg/lib/vagrant/bundler.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/bundler.rb 2021-11-05 21:15:44.000000000 +0000 @@ -189,8 +189,11 @@ attr_reader :env_plugin_gem_path # @return [Pathname] Vagrant environment data path attr_reader :environment_data_path + # @return [Array, nil] List of builtin specs + attr_accessor :builtin_specs def initialize + @builtin_specs = [] @plugin_gem_path = Vagrant.user_data_path.join("gems", RUBY_VERSION).freeze @logger = Log4r::Logger.new("vagrant::bundler") end @@ -287,7 +290,6 @@ # Never allow dependencies to be remotely satisfied during init request_set.remote = false - repair_result = nil begin @logger.debug("resolving solution from available specification set") # Resolve the request set to ensure proper activation order @@ -514,6 +516,9 @@ @logger.debug("Enabling strict dependency enforcement") plugin_deps += vagrant_internal_specs.map do |spec| next if system_plugins.include?(spec.name) + # If this spec is for a default plugin included in + # the ruby stdlib, ignore it + next if spec.default_gem? # If we are not running within the installer and # we are not within a bundler environment then we # only want activated specs @@ -647,7 +652,6 @@ self_spec.activate @logger.info("Activated vagrant specification version - #{self_spec.version}") end - self_spec.runtime_dependencies.each { |d| gem d.name, *d.requirement.as_list } # discover all the gems we have available list = {} if Gem.respond_to?(:default_specifications_dir) @@ -656,10 +660,16 @@ spec_dir = Gem::Specification.default_specifications_dir end directories = [spec_dir] - Gem::Specification.find_all{true}.each do |spec| - list[spec.full_name] = spec + if Vagrant.in_bundler? + Gem::Specification.find_all{true}.each do |spec| + list[spec.full_name] = spec + end + else + builtin_specs.each do |spec| + list[spec.full_name] = spec + end end - if(!Object.const_defined?(:Bundler)) + if Vagrant.in_installer? directories += Gem::Specification.dirs.find_all do |path| !path.start_with?(Gem.user_dir) end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/config/v2.rb vagrant-2.2.19+dfsg/lib/vagrant/config/v2.rb --- vagrant-2.2.14+dfsg/lib/vagrant/config/v2.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/config/v2.rb 2021-11-05 21:15:44.000000000 +0000 @@ -3,7 +3,8 @@ module V2 autoload :DummyConfig, "vagrant/config/v2/dummy_config" autoload :Loader, "vagrant/config/v2/loader" - autoload :Root, "vagrant/config/v2/root" + autoload :Root, "vagrant/config/v2/root" + autoload :Util, "vagrant/config/v2/util" end end end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/environment.rb vagrant-2.2.19+dfsg/lib/vagrant/environment.rb --- vagrant-2.2.14+dfsg/lib/vagrant/environment.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/environment.rb 2021-11-05 21:15:44.000000000 +0000 @@ -517,6 +517,7 @@ # @param [Action::Runner] action_runner A custom action runner for running hooks. def hook(name, opts=nil) @logger.info("Running hook: #{name}") + opts ||= {} opts[:callable] ||= Action::Builder.new opts[:runner] ||= action_runner @@ -1010,7 +1011,7 @@ options[:require] = pconfig[:entry_point] if pconfig[:entry_point] options[:version] = pconfig[:version] if pconfig[:version] - spec = Plugin::Manager.instance.install_plugin(name, options) + spec = Plugin::Manager.instance.install_plugin(name, **options) ui.info(I18n.t("vagrant.commands.plugin.installed", name: spec.name, version: spec.version.to_s)) diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/errors.rb vagrant-2.2.19+dfsg/lib/vagrant/errors.rb --- vagrant-2.2.14+dfsg/lib/vagrant/errors.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/errors.rb 2021-11-05 21:15:44.000000000 +0000 @@ -356,6 +356,10 @@ error_key(:darwin_mount_failed) end + class DarwinVersionFailed < VagrantError + error_key(:darwin_version_failed) + end + class DestroyRequiresForce < VagrantError error_key(:destroy_requires_force) end @@ -592,6 +596,10 @@ error_key(:requires_directory, "vagrant.actions.general.package") end + class PackageInvalidInfo < VagrantError + error_key(:package_invalid_info) + end + class PowerShellNotFound < VagrantError error_key(:powershell_not_found) end @@ -636,6 +644,18 @@ error_key(:provisioner_winrm_unsupported) end + class PluginNeedsDeveloperTools < VagrantError + error_key(:plugin_needs_developer_tools) + end + + class PluginMissingLibrary < VagrantError + error_key(:plugin_missing_library) + end + + class PluginMissingRubyDev < VagrantError + error_key(:plugin_missing_ruby_dev) + end + class PluginGemNotFound < VagrantError error_key(:plugin_gem_not_found) end @@ -1008,6 +1028,10 @@ error_key(:virtualbox_version_empty) end + class VirtualBoxInvalidHostSubnet < VagrantError + error_key(:virtualbox_invalid_host_subnet) + end + class VMBaseMacNotSpecified < VagrantError error_key(:no_base_mac, "vagrant.actions.vm.match_mac") end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/machine_index.rb vagrant-2.2.19+dfsg/lib/vagrant/machine_index.rb --- vagrant-2.2.14+dfsg/lib/vagrant/machine_index.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/machine_index.rb 2021-11-05 21:15:44.000000000 +0000 @@ -263,7 +263,7 @@ # # @return [Hash] def find_by_prefix(prefix) - return if !prefix + return if !prefix || prefix == "" @machines.each do |uuid, data| return data.merge("id" => uuid) if uuid.start_with?(prefix) end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/patches/net-ssh.rb vagrant-2.2.19+dfsg/lib/vagrant/patches/net-ssh.rb --- vagrant-2.2.14+dfsg/lib/vagrant/patches/net-ssh.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/patches/net-ssh.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,279 @@ +require "net/ssh" + +# Only patch if we have version 6.1.0 loaded as +# these patches pull 6.1.0 up to the as of now +# current 6.2.0 beta +if Net::SSH::Version::STRING == "6.1.0" + module DeprecatedRsaSha1 + module KeyManager + def initialize(logger, options={}) + @deprecated_rsa_sha1 = options.delete(:deprecated_rsa_sha1) + super + end + + def sign(identity, data) + info = known_identities[identity] or raise Net::SSH::Authentication::KeyManager::KeyManagerError, "the given identity is unknown to the key manager" + + if info[:key].nil? && info[:from] == :file + begin + info[:key] = Net::SSH::KeyFactory.load_private_key(info[:file], options[:passphrase], !options[:non_interactive], options[:password_prompt]) + if @deprecated_rsa_sha1 && info[:key].respond_to?(:deprecated_rsa_sha1=) + info[:key].deprecated_rsa_sha1 = true + Vagrant.global_logger.debug("set RSA SHA1 deprecation on private key: #{info[:key].fingerprint}") + end + rescue OpenSSL::OpenSSLError, Exception => e + raise Net::SSH::Authentication::KeyManager::KeyManagerError, "the given identity is known, but the private key could not be loaded: #{e.class} (#{e.message})" + end + end + + if info[:key] + return Net::SSH::Buffer.from(:string, identity.ssh_signature_type, + :mstring, info[:key].ssh_do_sign(data.to_s)).to_s + end + + if info[:from] == :agent + raise Net::SSH::Authentication::KeyManager::KeyManagerError, "the agent is no longer available" unless agent + return agent.sign(info[:identity], data.to_s) + end + + raise Net::SSH::Authentication::KeyManager::KeyManagerError, "[BUG] can't determine identity origin (#{info.inspect})" + end + + def load_identities(identities, ask_passphrase, ignore_decryption_errors) + identities.map do |identity| + begin + case identity[:load_from] + when :pubkey_file + key = Net::SSH::KeyFactory.load_public_key(identity[:pubkey_file]) + if @deprecated_rsa_sha1 && key.respond_to?(:deprecated_rsa_sha1=) + key.deprecated_rsa_sha1 = true + Vagrant.global_logger.debug("set RSA SHA1 deprecation on public key: #{key.fingerprint}") + end + { public_key: key, from: :file, file: identity[:privkey_file] } + when :privkey_file + private_key = Net::SSH::KeyFactory.load_private_key( + identity[:privkey_file], options[:passphrase], ask_passphrase, options[:password_prompt] + ) + key = private_key.send(:public_key) + if @deprecated_rsa_sha1 && key.respond_to?(:deprecated_rsa_sha1=) + key.deprecated_rsa_sha1 = true + private_key.deprecated_rsa_sha1 = true + Vagrant.global_logger.debug("set RSA SHA1 deprecation on public key: #{key.fingerprint}") + Vagrant.global_logger.debug("set RSA SHA1 deprecation on private key: #{private_key.fingerprint}") + end + { public_key: key, from: :file, file: identity[:privkey_file], key: private_key } + when :data + private_key = Net::SSH::KeyFactory.load_data_private_key( + identity[:data], options[:passphrase], ask_passphrase, "", options[:password_prompt] + ) + key = private_key.send(:public_key) + if @deprecated_rsa_sha1 && key.respond_to?(:deprecated_rsa_sha1=) + key.deprecated_rsa_sha1 = true + private_key.deprecated_rsa_sha1 = true + Vagrant.global_logger.debug("set RSA SHA1 deprecation on public key: #{key.fingerprint}") + Vagrant.global_logger.debug("set RSA SHA1 deprecation on private key: #{private_key.fingerprint}") + end + { public_key: key, from: :key_data, data: identity[:data], key: private_key } + else + identity + end + rescue OpenSSL::PKey::RSAError, OpenSSL::PKey::DSAError, OpenSSL::PKey::ECError, OpenSSL::PKey::PKeyError, ArgumentError => e + if ignore_decryption_errors + identity + else + process_identity_loading_error(identity, e) + nil + end + rescue Exception => e + process_identity_loading_error(identity, e) + nil + end + end.compact + end + end + + module AuthenticationSession + def initialize(transport, options={}) + s_ver_str = transport.server_version.version. + match(/OpenSSH_.*?(?\d+\.\d+)/)&.[](:version).to_s + Vagrant.global_logger.debug("ssh server version detected: #{s_ver_str}") + if !s_ver_str.empty? + begin + ver = Gem::Version.new(s_ver_str) + if ver >= Gem::Version.new("7.2") + Vagrant.global_logger.debug("ssh server supports deprecation of RSA SHA1, deprecating") + options[:deprecated_rsa_sha1] = true + else + Vagrant.global_logger.debug("ssh server does not support deprecation of RSA SHA1") + end + rescue ArgumentError => err + Vagrant.global_logger.debug("failed to determine valid ssh server version - #{err}") + end + end + super + end + end + end + + require "net/ssh/authentication/key_manager" + Net::SSH::Authentication::KeyManager.prepend(DeprecatedRsaSha1::KeyManager) + require "net/ssh/authentication/session" + Net::SSH::Authentication::Session.prepend(DeprecatedRsaSha1::AuthenticationSession) + + require "net/ssh/authentication/agent" + # net/ssh/authentication/agent + Net::SSH::Authentication::Agent.class_eval do + SSH2_AGENT_LOCK = 22 + SSH2_AGENT_UNLOCK = 23 + + # lock the ssh agent with password + def lock(password) + type, = send_and_wait(SSH2_AGENT_LOCK, :string, password) + raise AgentError, "could not lock agent" if type != SSH_AGENT_SUCCESS + end + + # unlock the ssh agent with password + def unlock(password) + type, = send_and_wait(SSH2_AGENT_UNLOCK, :string, password) + raise AgentError, "could not unlock agent" if type != SSH_AGENT_SUCCESS + end + end + + require "net/ssh/authentication/certificate" + # net/ssh/authentication/certificate + Net::SSH::Authentication::Certificate.class_eval do + def ssh_do_verify(sig, data, options = {}) + key.ssh_do_verify(sig, data, options) + end + end + + require "net/ssh/authentication/ed25519" + # net/ssh/authentication/ed25519 + Net::SSH::Authentication::ED25519::PubKey.class_eval do + def ssh_do_verify(sig, data, options = {}) + @verify_key.verify(sig,data) + end + end + + require "net/ssh/transport/algorithms" + # net/ssh/transport/algorithms + Net::SSH::Transport::Algorithms::DEFAULT_ALGORITHMS[:host_key].insert( + Net::SSH::Transport::Algorithms::DEFAULT_ALGORITHMS[:host_key].size - 1, "rsa-sha2-256") + Net::SSH::Transport::Algorithms::DEFAULT_ALGORITHMS[:host_key].insert( + Net::SSH::Transport::Algorithms::DEFAULT_ALGORITHMS[:host_key].size - 1, "rsa-sha2-512") + + require "net/ssh/transport/cipher_factory" + # net/ssh/transport/cipher_factory + Net::SSH::Transport::CipherFactory::SSH_TO_OSSL["aes256-ctr"] = ::OpenSSL::Cipher.ciphers.include?("aes-256-ctr") ? "aes-256-ctr" : "aes-256-ecb" + Net::SSH::Transport::CipherFactory::SSH_TO_OSSL["aes192-ctr"] = ::OpenSSL::Cipher.ciphers.include?("aes-192-ctr") ? "aes-192-ctr" : "aes-192-ecb" + Net::SSH::Transport::CipherFactory::SSH_TO_OSSL["aes128-ctr"] = ::OpenSSL::Cipher.ciphers.include?("aes-128-ctr") ? "aes-128-ctr" : "aes-128-ecb" + + require "net/ssh/transport/kex/abstract" + # net/ssh/transport/kex/abstract + Net::SSH::Transport::Kex::Abstract.class_eval do + def matching?(key_ssh_type, host_key_alg) + return true if key_ssh_type == host_key_alg + return true if key_ssh_type == 'ssh-rsa' && ['rsa-sha2-512', 'rsa-sha2-256'].include?(host_key_alg) + end + + def verify_server_key(key) #:nodoc: + unless matching?(key.ssh_type, algorithms.host_key) + raise Net::SSH::Exception, "host key algorithm mismatch '#{key.ssh_type}' != '#{algorithms.host_key}'" + end + + blob, fingerprint = generate_key_fingerprint(key) + + unless connection.host_key_verifier.verify(key: key, key_blob: blob, fingerprint: fingerprint, session: connection) + raise Net::SSH::Exception, 'host key verification failed' + end + end + + def verify_signature(result) #:nodoc: + response = build_signature_buffer(result) + + hash = digester.digest(response.to_s) + + server_key = result[:server_key] + server_sig = result[:server_sig] + unless connection.host_key_verifier.verify_signature { server_key.ssh_do_verify(server_sig, hash, host_key: algorithms.host_key) } + raise Net::SSH::Exception, 'could not verify server signature' + end + + hash + end + end + + require "net/ssh/transport/openssl" + # net/ssh/transport/openssl + OpenSSL::PKey::RSA.class_eval do + attr_accessor :deprecated_rsa_sha1 + + def ssh_do_verify(sig, data, options = {}) + digester = + if options[:host_key] == "rsa-sha2-512" + OpenSSL::Digest::SHA512.new + elsif options[:host_key] == "rsa-sha2-256" + OpenSSL::Digest::SHA256.new + else + OpenSSL::Digest::SHA1.new + end + + verify(digester, sig, data) + end + + def ssh_type + deprecated_rsa_sha1 ? signature_algorithm : "ssh-rsa" + end + + def signature_algorithm + "rsa-sha2-256" + end + + def ssh_do_sign(data) + if deprecated_rsa_sha1 + sign(OpenSSL::Digest::SHA256.new, data) + else + sign(OpenSSL::Digest::SHA1.new, data) + end + end + end + + OpenSSL::PKey::DSA.class_eval do + def ssh_do_verify(sig, data, options = {}) + sig_r = sig[0,20].unpack("H*")[0].to_i(16) + sig_s = sig[20,20].unpack("H*")[0].to_i(16) + a1sig = OpenSSL::ASN1::Sequence([ + OpenSSL::ASN1::Integer(sig_r), + OpenSSL::ASN1::Integer(sig_s) + ]) + return verify(OpenSSL::Digest::SHA1.new, a1sig.to_der, data) + end + end + + OpenSSL::PKey::EC.class_eval do + def ssh_do_verify(sig, data, options = {}) + digest = digester.digest(data) + a1sig = nil + + begin + sig_r_len = sig[0, 4].unpack('H*')[0].to_i(16) + sig_l_len = sig[4 + sig_r_len, 4].unpack('H*')[0].to_i(16) + + sig_r = sig[4, sig_r_len].unpack('H*')[0] + sig_s = sig[4 + sig_r_len + 4, sig_l_len].unpack('H*')[0] + + a1sig = OpenSSL::ASN1::Sequence([ + OpenSSL::ASN1::Integer(sig_r.to_i(16)), + OpenSSL::ASN1::Integer(sig_s.to_i(16)) + ]) + rescue StandardError + end + + if a1sig.nil? + return false + else + dsa_verify_asn1(digest, a1sig.to_der) + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/plugin/manager.rb vagrant-2.2.19+dfsg/lib/vagrant/plugin/manager.rb --- vagrant-2.2.14+dfsg/lib/vagrant/plugin/manager.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/plugin/manager.rb 2021-11-05 21:15:44.000000000 +0000 @@ -179,8 +179,26 @@ result rescue Gem::GemNotFoundException raise Errors::PluginGemNotFound, name: name - rescue Gem::Exception => e - raise Errors::BundlerError, message: e.to_s + rescue Gem::Exception => err + @logger.warn("Failed to install plugin: #{err}") + @logger.debug("#{err.class}: #{err}\n#{err.backtrace.join("\n")}") + # Try and determine a cause for the failure + case err.message + when /install development tools first/ + raise Errors::PluginNeedsDeveloperTools + when /library not found in default locations/ + lib = err.message.match(/(\w+) library not found in default locations/) + if lib.nil? + raise Errors::BundlerError, message: err.message + end + raise Errors::PluginMissingLibrary, + library: lib.captures.first, + name: name + when /find header files for ruby/ + raise Errors::PluginMissingRubyDev + else + raise Errors::BundlerError, message: err.message + end end # Uninstalls the plugin with the given name. diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/plugin/v1.rb vagrant-2.2.19+dfsg/lib/vagrant/plugin/v1.rb --- vagrant-2.2.14+dfsg/lib/vagrant/plugin/v1.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/plugin/v1.rb 2021-11-05 21:15:44.000000000 +0000 @@ -14,6 +14,10 @@ autoload :Plugin, "vagrant/plugin/v1/plugin" autoload :Provider, "vagrant/plugin/v1/provider" autoload :Provisioner, "vagrant/plugin/v1/provisioner" + + # Errors + autoload :Error, "vagrant/plugin/v1/error" + autoload :InvalidCommandName, "vagrant/plugin/v1/error" end end end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/plugin/v2/trigger.rb vagrant-2.2.19+dfsg/lib/vagrant/plugin/v2/trigger.rb --- vagrant-2.2.14+dfsg/lib/vagrant/plugin/v2/trigger.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/plugin/v2/trigger.rb 2021-11-05 21:15:44.000000000 +0000 @@ -271,7 +271,7 @@ options[:color] = :red if !config.keep_color end - @ui.detail(data, options) + @ui.detail(data, **options) end if !exit_codes.include?(result.exit_code) raise Errors::TriggersBadExitCodes, diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/plugin/v2.rb vagrant-2.2.19+dfsg/lib/vagrant/plugin/v2.rb --- vagrant-2.2.14+dfsg/lib/vagrant/plugin/v2.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/plugin/v2.rb 2021-11-05 21:15:44.000000000 +0000 @@ -10,6 +10,7 @@ module V2 autoload :Command, "vagrant/plugin/v2/command" autoload :Communicator, "vagrant/plugin/v2/communicator" + autoload :Components, "vagrant/plugin/v2/components" autoload :Config, "vagrant/plugin/v2/config" autoload :Guest, "vagrant/plugin/v2/guest" autoload :Host, "vagrant/plugin/v2/host" @@ -20,6 +21,10 @@ autoload :Provisioner, "vagrant/plugin/v2/provisioner" autoload :SyncedFolder, "vagrant/plugin/v2/synced_folder" autoload :Trigger, "vagrant/plugin/v2/trigger" + + # Errors + autoload :Error, "vagrant/plugin/v2/error" + autoload :InvalidCommandName, "vagrant/plugin/v2/error" end end end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/ui.rb vagrant-2.2.19+dfsg/lib/vagrant/ui.rb --- vagrant-2.2.14+dfsg/lib/vagrant/ui.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/ui.rb 2021-11-05 21:15:44.000000000 +0000 @@ -45,7 +45,7 @@ end [:ask, :detail, :warn, :error, :info, :output, :success].each do |method| - define_method(method) do |message, *opts| + define_method(method) do |message, **opts| # Log normal console messages begin @logger.info { "#{method}: #{message}" } @@ -86,7 +86,7 @@ # This is a UI implementation that does nothing. class Silent < Interface - def ask(*args) + def ask(*args, **opts) super # Silent can't do this, obviously. @@ -103,7 +103,7 @@ @lock = Mutex.new end - def ask(*args) + def ask(*args, **opts) super # Machine-readable can't ask for input @@ -111,8 +111,8 @@ end [:detail, :warn, :error, :info, :output, :success].each do |method| - define_method(method) do |message, *args, **opts| - machine("ui", method.to_s, message, *args, **opts) + define_method(method) do |message, **opts| + machine("ui", method.to_s, message, **opts) end end @@ -155,14 +155,14 @@ # to `say`. [:detail, :info, :warn, :error, :output, :success].each do |method| class_eval <<-CODE - def #{method}(message, *args) + def #{method}(message, **opts) super(message) - say(#{method.inspect}, message, *args) + say(#{method.inspect}, message, **opts) end CODE end - def ask(message, opts=nil) + def ask(message, **opts) super(message) # We can't ask questions when the output isn't a TTY. @@ -192,7 +192,7 @@ say(:info, "\n#{I18n.t("vagrant.stdin_cant_hide_input")}\n ", opts) # Ask again, with echo enabled - input = ask(message, opts.merge(echo: true)) + input = ask(message, **opts.merge(echo: true)) end end @@ -278,7 +278,7 @@ say(:info, "\n", opts) end - def ask(*args) + def ask(*args, **opts) # Non interactive can't ask for input raise Errors::UIExpectsTTY end @@ -306,7 +306,7 @@ # to `say`. [:ask, :detail, :info, :warn, :error, :output, :success].each do |method| class_eval <<-CODE - def #{method}(message, *args, **opts) + def #{method}(message, **opts) super(message) if !@ui.opts.key?(:bold) && !opts.key?(:bold) opts[:bold] = #{method.inspect} != :detail && \ @@ -315,7 +315,7 @@ if !opts.key?(:target) opts[:target] = @prefix end - @ui.#{method}(format_message(#{method.inspect}, message, **opts), *args, **opts) + @ui.#{method}(format_message(#{method.inspect}, message, **opts), **opts) end CODE end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/util/curl_helper.rb vagrant-2.2.19+dfsg/lib/vagrant/util/curl_helper.rb --- vagrant-2.2.14+dfsg/lib/vagrant/util/curl_helper.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/util/curl_helper.rb 2021-11-05 21:15:44.000000000 +0000 @@ -4,6 +4,7 @@ # Hosts that do not require notification on redirect SILENCED_HOSTS = [ + "vagrantcloud-files-production.s3-accelerate.amazonaws.com".freeze, "vagrantcloud.com".freeze, "vagrantup.com".freeze ].freeze @@ -21,6 +22,7 @@ # Accumulate progress_data progress_data << data + redirect_notify = false while true # If the download has been redirected and we are no longer downloading # from the original host, notify the user that the target host has @@ -30,16 +32,15 @@ if !location.empty? location_uri = URI.parse(location) - unless location_uri.host.nil? - redirect_notify = false + if !location_uri.host.nil? && !redirect_notify logger.info("download redirected to #{location}") source_uri = URI.parse(source) source_host = source_uri.host.to_s.split(".", 2).last location_host = location_uri.host.to_s.split(".", 2).last - if !redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host) - ui.rewriting do |ui| - ui.clear_line - ui.detail "Download redirected to host: #{location_uri.host}" + if location_host != source_host && !SILENCED_HOSTS.include?(location_host) && !SILENCED_HOSTS.include?(location_uri.host.to_s) + ui.rewriting do |_ui| + _ui.clear_line + _ui.detail "Download redirected to host: #{location_uri.host}" end end redirect_notify = true diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/util/guest_hosts.rb vagrant-2.2.19+dfsg/lib/vagrant/util/guest_hosts.rb --- vagrant-2.2.14+dfsg/lib/vagrant/util/guest_hosts.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/util/guest_hosts.rb 2021-11-05 21:15:44.000000000 +0000 @@ -17,7 +17,7 @@ basename = name.split(".", 2)[0] comm.sudo <<-EOH.gsub(/^ {14}/, '') grep -w '#{name}' /etc/hosts || { - for i in {1..#{loop_bound}}; do + for i in #{[*1..loop_bound].join(' ')}; do grep -w "127.0.${i}.1" /etc/hosts || { echo "127.0.${i}.1 #{name} #{basename}" >> /etc/hosts break diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/util/line_buffer.rb vagrant-2.2.19+dfsg/lib/vagrant/util/line_buffer.rb --- vagrant-2.2.14+dfsg/lib/vagrant/util/line_buffer.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/util/line_buffer.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,60 @@ +module Vagrant + module Util + class LineBuffer + + # Maximum number of characters to buffer before sending + # to callback without detecting a new line + MAX_LINE_LENGTH = 5000.freeze + + # Create a new line buffer. The registered block + # will be called when a new line is encountered on + # provided input, or the max line length is reached + def initialize(&callback) + raise ArgumentError, + "Expected callback but received none" if callback.nil? + @mu = Mutex.new + @callback = callback + @buffer = "" + end + + # Add string data to output + # + # @param [String] str String of data to output + # @return [self] + def <<(str) + @mu.synchronize do + while i = str.index("\n") + @callback.call((@buffer + str[0, i+1]).rstrip) + @buffer.clear + str = str[i+1, str.length].to_s + end + + @buffer << str.to_s + + if @buffer.length > MAX_LINE_LENGTH + @callback.call(@buffer.dup) + @buffer.clear + end + end + self + end + + # Closes the buffer. Any remaining data that has + # been buffered will be given to the callback. + # Once closed the instance will no longer be usable. + # + # @return [self] + def close + @mu.synchronize do + # Send any remaining output on the buffer + @callback.call(@buffer.dup) if !@buffer.empty? + # Disable this buffer instance + @callback = nil + @buffer.clear + @buffer.freeze + end + self + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/util/numeric.rb vagrant-2.2.19+dfsg/lib/vagrant/util/numeric.rb --- vagrant-2.2.14+dfsg/lib/vagrant/util/numeric.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/util/numeric.rb 2021-11-05 21:15:44.000000000 +0000 @@ -49,6 +49,26 @@ bytes end + # Convert bytes to a user friendly string representation + # + # @param [Numeric] bytes Number of bytes to represent + # @return [String] user friendly output + def bytes_to_string(bytes) + # We want to locate the size that will return the + # smallest whole value number + BYTES_CONVERSION_MAP.sort { |a, b| + b.last <=> a.last + }.each do |suffix, size| + val = bytes.to_f / size + next if val < 1 + val = sprintf("%.2f", val) + val.slice!(-1, 1) while val.end_with?("0") + val.slice!(-1, 1) if val.end_with?(".") + return "#{val}#{suffix}" + end + "#{bytes} byte#{"s" if bytes > 1}" + end + # Rounds actual value to two decimal places # # @param [Integer] bytes diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/util/powershell.rb vagrant-2.2.19+dfsg/lib/vagrant/util/powershell.rb --- vagrant-2.2.14+dfsg/lib/vagrant/util/powershell.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/util/powershell.rb 2021-11-05 21:15:44.000000000 +0000 @@ -14,28 +14,45 @@ MINIMUM_REQUIRED_VERSION = 3 # Number of seconds to wait while attempting to get powershell version DEFAULT_VERSION_DETECTION_TIMEOUT = 30 + # Names of the powershell executable + POWERSHELL_NAMES = ["powershell", "pwsh"].map(&:freeze).freeze + # Paths to powershell executable + POWERSHELL_PATHS = [ + "%SYSTEMROOT%/System32/WindowsPowerShell/v1.0", + "%WINDIR%/System32/WindowsPowerShell/v1.0", + "%PROGRAMFILES%/PowerShell/7", + "%PROGRAMFILES%/PowerShell/6" + ].map(&:freeze).freeze + LOGGER = Log4r::Logger.new("vagrant::util::powershell") # @return [String|nil] a powershell executable, depending on environment def self.executable if !defined?(@_powershell_executable) - @_powershell_executable = "powershell" + # First start with detecting executable on configured path + POWERSHELL_NAMES.detect do |psh| + return @_powershell_executable = psh if Which.which(psh) + psh += ".exe" + return @_powershell_executable = psh if Which.which(psh) + end + + # Now attempt with paths + paths = POWERSHELL_PATHS.map do |ppath| + result = Util::Subprocess.execute("cmd.exe", "/c", "echo #{ppath}") + result.stdout.gsub("\"", "").strip if result.exit_code == 0 + end.compact + + paths.each do |psh_path| + POWERSHELL_NAMES.each do |psh| + path = File.join(psh_path, psh) + return @_powershell_executable = path if Which.which(path) + + path += ".exe" + return @_powershell_executable = path if Which.which(path) - if Which.which(@_powershell_executable).nil? - # Try to use WSL interoperability if PowerShell is not symlinked to - # the container. - if Platform.wsl? - @_powershell_executable += ".exe" - - if Which.which(@_powershell_executable).nil? - @_powershell_executable = "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe" - - if Which.which(@_powershell_executable).nil? - @_powershell_executable = nil - end - end - else - @_powershell_executable = nil + # Finally test the msys2 style path + path = path.sub(/^([A-Za-z]):/, "/mnt/\\1") + return @_powershell_executable = path if Which.which(path) end end end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/util.rb vagrant-2.2.19+dfsg/lib/vagrant/util.rb --- vagrant-2.2.14+dfsg/lib/vagrant/util.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/util.rb 2021-11-05 21:15:44.000000000 +0000 @@ -1,24 +1,56 @@ module Vagrant module Util + autoload :ANSIEscapeCodeRemover, 'vagrant/util/ansi_escape_code_remover' autoload :Busy, 'vagrant/util/busy' + autoload :Caps, 'vagrant/util/caps' autoload :CheckpointClient, 'vagrant/util/checkpoint_client' autoload :CommandDeprecation, 'vagrant/util/command_deprecation' autoload :Counter, 'vagrant/util/counter' autoload :CredentialScrubber, 'vagrant/util/credential_scrubber' + autoload :CurlHelper, 'vagrant/util/curl_helper' autoload :DeepMerge, 'vagrant/util/deep_merge' + autoload :Directory, 'vagrant/util/directory' + autoload :Downloader, 'vagrant/util/downloader' autoload :Env, 'vagrant/util/env' autoload :Experimental, 'vagrant/util/experimental' - autoload :HashWithIndifferentAccess, 'vagrant/util/hash_with_indifferent_access' + autoload :FileChecksum, 'vagrant/util/file_checksum' + autoload :FileMode, 'vagrant/util/file_mode' + autoload :GuestHosts, 'vagrant/util/guest_hosts' autoload :GuestInspection, 'vagrant/util/guest_inspection' + autoload :HashWithIndifferentAccess, 'vagrant/util/hash_with_indifferent_access' + autoload :InstallShellConfig, 'vagrant/util/install_cli_autocomplete' + autoload :InstallZSHShellConfig, 'vagrant/util/install_cli_autocomplete' + autoload :InstallBashShellConfig, 'vagrant/util/install_cli_autocomplete' + autoload :InstallCLIShellConfig, 'vagrant/util/install_cli_autocomplete' + autoload :IO, 'vagrant/util/io' + autoload :IPV4Interfaces, 'vagrant/util/ipv4_interfaces' + autoload :IsPortOpen, 'vagrant/util/is_port_open' + autoload :KeyPair, 'vagrant/util/key_pair' + autoload :LineBuffer, 'vagrant/util/line_buffer' + autoload :LineEndingHelpers, 'vagrant/util/line_ending_helpers' autoload :LoggingFormatter, 'vagrant/util/logging_formatter' + autoload :MapCommandOptions, 'vagrant/util/map_command_options' + autoload :Mime, 'vagrant/util/mime' + autoload :NetworkIP, 'vagrant/util/network_ip' + autoload :Numeric, 'vagrant/util/numeric' autoload :Platform, 'vagrant/util/platform' + autoload :Powershell, 'vagrant/util/powershell' + autoload :Presence, 'vagrant/util/presence' autoload :Retryable, 'vagrant/util/retryable' + autoload :SafeChdir, 'vagrant/util/safe_chdir' + autoload :SafeEnv, 'vagrant/util/safe_env' autoload :SafeExec, 'vagrant/util/safe_exec' + autoload :SafePuts, 'vagrant/util/safe_puts' + autoload :ScopedHashOverride, 'vagrant/util/scoped_hash_override' + autoload :ShellQuote, 'vagrant/util/shell_quote' autoload :SilenceWarnings, 'vagrant/util/silence_warnings' + autoload :SSH, 'vagrant/util/ssh' autoload :StackedProcRunner, 'vagrant/util/stacked_proc_runner' autoload :StringBlockEditor, 'vagrant/util/string_block_editor' autoload :Subprocess, 'vagrant/util/subprocess' autoload :TemplateRenderer, 'vagrant/util/template_renderer' + autoload :Uploader, 'vagrant/util/uploader' autoload :Which, 'vagrant/util/which' + autoload :WindowsPath, 'vagrant/util/windows_path' end end diff -Nru vagrant-2.2.14+dfsg/lib/vagrant/vagrantfile.rb vagrant-2.2.19+dfsg/lib/vagrant/vagrantfile.rb --- vagrant-2.2.14+dfsg/lib/vagrant/vagrantfile.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant/vagrantfile.rb 2021-11-05 21:15:44.000000000 +0000 @@ -241,7 +241,7 @@ # configuration and attempt to load that if box.nil? @logger.warn("Failed to locate #{config.vm.box} with version #{config.vm.box_version}") - @logger.warn("Performing lookup with inital values #{initial_box} with version #{initial_version}") + @logger.warn("Performing lookup with initial values #{initial_box} with version #{initial_version}") config.vm.box = original_box = initial_box config.vm.box_version = original_box = initial_version load_box_proc.call diff -Nru vagrant-2.2.14+dfsg/lib/vagrant.rb vagrant-2.2.19+dfsg/lib/vagrant.rb --- vagrant-2.2.14+dfsg/lib/vagrant.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/lib/vagrant.rb 2021-11-05 21:15:44.000000000 +0000 @@ -9,6 +9,8 @@ end end +# Add our patches to net-ssh +require "vagrant/patches/net-ssh" require "optparse" @@ -79,7 +81,7 @@ # See https://github.com/rest-client/rest-client/issues/34#issuecomment-290858 # for more information class VagrantLogger < Log4r::Logger - def << (msg) + def << msg debug(msg.strip) end end @@ -128,25 +130,29 @@ require "vagrant/registry" module Vagrant - autoload :Action, 'vagrant/action' - autoload :Alias, 'vagrant/alias' - autoload :BatchAction, 'vagrant/batch_action' - autoload :Box, 'vagrant/box' - autoload :BoxCollection, 'vagrant/box_collection' - autoload :CLI, 'vagrant/cli' - autoload :Command, 'vagrant/command' - autoload :Config, 'vagrant/config' - autoload :Driver, 'vagrant/driver' - autoload :Environment, 'vagrant/environment' - autoload :Errors, 'vagrant/errors' - autoload :Guest, 'vagrant/guest' - autoload :Host, 'vagrant/host' - autoload :Machine, 'vagrant/machine' - autoload :MachineIndex, 'vagrant/machine_index' - autoload :MachineState, 'vagrant/machine_state' - autoload :Plugin, 'vagrant/plugin' - autoload :UI, 'vagrant/ui' - autoload :Util, 'vagrant/util' + autoload :Action, 'vagrant/action' + autoload :Alias, 'vagrant/alias' + autoload :BatchAction, 'vagrant/batch_action' + autoload :Box, 'vagrant/box' + autoload :BoxCollection, 'vagrant/box_collection' + autoload :BoxMetadata, 'vagrant/box_metadata' + autoload :Bundler, 'vagrant/bundler' + autoload :CLI, 'vagrant/cli' + autoload :CapabilityHost, 'vagrant/capability_host' + autoload :Config, 'vagrant/config' + autoload :Environment, 'vagrant/environment' + autoload :Errors, 'vagrant/errors' + autoload :Guest, 'vagrant/guest' + autoload :Host, 'vagrant/host' + autoload :Machine, 'vagrant/machine' + autoload :MachineIndex, 'vagrant/machine_index' + autoload :MachineState, 'vagrant/machine_state' + autoload :Plugin, 'vagrant/plugin' + autoload :Registry, 'vagrant/registry' + autoload :UI, 'vagrant/ui' + autoload :Util, 'vagrant/util' + autoload :Vagrantfile, 'vagrant/vagrantfile' + autoload :VERSION, 'vagrant/version' # These are the various plugin versions and their components in # a lazy loaded Hash-like structure. diff -Nru vagrant-2.2.14+dfsg/plugins/commands/cloud/auth/middleware/add_authentication.rb vagrant-2.2.19+dfsg/plugins/commands/cloud/auth/middleware/add_authentication.rb --- vagrant-2.2.14+dfsg/plugins/commands/cloud/auth/middleware/add_authentication.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/cloud/auth/middleware/add_authentication.rb 2021-11-05 21:15:44.000000000 +0000 @@ -1,5 +1,6 @@ require "cgi" require "uri" +require "log4r" require Vagrant.source_root.join("plugins/commands/cloud/client/client") @@ -27,55 +28,84 @@ def initialize(app, env) @app = app + @logger = Log4r::Logger.new("vagrant::cloud::auth::authenticate-box-url") CloudCommand::Plugin.init! end def call(env) - client = Client.new(env[:env]) - token = client.token + if ENV["VAGRANT_SERVER_ACCESS_TOKEN_BY_URL"] + @logger.warn("Adding access token as GET parameter by user request") + client = Client.new(env[:env]) + token = client.token - env[:box_urls].map! do |url| - begin - u = URI.parse(url) - if u.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(u.host) - u.host = TARGET_HOST - u.to_s - else + env[:box_urls].map! do |url| + begin + u = URI.parse(url) + if u.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(u.host) + u.host = TARGET_HOST + u.to_s + else + url + end + rescue URI::Error url end - rescue URI::Error - url end - end - - server_uri = URI.parse(Vagrant.server_url.to_s) - if token && !server_uri.host.to_s.empty? - env[:box_urls].map! do |url| - u = URI.parse(url) + server_uri = URI.parse(Vagrant.server_url.to_s) - if u.host == server_uri.host - if server_uri.host != TARGET_HOST && !self.class.custom_host_notified? - env[:ui].warn(I18n.t("cloud_command.middleware.authentication.different_target", - custom_host: server_uri.host, known_host: TARGET_HOST) + "\n") - sleep CUSTOM_HOST_NOTIFY_WAIT - self.class.custom_host_notified! + if token && !server_uri.host.to_s.empty? + env[:box_urls].map! do |url| + begin + u = URI.parse(url) + + if u.host == server_uri.host + if server_uri.host != TARGET_HOST && !self.class.custom_host_notified? + env[:ui].warn(I18n.t("cloud_command.middleware.authentication.different_target", + custom_host: server_uri.host, known_host: TARGET_HOST) + "\n") + sleep CUSTOM_HOST_NOTIFY_WAIT + self.class.custom_host_notified! + end + + q = CGI.parse(u.query || "") + + current = q["access_token"] + if current && current.empty? + q["access_token"] = token + end + + u.query = URI.encode_www_form(q) + end + + u.to_s + rescue URI::Error + url end - + end + end + else + env[:box_urls].map! do |url| + begin + u = URI.parse(url) q = CGI.parse(u.query || "") - - current = q["access_token"] - if current && current.empty? - q["access_token"] = token + if !q["access_token"].empty? + @logger.warn("Removing access token from URL parameter.") + q.delete("access_token") + if q.empty? + u.query = nil + else + u.query = URI.encode_www_form(q) + end + u.to_s + else + @logger.warn("Authentication token not found as GET parameter.") + url end - - u.query = URI.encode_www_form(q) + rescue URI::Error + url end - - u.to_s end end - @app.call(env) end.freeze end diff -Nru vagrant-2.2.14+dfsg/plugins/commands/cloud/auth/middleware/add_downloader_authentication.rb vagrant-2.2.19+dfsg/plugins/commands/cloud/auth/middleware/add_downloader_authentication.rb --- vagrant-2.2.14+dfsg/plugins/commands/cloud/auth/middleware/add_downloader_authentication.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/cloud/auth/middleware/add_downloader_authentication.rb 2021-11-05 21:15:44.000000000 +0000 @@ -7,47 +7,54 @@ require Vagrant.source_root.join("plugins/commands/cloud/client/client") # Similar to AddAuthentication this middleware will add authentication for interacting -# with Vagrant cloud. It does this by adding Authentication headers to a -# Vagrant::Util::Downloader object. +# with Vagrant cloud. It does this by adding Authentication headers to a +# Vagrant::Util::Downloader object. module VagrantPlugins module CloudCommand class AddDownloaderAuthentication < AddAuthentication - @@logger = Log4r::Logger.new("vagrant::clout::add_download_authentication") + def initialize(app, env) + super + @logger = Log4r::Logger.new("vagrant::cloud::auth::add-download-authentication") + end def call(env) - client = Client.new(env[:env]) - token = client.token - Vagrant::Util::CredentialScrubber.sensitive(token) - - begin - target_url = URI.parse(env[:downloader].source) - if target_url.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(target_url.host) + if ENV["VAGRANT_SERVER_ACCESS_TOKEN_BY_URL"] + @logger.warn("Authentication header not added due to user requested access token URL parameter") + else + client = Client.new(env[:env]) + token = client.token + Vagrant::Util::CredentialScrubber.sensitive(token) + + begin + target_url = URI.parse(env[:downloader].source) + if target_url.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(target_url.host) target_url.host = TARGET_HOST env[:downloader].source = target_url.to_s + end + rescue URI::Error + # if there is an error, use current target_url end - rescue URI::Error - # if there is an error, use current target_url - end - server_uri = URI.parse(Vagrant.server_url.to_s) - if token && !server_uri.host.to_s.empty? - if target_url.host == server_uri.host - if server_uri.host != TARGET_HOST && !self.class.custom_host_notified? - env[:ui].warn(I18n.t("cloud_command.middleware.authentication.different_target", - custom_host: server_uri.host, known_host: TARGET_HOST) + "\n") - sleep CUSTOM_HOST_NOTIFY_WAIT - self.class.custom_host_notified! + server_uri = URI.parse(Vagrant.server_url.to_s) + if token && !server_uri.host.to_s.empty? + if target_url.host == server_uri.host + if server_uri.host != TARGET_HOST && !self.class.custom_host_notified? + env[:ui].warn(I18n.t("cloud_command.middleware.authentication.different_target", + custom_host: server_uri.host, known_host: TARGET_HOST) + "\n") + sleep CUSTOM_HOST_NOTIFY_WAIT + self.class.custom_host_notified! + end + + if Array(env[:downloader].headers).any? { |h| h.include?("Authorization") } + @logger.info("Not adding an authentication header, one already found") + else + env[:downloader].headers << "Authorization: Bearer #{token}" + end end - if Array(env[:downloader].headers).any? { |h| h.include?("Authorization") } - @@logger.info("Not adding an authentication header, one already found") - else - env[:downloader].headers << "Authorization: Bearer #{token}" - end + env[:downloader] end - - env[:downloader] end @app.call(env) diff -Nru vagrant-2.2.14+dfsg/plugins/commands/cloud/client/client.rb vagrant-2.2.19+dfsg/plugins/commands/cloud/client/client.rb --- vagrant-2.2.14+dfsg/plugins/commands/cloud/client/client.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/cloud/client/client.rb 2021-11-05 21:15:44.000000000 +0000 @@ -18,6 +18,7 @@ ###################################################################### APP = "app".freeze + include Util include Vagrant::Util::Presence attr_accessor :client @@ -32,7 +33,10 @@ def initialize(env) @logger = Log4r::Logger.new("vagrant::cloud::client") @env = env - @client = VagrantCloud::Client.new(access_token: token) + @client = VagrantCloud::Client.new( + access_token: token, + url_base: api_server_url + ) end # Removes the token, effectively logging the user out. @@ -72,7 +76,10 @@ password: password, description: description, code: code) Vagrant::Util::CredentialScrubber.sensitive(r[:token]) - @client = VagrantCloud::Client.new(access_token: r[:token]) + @client = VagrantCloud::Client.new( + access_token: r[:token], + url_base: api_server_url + ) r[:token] end end @@ -106,7 +113,7 @@ end # Reset after we store the token since this is now _our_ token - @client = VagrantCloud::Client.new(access_token: token) + @client = VagrantCloud::Client.new(access_token: token, url_base: api_server_url) nil end diff -Nru vagrant-2.2.14+dfsg/plugins/commands/cloud/locales/en.yml vagrant-2.2.19+dfsg/plugins/commands/cloud/locales/en.yml --- vagrant-2.2.14+dfsg/plugins/commands/cloud/locales/en.yml 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/cloud/locales/en.yml 2021-11-05 21:15:44.000000000 +0000 @@ -75,6 +75,10 @@ Updated provider %{provider} on %{org}/%{box_name} for version %{version} not_found: |- Failed to locate %{provider_name} provider for %{org}/%{box_name} on version %{version} + direct_disable: |- + Vagrant is automatically disabling direct upload to backend storage. + Uploads directly to backend storage are currently only supported for + files 5G in size or smaller. Box file to upload is: %{size} version: create_success: |- Created version %{version} on %{org}/%{box_name} for version %{version} @@ -112,7 +116,7 @@ Failed to update box %{org}/%{box_name} whoami: read_error: |- - Failed to read organization %{org} + Failed to locate account information provider: create_fail: |- Failed to create provider %{provider} on box %{org}/%{box_name} for version %{version} diff -Nru vagrant-2.2.14+dfsg/plugins/commands/cloud/provider/upload.rb vagrant-2.2.19+dfsg/plugins/commands/cloud/provider/upload.rb --- vagrant-2.2.14+dfsg/plugins/commands/cloud/provider/upload.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/cloud/provider/upload.rb 2021-11-05 21:15:44.000000000 +0000 @@ -58,6 +58,16 @@ access_token: access_token ) + # Include size check on file and disable direct if over 5G + if options[:direct] + fsize = File.stat(file).size + if fsize > (5 * Vagrant::Util::Numeric::GIGABYTE) + box_size = Vagrant::Util::Numeric.bytes_to_string(fsize) + @env.ui.warn(I18n.t("cloud_command.provider.direct_disable", size: box_size)) + options[:direct] = false + end + end + with_provider(account: account, org: org, box: box, version: version, provider: provider) do |p| p.upload(direct: options[:direct]) do |upload_url| m = options[:direct] ? :put : :put diff -Nru vagrant-2.2.14+dfsg/plugins/commands/cloud/publish.rb vagrant-2.2.19+dfsg/plugins/commands/cloud/publish.rb --- vagrant-2.2.14+dfsg/plugins/commands/cloud/publish.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/cloud/publish.rb 2021-11-05 21:15:44.000000000 +0000 @@ -129,6 +129,16 @@ def upload_box_file(provider, box_file, options={}) box_file = File.absolute_path(box_file) @env.ui.info(I18n.t("cloud_command.publish.upload_provider", file: box_file)) + # Include size check on file and disable direct if over 5G + if options[:direct_upload] + fsize = File.stat(box_file).size + if fsize > (5 * Vagrant::Util::Numeric::GIGABYTE) + box_size = Vagrant::Util::Numeric.bytes_to_string(fsize) + @env.ui.warn(I18n.t("cloud_command.provider.direct_disable", size: box_size)) + options[:direct_upload] = false + end + end + provider.upload(direct: options[:direct_upload]) do |upload_url| Vagrant::Util::Uploader.new(upload_url, box_file, ui: @env.ui, method: :put).upload! end diff -Nru vagrant-2.2.14+dfsg/plugins/commands/cloud/util.rb vagrant-2.2.19+dfsg/plugins/commands/cloud/util.rb --- vagrant-2.2.14+dfsg/plugins/commands/cloud/util.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/cloud/util.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,8 +5,16 @@ def api_server_url if Vagrant.server_url == Vagrant::DEFAULT_SERVER_URL return "#{Vagrant.server_url}/api/v1" - else - return Vagrant.server_url + end + begin + addr = URI.parse(Vagrant.server_url) + if addr.path.empty? || addr.path.to_s == "/" + addr.path = "/api/v1" + end + + addr.to_s + rescue URI::Error + Vagrant.server_url end end diff -Nru vagrant-2.2.14+dfsg/plugins/commands/destroy/command.rb vagrant-2.2.19+dfsg/plugins/commands/destroy/command.rb --- vagrant-2.2.14+dfsg/plugins/commands/destroy/command.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/destroy/command.rb 2021-11-05 21:15:44.000000000 +0000 @@ -56,7 +56,7 @@ end machines.each do |m| - if m.state.id == init_states[m.name] + if init_states[m.name] != :not_created && m.state.id == init_states[m.name] declined += 1 end end @@ -64,10 +64,6 @@ # Nothing was declined return 0 if declined == 0 - # Everything was declined, and all states are `not_created` - return 0 if declined == machines.length && - declined == init_states.values.count(:not_created) - # Everything was declined, state was not changed return 1 if declined == machines.length diff -Nru vagrant-2.2.14+dfsg/plugins/commands/package/command.rb vagrant-2.2.19+dfsg/plugins/commands/package/command.rb --- vagrant-2.2.14+dfsg/plugins/commands/package/command.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/package/command.rb 2021-11-05 21:15:44.000000000 +0000 @@ -29,6 +29,10 @@ options[:include] = i end + o.on("--info FILE", "Path to a custom info.json file containing additional box information") do |info| + options[:info] = info + end + o.on("--vagrantfile FILE", "Vagrantfile to package with the box") do |v| options[:vagrantfile] = v end diff -Nru vagrant-2.2.14+dfsg/plugins/commands/upload/command.rb vagrant-2.2.19+dfsg/plugins/commands/upload/command.rb --- vagrant-2.2.14+dfsg/plugins/commands/upload/command.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/commands/upload/command.rb 2021-11-05 21:15:44.000000000 +0000 @@ -52,7 +52,7 @@ end # NOTE: We do this to handle paths on Windows like: "..\space dir\" - # because the final separater acts to escape the quote and ends up + # because the final separator acts to escape the quote and ends up # in the source value. source = source.sub(/["']$/, "") destination ||= File.basename(source) diff -Nru vagrant-2.2.14+dfsg/plugins/guests/alpine/cap/configure_networks.rb vagrant-2.2.19+dfsg/plugins/guests/alpine/cap/configure_networks.rb --- vagrant-2.2.14+dfsg/plugins/guests/alpine/cap/configure_networks.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/alpine/cap/configure_networks.rb 2021-11-05 21:15:44.000000000 +0000 @@ -45,7 +45,7 @@ # each specifically, we avoid reconfiguring eth0 (the NAT interface) so # SSH never dies. interfaces.each do |interface| - comm.sudo("/sbin/ifdown eth#{interface} 2> /dev/null") + comm.sudo("if [[ $(/sbin/ip a show eth#{interface} | grep UP) ]]; then /sbin/ifdown eth#{interface} 2> /dev/null; fi") comm.sudo("/sbin/ip addr flush dev eth#{interface} 2> /dev/null") end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/atomic/guest.rb vagrant-2.2.19+dfsg/plugins/guests/atomic/guest.rb --- vagrant-2.2.14+dfsg/plugins/guests/atomic/guest.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/atomic/guest.rb 2021-11-05 21:15:44.000000000 +0000 @@ -4,7 +4,7 @@ module GuestAtomic class Guest < Vagrant.plugin("2", :guest) def detect?(machine) - machine.communicate.test("grep 'ostree=' /proc/cmdline") + machine.communicate.test("grep 'ostree=.*atomic' /proc/cmdline") end end end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/coreos/cap/configure_networks.rb vagrant-2.2.19+dfsg/plugins/guests/coreos/cap/configure_networks.rb --- vagrant-2.2.14+dfsg/plugins/guests/coreos/cap/configure_networks.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/coreos/cap/configure_networks.rb 2021-11-05 21:15:44.000000000 +0000 @@ -1,4 +1,5 @@ require "tempfile" +require "yaml" require_relative "../../../../lib/vagrant/util/template_renderer" @@ -8,9 +9,73 @@ class ConfigureNetworks extend Vagrant::Util::GuestInspection::Linux + NETWORK_MANAGER_CONN_DIR = "/etc/NetworkManager/system-connections".freeze DEFAULT_ENVIRONMENT_IP = "127.0.0.1".freeze def self.configure_networks(machine, networks) + comm = machine.communicate + return configure_networks_cloud_init(machine, networks) if comm.test("command -v cloud-init") + + interfaces = machine.guest.capability(:network_interfaces) + nm_dev = {} + comm.execute("nmcli -t c show") do |type, data| + if type == :stdout + _, id, _, dev = data.strip.split(":") + nm_dev[dev] = id + end + end + comm.sudo("rm #{File.join(NETWORK_MANAGER_CONN_DIR, 'vagrant-*.conf')}", + error_check: false) + + networks.each_with_index do |network, i| + network[:device] = interfaces[network[:interface]] + addr = IPAddr.new(network[:ip]) + mask = addr.mask(network[:netmask]) + if !network[:mac_address] + comm.execute("cat /sys/class/net/#{network[:device]}/address") do |type, data| + if type == :stdout + network[:mac_address] = data + end + end + end + + f = Tempfile.new("vagrant-coreos-network") + { + connection: { + type: "ethernet", + id: network[:device], + "interface-name": network[:device] + }, + ethernet: { + "mac-address": network[:mac_address] + }, + ipv4: { + method: "manual", + addresses: "#{network[:ip]}/#{mask.prefix}", + gateway: network.fetch(:gateway, mask.to_range.first.succ), + }, + }.each_pair do |section, content| + f.puts "[#{section}]" + content.each_pair do |key, value| + f.puts "#{key}=#{value}" + end + end + f.close + comm.sudo("nmcli d disconnect '#{network[:device]}'", error_check: false) + comm.sudo("nmcli c delete '#{nm_dev[network[:device]]}'", error_check: false) + dst = File.join("/var/tmp", "vagrant-#{network[:device]}.conf") + final = File.join(NETWORK_MANAGER_CONN_DIR, "vagrant-#{network[:device]}.conf") + comm.upload(f.path, dst) + comm.sudo("chown root:root '#{dst}'") + comm.sudo("chmod 0600 '#{dst}'") + comm.sudo("mv '#{dst}' '#{final}'") + comm.sudo("nmcli c load '#{final}'") + comm.sudo("nmcli d connect '#{network[:device]}'") + f.delete + end + end + + def self.configure_networks_cloud_init(machine, networks) cloud_config = {} # Locate configured IP addresses to drop in /etc/environment # for export. If no addresses found, fall back to default diff -Nru vagrant-2.2.14+dfsg/plugins/guests/darwin/cap/mount_smb_shared_folder.rb vagrant-2.2.19+dfsg/plugins/guests/darwin/cap/mount_smb_shared_folder.rb --- vagrant-2.2.14+dfsg/plugins/guests/darwin/cap/mount_smb_shared_folder.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/darwin/cap/mount_smb_shared_folder.rb 2021-11-05 21:15:44.000000000 +0000 @@ -29,9 +29,12 @@ "//#{options[:smb_username]}:#{smb_password}@#{options[:smb_host]}/#{name} " + "#{expanded_guest_path}" retryable(on: Vagrant::Errors::DarwinMountFailed, tries: 10, sleep: 2) do - machine.communicate.execute( - mount_command, - error_class: Vagrant::Errors::DarwinMountFailed) + result = machine.communicate.execute(mount_command) + if result.exit_code != 0 + raise Vagrant::Errors::DarwinMountFailed, + command: mount_command, + output: result.stderr + end end end end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/debian/cap/configure_networks.rb vagrant-2.2.19+dfsg/plugins/guests/debian/cap/configure_networks.rb --- vagrant-2.2.14+dfsg/plugins/guests/debian/cap/configure_networks.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/debian/cap/configure_networks.rb 2021-11-05 21:15:44.000000000 +0000 @@ -8,6 +8,7 @@ class ConfigureNetworks include Vagrant::Util extend Vagrant::Util::GuestInspection::Linux + extend Vagrant::Util::Retryable NETPLAN_DEFAULT_VERSION = 2 NETPLAN_DIRECTORY = "/etc/netplan".freeze @@ -166,11 +167,16 @@ rm -f /tmp/vagrant-network-interfaces.post EOH + comm.sudo(commands.join("\n")) + network_up_commands = [] + # Bring back up each network interface, reconfigured. networks.each do |network| - commands << "/sbin/ifup '#{network[:device]}'" + network_up_commands << "/sbin/ifup '#{network[:device]}'" + end + retryable(on: Vagrant::Errors::VagrantError, sleep: 2, tries: 2) do + comm.sudo(network_up_commands.join("\n")) end - comm.sudo(commands.join("\n")) end # Simple helper to upload content to guest temporary file diff -Nru vagrant-2.2.14+dfsg/plugins/guests/fedora/guest.rb vagrant-2.2.19+dfsg/plugins/guests/fedora/guest.rb --- vagrant-2.2.14+dfsg/plugins/guests/fedora/guest.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/fedora/guest.rb 2021-11-05 21:15:44.000000000 +0000 @@ -1,11 +1,11 @@ require "vagrant" +require_relative '../linux/guest' module VagrantPlugins module GuestFedora - class Guest < Vagrant.plugin("2", :guest) - def detect?(machine) - machine.communicate.test("grep 'Fedora release' /etc/redhat-release") - end + class Guest < VagrantPlugins::GuestLinux::Guest + # Name used for guest detection + GUEST_DETECTION_NAME = "fedora".freeze end end end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/linux/cap/mount_smb_shared_folder.rb vagrant-2.2.19+dfsg/plugins/guests/linux/cap/mount_smb_shared_folder.rb --- vagrant-2.2.14+dfsg/plugins/guests/linux/cap/mount_smb_shared_folder.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/linux/cap/mount_smb_shared_folder.rb 2021-11-05 21:15:44.000000000 +0000 @@ -20,7 +20,7 @@ :shell_expand_guest_path, guestpath) options[:smb_id] ||= name - mount_device = options[:plugin].capability(:mount_name, options) + mount_device = options[:plugin].capability(:mount_name, name, options) mount_options, _, _ = options[:plugin].capability( :mount_options, name, expanded_guest_path, options) mount_type = options[:plugin].capability(:mount_type) diff -Nru vagrant-2.2.14+dfsg/plugins/guests/linux/cap/persist_mount_shared_folder.rb vagrant-2.2.19+dfsg/plugins/guests/linux/cap/persist_mount_shared_folder.rb --- vagrant-2.2.14+dfsg/plugins/guests/linux/cap/persist_mount_shared_folder.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/linux/cap/persist_mount_shared_folder.rb 2021-11-05 21:15:44.000000000 +0000 @@ -34,13 +34,12 @@ mount_options, _, _ = data[:plugin].capability( :mount_options, name, guest_path, data) if data[:plugin].capability?(:mount_name) - name = data[:plugin].capability(:mount_name, data) + name = data[:plugin].capability(:mount_name, name, data) end else next end - mount_options = "#{mount_options},nofail" { name: name, mount_point: guest_path, diff -Nru vagrant-2.2.14+dfsg/plugins/guests/linux/cap/reboot.rb vagrant-2.2.19+dfsg/plugins/guests/linux/cap/reboot.rb --- vagrant-2.2.14+dfsg/plugins/guests/linux/cap/reboot.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/linux/cap/reboot.rb 2021-11-05 21:15:44.000000000 +0000 @@ -12,13 +12,16 @@ def self.reboot(machine) @logger = Log4r::Logger.new("vagrant::linux::reboot") + reboot_script = "ps -q 1 -o comm=,start= > /tmp/.vagrant-reboot" + if systemd?(machine.communicate) - reboot_script = "systemctl reboot" + reboot_cmd = "systemctl reboot" else - reboot_script = "reboot" + reboot_cmd = "reboot" end comm = machine.communicate + reboot_script += "; #{reboot_cmd}" @logger.debug("Issuing reboot command for guest") comm.sudo(reboot_script) @@ -43,8 +46,23 @@ end def self.wait_for_reboot(machine) - while !machine.guest.ready? + caught = false + begin + check_script = 'grep "$(ps -q 1 -o comm=,start=)" /tmp/.vagrant-reboot' + while machine.guest.ready? && machine.communicate.execute(check_script, error_check: false) == 0 + sleep 10 + end + rescue + # The check script execution may result in an exception + # getting raised depending on the state of the communicator + # when executing. We'll allow for it to happen once, and then + # raise if we get an exception again + if caught + raise + end + caught = true sleep 10 + retry end end end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/change_host_name.rb vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/change_host_name.rb --- vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/change_host_name.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/change_host_name.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,19 @@ +module VagrantPlugins + module GuestOpenWrt + module Cap + class ChangeHostName + def self.change_host_name(machine, name) + comm = machine.communicate + + if !comm.test("uci get system.@system[0].hostname | grep '^#{name}$'", sudo: false) + comm.execute <<~EOH + uci set system.@system[0].hostname='#{name}' + uci commit system + /etc/init.d/system reload + EOH + end + end + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/halt.rb vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/halt.rb --- vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/halt.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/halt.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,16 @@ +module VagrantPlugins + module GuestOpenWrt + module Cap + class Halt + def self.halt(machine) + begin + machine.communicate.execute("halt") + rescue IOError, Vagrant::Errors::SSHDisconnected + # Ignore, this probably means connection closed because it + # shut down. + end + end + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/insert_public_key.rb vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/insert_public_key.rb --- vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/insert_public_key.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/insert_public_key.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,20 @@ +require "vagrant/util/shell_quote" + +module VagrantPlugins + module GuestOpenWrt + module Cap + class InsertPublicKey + def self.insert_public_key(machine, contents) + contents = contents.chomp + contents = Vagrant::Util::ShellQuote.escape(contents, "'") + + machine.communicate.tap do |comm| + comm.execute <<~EOH + printf '#{contents}\\n' >> /etc/dropbear/authorized_keys + EOH + end + end + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/remove_public_key.rb vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/remove_public_key.rb --- vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/remove_public_key.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/remove_public_key.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,22 @@ +require "vagrant/util/shell_quote" + +module VagrantPlugins + module GuestOpenWrt + module Cap + class RemovePublicKey + def self.remove_public_key(machine, contents) + contents = contents.chomp + contents = Vagrant::Util::ShellQuote.escape(contents, "'") + + machine.communicate.tap do |comm| + comm.execute <<~EOH + if test -f /etc/dropbear/authorized_keys ; then + sed -i '/^.*#{contents}.*$/d' /etc/dropbear/authorized_keys + fi + EOH + end + end + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/rsync.rb vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/rsync.rb --- vagrant-2.2.14+dfsg/plugins/guests/openwrt/cap/rsync.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/openwrt/cap/rsync.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,35 @@ +module VagrantPlugins + module GuestOpenWrt + module Cap + class RSync + def self.rsync_installed(machine) + machine.communicate.test("which rsync") + end + + def self.rsync_install(machine) + machine.communicate.tap do |comm| + comm.execute <<~EOH + opkg update + opkg install rsync + EOH + end + end + + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.execute("mkdir -p '#{opts[:guestpath]}'") + end + end + + def self.rsync_command(machine) + "rsync -zz" + end + + def self.rsync_post(machine, opts) + # Don't do anything because BusyBox's `find` doesn't support the + # syntax in plugins/synced_folders/rsync/default_unix_cap.rb. + end + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/openwrt/guest.rb vagrant-2.2.19+dfsg/plugins/guests/openwrt/guest.rb --- vagrant-2.2.14+dfsg/plugins/guests/openwrt/guest.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/openwrt/guest.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,23 @@ +module VagrantPlugins + module GuestOpenWrt + class Guest + # Name used for guest detection + GUEST_DETECTION_NAME = "openwrt".freeze + + def detect?(machine) + machine.communicate.test <<~EOH + if test -e /etc/openwrt_release; then + exit + fi + if test -r /etc/os-release; then + source /etc/os-release && test 'x#{self.class.const_get(:GUEST_DETECTION_NAME)}' = "x$ID" && exit + fi + if test -r /etc/banner; then + cat /etc/banner | grep -qi '#{self.class.const_get(:GUEST_DETECTION_NAME)}' && exit + fi + exit 1 + EOH + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/openwrt/plugin.rb vagrant-2.2.19+dfsg/plugins/guests/openwrt/plugin.rb --- vagrant-2.2.14+dfsg/plugins/guests/openwrt/plugin.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/openwrt/plugin.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,61 @@ +require "vagrant" + +module VagrantPlugins + module GuestOpenWrt + class Plugin < Vagrant.plugin("2") + name "OpenWrt guest" + description "OpenWrt guest support." + + guest(:openwrt, :linux) do + require_relative "guest" + Guest + end + + guest_capability(:openwrt, :insert_public_key) do + require_relative "cap/insert_public_key" + Cap::InsertPublicKey + end + + guest_capability(:openwrt, :remove_public_key) do + require_relative "cap/remove_public_key" + Cap::RemovePublicKey + end + + guest_capability(:openwrt, :change_host_name) do + require_relative "cap/change_host_name" + Cap::ChangeHostName + end + + guest_capability(:openwrt, :rsync_installed) do + require_relative "cap/rsync" + Cap::RSync + end + + guest_capability(:openwrt, :rsync_install) do + require_relative "cap/rsync" + Cap::RSync + end + + guest_capability(:openwrt, :rsync_pre) do + require_relative "cap/rsync" + Cap::RSync + end + + guest_capability(:openwrt, :rsync_command) do + require_relative "cap/rsync" + Cap::RSync + end + + guest_capability(:openwrt, :rsync_post) do + require_relative "cap/rsync" + Cap::RSync + end + + guest_capability(:openwrt, :halt) do + require_relative "cap/halt" + Cap::Halt + end + end + end +end + diff -Nru vagrant-2.2.14+dfsg/plugins/guests/rocky/cap/flavor.rb vagrant-2.2.19+dfsg/plugins/guests/rocky/cap/flavor.rb --- vagrant-2.2.14+dfsg/plugins/guests/rocky/cap/flavor.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/rocky/cap/flavor.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,23 @@ +module VagrantPlugins + module GuestRocky + module Cap + class Flavor + def self.flavor(machine) + # Read the version file + version = "" + machine.communicate.sudo("source /etc/os-release && printf $VERSION_ID") do |type, data| + if type == :stdout + version = data.split(".").first.to_i + end + end + + if version.nil? || version < 1 + :rocky + else + "rocky_#{version}".to_sym + end + end + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/rocky/guest.rb vagrant-2.2.19+dfsg/plugins/guests/rocky/guest.rb --- vagrant-2.2.14+dfsg/plugins/guests/rocky/guest.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/rocky/guest.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,10 @@ +require_relative "../linux/guest" + +module VagrantPlugins + module GuestRocky + class Guest < VagrantPlugins::GuestLinux::Guest + # Name used for guest detection + GUEST_DETECTION_NAME = "rocky".freeze + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/rocky/plugin.rb vagrant-2.2.19+dfsg/plugins/guests/rocky/plugin.rb --- vagrant-2.2.14+dfsg/plugins/guests/rocky/plugin.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/rocky/plugin.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,20 @@ +require "vagrant" + +module VagrantPlugins + module GuestRocky + class Plugin < Vagrant.plugin("2") + name "Rocky guest" + description "Rocky guest support." + + guest(:rocky, :redhat) do + require_relative "guest" + Guest + end + + guest_capability(:rocky, :flavor) do + require_relative "cap/flavor" + Cap::Flavor + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/guests/suse/cap/halt.rb vagrant-2.2.19+dfsg/plugins/guests/suse/cap/halt.rb --- vagrant-2.2.14+dfsg/plugins/guests/suse/cap/halt.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/suse/cap/halt.rb 2021-11-05 21:15:44.000000000 +0000 @@ -4,7 +4,11 @@ class Halt def self.halt(machine) begin - machine.communicate.sudo("/sbin/shutdown -h now") + if machine.communicate.test("test -e /usr/bin/systemctl") + machine.communicate.sudo("/usr/bin/systemctl poweroff &") + else + machine.communicate.sudo("/sbin/shutdown -h now &") + end rescue IOError, Vagrant::Errors::SSHDisconnected # Do nothing, because it probably means the machine shut down # and SSH connection was lost. diff -Nru vagrant-2.2.14+dfsg/plugins/guests/windows/cap/rsync.rb vagrant-2.2.19+dfsg/plugins/guests/windows/cap/rsync.rb --- vagrant-2.2.14+dfsg/plugins/guests/windows/cap/rsync.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/guests/windows/cap/rsync.rb 2021-11-05 21:15:44.000000000 +0000 @@ -13,7 +13,11 @@ machine.communicate.tap do |comm| # rsync does not construct any gaps in the path to the target directory # make sure that all subdirectories are created - comm.execute("mkdir -p '#{opts[:guestpath]}'") + # NB: Per #11878, the `mkdir` command on Windows is different than used on Unix. + # This formulation matches the form used in the WinRM communicator plugin. + # This will ignore any -p switches, which are redundant in PowerShell, + # and ambiguous in PowerShell 4+ + comm.execute("mkdir \"#{opts[:guestpath]}\" -force") end end end diff -Nru vagrant-2.2.14+dfsg/plugins/hosts/darwin/cap/path.rb vagrant-2.2.19+dfsg/plugins/hosts/darwin/cap/path.rb --- vagrant-2.2.14+dfsg/plugins/hosts/darwin/cap/path.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/hosts/darwin/cap/path.rb 2021-11-05 21:15:44.000000000 +0000 @@ -6,6 +6,7 @@ FIRMLINK_DEFS = "/usr/share/firmlinks".freeze FIRMLINK_DATA_PATH = "/System/Volumes/Data".freeze + CATALINA_CONSTRAINT = Gem::Requirement.new("~> 10.15") # Resolve the given host path to the actual # usable system path by detecting firmlinks @@ -15,6 +16,9 @@ # @return [String] resolved path def self.resolve_host_path(env, path) path = File.expand_path(path) + # Only expand firmlink paths on Catalina + return path if !CATALINA_CONSTRAINT.satisfied_by?(Cap::Version.version(env)) + firmlink = firmlink_map.detect do |mount_path, data_path| path.start_with?(mount_path) end diff -Nru vagrant-2.2.14+dfsg/plugins/hosts/darwin/cap/version.rb vagrant-2.2.19+dfsg/plugins/hosts/darwin/cap/version.rb --- vagrant-2.2.14+dfsg/plugins/hosts/darwin/cap/version.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/hosts/darwin/cap/version.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,23 @@ +module VagrantPlugins + module HostDarwin + module Cap + class Version + def self.version(env) + r = Vagrant::Util::Subprocess.execute("sw_vers", "-productVersion") + if r.exit_code != 0 + raise Vagrant::Errors::DarwinVersionFailed, + version: r.stdout, + error: r.stderr + end + begin + Gem::Version.new(r.stdout) + rescue => err + raise Vagrant::Errors::DarwinVersionFailed, + version: r.stdout, + error: err.message + end + end + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/plugins/hosts/darwin/plugin.rb vagrant-2.2.19+dfsg/plugins/hosts/darwin/plugin.rb --- vagrant-2.2.14+dfsg/plugins/hosts/darwin/plugin.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/hosts/darwin/plugin.rb 2021-11-05 21:15:44.000000000 +0000 @@ -70,6 +70,11 @@ require_relative "cap/nfs" Cap::NFS end + + host_capability("darwin", "version") do + require_relative "cap/version" + Cap::Version + end end end end diff -Nru vagrant-2.2.14+dfsg/plugins/hosts/windows/cap/ssh.rb vagrant-2.2.19+dfsg/plugins/hosts/windows/cap/ssh.rb --- vagrant-2.2.14+dfsg/plugins/hosts/windows/cap/ssh.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/hosts/windows/cap/ssh.rb 2021-11-05 21:15:44.000000000 +0000 @@ -10,7 +10,7 @@ def self.set_ssh_key_permissions(env, key_path) script_path = Host.scripts_path.join("set_ssh_key_permissions.ps1") result = Vagrant::Util::PowerShell.execute( - script_path.to_s, "-KeyPath", key_path.to_s, + script_path.to_s, "-KeyPath", key_path.to_s.gsub(' ', '` '), module_path: Host.modules_path.to_s ) if result.exit_code != 0 diff -Nru vagrant-2.2.14+dfsg/plugins/hosts/windows/scripts/check_credentials.ps1 vagrant-2.2.19+dfsg/plugins/hosts/windows/scripts/check_credentials.ps1 --- vagrant-2.2.14+dfsg/plugins/hosts/windows/scripts/check_credentials.ps1 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/hosts/windows/scripts/check_credentials.ps1 2021-11-05 21:15:44.000000000 +0000 @@ -11,9 +11,24 @@ [System.DirectoryServices.AccountManagement.ContextType]::Machine, $env:COMPUTERNAME ) +if ( $DSContext.ValidateCredentials( $username, $password ) ) { + exit 0 +} + +$DSContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext( + [System.DirectoryServices.AccountManagement.ContextType]::Domain, + $env:COMPUTERNAME +) +if ( $DSContext.ValidateCredentials( $username, $password ) ) { + exit 0 +} +$DSContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext( + [System.DirectoryServices.AccountManagement.ContextType]::ApplicationDirectory, + $env:COMPUTERNAME +) if ( $DSContext.ValidateCredentials( $username, $password ) ) { exit 0 -} else { - exit 1 -} \ No newline at end of file +} + +exit 1 diff -Nru vagrant-2.2.14+dfsg/plugins/providers/docker/action/prepare_networks.rb vagrant-2.2.19+dfsg/plugins/providers/docker/action/prepare_networks.rb --- vagrant-2.2.14+dfsg/plugins/providers/docker/action/prepare_networks.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/providers/docker/action/prepare_networks.rb 2021-11-05 21:15:44.000000000 +0000 @@ -171,8 +171,8 @@ raise Errors::NetworkNoInterfaces elsif valid_interfaces.size == 1 bridge_interface = valid_interfaces.first - elsif i = valid_interfaces.detect{|i| Array(root_options[:bridge]).include?(i.name) } - bridge_interface = i + elsif idx = valid_interfaces.detect{|i| Array(root_options[:bridge]).include?(i.name) } + bridge_interface = idx end if !bridge_interface env[:ui].info(I18n.t("vagrant.actions.vm.bridged_networking.available"), diff -Nru vagrant-2.2.14+dfsg/plugins/providers/docker/driver.rb vagrant-2.2.19+dfsg/plugins/providers/docker/driver.rb --- vagrant-2.2.14+dfsg/plugins/providers/docker/driver.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/providers/docker/driver.rb 2021-11-05 21:15:44.000000000 +0000 @@ -23,11 +23,11 @@ args = Array(opts[:extra_args]) args << dir opts = {with_stderr: true} - result = execute('docker', 'build', *args, opts, &block) + result = execute('docker', 'build', *args, **opts, &block) # Check for the new output format 'writing image sha256...' - # In this case, docker builtkit is enabled. Its format is different + # In this case, docker buildkit is enabled. Its format is different # from standard docker - matches = result.scan(/writing image .+:([0-9a-z]+) done/i).last + matches = result.scan(/writing image .+:([^\s]+)/i).last if !matches if podman? # Check for podman format when it is emulating docker CLI. @@ -47,7 +47,7 @@ end # Return the matched group `id` - matches[0] + matches[0].strip end # Check if podman emulating docker CLI is enabled. @@ -79,7 +79,7 @@ if v.index(":") != v.rindex(":") # If we have 2 colons, the host path is an absolute Windows URL # and we need to remove the colon from it - host, colon, guest = v.rpartition(":") + host, _, guest = v.rpartition(":") host = "//" + host[0].downcase + host[2..-1] v = [host, guest].join(":") else diff -Nru vagrant-2.2.14+dfsg/plugins/providers/hyperv/scripts/get_network_config.ps1 vagrant-2.2.19+dfsg/plugins/providers/hyperv/scripts/get_network_config.ps1 --- vagrant-2.2.14+dfsg/plugins/providers/hyperv/scripts/get_network_config.ps1 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/providers/hyperv/scripts/get_network_config.ps1 2021-11-05 21:15:44.000000000 +0000 @@ -15,10 +15,10 @@ } try { - $networks = Hyper-V\Get-VMNetworkAdapter -VM $vm - foreach ($network in $networks) { - if ($network.IpAddresses.Length -gt 0) { - foreach ($ip_address in $network.IpAddresses) { + $netdev = Hyper-V\Get-VMNetworkAdapter -VM $vm | Select-Object -Index 0 + if ($netdev -ne $null) { + if ($netdev.IpAddresses.Length -gt 0) { + foreach ($ip_address in $netdev.IpAddresses) { if ($ip_address.Contains(".") -And [string]::IsNullOrEmpty($ip4_address)) { $ip4_address = $ip_address } elseif ($ip_address.Contains(":") -And [string]::IsNullOrEmpty($ip6_address)) { @@ -26,14 +26,11 @@ } } } - } - # If no address was found in the network settings, check for - # neighbor with mac address and see if an IP exists - if (([string]::IsNullOrEmpty($ip4_address)) -And ([string]::IsNullOrEmpty($ip6_address))) { - $macaddresses = $vm | select -ExpandProperty NetworkAdapters | select MacAddress - foreach ($macaddr in $macaddresses) { - $macaddress = $macaddr.MacAddress -replace '(.{2})(?!$)', '${1}-' + # If no address was found in the network settings, check for + # neighbor with mac address and see if an IP exists + if (([string]::IsNullOrEmpty($ip4_address)) -And ([string]::IsNullOrEmpty($ip6_address))) { + $macaddress = $netdev.MacAddress -replace '(.{2})(?!$)', '${1}-' $addr = Get-NetNeighbor -LinkLayerAddress $macaddress -ErrorAction SilentlyContinue | select IPAddress if ($addr) { $ip_address = $addr.IPAddress diff -Nru vagrant-2.2.14+dfsg/plugins/providers/virtualbox/action/network.rb vagrant-2.2.19+dfsg/plugins/providers/virtualbox/action/network.rb --- vagrant-2.2.14+dfsg/plugins/providers/virtualbox/action/network.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/providers/virtualbox/action/network.rb 2021-11-05 21:15:44.000000000 +0000 @@ -16,6 +16,14 @@ # # This handles all the `config.vm.network` configurations. class Network + + # Location of the VirtualBox networks configuration file + VBOX_NET_CONF = "/etc/vbox/networks.conf".freeze + # Version of VirtualBox that introduced hostonly network range restrictions + HOSTONLY_VALIDATE_VERSION = Gem::Version.new("6.1.28") + # Default valid range for hostonly networks + HOSTONLY_DEFAULT_RANGE = [IPAddr.new("192.168.56.0/21").freeze].freeze + include Vagrant::Util::NetworkIP include Vagrant::Util::ScopedHashOverride @@ -256,8 +264,16 @@ # Make sure the type is a symbol options[:type] = options[:type].to_sym - # Default IP is in the 20-bit private network block for DHCP based networks - options[:ip] = "172.28.128.1" if options[:type] == :dhcp && !options[:ip] + if options[:type] == :dhcp && !options[:ip] + # Try to find a matching device to set the config ip to + matching_device = hostonly_find_matching_network(options) + if matching_device + options[:ip] = matching_device[:ip] + else + # Default IP is in the 20-bit private network block for DHCP based networks + options[:ip] = "192.168.56.1" + end + end begin ip = IPAddr.new(options[:ip]) @@ -280,6 +296,8 @@ error: e.message end + validate_hostonly_ip!(options[:ip], @env[:machine].provider.driver) + if ip.ipv4? # Verify that a host-only network subnet would not collide # with a bridged networking interface. @@ -469,7 +487,7 @@ # This finds a matching host only network for the given configuration. def hostonly_find_matching_network(config) - this_netaddr = network_address(config[:ip], config[:netmask]) + this_netaddr = network_address(config[:ip], config[:netmask]) if config[:ip] @env[:machine].provider.driver.read_host_only_interfaces.each do |interface| return interface if config[:name] && config[:name] == interface[:name] @@ -493,6 +511,33 @@ nil end + # Validates the IP used to configure the network is within the allowed + # ranges. It only validates if the network configuration file exists. + # This was introduced in 6.1.28 so previous version won't have restrictions + # placed on the valid ranges + def validate_hostonly_ip!(ip, driver) + return if Gem::Version.new(driver.version) < HOSTONLY_VALIDATE_VERSION || + Vagrant::Util::Platform.windows? + + ip = IPAddr.new(ip.to_s) if !ip.is_a?(IPAddr) + valid_ranges = load_net_conf + return if valid_ranges.any?{ |range| range.include?(ip) } + raise Vagrant::Errors::VirtualBoxInvalidHostSubnet, + address: ip, + ranges: valid_ranges.map{ |r| "#{r}/#{r.prefix}" }.join(", ") + end + + def load_net_conf + return HOSTONLY_DEFAULT_RANGE if !File.exist?(VBOX_NET_CONF) + File.readlines(VBOX_NET_CONF).map do |line| + line = line.strip + next if !line.start_with?("*") + line[1,line.length].strip.split(" ").map do |entry| + IPAddr.new(entry) + end + end.flatten.compact + end + #----------------------------------------------------------------- # DHCP Server Helper Functions #----------------------------------------------------------------- @@ -515,7 +560,6 @@ # @param [Hash] config hash as returned from hostonly_config def create_dhcp_server_if_necessary(interface, config) existing_dhcp_server = find_matching_dhcp_server(interface) - if existing_dhcp_server if dhcp_server_matches_config?(existing_dhcp_server, config) @logger.debug("DHCP server already properly configured") diff -Nru vagrant-2.2.14+dfsg/plugins/providers/virtualbox/cap/mount_options.rb vagrant-2.2.19+dfsg/plugins/providers/virtualbox/cap/mount_options.rb --- vagrant-2.2.14+dfsg/plugins/providers/virtualbox/cap/mount_options.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/providers/virtualbox/cap/mount_options.rb 2021-11-05 21:15:44.000000000 +0000 @@ -22,6 +22,7 @@ mount_options << "uid=#{mount_uid}" mount_options << "gid=#{mount_gid}" + mount_options << "_netdev" mount_options = mount_options.join(',') return mount_options, mount_uid, mount_gid end @@ -29,6 +30,10 @@ def self.mount_type(machine) return VB_MOUNT_TYPE end + + def self.mount_name(machine, name, data) + name.gsub(/[\s\/\\]/,'_').sub(/^_/, '') + end end end end diff -Nru vagrant-2.2.14+dfsg/plugins/providers/virtualbox/plugin.rb vagrant-2.2.19+dfsg/plugins/providers/virtualbox/plugin.rb --- vagrant-2.2.14+dfsg/plugins/providers/virtualbox/plugin.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/providers/virtualbox/plugin.rb 2021-11-05 21:15:44.000000000 +0000 @@ -78,6 +78,11 @@ require_relative "cap/mount_options" Cap::MountOptions end + + synced_folder_capability(:virtualbox, "mount_name") do + require_relative "cap/mount_options" + Cap::MountOptions + end end autoload :Action, File.expand_path("../action", __FILE__) diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb vagrant-2.2.19+dfsg/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb --- vagrant-2.2.14+dfsg/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb 2021-11-05 21:15:44.000000000 +0000 @@ -11,7 +11,7 @@ if install_mode != :default raise Ansible::Errors::AnsiblePipInstallIsNotSupported else - machine.communicate.sudo "pkg install -qy py36-ansible" + machine.communicate.sudo "pkg install -qy py37-ansible" end end diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/ansible/provisioner/base.rb vagrant-2.2.19+dfsg/plugins/provisioners/ansible/provisioner/base.rb --- vagrant-2.2.14+dfsg/plugins/provisioners/ansible/provisioner/base.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/ansible/provisioner/base.rb 2021-11-05 21:15:44.000000000 +0000 @@ -388,8 +388,9 @@ ansible_version_pattern = first_line.match(/(^ansible\s+)(.+)$/) if ansible_version_pattern _, @gathered_version, _ = ansible_version_pattern.captures + @gathered_version.strip! if @gathered_version - @gathered_version_major = @gathered_version.match(/^(\d)\..+$/).captures[0].to_i + @gathered_version_major = @gathered_version.match(/(\d)\..+$/).captures[0].to_i end end end diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/chef/cap/freebsd/chef_installed.rb vagrant-2.2.19+dfsg/plugins/provisioners/chef/cap/freebsd/chef_installed.rb --- vagrant-2.2.14+dfsg/plugins/provisioners/chef/cap/freebsd/chef_installed.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/chef/cap/freebsd/chef_installed.rb 2021-11-05 21:15:44.000000000 +0000 @@ -6,11 +6,13 @@ # Check if Chef is installed at the given version. # @return [true, false] def self.chef_installed(machine, product, version) - knife = "/opt/#{product}/bin/knife" - command = "test -x #{knife}" + product_name = product == 'chef-workstation' ? 'chef-workstation' : 'chef' + verify_bin = product_name == 'chef-workstation' ? 'chef' : 'chef-client' + verify_path = "/opt/#{product_name}/bin/#{verify_bin}" + command = "test -x #{verify_path}" if version != :latest - command << "&& #{knife} --version | grep '#{version}'" + command << "&& #{verify_path} --version | grep '#{version}'" end machine.communicate.test(command, sudo: true) diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/chef/cap/linux/chef_installed.rb vagrant-2.2.19+dfsg/plugins/provisioners/chef/cap/linux/chef_installed.rb --- vagrant-2.2.14+dfsg/plugins/provisioners/chef/cap/linux/chef_installed.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/chef/cap/linux/chef_installed.rb 2021-11-05 21:15:44.000000000 +0000 @@ -6,11 +6,13 @@ # Check if Chef is installed at the given version. # @return [true, false] def self.chef_installed(machine, product, version) - knife = "/opt/#{product}/bin/knife" - command = "test -x #{knife}" + product_name = product == 'chef-workstation' ? 'chef-workstation' : 'chef' + verify_bin = product_name == 'chef-workstation' ? 'chef' : 'chef-client' + verify_path = "/opt/#{product_name}/bin/#{verify_bin}" + command = "test -x #{verify_path}" if version != :latest - command << "&& #{knife} --version | grep '#{version}'" + command << "&& #{verify_path} --version | grep '#{version}'" end machine.communicate.test(command, sudo: true) diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/chef/cap/omnios/chef_installed.rb vagrant-2.2.19+dfsg/plugins/provisioners/chef/cap/omnios/chef_installed.rb --- vagrant-2.2.14+dfsg/plugins/provisioners/chef/cap/omnios/chef_installed.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/chef/cap/omnios/chef_installed.rb 2021-11-05 21:15:44.000000000 +0000 @@ -2,19 +2,21 @@ module Chef module Cap module OmniOS - module ChefInstalled + module ChefInstalled # TODO: this is the same code as cap/linux/chef_installed, consider merging # Check if Chef is installed at the given version. # @return [true, false] def self.chef_installed(machine, product, version) - knife = "/opt/#{product}/bin/knife" - command = "test -x #{knife}" + product_name = product == 'chef-workstation' ? 'chef-workstation' : 'chef' + verify_bin = product_name == 'chef-workstation' ? 'chef' : 'chef-client' + verify_path = "/opt/#{product_name}/bin/#{verify_bin}" + command = "test -x #{verify_path}" if version != :latest - command << "&& #{knife} --version | grep '#{version}'" + command << "&& #{verify_path} --version | grep '#{version}'" end - machine.communicate.test(command, sudo: true) + machine.communicate.test(command, sudo: true) end end end diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/chef/cap/windows/chef_installed.rb vagrant-2.2.19+dfsg/plugins/provisioners/chef/cap/windows/chef_installed.rb --- vagrant-2.2.14+dfsg/plugins/provisioners/chef/cap/windows/chef_installed.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/chef/cap/windows/chef_installed.rb 2021-11-05 21:15:44.000000000 +0000 @@ -6,10 +6,11 @@ # Check if Chef is installed at the given version. # @return [true, false] def self.chef_installed(machine, product, version) + verify_bin = product == 'chef-workstation' ? 'chef' : 'chef-client' if version != :latest - command = 'if ((&knife --version) -Match "' + version.to_s + '"){ exit 0 } else { exit 1 }' + command = 'if ((&' + verify_bin + ' --version) -Match "' + version.to_s + '"){ exit 0 } else { exit 1 }' else - command = 'if ((&knife --version) -Match "Chef*"){ exit 0 } else { exit 1 }' + command = 'if ((&' + verify_bin + ' --version) -Match "Chef*"){ exit 0 } else { exit 1 }' end machine.communicate.test(command, sudo: true) end diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/container/client.rb vagrant-2.2.19+dfsg/plugins/provisioners/container/client.rb --- vagrant-2.2.14+dfsg/plugins/provisioners/container/client.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/container/client.rb 2021-11-05 21:15:44.000000000 +0000 @@ -10,7 +10,7 @@ # Build an image given a path to a Dockerfile # - # @param [String] - Path to the Dockerfile to pass to + # @param [Array>] - Path and options to the Dockerfile to pass to # container build command def build_images(images) @machine.communicate.tap do |comm| @@ -195,7 +195,7 @@ options = {} #options[:color] = color if !config.keep_color - @machine.ui.info(data.chomp, options) + @machine.ui.info(data.chomp, **options) end end end diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/salt/bootstrap-salt.ps1 vagrant-2.2.19+dfsg/plugins/provisioners/salt/bootstrap-salt.ps1 --- vagrant-2.2.14+dfsg/plugins/provisioners/salt/bootstrap-salt.ps1 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/salt/bootstrap-salt.ps1 2021-11-05 21:15:44.000000000 +0000 @@ -1,151 +1,11 @@ -Param( - [string]$version, - [string]$pythonVersion = "2", - [string]$runservice, - [string]$minion, - [string]$master -) +# Powershell supports only TLS 1.0 by default. Add support for TLS 1.2 +[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls12' -# Constants -$ServiceName = "salt-minion" -$startupType = "Manual" +# Define script root for PowerShell 2.0 +$ScriptRoot = Split-Path $script:MyInvocation.MyCommand.Path -# Version to install - default to latest if there is an issue -If ($version -notmatch "2\d{3}\.\d{1,2}\.\d+(\-\d{1})?"){ - $version = '2018.3.3' -} +# Download the upstream bootstrap script +(New-Object System.Net.WebClient).DownloadFile('https://winbootstrap.saltproject.io', "${ScriptRoot}\bootstrap_salt_upstream.ps1") -If ($pythonVersion -notmatch "\d+") { - $pythonVersion = "2" - Write-Host "Defaulting to minion Python version $pythonVersion" -} - -If ($runservice.ToLower() -eq "true"){ - Write-Host "Service is set to run." - [bool]$runservice = $True -} -ElseIf ($runservice.ToLower() -eq "false"){ - Write-Host "Service will be stopped and set to manual." - [bool]$runservice = $False -} -Else { - # Param passed in wasn't clear so defaulting to true. - Write-Host "Service defaulting to run." - [bool]$runservice = $True -} - - -# Create C:\tmp\ - if Vagrant doesn't upload keys and/or config it might not exist -New-Item C:\tmp\ -ItemType directory -force | out-null - -# Copy minion keys & config to correct location -New-Item C:\salt\conf\pki\minion\ -ItemType directory -force | out-null - -# Check if minion keys have been uploaded -If (Test-Path C:\tmp\minion.pem) { - cp C:\tmp\minion.pem C:\salt\conf\pki\minion\ - cp C:\tmp\minion.pub C:\salt\conf\pki\minion\ -} - -# Detect architecture -If ([IntPtr]::Size -eq 4) { - $arch = "x86" -} Else { - $arch = "AMD64" -} - -# Download minion setup file -$minionFilename = "Salt-Minion-$version-$arch-Setup.exe" -$versionYear = [regex]::Match($version, "\d+").Value -If ([convert]::ToInt32($versionYear) -ge 2017) -{ - $minionFilename = "Salt-Minion-$version-Py$pythonVersion-$arch-Setup.exe" -} -Write-Host "Downloading Salt minion installer $minionFilename" -$webclient = New-Object System.Net.WebClient -$url = "https://repo.saltstack.com/windows/$minionFilename" -$file = "C:\tmp\salt.exe" - -[int]$retries = 0 -Do { - try { - $retries++ - $ErrorActionPreference='Stop' - $webclient.DownloadFile($url, $file) - break - } catch [Exception] { - if($retries -eq 5) { - $_ - $_.GetType() - $_.Exception - $_.Exception.StackTrace - Write-Host - exit 1 - } - Write-Warning "Retrying download in 2 seconds. Retry # $retries" - Start-Sleep -s 2 - } -} -Until($retries -eq 5) - - -# Install minion silently -Write-Host "Installing Salt minion..." -#Wait for process to exit before continuing... -If($PSBoundParameters.ContainsKey('minion') -and $PSBoundParameters.ContainsKey('master')) { - C:\tmp\salt.exe /S /minion-name=$minion /master=$master | Out-Null - Write-Host C:\tmp\salt.exe /S /minion-name=$minion /master=$master | Out-Null -} -ElseIf($PSBoundParameters.ContainsKey('minion') -and !$PSBoundParameters.ContainsKey('master')) { - C:\tmp\salt.exe /S /minion-name=$minion | Out-Null - Write-Host C:\tmp\salt.exe /S /minion-name=$minion | Out-Null -} -ElseIf(!$PSBoundParameters.ContainsKey('minion') -and $PSBoundParameters.ContainsKey('master')) { - C:\tmp\salt.exe /S /master=$master | Out-Null - Write-Host C:\tmp\salt.exe /S /master=$master | Out-Null -} -Else { - C:\tmp\salt.exe /S | Out-Null - Write-Host C:\tmp\salt.exe /S | Out-Null -} - -# Check if minion config has been uploaded -If (Test-Path C:\tmp\minion) { - cp C:\tmp\minion C:\salt\conf\ -} - -# Wait for salt-minion service to be registered before trying to start it -$service = Get-Service salt-minion -ErrorAction SilentlyContinue -While (!$service) { - Start-Sleep -s 2 - $service = Get-Service salt-minion -ErrorAction SilentlyContinue -} - -If($runservice) { - # Start service - Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue - - # Check if service is started, otherwise retry starting the - # service 4 times. - $try = 0 - While (($service.Status -ne "Running") -and ($try -ne 4)) { - Start-Service -Name "salt-minion" -ErrorAction SilentlyContinue - $service = Get-Service salt-minion -ErrorAction SilentlyContinue - Start-Sleep -s 2 - $try += 1 - } - - # If the salt-minion service is still not running, something probably - # went wrong and user intervention is required - report failure. - If ($service.Status -eq "Stopped") { - Write-Host "Failed to start Salt minion" - exit 1 - } -} -Else { - Write-Host "Stopping salt minion" - Set-Service "$ServiceName" -startupType "$startupType" - Stop-Service "$ServiceName" -} - -Write-Host "Salt minion successfully installed" \ No newline at end of file +# Run the upstream bootstrap script with passthrough arguments +& "${ScriptRoot}\bootstrap_salt_upstream.ps1" @args diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/salt/bootstrap-salt.sh vagrant-2.2.19+dfsg/plugins/provisioners/salt/bootstrap-salt.sh --- vagrant-2.2.14+dfsg/plugins/provisioners/salt/bootstrap-salt.sh 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/salt/bootstrap-salt.sh 2021-11-05 21:15:44.000000000 +0000 @@ -4,13 +4,16 @@ # We just download the bootstrap script by default and execute that. if [ -x /usr/bin/fetch ]; then - /usr/bin/fetch -o bootstrap-salt.sh https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh + /usr/bin/fetch -o bootstrap-salt.sh https://bootstrap.saltproject.io elif [ -x /usr/bin/curl ]; then - /usr/bin/curl --silent --show-error -L -O https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh + /usr/bin/curl --silent --show-error -L --output bootstrap-salt.sh https://bootstrap.saltproject.io elif [ -x /usr/bin/wget ]; then - /usr/bin/wget -O bootstrap-salt.sh https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh + /usr/bin/wget -O bootstrap-salt.sh https://bootstrap.saltproject.io +elif [ "2" = `python -c 'import sys; sys.stdout.write(str(sys.version_info.major))'` ]; then + # TODO: remove after there is no supported distros with Python 2 + python -c 'import urllib; urllib.urlretrieve("https://bootstrap.saltproject.io", "bootstrap-salt.sh")' else - python -c 'import urllib; urllib.urlretrieve("https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh", "bootstrap-salt.sh")' + python -c 'import urllib.request; urllib.request.urlretrieve("https://bootstrap.saltproject.io", "bootstrap-salt.sh")' fi if [ -e bootstrap-salt.sh ]; then diff -Nru vagrant-2.2.14+dfsg/plugins/provisioners/shell/provisioner.rb vagrant-2.2.19+dfsg/plugins/provisioners/shell/provisioner.rb --- vagrant-2.2.14+dfsg/plugins/provisioners/shell/provisioner.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/provisioners/shell/provisioner.rb 2021-11-05 21:15:44.000000000 +0000 @@ -2,6 +2,7 @@ require "tempfile" require "vagrant/util/downloader" +require "vagrant/util/line_buffer" require "vagrant/util/retryable" module VagrantPlugins @@ -65,20 +66,27 @@ protected - # This handles outputting the communication data back to the UI + def build_outputs + outputs = { + stdout: Vagrant::Util::LineBuffer.new { |line| handle_comm(:stdout, line) }, + stderr: Vagrant::Util::LineBuffer.new { |line| handle_comm(:stderr, line) }, + } + block = proc { |type, data| + outputs[type] << data if outputs[type] + } + return outputs, block + end + + # This handles outputting the communication line back to the UI def handle_comm(type, data) if [:stderr, :stdout].include?(type) - # Output the data with the proper color based on the stream. + # Output the line with the proper color based on the stream. color = type == :stdout ? :green : :red - # Clear out the newline since we add one - data = data.chomp - return if data.empty? - options = {} options[:color] = color if !config.keep_color - @machine.ui.detail(data.chomp, options) + @machine.ui.detail(data.chomp, **options) end end @@ -121,12 +129,16 @@ end # Execute it with sudo - comm.execute( - command, - sudo: config.privileged, - error_key: :ssh_bad_exit_status_muted - ) do |type, data| - handle_comm(type, data) + outputs, handler = build_outputs + begin + comm.execute( + command, + sudo: config.privileged, + error_key: :ssh_bad_exit_status_muted, + &handler + ) + ensure + outputs.values.map(&:close) end end end @@ -161,7 +173,7 @@ info = @machine.ssh_info raise Vagrant::Errors::SSHNotReady if info.nil? end - + comm.upload(path.to_s, remote_path) if config.name @@ -176,12 +188,16 @@ end # Execute it with sudo - comm.execute( - command, - shell: :powershell, - error_key: :ssh_bad_exit_status_muted - ) do |type, data| - handle_comm(type, data) + begin + outputs, handler = build_outputs + comm.execute( + command, + shell: :powershell, + error_key: :ssh_bad_exit_status_muted, + &handler + ) + ensure + outputs.values.map(&:close) end end end @@ -245,8 +261,15 @@ end # Execute it with sudo - comm.sudo(command, { elevated: config.privileged, interactive: config.powershell_elevated_interactive }) do |type, data| - handle_comm(type, data) + begin + outputs, handler = build_outputs + comm.sudo(command, + elevated: config.privileged, + interactive: config.powershell_elevated_interactive, + &handler + ) + ensure + outputs.values.map(&:close) end end end diff -Nru vagrant-2.2.14+dfsg/plugins/synced_folders/smb/cap/mount_options.rb vagrant-2.2.19+dfsg/plugins/synced_folders/smb/cap/mount_options.rb --- vagrant-2.2.14+dfsg/plugins/synced_folders/smb/cap/mount_options.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/plugins/synced_folders/smb/cap/mount_options.rb 2021-11-05 21:15:44.000000000 +0000 @@ -36,7 +36,7 @@ end mnt_opts << "_netdev" mnt_opts = merge_mount_options(mnt_opts, options[:mount_options] || []) - + mnt_opts << "nofail" mount_options = mnt_opts.join(",") return mount_options, mount_uid, mount_gid end @@ -45,7 +45,7 @@ return MOUNT_TYPE end - def self.mount_name(machine, data) + def self.mount_name(machine, name, data) data[:smb_host] ||= machine.guest.capability( :choose_addressable_ip_addr, candidate_ips) "//#{data[:smb_host]}/#{data[:smb_id]}" diff -Nru vagrant-2.2.14+dfsg/scripts/install_rvm vagrant-2.2.19+dfsg/scripts/install_rvm --- vagrant-2.2.14+dfsg/scripts/install_rvm 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/scripts/install_rvm 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +export DEBIAN_FRONTEND=noninteractive + +if ! rvm --version +then + # https://github.com/rvm/ubuntu_rvm#install + apt-add-repository -y ppa:rael-gc/rvm && + apt-get update -y && + apt-get install -y rvm || { + echo 'Failed to install rvm' >&2 + exit 1 + } +fi + +usermod -a -G rvm vagrant || { + echo 'Failed to add vagrant to the rvm group' >&2 + exit 1 +} diff -Nru vagrant-2.2.14+dfsg/scripts/setup_tests vagrant-2.2.19+dfsg/scripts/setup_tests --- vagrant-2.2.14+dfsg/scripts/setup_tests 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/scripts/setup_tests 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +rvm --version || { + echo 'rvm not installed' >&2 + exit 1 +} + +# bsdtar is required for a small subset of the tests +if ! bsdtar --version +then + apt-get install -y bsdtar && + bsdtar --version || { + echo 'Failed to install bsdtar' >&2 + exit 1 + } +fi + +# Install next-to-last Ruby that complies with Vagrant's version +# constraint +RUBY_VER_REQ=$( + awk ' + $1 == "s.required_ruby_version" { print $4 } + ' /vagrant/vagrant.gemspec | + tr -d '"') +RUBY_VER=$(sudo -u vagrant -i rvm list known | + tr '[]-' ' ' | + awk "/^ ruby ${RUBY_VER_REQ:0:1}\./ { print \$2 }" | + sort -r | + sed -n '2p') +sudo -u vagrant -i rvm install "${RUBY_VER}" +sudo -u vagrant -i rvm --default use "${RUBY_VER}" + +# Output the Ruby version (for sanity) +sudo -u vagrant -i ruby --version + +# Upgrade Rubygems +sudo -u vagrant -i rvm "${RUBY_VER}" do gem update --system + +# Prepare to run unit tests +sudo -u vagrant -i bash -c 'cd /vagrant; bundle install' + +# Automatically move into the shared folder, but only add the command if +# it's not already there. +if ! grep -q 'cd /vagrant' /home/vagrant/.bash_profile +then + cat <> /home/vagrant/.bash_profile +cd /vagrant +EOF +fi diff -Nru vagrant-2.2.14+dfsg/templates/commands/init/Vagrantfile.min.erb vagrant-2.2.19+dfsg/templates/commands/init/Vagrantfile.min.erb --- vagrant-2.2.14+dfsg/templates/commands/init/Vagrantfile.min.erb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/templates/commands/init/Vagrantfile.min.erb 2021-11-05 21:15:44.000000000 +0000 @@ -1,3 +1,6 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + Vagrant.configure("2") do |config| config.vm.box = "<%= box_name %>" <% if box_version -%> diff -Nru vagrant-2.2.14+dfsg/templates/guests/nixos/network.erb vagrant-2.2.19+dfsg/templates/guests/nixos/network.erb --- vagrant-2.2.14+dfsg/templates/guests/nixos/network.erb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/templates/guests/nixos/network.erb 2021-11-05 21:15:44.000000000 +0000 @@ -1,16 +1,15 @@ { config, pkgs, ... }: { - networking.interfaces = [ + networking.interfaces = { <% networks.select {|n| n[:device]}.each do |network| %> - { - name = "<%= network[:device] %>"; + <%= network[:device] %>.ipv4.addresses = [{ <% if network[:type] == :static %> - ipAddress = "<%= network[:ip] %>"; + address = "<%= network[:ip] %>"; <% end %> <% if network[:prefix_length] %> prefixLength = <%= network[:prefix_length] %>; <% end %> - } + }]; <% end %> - ]; + }; } diff -Nru vagrant-2.2.14+dfsg/templates/locales/en.yml vagrant-2.2.19+dfsg/templates/locales/en.yml --- vagrant-2.2.14+dfsg/templates/locales/en.yml 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/templates/locales/en.yml 2021-11-05 21:15:44.000000000 +0000 @@ -794,9 +794,9 @@ matching this provider. For example, if you're using VirtualBox, the clone environment must also be using VirtualBox. cloud_init_not_found: |- - cloud-init is not found. Please ensure that cloud-init is installed and + cloud-init is not found. Please ensure that cloud-init is installed and available on path for guest '%{guest_name}'. - cloud_init_command_failed: |- + cloud_init_command_failed: |- cloud init command '%{cmd}' failed on guest '%{guest_name}'. command_deprecated: |- The command 'vagrant %{name}' has been deprecated and is no longer functional @@ -845,6 +845,19 @@ create_iso_host_cap_not_found: |- Vagrant cannot create an iso due to the host capability for creating isos not existing. Vagrant will now exit. + darwin_mount_failed: |- + Failed to mount folders in Darwin guest. The command attempted was: + + %{command} + + The error output from the last command was: + + %{output} + darwin_version_failed: |- + Failed to determine macOS version. + + Version string: %{version} + Error information: %{error} destroy_requires_force: |- Destroy doesn't have a TTY to ask for confirmation. Please pass the `--force` flag to force a destroy, otherwise attach a TTY so that @@ -1238,6 +1251,23 @@ following command: vagrant plugin install --local + plugin_needs_developer_tools: |- + Vagrant failed to install the requested plugin because development tools + are required for installation but are not currently installed on this + machine. Please install development tools and then try this command + again. + plugin_missing_library: |- + Vagrant failed to install the requested plugin because it depends + on a library which is not currently installed on this system. The + following library is required by the '%{name}' plugin: + + %{library} + + Please install the library and then run the command again. + plugin_missing_ruby_dev: |- + Vagrant failed to install the requested plugin because the Ruby header + files could not be found. Install the ruby development package for your + system and then run this command again. powershell_not_found: |- Failed to locate the powershell executable on the available PATH. Please ensure powershell is installed and available on the local PATH, then @@ -1276,6 +1306,9 @@ A file or directory you're attempting to include with your packaged box has symlinks in it. Vagrant cannot include symlinks in the resulting package. Please remove the symlinks and try again. + package_invalid_info: |- + The information file that you've attempted to include doesn't exist or isn't a valid JSON file. + Please check that the file exists and is titled 'info.json' and try again. provider_cant_install: |- The provider '%{provider}' doesn't support automatic installation. This is a limitation of this provider. Please report this as a feature @@ -1822,6 +1855,18 @@ outputted: %{vboxmanage} --version + virtualbox_invalid_host_subnet: |- + The IP address configured for the host-only network is not within the + allowed ranges. Please update the address used to be within the allowed + ranges and run the command again. + + Address: %{address} + Ranges: %{ranges} + + Valid ranges can be modified in the /etc/vbox/networks.conf file. For + more information including valid format see: + + https://www.virtualbox.org/manual/ch06.html#network_hostonly vm_creation_required: |- VM must be created before running this command. Run `vagrant up` first. vm_inaccessible: |- @@ -1884,7 +1929,7 @@ Disks of type ':dvd' cannot be defined as a primary disks. Please remove the 'primary' argument for disk '%{name}' on guest '%{machine}'. invalid_ext: |- - Disk type '%{ext}' is not a valid disk extention for '%{name}'. Please pick one of the following supported disk types: %{exts} + Disk type '%{ext}' is not a valid disk extension for '%{name}'. Please pick one of the following supported disk types: %{exts} invalid_type: |- Disk type '%{type}' is not a valid type. Please pick one of the following supported disk types: %{types} invalid_size: |- @@ -2865,7 +2910,7 @@ Vagrant has detected a host range pattern in the `groups` option. Vagrant doesn't fully check the validity of these parameters! - Please check https://docs.ansible.com/ansible/intro_inventory.html#hosts-and-groups + Please check https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#inventory-basics-formats-hosts-and-groups for more information. cannot_detect: |- Vagrant does not support detecting whether Ansible is installed @@ -2998,7 +3043,7 @@ pushes: file: no_destination: "File destination must be specified." - + autocomplete: installed: |- Autocomplete installed at paths: diff -Nru vagrant-2.2.14+dfsg/test/unit/base.rb vagrant-2.2.19+dfsg/test/unit/base.rb --- vagrant-2.2.14+dfsg/test/unit/base.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/base.rb 2021-11-05 21:15:44.000000000 +0000 @@ -3,7 +3,6 @@ # Gems require "checkpoint" -require "webmock/rspec" require "rspec/its" # Require Vagrant itself so we can reference the proper @@ -33,7 +32,8 @@ # Configure RSpec RSpec.configure do |c| - c.formatter = :documentation + #c.formatter = :progress + c.color_mode = :on if Vagrant::Util::Platform.windows? c.filter_run_excluding :skip_windows diff -Nru vagrant-2.2.14+dfsg/test/unit/bin/vagrant_test.rb vagrant-2.2.19+dfsg/test/unit/bin/vagrant_test.rb --- vagrant-2.2.14+dfsg/test/unit/bin/vagrant_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/bin/vagrant_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -30,6 +30,7 @@ allow(Kernel).to receive(:exit) allow(Vagrant::Environment).to receive(:new).and_return(env) allow(Vagrant).to receive(:in_installer?).and_return(true) + allow(self).to receive(:require_relative) end after { expect(run_vagrant).to eq(exit_code) } diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/box/command/prune_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/box/command/prune_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/box/command/prune_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/box/command/prune_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -67,16 +67,12 @@ iso_vagrant_env.machine_index.set(new_entry("foo", "foobox", "virtualbox", 1)) - output = "" - allow(iso_vagrant_env.ui).to receive(:info) do |data| - output << data - end + allow(iso_vagrant_env.ui).to receive(:info).and_call_original + expect(iso_vagrant_env.ui).to receive(:info).with(/No old versions of boxes/). + and_call_original expect(iso_vagrant_env.boxes.all.count).to eq(2) expect(subject.execute).to eq(0) expect(iso_vagrant_env.boxes.all.count).to eq(2) - - expect(output).to include("No old versions of boxes to remove...") - end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/auth/middleware/add_authentication_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/auth/middleware/add_authentication_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/auth/middleware/add_authentication_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/auth/middleware/add_authentication_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -6,7 +6,7 @@ include_context "unit" let(:app) { lambda { |env| } } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:env) { { env: iso_env, ui: ui @@ -14,21 +14,23 @@ let(:iso_env) { isolated_environment.create_vagrant_env } let(:server_url) { "http://vagrantcloud.com" } + let(:client) { double("client", token: token) } + let(:token) { "TEST_TOKEN" } subject { described_class.new(app, env) } before do allow(Vagrant).to receive(:server_url).and_return(server_url) - allow(ui).to receive(:warn) + allow(VagrantPlugins::CloudCommand::Client).to receive(:new). + with(iso_env).and_return(client) stub_env("ATLAS_TOKEN" => nil) end describe "#call" do it "does nothing if we have no server set" do allow(Vagrant).to receive(:server_url).and_return(nil) - VagrantPlugins::CloudCommand::Client.new(iso_env).store_token("foo") - original = ["foo", "#{server_url}/bar"] + original = [token, "#{server_url}/bar"] env[:box_urls] = original.dup subject.call(env) @@ -45,125 +47,180 @@ expect(env[:box_urls]).to eq(original) end - it "appends the access token to the URL of server URLs" do - token = "foobarbaz" - VagrantPlugins::CloudCommand::Client.new(iso_env).store_token(token) - - original = [ - "http://example.com/box.box", - "#{server_url}/foo.box", - "#{server_url}/bar.box?arg=true", - ] - - expected = original.dup - expected[1] = "#{original[1]}?access_token=#{token}" - expected[2] = "#{original[2]}&access_token=#{token}" - - env[:box_urls] = original.dup - subject.call(env) + context "when urls are set" do + it "does not modify urls" do + original = ["https://example.com/boxes/test.box", + "file://C:/my/box/path/local.box"] + env[:box_urls] = original.dup + subject.call(env) + expect(env[:box_urls]).to eq(original) + end - expect(env[:box_urls]).to eq(expected) + it "should remove access_token parameters when found" do + env[:box_urls] = ["https://example.com/boxes/test.box?access_token=TEST", + "file://C:/my/box/path/local.box"] + subject.call(env) + expect(env[:box_urls]).to eq([ + "https://example.com/boxes/test.box", + "file://C:/my/box/path/local.box"]) + end end - it "does not append the access token to vagrantcloud.com URLs if Atlas" do - server_url = "https://atlas.hashicorp.com" - allow(Vagrant).to receive(:server_url).and_return(server_url) - allow(subject).to receive(:sleep) - - token = "foobarbaz" - VagrantPlugins::CloudCommand::Client.new(iso_env).store_token(token) - - original = [ - "http://example.com/box.box", - "http://vagrantcloud.com/foo.box", - "http://vagrantcloud.com/bar.box?arg=true", - ] + context "with VAGRANT_SERVER_ACCESS_TOKEN_BY_URL set" do - expected = original.dup + before { stub_env("VAGRANT_SERVER_ACCESS_TOKEN_BY_URL" => "1") } - env[:box_urls] = original.dup - subject.call(env) + it "appends the access token to the URL of server URLs" do + original = [ + "http://example.com/box.box", + "#{server_url}/foo.box", + "#{server_url}/bar.box?arg=true", + ] - expect(env[:box_urls]).to eq(expected) - end + expected = original.dup + expected[1] = "#{original[1]}?access_token=#{token}" + expected[2] = "#{original[2]}&access_token=#{token}" + + env[:box_urls] = original.dup + subject.call(env) - it "warns when adding token to custom server" do - server_url = "https://example.com" - allow(Vagrant).to receive(:server_url).and_return(server_url) - - token = "foobarbaz" - VagrantPlugins::CloudCommand::Client.new(iso_env).store_token(token) - - original = [ - "http://example.org/box.box", - "http://vagrantcloud.com/foo.box", - "http://example.com/bar.box", - "http://example.com/foo.box" - ] - - expected = original.dup - expected[2] = expected[2] + "?access_token=#{token}" - expected[3] = expected[3] + "?access_token=#{token}" + expect(env[:box_urls]).to eq(expected) + end - expect(subject).to receive(:sleep).once - expect(ui).to receive(:warn).once + it "does not append the access token to vagrantcloud.com URLs if Atlas" do + server_url = "https://atlas.hashicorp.com" + allow(Vagrant).to receive(:server_url).and_return(server_url) + allow(subject).to receive(:sleep) + + original = [ + "http://example.com/box.box", + "http://vagrantcloud.com/foo.box", + "http://vagrantcloud.com/bar.box?arg=true", + ] - env[:box_urls] = original.dup - subject.call(env) + expected = original.dup - expect(env[:box_urls]).to eq(expected) - end + env[:box_urls] = original.dup + subject.call(env) - it "modifies host URL to target if authorized host" do - originals = VagrantPlugins::CloudCommand::AddAuthentication:: - REPLACEMENT_HOSTS.map{ |h| "http://#{h}/box.box" } - expected = "http://#{VagrantPlugins::CloudCommand::AddAuthentication::TARGET_HOST}/box.box" - env[:box_urls] = originals - subject.call(env) - env[:box_urls].each do |url| - expect(url).to eq(expected) + expect(env[:box_urls]).to eq(expected) end - end - it "ignores urls that it cannot parse" do - bad_url = "this is not a valid url" - # Ensure the bad URL does cause an exception - expect{ URI.parse(bad_url) }.to raise_error URI::Error - env[:box_urls] = [bad_url] - subject.call(env) - expect(env[:box_urls].first).to eq(bad_url) - end + it "warns when adding token to custom server" do + server_url = "https://example.com" + allow(Vagrant).to receive(:server_url).and_return(server_url) + + original = [ + "http://example.org/box.box", + "http://vagrantcloud.com/foo.box", + "http://example.com/bar.box", + "http://example.com/foo.box" + ] + + expected = original.dup + expected[2] = expected[2] + "?access_token=#{token}" + expected[3] = expected[3] + "?access_token=#{token}" - it "returns original urls when not modified" do - to_persist = "file:////path/to/box.box" - to_change = VagrantPlugins::CloudCommand::AddAuthentication:: - REPLACEMENT_HOSTS.map{ |h| "http://#{h}/box.box" }.first - expected = "http://#{VagrantPlugins::CloudCommand::AddAuthentication::TARGET_HOST}/box.box" - env[:box_urls] = [to_persist, to_change] - subject.call(env) - check_persist, check_change = env[:box_urls] - expect(check_change).to eq(expected) - expect(check_persist).to eq(to_persist) - # NOTE: The behavior of URI.parse changes on Ruby 2.5 to produce - # the same string value. To make the test worthwhile in checking - # for the same value, check that the object IDs are still the same. - expect(check_persist.object_id).to eq(to_persist.object_id) + expect(subject).to receive(:sleep).once + expect(ui).to receive(:warn).once.and_call_original + + env[:box_urls] = original.dup + subject.call(env) + + expect(env[:box_urls]).to eq(expected) + end + + it "ignores urls that it cannot parse" do + bad_url = "this is not a valid url" + # Ensure the bad URL does cause an exception + expect{ URI.parse(bad_url) }.to raise_error URI::Error + env[:box_urls] = [bad_url] + subject.call(env) + expect(env[:box_urls].first).to eq(bad_url) + end + + it "does not append multiple access_tokens" do + original = [ + "#{server_url}/foo.box?access_token=existing", + "#{server_url}/bar.box?arg=true", + ] + + env[:box_urls] = original.dup + subject.call(env) + + expect(env[:box_urls][0]).to eq("#{server_url}/foo.box?access_token=existing") + expect(env[:box_urls][1]).to eq("#{server_url}/bar.box?arg=true&access_token=#{token}") + end + + + context "when token is not set" do + let(:token) { nil } + + it "modifies host URL to target if authorized host" do + originals = VagrantPlugins::CloudCommand::AddAuthentication:: + REPLACEMENT_HOSTS.map{ |h| "http://#{h}/box.box" } + expected = "http://#{VagrantPlugins::CloudCommand::AddAuthentication::TARGET_HOST}/box.box" + env[:box_urls] = originals + subject.call(env) + env[:box_urls].each do |url| + expect(url).to eq(expected) + end + end + + it "returns original urls when not modified" do + to_persist = "file:////path/to/box.box" + to_change = VagrantPlugins::CloudCommand::AddAuthentication:: + REPLACEMENT_HOSTS.map{ |h| "http://#{h}/box.box" }.first + expected = "http://#{VagrantPlugins::CloudCommand::AddAuthentication::TARGET_HOST}/box.box" + env[:box_urls] = [to_persist, to_change] + subject.call(env) + check_persist, check_change = env[:box_urls] + expect(check_change).to eq(expected) + expect(check_persist).to eq(to_persist) + # NOTE: The behavior of URI.parse changes on Ruby 2.5 to produce + # the same string value. To make the test worthwhile in checking + # for the same value, check that the object IDs are still the same. + expect(check_persist.object_id).to eq(to_persist.object_id) + end + end end - it "does not append multiple access_tokens" do - token = "foobarbaz" - VagrantPlugins::CloudCommand::Client.new(iso_env).store_token(token) - - original = [ - "#{server_url}/foo.box?access_token=existing", - "#{server_url}/bar.box?arg=true", - ] - env[:box_urls] = original.dup - subject.call(env) + context "with VAGRANT_SERVER_ACCESS_TOKEN_BY_URL unset" do + + before { stub_env("VAGRANT_SERVER_ACCESS_TOKEN_BY_URL" => nil) } - expect(env[:box_urls][0]).to eq("#{server_url}/foo.box?access_token=existing") - expect(env[:box_urls][1]).to eq("#{server_url}/bar.box?arg=true&access_token=foobarbaz") + it "returns the original urls" do + box1 = "http://vagrantcloud.com/box.box" + box2 = "http://app.vagrantup.com/box.box" + + env = { + box_urls: [ + box1.dup, + box2.dup + ] + } + subject.call(env) + + expect(env[:box_urls]).to eq([box1, box2]) + end + + it "removes access_token parameters if set" do + box1 = "http://vagrantcloud.com/box.box" + box2 = "http://app.vagrantup.com/box.box" + box3 = "http://app.vagrantup.com/box.box?arg1=value1" + + env = { + box_urls: [ + "#{box1}?access_token=TEST_TOKEN", + box2.dup, + "#{box3}&access_token=TEST_TOKEN" + ] + } + subject.call(env) + + expect(env[:box_urls]).to eq([box1, box2, box3]) + end end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/auth/middleware/add_downloader_authentication_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/auth/middleware/add_downloader_authentication_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/auth/middleware/add_downloader_authentication_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/auth/middleware/add_downloader_authentication_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -7,7 +7,7 @@ include_context "unit" let(:app) { lambda { |env| } } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:env) { { env: iso_env, ui: ui @@ -21,8 +21,8 @@ before do allow(Vagrant).to receive(:server_url).and_return(server_url) - allow(ui).to receive(:warn) stub_env("ATLAS_TOKEN" => nil) + stub_env("VAGRANT_SERVER_ACCESS_TOKEN_BY_URL" => nil) end describe "#call" do @@ -53,16 +53,16 @@ it "warns when adding token to custom server" do server_url = "https://surprise.com" allow(Vagrant).to receive(:server_url).and_return(server_url) - + token = "foobarbaz" VagrantPlugins::CloudCommand::Client.new(iso_env).store_token(token) - + expect(subject).to receive(:sleep).once - expect(ui).to receive(:warn).once - + expect(ui).to receive(:warn).once.and_call_original + env[:downloader] = dwnloader subject.call(env) - + expect(env[:downloader].headers).to eq(["Authorization: Bearer #{token}"]) end end @@ -97,11 +97,11 @@ let(:auth_header) { "Authorization Bearer: token" } let(:other_header) {"some: thing"} let(:dwnloader) { Vagrant::Util::Downloader.new(server_url, "/some/path", {headers: [other_header]}) } - + it "appends the auth header" do token = "foobarbaz" VagrantPlugins::CloudCommand::Client.new(iso_env).store_token(token) - + env[:downloader] = dwnloader subject.call(env) @@ -115,7 +115,7 @@ it "returns original urls when not modified" do env[:downloader] = dwnloader subject.call(env) - + expect(env[:downloader].source).to eq(file_path) expect(env[:downloader].headers.empty?).to eq(true) end @@ -125,7 +125,7 @@ dwnloader.headers << auth_header token = "foobarbaz" VagrantPlugins::CloudCommand::Client.new(iso_env).store_token(token) - + env[:downloader] = dwnloader subject.call(env) @@ -151,5 +151,19 @@ subject.call(env) expect(env[:downloader].headers.empty?).to eq(true) end + + context "with VAGRANT_SERVER_ACCESS_TOKEN_BY_URL environment variable set" do + before do + stub_env("VAGRANT_SERVER_ACCESS_TOKEN_BY_URL" => "1") + end + + it "does not add a token to the headers" do + token = "foobarbaz" + VagrantPlugins::CloudCommand::Client.new(iso_env).store_token(token) + env[:downloader] = dwnloader + subject.call(env) + expect(env[:downloader].headers).to eq([]) + end + end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/box/create_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/box/create_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/box/create_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/box/create_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -15,14 +15,10 @@ describe "#create_box" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/box/delete_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/box/delete_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/box/delete_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/box/delete_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -15,14 +15,10 @@ describe "#delete_box" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/box/show_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/box/show_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/box/show_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/box/show_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -15,15 +15,10 @@ describe "#show_box" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) - allow(ui).to receive(:output) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/box/update_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/box/update_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/box/update_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/box/update_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -14,14 +14,10 @@ describe "#update_box" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/client_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/client_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/client_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/client_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -101,7 +101,7 @@ end it "should create a new internal client" do - expect(VagrantCloud::Client).to receive(:new).with(access_token: new_token) + expect(VagrantCloud::Client).to receive(:new).with(access_token: new_token, url_base: anything) subject.login end @@ -174,7 +174,7 @@ end it "should create a new internal client with token" do - expect(VagrantCloud::Client).to receive(:new).with(access_token: new_token) + expect(VagrantCloud::Client).to receive(:new).with(access_token: new_token, url_base: anything) subject.store_token(new_token) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/provider/create_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/provider/create_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/provider/create_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/provider/create_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -19,14 +19,10 @@ describe "#create_provider" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/provider/delete_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/provider/delete_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/provider/delete_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/provider/delete_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -18,14 +18,10 @@ describe "#delete_provider" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/provider/update_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/provider/update_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/provider/update_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/provider/update_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -20,13 +20,9 @@ let(:argv) { [] } let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/provider/upload_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/provider/upload_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/provider/upload_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/provider/upload_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -15,21 +15,17 @@ let(:version) { double("version", version: box_version, provdiers: [provider]) } let(:provider) { double("provider", name: box_version_provider) } let(:provider_file) { double("provider-file") } + let(:provider_file_size) { 1 } describe "#upload_provider" do let(:argv) { [] } let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:upload_url) { double("upload-url") } let(:uploader) { double("uploader") } before do - allow(ui).to receive(:info) - allow(ui).to receive(:output) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(I18n).to receive(:t) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). @@ -42,6 +38,8 @@ allow(uploader).to receive(:upload!) allow(Vagrant::UI::Prefixed).to receive(:new).with(ui, "cloud").and_return(ui) allow(Vagrant::Util::Uploader).to receive(:new).and_return(uploader) + allow(File).to receive(:stat).with(provider_file). + and_return(double("provider-stat", size: provider_file_size)) end subject { described_class.new(argv, env) } @@ -91,6 +89,28 @@ end subject.upload_provider(org_name, box_name, box_version, box_version_provider, provider_file, access_token, options) end + + context "when file size is 5GB" do + let(:provider_file_size) { 5368709120 } + + it "should use direct upload" do + expect(provider).to receive(:upload) do |**args| + expect(args[:direct]).to be_truthy + end + subject.upload_provider(org_name, box_name, box_version, box_version_provider, provider_file, access_token, options) + end + end + + context "when file size is greater than 5GB" do + let(:provider_file_size) { 5368709121 } + + it "should disable direct upload" do + expect(provider).to receive(:upload) do |**args| + expect(args[:direct]).to be_falsey + end + subject.upload_provider(org_name, box_name, box_version, box_version_provider, provider_file, access_token, options) + end + end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/publish_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/publish_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/publish_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/publish_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -10,21 +10,20 @@ let(:account) { double("account") } let(:organization) { double("organization") } let(:box) { double("box") } + let(:box_size) { 1 } let(:version) { double("version") } let(:provider) { double("provider") } let(:uploader) { double("uploader") } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:upload_url) { double("upload_url") } let(:access_token) { double("access_token") } subject { described_class.new(argv, iso_env) } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(iso_env).to receive(:ui).and_return(ui) + allow(File).to receive(:stat).with(box). + and_return(double("box_stat", size: box_size)) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: anything). and_return(account) @@ -60,10 +59,30 @@ subject.upload_box_file(provider, box) end - it "should upload with PUT method when direct upload option set" do - expect(Vagrant::Util::Uploader).to receive(:new). - with(upload_url, anything, hash_including(method: :put)).and_return(uploader) - subject.upload_box_file(provider, box, direct_upload: true) + context "with direct upload option enabled" do + it "should upload with PUT method when direct upload option set" do + expect(Vagrant::Util::Uploader).to receive(:new). + with(upload_url, anything, hash_including(method: :put)).and_return(uploader) + subject.upload_box_file(provider, box, direct_upload: true) + end + + context "with box size of 5GB" do + let(:box_size) { 5368709120 } + + it "should upload using direct to storage option" do + expect(provider).to receive(:upload).with(direct: true) + subject.upload_box_file(provider, box, direct_upload: true) + end + end + + context "with box size greater than 5GB" do + let(:box_size) { 5368709121 } + + it "should disable direct to storage upload" do + expect(provider).to receive(:upload).with(direct: false) + subject.upload_box_file(provider, box, direct_upload: true) + end + end end end @@ -148,7 +167,7 @@ describe "load_box_version" do let(:box_version) { "1.0.0" } - context "when vesion exists" do + context "when version exists" do before do allow(box).to receive(:versions).and_return([version]) allow(version).to receive(:version).and_return(box_version) @@ -220,6 +239,8 @@ let(:client) { double("client", token: "1234token1234") } let(:action_runner) { double("action_runner") } let(:box_path) { "path/to/the/virtualbox.box" } + let(:full_box_path) { "/full/#{box_path}" } + let(:box) { full_box_path } before do allow(iso_env).to receive(:action_runner). @@ -229,8 +250,10 @@ allow(subject).to receive(:format_box_results) allow(iso_env.ui).to receive(:ask).and_return("y") - allow(File).to receive(:absolute_path).and_return("/full/#{box_path}") - allow(File).to receive(:file?).and_return(true) + allow(File).to receive(:absolute_path).with(box_path) + .and_return("/full/#{box_path}") + allow(File).to receive(:file?).with(box_path) + .and_return(true) end context "with no arguments" do diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/create_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/create_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/create_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/create_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -16,14 +16,10 @@ describe "#create_version" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/delete_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/delete_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/delete_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/delete_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -16,14 +16,10 @@ describe "#delete_version" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/release_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/release_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/release_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/release_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -16,14 +16,10 @@ describe "#release_version" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/revoke_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/revoke_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/revoke_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/revoke_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -16,14 +16,10 @@ describe "#revoke_version" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/update_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/update_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/cloud/version/update_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/cloud/version/update_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -16,14 +16,10 @@ describe "#update_version" do let(:options) { {} } let(:env) { double("env", ui: ui) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:argv) { [] } before do - allow(ui).to receive(:info) - allow(ui).to receive(:warn) - allow(ui).to receive(:success) - allow(ui).to receive(:error) allow(env).to receive(:ui).and_return(ui) allow(VagrantCloud::Account).to receive(:new). with(custom_server: anything, access_token: access_token). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/destroy/command_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/destroy/command_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/destroy/command_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/destroy/command_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -7,7 +7,7 @@ let(:entry_klass) { Vagrant::MachineIndex::Entry } let(:argv) { [] } - let(:vagrantfile_content){ "" } + let(:vagrantfile_content) { "" } let(:iso_env) do env = isolated_environment env.vagrantfile(vagrantfile_content) @@ -36,6 +36,7 @@ let(:machine) do iso_env.machine(iso_env.machine_names[0], :dummy).tap do |m| allow(m).to receive(:state).and_return(state) + allow(m).to receive(:name).and_return("default") end end @@ -67,6 +68,77 @@ expect(subject.execute).to eq(1) end + context "with multiple machines" do + let(:vagrantfile_content) do + <<-VF + Vagrant.configure("2") do |config| + config.vm.box = "base" + config.vm.define :machine1 + config.vm.define :machine2 + end + VF + end + + let(:state2) { "" } + + let(:machine2) do + iso_env.machine(iso_env.machine_names[1], :dummy).tap do |m| + allow(m).to receive(:state).and_return(state2) + allow(m).to receive(:name).and_return("not_default") + end + end + + before do + allow(subject).to receive(:with_target_vms).and_yield(machine).and_yield(machine2) + allow_any_instance_of(Vagrant::BatchAction).to receive(:action) .with(machine2, :destroy, anything) + allow_any_instance_of(Vagrant::BatchAction).to receive(:action) .with(machine, :destroy, anything) + end + + context "second machine is not created" do + let(:state2) { double("state", id: :not_created) } + let(:state) { double("state", id: :not_created) } + + + it "exits 0 if vms are successfully destroyed" do + expect(machine.state).to receive(:id).and_return(:running) + expect(machine.state).to receive(:id).and_return(:dead) + expect(machine2.state).to receive(:id).and_return(:not_created) + expect(subject.execute).to eq(0) + end + + it "exits 0 if vms are not created" do + expect(machine.state).to receive(:id).and_return(:not_created) + expect(machine2.state).to receive(:id).and_return(:not_created) + expect(subject.execute).to eq(0) + end + end + + context "second machine is running" do + let(:state2) { double("state", id: :running) } + + it "exits 0 if vms are not successfully destroyed" do + expect(machine.state).to receive(:id).and_return(:running) + expect(machine.state).to receive(:id).and_return(:dead) + expect(machine2.state).to receive(:id).and_return(:running) + expect(machine2.state).to receive(:id).and_return(:dead) + expect(subject.execute).to eq(0) + end + + it "exits 1 if vms are not successfully destroyed" do + expect(machine.state).to receive(:id).and_return(:running) + expect(machine2.state).to receive(:id).and_return(:running) + expect(subject.execute).to eq(1) + end + + it "exits 2 if some vms are not successfully destroyed" do + expect(machine.state).to receive(:id).and_return(:running) + expect(machine.state).to receive(:id).and_return(:dead) + expect(machine2.state).to receive(:id).and_return(:running) + expect(subject.execute).to eq(2) + end + end + end + context "with VAGRANT_DEFAULT_PROVIDER set" do before do if ENV["VAGRANT_DEFAULT_PROVIDER"] @@ -164,11 +236,18 @@ subject.execute end - context "with an invalid argument" do + context "with machine that does not exist" do let(:argv){ ["notweb"] } it "raises an exception" do expect { subject.execute }.to raise_error(Vagrant::Errors::MachineNotFound) end + end + + context "with an invalid argument" do + let(:argv){ [""] } + it "raises an exception" do + expect { subject.execute }.to raise_error(Vagrant::Errors::MachineNotFound) + end end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/init/command_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/init/command_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/init/command_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/init/command_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -33,7 +33,6 @@ it "creates a minimal Vagrantfile" do described_class.new(["-m"], env).execute contents = File.read(vagrantfile_path) - expect(contents).to_not match(/#/) expect(contents).to_not match(/provision/) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/port/command_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/port/command_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/port/command_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/port/command_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -54,18 +54,16 @@ it "ensures the vm is running" do allow(state).to receive(:id).and_return(:stopped) - expect(env.ui).to receive(:error).with(any_args) { |message, _| - expect(message).to include("does not support listing forwarded ports") - } + expect(env.ui).to receive(:error).with(/does not support listing forwarded ports/). + and_call_original expect(subject.execute).to eq(1) end it "shows a friendly error when the capability is not supported" do allow(machine.provider).to receive(:capability?).and_return(false) - expect(env.ui).to receive(:error).with(any_args) { |message, _| - expect(message).to include("does not support listing forwarded ports") - } + expect(env.ui).to receive(:error).with(/does not support listing forwarded ports/). + and_call_original expect(subject.execute).to eq(1) end @@ -75,9 +73,8 @@ allow(machine.provider).to receive(:capability).with(:forwarded_ports) .and_return([]) - expect(env.ui).to receive(:info).with(any_args) { |message, _| - expect(message).to include("there are no forwarded ports") - } + expect(env.ui).to receive(:info).with(/there are no forwarded ports/). + and_call_original expect(subject.execute).to eq(0) end @@ -125,14 +122,10 @@ allow(machine.provider).to receive(:capability).with(:forwarded_ports) .and_return([[2222,22]]) - output = "" - allow(env.ui).to receive(:error) do |data| - output << data - end + expect(env.ui).to receive(:error).with(/not currently mapping port 80/). + and_call_original expect(subject.execute).to_not eq(0) - - expect(output).to include("not currently mapping port 80") end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/commands/snapshot/command/list_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/commands/snapshot/command/list_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/commands/snapshot/command/list_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/commands/snapshot/command/list_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -52,8 +52,8 @@ it "prints a message if the vm does not exist" do machine.id = nil - expect(iso_env.ui).to receive(:info).with("==> default: VM not created. Moving on...", anything) - .and_return({}) + expect(iso_env.ui).to receive(:info).with("==> default: VM not created. Moving on...", anything). + and_call_original expect(machine).to_not receive(:action) expect(subject.execute).to eq(0) end @@ -61,7 +61,7 @@ it "prints a message if no snapshots have been taken" do machine.id = "foo" - expect(iso_env.ui).to receive(:output) + expect(iso_env.ui).to receive(:output).and_call_original .with(/No snapshots have been taken yet!/, anything) expect(subject.execute).to eq(0) end @@ -72,9 +72,9 @@ allow(machine.provider).to receive(:capability).with(:snapshot_list). and_return(["foo", "bar", "baz"]) - expect(iso_env.ui).to receive(:output).with(/default/, anything) - expect(iso_env.ui).to receive(:detail).with(/foo/, anything) - expect(iso_env.ui).to receive(:detail).with(/bar/, anything) + expect(iso_env.ui).to receive(:output).with(/default/, anything).and_call_original + expect(iso_env.ui).to receive(:detail).with(/foo/, anything).and_call_original + expect(iso_env.ui).to receive(:detail).with(/bar/, anything).and_call_original expect(iso_env.ui).to receive(:detail).with(/baz/, anything) expect(subject.execute).to eq(0) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/communicators/ssh/communicator_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/communicators/ssh/communicator_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/communicators/ssh/communicator_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/communicators/ssh/communicator_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -27,8 +27,7 @@ let(:config) { double("config", ssh: ssh) } # Provider mock let(:provider) { double("provider") } - # UI mock - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } # Machine mock built with previously defined let(:machine) do double("machine", @@ -99,10 +98,6 @@ describe ".wait_for_ready" do before(&connection_setup) context "with no static config (default scenario)" do - before do - allow(ui).to receive(:detail) - end - context "when ssh_info requires a multiple tries before it is ready" do before do expect(machine).to receive(:ssh_info). @@ -123,18 +118,19 @@ and_return(host: '10.1.2.3', port: 22) allow(communicator).to receive(:connect) allow(communicator).to receive(:ready?).and_return(true) + allow(ui).to receive(:detail).and_call_original end it "should print message" do expect(communicator).to receive(:connect).and_raise(Vagrant::Errors::SSHConnectionTimeout) - expect(ui).to receive(:detail).with(/timeout/) + expect(ui).to receive(:detail).with(/timeout/).and_call_original communicator.wait_for_ready(0.5) end it "should not print the same message twice" do expect(communicator).to receive(:connect).and_raise(Vagrant::Errors::SSHConnectionTimeout) expect(communicator).to receive(:connect).and_raise(Vagrant::Errors::SSHConnectionTimeout) - expect(ui).to receive(:detail).with(/timeout/) + expect(ui).to receive(:detail).with(/timeout/).and_call_original expect(ui).not_to receive(:detail).with(/timeout/) communicator.wait_for_ready(0.5) end @@ -142,8 +138,8 @@ it "should print different messages" do expect(communicator).to receive(:connect).and_raise(Vagrant::Errors::SSHConnectionTimeout) expect(communicator).to receive(:connect).and_raise(Vagrant::Errors::SSHDisconnected) - expect(ui).to receive(:detail).with(/timeout/) - expect(ui).to receive(:detail).with(/disconnect/) + expect(ui).to receive(:detail).with(/timeout/).and_call_original + expect(ui).to receive(:detail).with(/disconnect/).and_call_original communicator.wait_for_ready(0.5) end @@ -152,8 +148,8 @@ expect(communicator).to receive(:connect).and_raise(Vagrant::Errors::SSHDisconnected) expect(communicator).to receive(:connect).and_raise(Vagrant::Errors::SSHConnectionTimeout) expect(communicator).to receive(:connect).and_raise(Vagrant::Errors::SSHDisconnected) - expect(ui).to receive(:detail).with(/timeout/) - expect(ui).to receive(:detail).with(/disconnect/) + expect(ui).to receive(:detail).with(/timeout/).and_call_original + expect(ui).to receive(:detail).with(/disconnect/).and_call_original expect(ui).not_to receive(:detail).with(/timeout/) expect(ui).not_to receive(:detail).with(/disconnect/) communicator.wait_for_ready(0.5) @@ -206,7 +202,6 @@ allow(guest).to receive(:capability?).with(:remove_public_key). and_return(has_remove_cap) allow(communicator).to receive(:insecure_key?).with("KEY_PATH").and_return(true) - allow(ui).to receive(:detail) end let(:insert_ssh_key){ true } @@ -249,7 +244,6 @@ let(:path_joiner){ double("path_joiner") } before do - allow(ui).to receive(:info) allow(Vagrant::Util::Keypair).to receive(:create). and_return([new_public_key, new_private_key, openssh]) allow(private_key_file).to receive(:open).and_yield(private_key_file) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/communicators/winrm/communicator_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/communicators/winrm/communicator_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/communicators/winrm/communicator_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/communicators/winrm/communicator_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -8,7 +8,7 @@ let(:winrm) { double("winrm", timeout: 1, host: nil, port: 5986, guest_port: 5986) } let(:config) { double("config", winrm: winrm) } let(:provider) { double("provider") } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:machine) { double("machine", config: config, provider: provider, ui: ui) } let(:shell) { double("shell") } let(:good_output) { WinRM::Output.new.tap { |out| out.exitcode = 0 } } @@ -33,7 +33,6 @@ allow(provider).to receive(:capability?).with(:winrm_info).and_return(false) # Get us through the detail prints - allow(ui).to receive(:detail) allow(shell).to receive(:host) allow(shell).to receive(:port) allow(shell).to receive(:username) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/communicators/winssh/communicator_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/communicators/winssh/communicator_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/communicators/winssh/communicator_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/communicators/winssh/communicator_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -33,8 +33,7 @@ let(:config) { double("config", winssh: winssh, ssh: ssh) } # Provider mock let(:provider) { double("provider") } - # UI mock - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } # SSH info mock let(:ssh_info) { double("ssh_info") } # Machine mock built with previously defined @@ -111,10 +110,6 @@ describe "#wait_for_ready" do before(&connection_setup) context "with no static config (default scenario)" do - before do - allow(ui).to receive(:detail) - end - context "when ssh_info requires a multiple tries before it is ready" do before do expect(machine).to receive(:ssh_info). diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/alpine/cap/configure_networks_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/alpine/cap/configure_networks_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/alpine/cap/configure_networks_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/alpine/cap/configure_networks_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -23,9 +23,9 @@ expect(communicator).to receive(:sudo).with("sed -e '/^#VAGRANT-BEGIN/,$ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces.pre") expect(communicator).to receive(:sudo).with("sed -ne '/^#VAGRANT-END/,$ p' /etc/network/interfaces | tail -n +2 > /tmp/vagrant-network-interfaces.post") - expect(communicator).to receive(:sudo).with('/sbin/ifdown eth0 2> /dev/null') + expect(communicator).to receive(:sudo).with(/\/sbin\/ifdown eth0/) expect(communicator).to receive(:sudo).with('/sbin/ip addr flush dev eth0 2> /dev/null') - expect(communicator).to receive(:sudo).with('/sbin/ifdown eth1 2> /dev/null') + expect(communicator).to receive(:sudo).with(/\/sbin\/ifdown eth1/) expect(communicator).to receive(:sudo).with('/sbin/ip addr flush dev eth1 2> /dev/null') expect(communicator).to receive(:sudo).with('cat /tmp/vagrant-network-interfaces.pre /tmp/vagrant-network-entry /tmp/vagrant-network-interfaces.post > /etc/network/interfaces') expect(communicator).to receive(:sudo).with('rm -f /tmp/vagrant-network-interfaces.pre /tmp/vagrant-network-entry /tmp/vagrant-network-interfaces.post') diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/coreos/cap/configure_networks_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/coreos/cap/configure_networks_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/coreos/cap/configure_networks_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/coreos/cap/configure_networks_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -12,12 +12,10 @@ let(:guest) { double("guest") } let(:config) { double("config", vm: vm) } let(:vm) { double("vm") } - # let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } let(:comm) { double("comm") } let(:env) do double("env", machine: machine, active_machines: [machine]) end - let(:interfaces) { ["eth0", "eth1", "lo"] } before do allow(machine).to receive(:communicate).and_return(comm) @@ -25,127 +23,219 @@ end describe ".configure_networks" do - let(:network_1) do - { - interface: 0, - type: "dhcp", - } - end - let(:netconfig_1) do - [:public_interface, {}] - end - let(:network_2) do - { - interface: 1, - type: "static", - ip: "33.33.33.10", - netmask: "255.255.0.0", - gateway: "33.33.0.1", - } - end - let(:netconfig_2) do - [:public_network, {ip: "33.33.33.10", netmask: 16}] - end - let(:network_3) do - { - interface: 2, - type: "static", - ip: "192.168.120.22", - netmask: "255.255.255.0", - gateway: "192.168.120.1" - } - end - let(:netconfig_3) do - [:private_network, {ip: "192.168.120.22", netmask: 24}] - end - let(:networks) { [network_1, network_2, network_3] } - let(:network_configs) { [netconfig_1, netconfig_2, netconfig_3] } - let(:vm) { double("vm") } - let(:default_env_ip) { described_class.const_get(:DEFAULT_ENVIRONMENT_IP) } - - before do - allow(guest).to receive(:capability).with(:network_interfaces). - and_return(interfaces) - allow(vm).to receive(:networks).and_return(network_configs) - allow(comm).to receive(:upload) - allow(comm).to receive(:sudo) - end + context "with network manager" do + let(:network_1) do + { + interface: 1, + type: "static", + ip: "10.0.0.3", + netmask: "255.255.255.0", + mac_address: "00:00:00:00:00:00", + gateway: "10.0.0.2", + } + end + let(:network_2) do + { + interface: 2, + type: "static", + ip: "192.168.3.3", + netmask: "255.255.0.0", + } + end + let(:nm_list) do + [ + "Wired connection 1:UUID_for_eth1:ethernet:eth1\n", + "Wired connection 2:UUID_for_eth2:ethernet:eth2\n" + ] + end + let(:interfaces) { ["eth0", "eth1", "eth2"] } + let(:networks) do + [ + network_1, + network_2, + ] + end + let(:tempfile) do + double("tempfile", + close: nil, + delete: nil, + path: temp_path, + ).tap do |f| + allow(f).to receive(:puts) + end + end + let(:temp_path) { "/dev/null" } - it "should upload network configuration file" do - expect(comm).to receive(:upload) - described_class.configure_networks(machine, networks) - end + before do + allow(guest).to receive(:capability). + with(:network_interfaces). + and_return(interfaces) + allow(comm).to receive(:upload) + allow(comm).to receive(:sudo) + allow(comm).to receive(:execute) + allow(Tempfile).to receive(:new).and_return(tempfile) + + expect(comm).to receive(:execute). + with("nmcli -t c show") { |&block| + nm_list.each { |line| + block.call(:stdout, line) + } + } + + allow(comm).to receive(:test). + with("command -v cloud-init"). + and_return(false) + end + + it "should test for cloud-init" do + expect(comm).to receive(:test). + with("command -v cloud-init"). + and_return(false) + described_class.configure_networks(machine, networks) + end - it "should configure public ipv4 address" do - expect(comm).to receive(:upload) do |src, dst| - content = File.read(src) - expect(content).to include("COREOS_PUBLIC_IPV4=#{netconfig_2.last[:ip]}") + it "should remove any previous vagrant configuration" do + expect(comm).to receive(:sudo). + with(/rm .*vagrant-.*conf/, error_check: false) + described_class.configure_networks(machine, networks) end - described_class.configure_networks(machine, networks) - end - it "should configure the private ipv4 address" do - expect(comm).to receive(:upload) do |src, dst| - content = File.read(src) - expect(content).to include("COREOS_PRIVATE_IPV4=#{netconfig_3.last[:ip]}") + it "should get MAC address from guest if not provided" do + expect(comm).to receive(:execute). + with(/cat .*eth2\/address/) + described_class.configure_networks(machine, networks) end - described_class.configure_networks(machine, networks) - end - it "should configure network interfaces" do - expect(comm).to receive(:upload) do |src, dst| - content = File.read(src) - interfaces.each { |i| expect(content).to include("Name=#{i}") } + it "should not get MAC address from guest when provided" do + expect(comm).not_to receive(:execute). + with(/cat .*eth1\/address/) + described_class.configure_networks(machine, networks) + end + + it "should provide a default gateway when one is not provided" do + expect(tempfile).to receive(:puts). + with("gateway=192.168.0.1") + described_class.configure_networks(machine, networks) end - described_class.configure_networks(machine, networks) - end - it "should configure DHCP interface" do - expect(comm).to receive(:upload) do |src, dst| - content = File.read(src) - expect(content).to include("DHCP=yes") + it "should use gateway value when provided" do + expect(tempfile).to receive(:puts). + with("gateway=10.0.0.2") + described_class.configure_networks(machine, networks) end - described_class.configure_networks(machine, networks) - end - it "should configure static IP addresses" do - expect(comm).to receive(:upload) do |src, dst| - content = File.read(src) - network_configs.map(&:last).find_all { |c| c[:ip] }.each { |c| - expect(content).to include("Address=#{c[:ip]}") - } + it "should disconnect device in network manager" do + expect(comm).to receive(:sudo). + with("nmcli d disconnect 'eth1'", error_check: false) + expect(comm).to receive(:sudo). + with("nmcli d disconnect 'eth2'", error_check: false) + described_class.configure_networks(machine, networks) end - described_class.configure_networks(machine, networks) - end - context "when no public network is defined" do - let(:networks) { [network_1, network_3] } - let(:network_configs) { [netconfig_1, netconfig_3] } + it "should delete connection from network manager" do + expect(comm).to receive(:sudo). + with("nmcli c delete 'UUID_for_eth1'", error_check: false) + expect(comm).to receive(:sudo). + with("nmcli c delete 'UUID_for_eth2'", error_check: false) + described_class.configure_networks(machine, networks) + end + it "should upload configuration files" do + expect(comm).to receive(:upload).twice + described_class.configure_networks(machine, networks) + end - it "should set public IP to the default environment IP" do - expect(comm).to receive(:upload) do |src, dst| - content = File.read(src) - expect(content).to include("COREOS_PUBLIC_IPV4=#{default_env_ip}") - end + it "should change file ownership to root" do + expect(comm).to receive(:sudo). + with(/chown root:root .*/) described_class.configure_networks(machine, networks) end - it "should set the private IP to the private network" do - expect(comm).to receive(:upload) do |src, dst| - content = File.read(src) - expect(content).to include("COREOS_PRIVATE_IPV4=#{netconfig_3.last[:ip]}") - end + it "should modify file permissions to remove read access" do + expect(comm).to receive(:sudo). + with(/chmod 0600 .*/) + described_class.configure_networks(machine, networks) + end + + it "should delete local temporary files" do + expect(tempfile).to receive(:delete) + described_class.configure_networks(machine, networks) + end + + it "should load the configuration files into network manager" do + expect(comm).to receive(:sudo). + with(/nmcli c load .*conf/).twice + described_class.configure_networks(machine, networks) + end + + it "should connect the devices in network manager" do + expect(comm).to receive(:sudo). + with("nmcli d connect 'eth1'") + expect(comm).to receive(:sudo). + with("nmcli d connect 'eth2'") described_class.configure_networks(machine, networks) end end - context "when no private network is defined" do - let(:networks) { [network_1, network_2] } - let(:network_configs) { [netconfig_1, netconfig_2] } + context "with cloud-init" do + let(:interfaces) { ["eth0", "eth1", "lo"] } + let(:network_1) do + { + interface: 0, + type: "dhcp", + } + end + let(:netconfig_1) do + [:public_interface, {}] + end + let(:network_2) do + { + interface: 1, + type: "static", + ip: "33.33.33.10", + netmask: "255.255.0.0", + gateway: "33.33.0.1", + } + end + let(:netconfig_2) do + [:public_network, {ip: "33.33.33.10", netmask: 16}] + end + let(:network_3) do + { + interface: 2, + type: "static", + ip: "192.168.120.22", + netmask: "255.255.255.0", + gateway: "192.168.120.1" + } + end + let(:netconfig_3) do + [:private_network, {ip: "192.168.120.22", netmask: 24}] + end + let(:networks) { [network_1, network_2, network_3] } + let(:network_configs) { [netconfig_1, netconfig_2, netconfig_3] } + let(:vm) { double("vm") } + let(:default_env_ip) { described_class.const_get(:DEFAULT_ENVIRONMENT_IP) } + + before do + allow(guest).to receive(:capability).with(:network_interfaces). + and_return(interfaces) + allow(vm).to receive(:networks).and_return(network_configs) + allow(comm).to receive(:upload) + allow(comm).to receive(:sudo) + + allow(comm).to receive(:test). + with("command -v cloud-init"). + and_return(true) + end + + it "should upload network configuration file" do + expect(comm).to receive(:upload) + described_class.configure_networks(machine, networks) + end - it "should set public IP to the public network" do + it "should configure public ipv4 address" do expect(comm).to receive(:upload) do |src, dst| content = File.read(src) expect(content).to include("COREOS_PUBLIC_IPV4=#{netconfig_2.last[:ip]}") @@ -153,35 +243,105 @@ described_class.configure_networks(machine, networks) end - it "should set the private IP to the public IP" do + it "should configure the private ipv4 address" do expect(comm).to receive(:upload) do |src, dst| content = File.read(src) - expect(content).to include("COREOS_PRIVATE_IPV4=#{netconfig_2.last[:ip]}") + expect(content).to include("COREOS_PRIVATE_IPV4=#{netconfig_3.last[:ip]}") end described_class.configure_networks(machine, networks) end - end - - context "when no public or private network is defined" do - let(:networks) { [network_1] } - let(:network_configs) { [netconfig_1] } + it "should configure network interfaces" do + expect(comm).to receive(:upload) do |src, dst| + content = File.read(src) + interfaces.each { |i| expect(content).to include("Name=#{i}") } + end + described_class.configure_networks(machine, networks) + end - it "should set public IP to the default environment IP" do + it "should configure DHCP interface" do expect(comm).to receive(:upload) do |src, dst| content = File.read(src) - expect(content).to include("COREOS_PUBLIC_IPV4=#{default_env_ip}") + expect(content).to include("DHCP=yes") end described_class.configure_networks(machine, networks) end - it "should set the private IP to the default environment IP" do + it "should configure static IP addresses" do expect(comm).to receive(:upload) do |src, dst| content = File.read(src) - expect(content).to include("COREOS_PRIVATE_IPV4=#{default_env_ip}") + network_configs.map(&:last).find_all { |c| c[:ip] }.each { |c| + expect(content).to include("Address=#{c[:ip]}") + } end described_class.configure_networks(machine, networks) end + + context "when no public network is defined" do + let(:networks) { [network_1, network_3] } + let(:network_configs) { [netconfig_1, netconfig_3] } + + + it "should set public IP to the default environment IP" do + expect(comm).to receive(:upload) do |src, dst| + content = File.read(src) + expect(content).to include("COREOS_PUBLIC_IPV4=#{default_env_ip}") + end + described_class.configure_networks(machine, networks) + end + + it "should set the private IP to the private network" do + expect(comm).to receive(:upload) do |src, dst| + content = File.read(src) + expect(content).to include("COREOS_PRIVATE_IPV4=#{netconfig_3.last[:ip]}") + end + described_class.configure_networks(machine, networks) + end + end + + context "when no private network is defined" do + let(:networks) { [network_1, network_2] } + let(:network_configs) { [netconfig_1, netconfig_2] } + + + it "should set public IP to the public network" do + expect(comm).to receive(:upload) do |src, dst| + content = File.read(src) + expect(content).to include("COREOS_PUBLIC_IPV4=#{netconfig_2.last[:ip]}") + end + described_class.configure_networks(machine, networks) + end + + it "should set the private IP to the public IP" do + expect(comm).to receive(:upload) do |src, dst| + content = File.read(src) + expect(content).to include("COREOS_PRIVATE_IPV4=#{netconfig_2.last[:ip]}") + end + described_class.configure_networks(machine, networks) + end + end + + context "when no public or private network is defined" do + let(:networks) { [network_1] } + let(:network_configs) { [netconfig_1] } + + + it "should set public IP to the default environment IP" do + expect(comm).to receive(:upload) do |src, dst| + content = File.read(src) + expect(content).to include("COREOS_PUBLIC_IPV4=#{default_env_ip}") + end + described_class.configure_networks(machine, networks) + end + + it "should set the private IP to the default environment IP" do + expect(comm).to receive(:upload) do |src, dst| + content = File.read(src) + expect(content).to include("COREOS_PRIVATE_IPV4=#{default_env_ip}") + end + described_class.configure_networks(machine, networks) + end + end end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/debian/cap/configure_networks_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/debian/cap/configure_networks_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/debian/cap/configure_networks_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/debian/cap/configure_networks_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -79,8 +79,9 @@ expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth1'") expect(comm.received_commands[0]).to match("/sbin/ifdown 'eth2' || true") expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth2'") - expect(comm.received_commands[0]).to match("/sbin/ifup 'eth1'") - expect(comm.received_commands[0]).to match("/sbin/ifup 'eth2'") + expect(comm.received_commands[1]).to match("/sbin/ifup 'eth1'") + expect(comm.received_commands[1]).to match("/sbin/ifup 'eth2'") + end context "with systemd" do @@ -96,8 +97,8 @@ expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth1'") expect(comm.received_commands[0]).to match("/sbin/ifdown 'eth2' || true") expect(comm.received_commands[0]).to match("/sbin/ip addr flush dev 'eth2'") - expect(comm.received_commands[0]).to match("/sbin/ifup 'eth1'") - expect(comm.received_commands[0]).to match("/sbin/ifup 'eth2'") + expect(comm.received_commands[1]).to match("/sbin/ifup 'eth1'") + expect(comm.received_commands[1]).to match("/sbin/ifup 'eth2'") end context "with systemd-networkd" do diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/freebsd/cap/mount_virtual_box_shared_folder_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/freebsd/cap/mount_virtual_box_shared_folder_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/freebsd/cap/mount_virtual_box_shared_folder_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/freebsd/cap/mount_virtual_box_shared_folder_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -152,9 +152,8 @@ context "with custom mount options" do - let(:ui){ double(:ui) } + let(:ui){ Vagrant::UI::Silent.new } before do - allow(ui).to receive(:warn) allow(machine).to receive(:ui).and_return(ui) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/linux/cap/mount_smb_shared_folder_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/linux/cap/mount_smb_shared_folder_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/linux/cap/mount_smb_shared_folder_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/linux/cap/mount_smb_shared_folder_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -8,7 +8,7 @@ end let(:machine) { double("machine", env: env, config: config) } - let(:env) { double("env", host: host, ui: double("ui"), data_dir: double("data_dir")) } + let(:env) { double("env", host: host, ui: Vagrant::UI::Silent.new, data_dir: double("data_dir")) } let(:host) { double("host") } let(:guest) { double("guest") } let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } @@ -43,7 +43,7 @@ allow(folder_plugin).to receive(:capability).with(:mount_options, mount_name, mount_guest_path, folder_options). and_return(["uid=#{mount_uid},gid=#{mount_gid},sec=ntlmssp,credentials=/etc/smb_creds_id", mount_uid, mount_gid]) allow(folder_plugin).to receive(:capability).with(:mount_type).and_return("cifs") - allow(folder_plugin).to receive(:capability).with(:mount_name, any_args).and_return("//localhost/#{mount_name}") + allow(folder_plugin).to receive(:capability).with(:mount_name, mount_name, folder_options).and_return("//localhost/#{mount_name}") end after do @@ -102,7 +102,7 @@ allow(gate_file).to receive(:to_path).and_return("PATH") allow(FileUtils).to receive(:touch) end - + it "should output warning message" do expect(env.ui).to receive(:warn).with(/VAGRANT_DISABLE_SMBMFSYMLINKS=1/) cap.display_mfsymlinks_warning(env) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/linux/cap/persist_mount_shared_folder_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/linux/cap/persist_mount_shared_folder_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/linux/cap/persist_mount_shared_folder_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/linux/cap/persist_mount_shared_folder_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -29,7 +29,7 @@ let (:folders) { { :folder_type => fstab_folders } } - let(:expected_mount_options) { "uid=#{options_uid},gid=#{options_gid},nofail" } + let(:expected_mount_options) { "uid=#{options_uid},gid=#{options_gid}" } before do allow(machine).to receive(:communicate).and_return(comm) @@ -48,11 +48,10 @@ describe ".persist_mount_shared_folder" do - let(:ui){ double(:ui) } + let(:ui){ Vagrant::UI::Silent.new } before do allow(comm).to receive(:sudo).with(any_args) - allow(ui).to receive(:warn) allow(machine).to receive(:ui).and_return(ui) end @@ -101,7 +100,7 @@ cap.persist_mount_shared_folder(machine, nil) end end - + context "smb folder" do let (:fstab_folders) { Vagrant::Plugin::V2::SyncedFolder::Collection[ @@ -121,15 +120,15 @@ before do allow(folder_plugin).to receive(:capability).with(:mount_type).and_return("cifs") allow(folder_plugin).to receive(:capability?).with(:mount_name).and_return(true) - allow(folder_plugin).to receive(:capability).with(:mount_name, any_args).and_return("//192.168.42.42/dummyname") + allow(folder_plugin).to receive(:capability).with(:mount_name, instance_of(String), any_args).and_return("//192.168.42.42/dummyname") end - + it "inserts folders into /etc/fstab" do expected_entry_vagrant = "//192.168.42.42/dummyname /vagrant cifs #{expected_mount_options} 0 0" expected_entry_test = "//192.168.42.42/dummyname /test1 cifs #{expected_mount_options} 0 0" expect(cap).to receive(:remove_vagrant_managed_fstab) expect(comm).to receive(:sudo).with(/#{expected_entry_test}\n#{expected_entry_vagrant}/) - + cap.persist_mount_shared_folder(machine, folders) end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/linux/cap/reboot_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/linux/cap/reboot_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/linux/cap/reboot_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/linux/cap/reboot_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -7,10 +7,10 @@ VagrantPlugins::GuestLinux::Plugin.components.guest_capabilities[:linux].get(:wait_for_reboot) end - let(:machine) { double("machine") } + let(:machine) { double("machine", guest: guest) } let(:guest) { double("guest") } let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } context "systemd not enabled" do before do @@ -18,7 +18,6 @@ allow(machine).to receive(:guest).and_return(guest) allow(machine.guest).to receive(:ready?).and_return(true) allow(machine).to receive(:ui).and_return(ui) - allow(ui).to receive(:info) allow(communicator).to receive(:test).and_return(false) end @@ -45,7 +44,7 @@ after { described_class.reboot(machine) } it "sends message to user that guest is rebooting" do - expect(ui).to receive(:info) + expect(ui).to receive(:info).and_call_original end end end @@ -56,7 +55,6 @@ allow(machine).to receive(:guest).and_return(guest) allow(machine.guest).to receive(:ready?).and_return(true) allow(machine).to receive(:ui).and_return(ui) - allow(ui).to receive(:info) allow(communicator).to receive(:test).and_return(true) end @@ -106,4 +104,62 @@ end end end + + describe ".wait_for_reboot" do + before do + allow(machine).to receive(:communicate).and_return(communicator) + allow(communicator).to receive(:execute).and_return(0) + allow(guest).to receive(:ready?).and_return(false) + end + + context "when guest is ready" do + before { expect(guest).to receive(:ready?).and_return(true) } + + it "should sleep" do + expect(described_class).to receive(:sleep).with(10) + described_class.wait_for_reboot(machine) + end + + context "when check script fails" do + before { expect(communicator).to receive(:execute).with(/grep/, any_args).and_return(1) } + + it "should not sleep" do + expect(described_class).not_to receive(:sleep) + described_class.wait_for_reboot(machine) + end + end + + context "when communicator raises an error" do + let(:error) { Class.new(StandardError) } + + before do + expect(communicator).to receive(:execute).with(/grep/, any_args).and_raise(error) + expect(guest).to receive(:ready?).and_return(true) + end + + it "should sleep once for exception and once for the guest being ready" do + expect(described_class).to receive(:sleep).with(10).twice + described_class.wait_for_reboot(machine) + end + + context "when communicator raises error more than once" do + before { expect(communicator).to receive(:execute).with(/grep/, any_args).and_raise(error) } + + it "should sleep once and raise error" do + expect(described_class).to receive(:sleep).with(10) + expect { described_class.wait_for_reboot(machine) }.to raise_error(error) + end + end + end + end + + context "when guest is not ready" do + before { expect(guest).to receive(:ready?).and_return(false) } + + it "should not sleep" do + expect(described_class).not_to receive(:sleep) + described_class.wait_for_reboot(machine) + end + end + end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/change_host_name_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/change_host_name_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/change_host_name_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/change_host_name_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,33 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::GuestOpenWrt::Cap::ChangeHostName" do + let(:caps) do + VagrantPlugins::GuestOpenWrt::Plugin + .components + .guest_capabilities[:openwrt] + end + + let(:machine) { double("machine") } + let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + + before do + allow(machine).to receive(:communicate).and_return(comm) + end + + after do + comm.verify_expectations! + end + + describe ".change_host_name" do + let(:cap) { caps.get(:change_host_name) } + + it "changes the hostname if appropriate" do + cap.change_host_name(machine, "testhost") + + expect(comm.received_commands[0]).to match(/uci get system\.@system\[0\].hostname | grep '^testhost$'/) + expect(comm.received_commands[1]).to match(/uci set system.@system\[0\].hostname='testhost'/) + expect(comm.received_commands[1]).to match(/uci commit system/) + expect(comm.received_commands[1]).to match(/\/etc\/init.d\/system reload/) + end + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/halt_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/halt_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/halt_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/halt_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,37 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::GuestOpenWrt::Cap::Halt" do + let(:plugin) { VagrantPlugins::GuestOpenWrt::Plugin.components.guest_capabilities[:openwrt].get(:halt) } + let(:machine) { double("machine") } + let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + let(:shutdown_command){ "halt" } + + before do + allow(machine).to receive(:communicate).and_return(communicator) + end + + after do + communicator.verify_expectations! + end + + describe ".halt" do + it "sends a shutdown signal" do + communicator.expect_command(shutdown_command) + plugin.halt(machine) + end + + it "ignores an IOError" do + communicator.stub_command(shutdown_command, raise: IOError) + expect { + plugin.halt(machine) + }.to_not raise_error + end + + it "ignores a Vagrant::Errors::SSHDisconnected" do + communicator.stub_command(shutdown_command, raise: Vagrant::Errors::SSHDisconnected) + expect { + plugin.halt(machine) + }.to_not raise_error + end + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/insert_public_key_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/insert_public_key_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/insert_public_key_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/insert_public_key_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,30 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::GuestOpenWrt::Cap::InsertPublicKey" do + let(:caps) do + VagrantPlugins::GuestOpenWrt::Plugin + .components + .guest_capabilities[:openwrt] + end + + let(:machine) { double("machine") } + let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + + before do + allow(machine).to receive(:communicate).and_return(comm) + end + + after do + comm.verify_expectations! + end + + describe ".insert_public_key" do + let(:cap) { caps.get(:insert_public_key) } + + it "inserts the public key" do + cap.insert_public_key(machine, "ssh-rsa ...") + + expect(comm.received_commands[0]).to match(/printf 'ssh-rsa ...\\n' >> \/etc\/dropbear\/authorized_keys/) + end + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/remove_public_key_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/remove_public_key_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/remove_public_key_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/remove_public_key_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,31 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::GuestOpenWrt::Cap::RemovePublicKey" do + let(:caps) do + VagrantPlugins::GuestOpenWrt::Plugin + .components + .guest_capabilities[:openwrt] + end + + let(:machine) { double("machine") } + let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + + before do + allow(machine).to receive(:communicate).and_return(comm) + end + + after do + comm.verify_expectations! + end + + describe ".remove_public_key" do + let(:cap) { caps.get(:remove_public_key) } + + it "removes the public key" do + cap.remove_public_key(machine, "ssh-rsa keyvalue comment") + expect(comm.received_commands[0]).to match(/if test -f \/etc\/dropbear\/authorized_keys ; then/) + expect(comm.received_commands[0]).to match(/sed -i '\/\^.*ssh-rsa keyvalue comment.*\$\/d' \/etc\/dropbear\/authorized_keys/) + expect(comm.received_commands[0]).to match(/fi/) + end + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/rsync_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/rsync_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/openwrt/cap/rsync_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/openwrt/cap/rsync_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,76 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::VagrantPlugins::Cap::Rsync" do + let(:caps) do + VagrantPlugins::GuestOpenWrt::Plugin + .components + .guest_capabilities[:openwrt] + end + + let(:machine) { double("machine") } + let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + let(:guest_directory) { "/guest/directory/path" } + + before do + allow(machine).to receive(:communicate).and_return(comm) + end + + after do + comm.verify_expectations! + end + + describe ".rsync_installed" do + let(:cap) { caps.get(:rsync_installed) } + + describe "when rsync is in the path" do + it "is true" do + comm.stub_command("which rsync", stdout: '/usr/bin/rsync', exit_code: 0) + expect(cap.rsync_installed(machine)).to be true + end + end + + describe "when rsync is not in the path" do + it "is false" do + comm.stub_command("which rsync", stdout: '', exit_code: 1) + expect(cap.rsync_installed(machine)).to be false + end + end + end + + describe ".rsync_install" do + let(:cap) { caps.get(:rsync_install) } + + it "installs rsync" do + cap.rsync_install(machine) + + expect(comm.received_commands[0]).to match(/opkg update/) + expect(comm.received_commands[0]).to match(/opkg install rsync/) + end + end + + describe ".rsync_command" do + let(:cap) { caps.get(:rsync_command) } + + it "provides the rsync command to use" do + expect(cap.rsync_command(machine)).to eq("rsync -zz") + end + end + + describe ".rsync_pre" do + let(:cap) { caps.get(:rsync_pre) } + + it "creates target directory on guest" do + cap.rsync_pre(machine, :guestpath => guest_directory) + expect(comm.received_commands[0]).to match(/mkdir -p '\/guest\/directory\/path'/) + end + end + + describe ".rsync_post" do + let(:cap) { caps.get(:rsync_post) } + + it "is a no-op" do + cap.rsync_post(machine, {}) + expect(comm).to_not receive(:execute) + end + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/rocky/cap/flavor_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/rocky/cap/flavor_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/rocky/cap/flavor_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/rocky/cap/flavor_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,36 @@ +require_relative "../../../../base" + +describe "VagrantPlugins::GuestRocky::Cap::Flavor" do + let(:caps) do + VagrantPlugins::GuestRocky::Plugin + .components + .guest_capabilities[:rocky] + end + + let(:machine) { double("machine") } + let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + + before do + allow(machine).to receive(:communicate).and_return(comm) + end + + after do + comm.verify_expectations! + end + + describe ".flavor" do + let(:cap) { caps.get(:flavor) } + + { + "" => :rocky, + "8.2" => :rocky_8, + "9" => :rocky_9, + "invalid" => :rocky + }.each do |str, expected| + it "returns #{expected} for #{str}" do + comm.stub_command("source /etc/os-release && printf $VERSION_ID", stdout: str) + expect(cap.flavor(machine)).to be(expected) + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/suse/cap/halt_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/suse/cap/halt_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/suse/cap/halt_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/suse/cap/halt_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -21,20 +21,31 @@ describe ".halt" do let(:cap) { caps.get(:halt) } - it "runs the shutdown command" do - comm.expect_command("/sbin/shutdown -h now") + it "runs systemctl shutdown when systemctl is present" do + comm.stub_command('test -e /usr/bin/systemctl', exit_code: 0) + comm.expect_command('test -e /usr/bin/systemctl') + comm.expect_command("/usr/bin/systemctl poweroff &") + cap.halt(machine) + end + + it "runs shutdown when systemctl is not present" do + comm.stub_command('test -e /usr/bin/systemctl', exit_code: 1) + comm.expect_command('test -e /usr/bin/systemctl') + comm.expect_command("/sbin/shutdown -h now &") cap.halt(machine) end it "does not raise an IOError" do - comm.stub_command("shutdown -h now", raise: IOError) + comm.stub_command('test -e /usr/bin/systemctl', exit_code: 0) + comm.stub_command("/usr/bin/systemctl poweroff &", raise: IOError) expect { cap.halt(machine) }.to_not raise_error end it "ignores a Vagrant::Errors::SSHDisconnected" do - comm.stub_command("shutdown -h now", raise: Vagrant::Errors::SSHDisconnected) + comm.stub_command('test -e /usr/bin/systemctl', exit_code: 1) + comm.stub_command("/sbin/shutdown -h now &", raise: Vagrant::Errors::SSHDisconnected) expect { cap.halt(machine) }.to_not raise_error diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/windows/cap/reboot_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/windows/cap/reboot_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/windows/cap/reboot_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/windows/cap/reboot_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -11,7 +11,7 @@ let(:machine) { double("machine", ui: ui) } let(:guest) { double("guest") } let(:communicator) { double("communicator") } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } before do allow(machine).to receive(:communicate).and_return(communicator) @@ -19,7 +19,6 @@ allow(machine.guest).to receive(:ready?).and_return(true) allow(machine).to receive(:config).and_return(config) allow(config).to receive(:vm).and_return(vm) - allow(ui).to receive(:info) end describe ".reboot" do @@ -47,7 +46,7 @@ it "sends message to user that guest is rebooting" do expect(communicator).to receive(:test).and_return(true) - expect(ui).to receive(:info) + expect(ui).to receive(:info).and_call_original end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/guests/windows/cap/rsync_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/guests/windows/cap/rsync_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/guests/windows/cap/rsync_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/guests/windows/cap/rsync_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -19,7 +19,7 @@ describe ".rsync_pre" do it 'makes the guestpath directory with mkdir' do - communicator.expect_command("mkdir -p '/sync_dir'") + communicator.expect_command("mkdir \"/sync_dir\" -force") described_class.rsync_pre(machine, guestpath: '/sync_dir') end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/hosts/bsd/cap/nfs_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/hosts/bsd/cap/nfs_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/hosts/bsd/cap/nfs_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/hosts/bsd/cap/nfs_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -8,7 +8,7 @@ describe ".nfs_export" do let(:environment) { double("environment", host: host) } let(:host) { double("host") } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:id) { "UUID" } let(:ips) { [] } let(:folders) { {} } @@ -20,7 +20,6 @@ allow(described_class).to receive(:nfs_cleanup) allow(described_class).to receive(:system) allow(File).to receive(:writable?).with("/etc/exports") - allow(ui).to receive(:info) allow(Vagrant::Util::Subprocess).to receive(:execute).with("nfsd", "checkexports"). and_return(Vagrant::Util::Subprocess::Result.new(0, "", "")) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/hosts/darwin/cap/path_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/hosts/darwin/cap/path_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/hosts/darwin/cap/path_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/hosts/darwin/cap/path_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -1,13 +1,21 @@ require_relative "../../../../base" require_relative "../../../../../../plugins/hosts/darwin/cap/path" +require_relative "../../../../../../plugins/hosts/darwin/cap/version" describe VagrantPlugins::HostDarwin::Cap::Path do describe ".resolve_host_path" do let(:env) { double("environment") } let(:path) { "/test/vagrant/path" } let(:firmlink_map) { {} } + let(:macos_version) { Gem::Version.new("10.15.1") } - before { allow(described_class).to receive(:firmlink_map).and_return(firmlink_map) } + before do + allow(VagrantPlugins::HostDarwin::Cap::Version).to receive(:version). + with(anything). + and_return(macos_version) + allow(described_class).to receive(:firmlink_map). + and_return(firmlink_map) + end it "should not change the path when no firmlinks are defined" do expect(described_class.resolve_host_path(env, path)).to eq(path) @@ -48,6 +56,18 @@ expect(described_class.resolve_host_path(env, path)).to include("other") end end + + context "when macos version is later than catalina" do + let(:macos_version) { Gem::Version.new("10.16.1") } + + it "should not update the path" do + expect(described_class.resolve_host_path(env, path)).to eq(path) + end + + it "should not prefix the path with the defined data path" do + expect(described_class.resolve_host_path(env, path)).not_to start_with(described_class.const_get(:FIRMLINK_DATA_PATH)) + end + end end describe ".firmlink_map" do diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/hosts/darwin/cap/version_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/hosts/darwin/cap/version_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/hosts/darwin/cap/version_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/hosts/darwin/cap/version_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,47 @@ +require_relative "../../../../base" +require_relative "../../../../../../plugins/hosts/darwin/cap/version" + +describe VagrantPlugins::HostDarwin::Cap::Version do + describe ".version" do + let(:product_version) { "10.5.1" } + let(:env) { double(:env) } + let(:exit_code) { 0 } + let(:stderr) { "" } + let(:stdout) { product_version } + let(:result) { + Vagrant::Util::Subprocess::Result.new(exit_code, stdout, stderr) + } + + before do + allow(Vagrant::Util::Subprocess).to receive(:execute). + with("sw_vers", "-productVersion"). + and_return(result) + end + + it "should return a Gem::Version" do + expect(described_class.version(env)).to be_a(Gem::Version) + end + + it "should equal the defined version" do + expect(described_class.version(env)).to eq(Gem::Version.new(product_version)) + end + + context "when version cannot be parsed" do + let(:product_version) { "invalid" } + + it "should raise a failure error" do + expect { described_class.version(env) }. + to raise_error(Vagrant::Errors::DarwinVersionFailed) + end + end + + context "when command execution fails" do + let(:exit_code) { 1 } + + it "should raise a failure error" do + expect { described_class.version(env) }. + to raise_error(Vagrant::Errors::DarwinVersionFailed) + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/hosts/linux/cap/nfs_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/hosts/linux/cap/nfs_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/hosts/linux/cap/nfs_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/hosts/linux/cap/nfs_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -17,7 +17,7 @@ end let(:exports_path){ VagrantPlugins::HostLinux::Cap::NFS::NFS_EXPORTS_PATH } let(:env){ double(:env) } - let(:ui){ double(:ui) } + let(:ui){ Vagrant::UI::Silent.new } let(:host){ double(:host) } before do @@ -125,7 +125,6 @@ allow(host).to receive(:capability).with(:nfs_apply_command).and_return("/bin/true") allow(host).to receive(:capability).with(:nfs_check_command).and_return("/bin/true") allow(host).to receive(:capability).with(:nfs_start_command).and_return("/bin/true") - allow(ui).to receive(:info) allow(Vagrant::Util::Subprocess).to receive(:execute).and_call_original allow(Vagrant::Util::Subprocess).to receive(:execute).with("sudo", "/bin/true").and_return(double(:result, exit_code: 0)) allow(Vagrant::Util::Subprocess).to receive(:execute).with("/bin/true").and_return(double(:result, exit_code: 0)) @@ -206,7 +205,6 @@ let(:cap){ caps.get(:nfs_prune) } before do - allow(ui).to receive(:info) allow(Vagrant::Util::Subprocess).to receive(:execute).with("mv", any_args). and_call_original end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/hosts/windows/cap/smb_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/hosts/windows/cap/smb_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/hosts/windows/cap/smb_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/hosts/windows/cap/smb_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -4,7 +4,7 @@ describe VagrantPlugins::HostWindows::Cap::SMB do let(:subject){ VagrantPlugins::HostWindows::Cap::SMB } - let(:machine){ double(:machine, env: double(:machine_env, ui: double(:ui))) } + let(:machine){ double(:machine, env: double(:machine_env, ui: Vagrant::UI::Silent.new)) } let(:env){ double(:env) } let(:options){ {} } let(:result){ Vagrant::Util::Subprocess::Result } @@ -62,7 +62,6 @@ allow(subject).to receive(:machine_id).and_return("CUSTOM_ID") allow(Vagrant::Util::PowerShell).to receive(:version).and_return(powershell_version) allow(Vagrant::Util::PowerShell).to receive(:execute_cmd).and_return("") - allow(machine.env.ui).to receive(:warn) allow(subject).to receive(:sleep) end @@ -103,7 +102,7 @@ after{ subject.smb_cleanup(env, machine, options) } it "should pause after warning user" do - expect(machine.env.ui).to receive(:warn) + expect(machine.env.ui).to receive(:warn).and_call_original expect(subject).to receive(:sleep) end @@ -184,7 +183,7 @@ end it "should pause after warning user" do - expect(machine.env.ui).to receive(:warn) + expect(machine.env.ui).to receive(:warn).and_call_original expect(subject).to receive(:sleep) subject.smb_prepare(env, machine, folders, options) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/kernel_v2/config/disk_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/kernel_v2/config/disk_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/kernel_v2/config/disk_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/kernel_v2/config/disk_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -9,7 +9,7 @@ subject { described_class.new(type) } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:env) { double("env", ui: ui) } let(:provider) { double("provider") } let(:machine) { double("machine", name: "name", provider: provider, env: env, @@ -30,8 +30,6 @@ end before do - env = double("env") - allow(provider).to receive(:capability?).with(:validate_disk_ext).and_return(true) allow(provider).to receive(:capability).with(:validate_disk_ext, "vdi").and_return(true) allow(provider).to receive(:capability?).with(:set_default_disk_ext).and_return(true) @@ -119,7 +117,7 @@ describe "#add_provider_config" do it "normalizes provider config" do test_provider_config = {provider__something: "special" } - subject.add_provider_config(test_provider_config) + subject.add_provider_config(**test_provider_config) expect(subject.provider_config).to eq( { provider: {something: "special" }} ) end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/docker/action/connect_networks_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/docker/action/connect_networks_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/docker/action/connect_networks_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/docker/action/connect_networks_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -97,7 +97,7 @@ expect(called).to eq(true) end - it "connects all of the avaiable networks to a container" do + it "connects all of the available networks to a container" do expect(driver).to receive(:connect_network).with("vagrant_network_172.20.0.0/16", "12345", ["--ip", "172.20.128.2", "--alias", "mynetwork"]) expect(driver).to receive(:connect_network).with("vagrant_network_public_wlp4s0", "12345", ["--ip", "172.30.130.2"]) expect(driver).to receive(:connect_network).with("vagrant_network_2a02:6b8:b010:9020:1::/80", "12345", []) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/docker/driver_compose_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/docker/driver_compose_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/docker/driver_compose_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/docker/driver_compose_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -1,3 +1,4 @@ +require "yaml" require_relative "../../../base" require Vagrant.source_root.join("lib/vagrant/util/deep_merge") @@ -5,6 +6,17 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do let(:cmd_executed) { @cmd } + let(:execute_result) { + double("execute_result", + exit_code: exit_code, + stderr: stderr, + stdout: stdout + ) + } + let(:exit_code) { 0 } + let(:stderr) { "" } + let(:stdout) { "" } + let(:cid) { 'side-1-song-10' } let(:docker_yml){ double("docker-yml", path: "/tmp-file") } let(:machine){ double("machine", env: env, name: :docker_1, id: :docker_id, provider_config: provider_config) } @@ -33,11 +45,26 @@ let(:data_directory){ double("data-directory", join: composition_path) } let(:local_data_path){ double("local-data-path") } let(:compose_execute_up){ ["docker-compose", "-f", "docker-compose.yml", "-p", "cwd", "up", "--remove-orphans", "-d", any_args] } - + let(:compose_execute_up_regex) { /docker-compose -f docker-compose.yml -p cwd up --remove-orphans -d/ } subject{ described_class.new(machine) } before do + @cmd = [] + allow(Vagrant::Util::Subprocess).to receive(:execute) { |*args| + if args.last.is_a?(Hash) + args = args[0, args.size - 1] + end + invalid = args.detect { |a| !a.is_a?(String) } + if invalid + raise TypeError, + "Vagrant::Util::Subprocess#execute only accepts signle option Hash and String arguments, received `#{invalid.class}'" + end + @cmd << args.join(" ") + }.and_return(execute_result) + allow_any_instance_of(Vagrant::Errors::VagrantError). + to receive(:translate_error) { |*args| args.join(" ") } + allow(Vagrant::Util::Which).to receive(:which).and_return("/dev/null/docker-compose") allow(env).to receive(:lock).and_yield allow(Pathname).to receive(:new).with(local_data_path).and_return(local_data_path) @@ -48,10 +75,6 @@ allow(Tempfile).to receive(:new).with("vagrant-docker-compose").and_return(docker_yml) allow(docker_yml).to receive(:write) allow(docker_yml).to receive(:close) - allow(subject).to receive(:execute) do |*args| - args.delete_if{|i| i.is_a?(Hash) } - @cmd = args.join(' ') - end end describe '#build' do @@ -85,8 +108,10 @@ privileged: true } } - before { expect(subject).to receive(:execute).with(*compose_execute_up) } - after { subject.create(params) } + after { + subject.create(params) + expect(cmd_executed.first).to match(compose_execute_up_regex) + } it 'sets container name' do expect(docker_yml).to receive(:write).with(/#{machine.name}/) @@ -168,26 +193,24 @@ it 'performs the check on all containers list' do subject.created?(cid) - expect(cmd_executed).to match(/docker ps \-a \-q/) + expect(cmd_executed.first).to match(/docker ps \-a \-q/) end context 'when container exists' do - before { allow(subject).to receive(:execute) - .and_return("foo\n#{cid}\nbar") } + let(:stdout) { "foo\n#{cid}\nbar" } it { expect(result).to be_truthy } end context 'when container does not exist' do - before { allow(subject).to receive(:execute) - .and_return("foo\n#{cid}extra\nbar") } + let(:stdout) { "foo\n#{cid}extra\nbar" } it { expect(result).to be_falsey } end end describe '#pull' do it 'should pull images' do - expect(subject).to receive(:execute).with('docker', 'pull', 'foo') subject.pull('foo') + expect(cmd_executed.first).to eq("docker pull foo") end end @@ -196,19 +219,17 @@ it 'performs the check on the running containers list' do subject.running?(cid) - expect(cmd_executed).to match(/docker ps \-q/) - expect(cmd_executed).to_not include('-a') + expect(cmd_executed.first).to match(/docker ps \-q/) + expect(cmd_executed.first).to_not include('-a') end context 'when container exists' do - before { allow(subject).to receive(:execute) - .and_return("foo\n#{cid}\nbar") } + let(:stdout) { "foo\n#{cid}\nbar" } it { expect(result).to be_truthy } end context 'when container does not exist' do - before { allow(subject).to receive(:execute) - .and_return("foo\n#{cid}extra\nbar") } + let(:stdout) { "foo\n#{cid}extra\nbar" } it { expect(result).to be_falsey } end end @@ -232,8 +253,8 @@ before { allow(subject).to receive(:running?).and_return(true) } it 'does not start the container' do - expect(subject).not_to receive(:execute).with('docker', 'start', cid) subject.start(cid) + expect(cmd_executed).to be_empty end end @@ -241,8 +262,8 @@ before { allow(subject).to receive(:running?).and_return(false) } it 'starts the container' do - expect(subject).to receive(:execute).with('docker', 'start', cid) subject.start(cid) + expect(cmd_executed.first).to eq("docker start #{cid}") end end end @@ -252,13 +273,13 @@ before { allow(subject).to receive(:running?).and_return(true) } it 'stops the container' do - expect(subject).to receive(:execute).with('docker', 'stop', '-t', '1', cid) subject.stop(cid, 1) + expect(cmd_executed.first).to eq("docker stop -t 1 #{cid}") end it "stops the container with the set timeout" do - expect(subject).to receive(:execute).with('docker', 'stop', '-t', '5', cid) subject.stop(cid, 5) + expect(cmd_executed.first).to eq("docker stop -t 5 #{cid}") end end @@ -268,6 +289,7 @@ it 'does not stop container' do expect(subject).not_to receive(:execute).with('docker', 'stop', '-t', '1', cid) subject.stop(cid, 1) + expect(cmd_executed).to be_empty end end end @@ -277,8 +299,8 @@ before { allow(subject).to receive(:created?).and_return(true) } it 'removes the container' do - expect(subject).to receive(:execute).with("docker-compose", "-f", "docker-compose.yml", "-p", "cwd", "rm", "-f", "docker_1", any_args) subject.rm(cid) + expect(cmd_executed.first).to match(/docker-compose -f docker-compose.yml -p cwd rm -f docker_1/) end end @@ -286,20 +308,18 @@ before { allow(subject).to receive(:created?).and_return(false) } it 'does not attempt to remove the container' do - expect(subject).not_to receive(:execute).with("docker-compose", "-f", "docker-compose.yml", "-p", "cwd", "rm", "-f", "docker_1", {}) subject.rm(cid) + expect(cmd_executed).to be_empty end end end describe '#inspect_container' do - let(:data) { '[{"json": "value"}]' } - - before { allow(subject).to receive(:execute).and_return(data) } + let(:stdout) { '[{"json": "value"}]' } it 'inspects the container' do - expect(subject).to receive(:execute).with('docker', 'inspect', cid) subject.inspect_container(cid) + expect(cmd_executed.first).to eq("docker inspect #{cid}") end it 'parses the json output' do @@ -308,24 +328,20 @@ end describe '#all_containers' do - let(:containers) { "container1\ncontainer2" } - - before { allow(subject).to receive(:execute).and_return(containers) } + let(:stdout) { "container1\ncontainer2" } it 'returns an array of all known containers' do - expect(subject).to receive(:execute).with('docker', 'ps', '-a', '-q', '--no-trunc') expect(subject.all_containers).to eq(['container1', 'container2']) + expect(cmd_executed.first).to eq("docker ps -a -q --no-trunc") end end describe '#docker_bridge_ip' do - let(:containers) { " inet 123.456.789.012/16 " } - - before { allow(subject).to receive(:execute).and_return(containers) } + let(:stdout) { " inet 123.456.789.012/16 " } it 'returns an array of all known containers' do - expect(subject).to receive(:execute).with('/sbin/ip', '-4', 'addr', 'show', 'scope', 'global', 'docker0') expect(subject.docker_bridge_ip).to eq('123.456.789.012') + expect(cmd_executed.first).to eq("/sbin/ip -4 addr show scope global docker0") end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/docker/driver_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/docker/driver_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/docker/driver_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/docker/driver_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,9 +5,31 @@ describe VagrantPlugins::DockerProvider::Driver do let(:cmd_executed) { @cmd } let(:cid) { 'side-1-song-10' } + let(:execute_result) { + double("execute_result", + exit_code: exit_code, + stderr: stderr, + stdout: stdout + ) + } + let(:exit_code) { 0 } + let(:stderr) { "" } + let(:stdout) { "" } before do - allow(subject).to receive(:execute) { |*args| @cmd = args.join(' ') } + allow(Vagrant::Util::Subprocess).to receive(:execute) { |*args| + if args.last.is_a?(Hash) + args = args[0, args.size - 1] + end + invalid = args.detect { |a| !a.is_a?(String) } + if invalid + raise TypeError, + "Vagrant::Util::Subprocess#execute only accepts signle option Hash and String arguments, received `#{invalid.class}'" + end + @cmd = args.join(" ") + }.and_return(execute_result) + allow_any_instance_of(Vagrant::Errors::VagrantError). + to receive(:translate_error) { |*args| args.join(" ") } end let(:docker_network_struct) { @@ -153,51 +175,62 @@ describe '#build' do - let(:result) { "Successfully built other_package\nSuccessfully built 1a2b3c4d" } - let(:buildkit_result) { "writing image sha256:1a2b3c4d done" } - let(:podman_result) { "1a2b3c4d5e6f7g8h9i10j11k12l13m14n16o17p18q19r20s21t22u23v24w25x2" } + let(:stdout) { "Successfully built other_package\nSuccessfully built 1a2b3c4d" } let(:cid) { "1a2b3c4d" } it "builds a container with standard docker" do - allow(subject).to receive(:execute).and_return(result) - container_id = subject.build("/tmp/fakedir") expect(container_id).to eq(cid) end - it "builds a container with buildkit docker" do - allow(subject).to receive(:execute).and_return(buildkit_result) + context "using buildkit" do + let(:stdout) { "writing image sha256:1a2b3c4d 0.0s done" } - container_id = subject.build("/tmp/fakedir") + it "builds a container with buildkit docker" do + container_id = subject.build("/tmp/fakedir") - expect(container_id).to eq(cid) + expect(container_id).to eq(cid) + end end - it "builds a container with podman emulating docker CLI" do - allow(subject).to receive(:execute).and_return(podman_result) - allow(subject).to receive(:podman?).and_return(true) + context "using buildkit with old output" do + let(:stdout) { "writing image sha256:1a2b3c4d done" } - container_id = subject.build("/tmp/fakedir") + it "builds a container with buildkit docker (old output)" do + container_id = subject.build("/tmp/fakedir") - expect(container_id).to eq(cid) + expect(container_id).to eq(cid) + end end - end - describe '#podman?' do - let(:emulating_docker_output) { "podman version 1.7.1-dev" } - let(:real_docker_output) { "Docker version 1.8.1, build d12ea79" } + context "using podman emulating docker CLI" do + let(:stdout) { "1a2b3c4d5e6f7g8h9i10j11k12l13m14n16o17p18q19r20s21t22u23v24w25x2" } - it 'returns false when docker is used' do - allow(subject).to receive(:execute).and_return(real_docker_output) + it "builds a container with podman emulating docker CLI" do + allow(subject).to receive(:podman?).and_return(true) - expect(subject.podman?).to be false + container_id = subject.build("/tmp/fakedir") + + expect(container_id).to eq(cid) + end end + end - it 'returns true when podman is used' do - allow(subject).to receive(:execute).and_return(emulating_docker_output) + describe '#podman?' do + context "when docker is used" do + let(:stdout) { "Docker version 1.8.1, build d12ea79" } + + it 'returns false' do + expect(subject.podman?).to be false + end + end + context "when podman is used" do + let(:stdout) { "podman version 1.7.1-dev" } - expect(subject.podman?).to be true + it 'returns true' do + expect(subject.podman?).to be true + end end end @@ -292,20 +325,22 @@ end context 'when container exists' do - before { allow(subject).to receive(:execute).and_return("foo\n#{cid}\nbar") } + let(:stdout) { "foo\n#{cid}\nbar" } + it { expect(result).to be_truthy } end context 'when container does not exist' do - before { allow(subject).to receive(:execute).and_return("foo\n#{cid}extra\nbar") } + let(:stdout) { "foo\n#{cid}extra\nbar" } + it { expect(result).to be_falsey } end end describe '#pull' do it 'should pull images' do - expect(subject).to receive(:execute).with('docker', 'pull', 'foo') subject.pull('foo') + expect(cmd_executed).to match(/docker pull foo/) end end @@ -346,12 +381,12 @@ end context 'when container exists' do - before { allow(subject).to receive(:execute).and_return("foo\n#{cid}\nbar") } + let(:stdout) { "foo\n#{cid}\nbar" } it { expect(result).to be_truthy } end context 'when container does not exist' do - before { allow(subject).to receive(:execute).and_return("foo\n#{cid}extra\nbar") } + let(:stdout) { "foo\n#{cid}extra\nbar" } it { expect(result).to be_falsey } end end @@ -373,8 +408,8 @@ before { allow(subject).to receive(:running?).and_return(true) } it 'does not start the container' do - expect(subject).to_not receive(:execute).with('docker', 'start', cid) subject.start(cid) + expect(cmd_executed).to be_nil end end @@ -382,8 +417,8 @@ before { allow(subject).to receive(:running?).and_return(false) } it 'starts the container' do - expect(subject).to receive(:execute).with('docker', 'start', cid) subject.start(cid) + expect(cmd_executed).to eq("docker start #{cid}") end end end @@ -393,13 +428,13 @@ before { allow(subject).to receive(:running?).and_return(true) } it 'stops the container' do - expect(subject).to receive(:execute).with('docker', 'stop', '-t', '1', cid) subject.stop(cid, 1) + expect(cmd_executed).to eq("docker stop -t 1 #{cid}") end it "stops the container with the set timeout" do - expect(subject).to receive(:execute).with('docker', 'stop', '-t', '5', cid) subject.stop(cid, 5) + expect(cmd_executed).to eq("docker stop -t 5 #{cid}") end end @@ -407,8 +442,8 @@ before { allow(subject).to receive(:running?).and_return(false) } it 'does not stop container' do - expect(subject).to_not receive(:execute).with('docker', 'stop', '-t', '1', cid) subject.stop(cid, 1) + expect(cmd_executed).to be_nil end end end @@ -418,8 +453,8 @@ before { allow(subject).to receive(:created?).and_return(true) } it 'removes the container' do - expect(subject).to receive(:execute).with('docker', 'rm', '-f', '-v', cid) subject.rm(cid) + expect(cmd_executed).to eq("docker rm -f -v #{cid}") end end @@ -427,8 +462,8 @@ before { allow(subject).to receive(:created?).and_return(false) } it 'does not attempt to remove the container' do - expect(subject).to_not receive(:execute).with('docker', 'rm', '-f', '-v', cid) subject.rm(cid) + expect(cmd_executed).to be_nil end end end @@ -438,8 +473,8 @@ context 'image exists' do it "removes the image" do - expect(subject).to receive(:execute).with('docker', 'rmi', id) subject.rmi(id) + expect(cmd_executed).to eq("docker rmi #{id}") end end @@ -481,13 +516,11 @@ end describe '#inspect_container' do - let(:data) { '[{"json": "value"}]' } - - before { allow(subject).to receive(:execute).and_return(data) } + let(:stdout) { '[{"json": "value"}]' } it 'inspects the container' do - expect(subject).to receive(:execute).with('docker', 'inspect', cid) subject.inspect_container(cid) + expect(cmd_executed).to eq("docker inspect #{cid}") end it 'parses the json output' do @@ -496,68 +529,66 @@ end describe '#all_containers' do - let(:containers) { "container1\ncontainer2" } - - before { allow(subject).to receive(:execute).and_return(containers) } + let(:stdout) { "container1\ncontainer2" } it 'returns an array of all known containers' do - expect(subject).to receive(:execute).with('docker', 'ps', '-a', '-q', '--no-trunc') expect(subject.all_containers).to eq(['container1', 'container2']) + expect(cmd_executed).to eq("docker ps -a -q --no-trunc") end end describe '#docker_bridge_ip' do - let(:containers) { " inet 123.456.789.012/16 " } - - before { allow(subject).to receive(:execute).and_return(containers) } + let(:stdout) { " inet 123.456.789.012/16 " } it 'returns an array of all known containers' do - expect(subject).to receive(:execute).with('/sbin/ip', '-4', 'addr', 'show', 'scope', 'global', 'docker0') expect(subject.docker_bridge_ip).to eq('123.456.789.012') + expect(cmd_executed).to eq("/sbin/ip -4 addr show scope global docker0") end end describe '#docker_connect_network' do let(:opts) { ["--ip", "172.20.128.2"] } + it 'connects a network to a container' do - expect(subject).to receive(:execute).with("docker", "network", "connect", "vagrant_network", cid, "--ip", "172.20.128.2") subject.connect_network("vagrant_network", cid, opts) + expect(cmd_executed).to eq("docker network connect vagrant_network #{cid} --ip 172.20.128.2") end end describe '#docker_create_network' do let(:opts) { ["--subnet", "172.20.0.0/16"] } + it 'creates a network' do - expect(subject).to receive(:execute).with("docker", "network", "create", "vagrant_network", "--subnet", "172.20.0.0/16") subject.create_network("vagrant_network", opts) + expect(cmd_executed).to eq("docker network create vagrant_network --subnet 172.20.0.0/16") end end describe '#docker_disconnet_network' do it 'disconnects a network from a container' do - expect(subject).to receive(:execute).with("docker", "network", "disconnect", "vagrant_network", cid, "--force") subject.disconnect_network("vagrant_network", cid) + expect(cmd_executed).to eq("docker network disconnect vagrant_network #{cid} --force") end end describe '#docker_inspect_network' do it 'gets info about a network' do - expect(subject).to receive(:execute).with("docker", "network", "inspect", "vagrant_network") subject.inspect_network("vagrant_network") + expect(cmd_executed).to eq("docker network inspect vagrant_network") end end describe '#docker_list_network' do it 'lists docker networks' do - expect(subject).to receive(:execute).with("docker", "network", "ls") subject.list_network() + expect(cmd_executed).to eq("docker network ls") end end describe '#docker_rm_network' do it 'deletes a docker network' do - expect(subject).to receive(:execute).with("docker", "network", "rm", "vagrant_network") subject.rm_network("vagrant_network") + expect(cmd_executed).to eq("docker network rm vagrant_network") end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/docker/provider_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/docker/provider_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/docker/provider_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/docker/provider_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -78,7 +78,7 @@ it "returns the host machine object" do allow(machine.provider_config).to receive(:vagrant_vagrantfile).and_return("/path/to/Vagrantfile") allow(machine.provider_config).to receive(:vagrant_machine).and_return(:default) - allow(machine).to receive(:env).and_return(true) + allow(machine).to receive(:env).and_return(double("env")) allow(machine.env).to receive(:root_path).and_return("/.vagrant.d") allow(machine.env).to receive(:home_path).and_return("/path/to") allow(machine.env).to receive(:ui_class).and_return(true) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/check_enabled_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/check_enabled_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/check_enabled_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/check_enabled_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,14 +5,12 @@ describe VagrantPlugins::HyperV::Action::CheckEnabled do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider) } let(:subject){ described_class.new(app, env) } - before{ allow(ui).to receive(:output) } - it "should continue when Hyper-V is enabled" do expect(driver).to receive(:execute).and_return("result" => true) expect(app).to receive(:call) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/configure_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/configure_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/configure_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/configure_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::Configure do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, config: config, provider_config: provider_config, data_dir: data_dir, id: "machineID") } @@ -41,8 +41,6 @@ allow(driver).to receive(:execute) allow(app).to receive(:call) expect(driver).to receive(:execute).with(:get_switches).and_return(switches) - allow(ui).to receive(:detail) - allow(ui).to receive(:output) allow(ui).to receive(:ask).and_return("1") allow(data_dir).to receive(:join).and_return(sentinel) allow(sentinel).to receive(:file?).and_return(false) @@ -126,7 +124,7 @@ end end - context "with enhanced session transport type" do + context "with enhanced session transport type" do let(:enable_enhanced_session_mode) { true } it "should call the driver to set enhanced session transport type" do diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/delete_vm_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/delete_vm_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/delete_vm_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/delete_vm_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::DeleteVM do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, data_dir: "/dev/null") } @@ -13,7 +13,6 @@ before do allow(app).to receive(:call) - allow(ui).to receive(:info) allow(driver).to receive(:delete_vm) allow(FileUtils).to receive(:rm_rf) allow(FileUtils).to receive(:mkdir_p) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/export_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/export_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/export_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/export_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::Export do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, state: state) } @@ -16,9 +16,6 @@ before do allow(app).to receive(:call) - allow(ui).to receive(:info) - allow(ui).to receive(:clear_line) - allow(ui).to receive(:report_progress) allow(driver).to receive(:export) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/import_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/import_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/import_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/import_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::Import do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, provider_config: provider_config, box: box, data_dir: data_dir, name: "machname") } @@ -36,8 +36,6 @@ allow(data_dir).to receive(:to_s).and_return("DATA_DIR_PATH") allow(driver).to receive(:import).and_return("id" => "VMID") allow(machine).to receive(:id=) - allow(ui).to receive(:output) - allow(ui).to receive(:detail) end context "with missing virtual machines directory" do diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/is_windows_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/is_windows_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/is_windows_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/is_windows_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::IsWindows do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, config: config) } diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/net_set_mac_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/net_set_mac_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/net_set_mac_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/net_set_mac_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::NetSetMac do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, provider_config: provider_config) } @@ -14,7 +14,6 @@ let(:subject){ described_class.new(app, env) } before do - allow(ui).to receive(:info) allow(driver).to receive(:net_set_mac) allow(app).to receive(:call) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/net_set_vlan_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/net_set_vlan_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/net_set_vlan_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/net_set_vlan_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::NetSetVLan do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, provider_config: provider_config) } @@ -14,7 +14,6 @@ let(:subject){ described_class.new(app, env) } before do - allow(ui).to receive(:info) allow(driver).to receive(:net_set_vlan) allow(app).to receive(:call) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/read_guest_ip_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/read_guest_ip_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/read_guest_ip_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/read_guest_ip_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::ReadGuestIP do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider) } diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/read_state_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/read_state_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/read_state_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/read_state_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::ReadState do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine, machine_state_id: state_id} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider) } diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/set_name_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/set_name_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/set_name_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/set_name_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::SetName do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine, root_path: Pathname.new("path")} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, provider_config: provider_config, data_dir: data_dir, name: "machname") } @@ -17,7 +17,6 @@ let(:subject){ described_class.new(app, env) } before do - allow(ui).to receive(:info) allow(driver).to receive(:set_name) allow(app).to receive(:call) allow(data_dir).to receive(:join).and_return(sentinel) diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/wait_for_ip_address_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/wait_for_ip_address_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/action/wait_for_ip_address_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/action/wait_for_ip_address_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Action::WaitForIPAddress do let(:app){ double("app") } let(:env){ {ui: ui, machine: machine} } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } let(:provider){ double("provider", driver: driver) } let(:driver){ double("driver") } let(:machine){ double("machine", provider: provider, provider_config: provider_config) } @@ -15,8 +15,6 @@ let(:subject){ described_class.new(app, env) } before do - allow(ui).to receive(:output) - allow(ui).to receive(:detail) allow(driver).to receive(:read_guest_ip).and_return("ip" => "127.0.0.1") allow(app).to receive(:call) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/config_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/config_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/hyperv/config_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/hyperv/config_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,7 +5,7 @@ describe VagrantPlugins::HyperV::Config do let(:machine){ double("machine", ui: ui) } - let(:ui){ double("ui") } + let(:ui){ Vagrant::UI::Silent.new } describe "#ip_address_timeout" do it "can be set" do @@ -241,7 +241,7 @@ expect(result["Hyper-V"]).not_to be_empty end end - + describe "#enable_enhanced_session_mode" do it "is false by default" do diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/virtualbox/action/match_mac_address_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/virtualbox/action/match_mac_address_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/virtualbox/action/match_mac_address_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/virtualbox/action/match_mac_address_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -1,7 +1,7 @@ require_relative "../base" describe VagrantPlugins::ProviderVirtualBox::Action::MatchMACAddress do - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:machine) { double("machine", config: config, provider: double("provider", driver: driver)) } let(:driver) { double("driver") } let(:env) { @@ -16,7 +16,6 @@ let(:subject) { described_class.new(app, env) } before do - allow(ui).to receive(:info) allow(app).to receive(:call) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/virtualbox/action/network_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/virtualbox/action/network_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/virtualbox/action/network_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/virtualbox/action/network_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -21,7 +21,8 @@ let(:env) {{ machine: machine, ui: machine.ui }} let(:app) { lambda { |*args| }} - let(:driver) { double("driver") } + let(:driver) { double("driver", version: vbox_version) } + let(:vbox_version) { "6.1.0" } let(:nics) { {} } @@ -32,6 +33,181 @@ allow(driver).to receive(:read_network_interfaces) { nics } end + describe "#hostonly_config" do + before do + allow(subject).to receive(:hostonly_find_matching_network) + allow(driver).to receive(:read_bridged_interfaces).and_return([]) + subject.instance_eval do + def env=(e) + @env = e + end + end + + subject.env = env + end + + let(:options) { + { + type: type, + ip: address, + } + } + let(:type) { :dhcp } + let(:address) { nil } + + it "should validate the IP" do + expect(subject).to receive(:validate_hostonly_ip!) + subject.hostonly_config(options) + end + end + + describe "#validate_hostonly_ip!" do + let(:address) { "192.168.1.2" } + let(:net_conf) { [IPAddr.new(address + "/24")]} + let(:vbox_version) { "6.1.28" } + + before do + allow(subject).to receive(:load_net_conf).and_return(net_conf) + expect(subject).to receive(:validate_hostonly_ip!).and_call_original + end + + it "should load net configuration" do + expect(subject).to receive(:load_net_conf).and_return(net_conf) + subject.validate_hostonly_ip!(address, driver) + end + + context "when address is within ranges" do + it "should not error" do + subject.validate_hostonly_ip!(address, driver) + end + end + + context "when address is not found within ranges" do + let(:net_conf) { [IPAddr.new("127.0.0.1/20")] } + + it "should raise an error" do + expect { + subject.validate_hostonly_ip!(address, driver) + }.to raise_error(Vagrant::Errors::VirtualBoxInvalidHostSubnet) + end + end + + context "when virtualbox version does not restrict range" do + let(:vbox_version) { "6.1.20" } + + it "should not error" do + subject.validate_hostonly_ip!(address, driver) + end + + it "should not attempt to load network configuration" do + expect(subject).not_to receive(:load_net_conf) + subject.validate_hostonly_ip!(address, driver) + end + end + + context "when platform is windows" do + before do + allow(Vagrant::Util::Platform).to receive(:windows?).and_return(true) + end + + it "should not error" do + subject.validate_hostonly_ip!(address, driver) + end + + it "should not attempt to load network configuration" do + expect(subject).not_to receive(:load_net_conf) + subject.validate_hostonly_ip!(address, driver) + end + end + end + + describe "#load_net_conf" do + let(:file_contents) { [""] } + + before do + allow(File).to receive(:exist?).and_call_original + allow(File).to receive(:exist?). + with(described_class.const_get(:VBOX_NET_CONF)). + and_return(true) + allow(File).to receive(:readlines). + with(described_class.const_get(:VBOX_NET_CONF)). + and_return(file_contents) + end + + it "should read the configuration file" do + expect(File).to receive(:readlines). + with(described_class.const_get(:VBOX_NET_CONF)). + and_return(file_contents) + + subject.load_net_conf + end + + context "when file has comments only" do + let(:file_contents) { + [ + "# A comment", + "# Another comment", + ] + } + + it "should return an empty array" do + expect(subject.load_net_conf).to eq([]) + end + end + + context "when file has valid range entries" do + let(:file_contents) { + [ + "* 127.0.0.1/24", + "* 192.168.1.1/24", + ] + } + + it "should return an array with content" do + expect(subject.load_net_conf).not_to be_empty + end + + it "should include IPAddr instances" do + subject.load_net_conf.each do |entry| + expect(entry).to be_a(IPAddr) + end + end + end + + context "when file has valid range entries and comments" do + let(:file_contents) { + [ + "# Comment in file", + "* 127.0.0.0/8", + "random text", + " * 192.168.2.0/28", + ] + } + + it "should contain two entries" do + expect(subject.load_net_conf.size).to eq(2) + end + end + + context "when file has multiple entries on single line" do + let(:file_contents) { + [ + "* 0.0.0.0/0 ::/0" + ] + } + + it "should contain two entries" do + expect(subject.load_net_conf.size).to eq(2) + end + + it "should contain an ipv4 and ipv6 range" do + result = subject.load_net_conf + expect(result.first).to be_ipv4 + expect(result.last).to be_ipv6 + end + end + end + it "calls the next action in the chain" do called = false app = lambda { |*args| called = true } @@ -91,37 +267,71 @@ allow(machine).to receive(:guest) { guest } end + it "tries to setup dhpc server using the ip for the specified network" do + allow(driver).to receive(:create_host_only_network) {{ name: 'vboxnet0' }} + allow(driver).to receive(:create_dhcp_server) + allow(guest).to receive(:capability) + allow(subject).to receive(:hostonly_find_matching_network).and_return({name: "vboxnet1", ip: "192.168.55.1"}) + + subject.call(env) + + expect(driver).to have_received(:create_dhcp_server).with('vboxnet1', { + adapter_ip: "192.168.55.1", + auto_config: true, + ip: "192.168.55.1", + mac: nil, + name: nil, + netmask: "255.255.255.0", + nic_type: nil, + type: :dhcp, + dhcp_ip: "192.168.55.2", + dhcp_lower: "192.168.55.3", + dhcp_upper: "192.168.55.254", + adapter: 2 + }) + + expect(guest).to have_received(:capability).with(:configure_networks, [{ + type: :dhcp, + adapter_ip: "192.168.55.1", + ip: "192.168.55.1", + netmask: "255.255.255.0", + auto_config: true, + interface: nil + }]) + end + it "creates a host only interface and a dhcp server using default ips, then tells the guest to configure the network after boot" do allow(driver).to receive(:create_host_only_network) {{ name: 'vboxnet0' }} allow(driver).to receive(:create_dhcp_server) allow(guest).to receive(:capability) + allow(subject).to receive(:hostonly_find_matching_network).and_return(nil) subject.call(env) expect(driver).to have_received(:create_host_only_network).with({ - adapter_ip: '172.28.128.1', + adapter_ip: '192.168.56.1', netmask: '255.255.255.0', }) expect(driver).to have_received(:create_dhcp_server).with('vboxnet0', { - adapter_ip: "172.28.128.1", + adapter_ip: "192.168.56.1", auto_config: true, - ip: "172.28.128.1", + ip: "192.168.56.1", mac: nil, name: nil, netmask: "255.255.255.0", nic_type: nil, type: :dhcp, - dhcp_ip: "172.28.128.2", - dhcp_lower: "172.28.128.3", - dhcp_upper: "172.28.128.254", + dhcp_ip: "192.168.56.2", + dhcp_lower: "192.168.56.3", + dhcp_upper: "192.168.56.254", adapter: 2 }) expect(guest).to have_received(:capability).with(:configure_networks, [{ type: :dhcp, - adapter_ip: "172.28.128.1", - ip: "172.28.128.1", + adapter_ip: "192.168.56.1", + ip: "192.168.56.1", netmask: "255.255.255.0", auto_config: true, interface: nil @@ -179,8 +389,8 @@ { ip: 'foo'}, { ip: '1.2.3'}, { ip: 'dead::beef::'}, - { ip: '172.28.128.3', netmask: 64}, - { ip: '172.28.128.3', netmask: 'ffff:ffff::'}, + { ip: '192.168.56.3', netmask: 64}, + { ip: '192.168.56.3', netmask: 'ffff:ffff::'}, { ip: 'dead:beef::', netmask: 'foo:bar::'}, { ip: 'dead:beef::', netmask: '255.255.255.0'} ].each do |args| diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/virtualbox/cap/mount_options_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/virtualbox/cap/mount_options_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/virtualbox/cap/mount_options_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/virtualbox/cap/mount_options_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -49,7 +49,7 @@ let(:mount_owner){ 2000 } it "generates the expected mount command using mount_owner directly" do out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_mount_options).to eq("uid=#{mount_owner},gid=#{mount_gid}") + expect(out_mount_options).to eq("uid=#{mount_owner},gid=#{mount_gid},_netdev") expect(out_mount_uid).to eq(mount_owner) expect(out_mount_gid).to eq(mount_gid) end @@ -59,7 +59,7 @@ let(:mount_owner){ "2000" } it "generates the expected mount command using mount_owner directly" do out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_mount_options).to eq("uid=#{mount_owner},gid=#{mount_gid}") + expect(out_mount_options).to eq("uid=#{mount_owner},gid=#{mount_gid},_netdev") expect(out_mount_uid).to eq(mount_owner) expect(out_mount_gid).to eq(mount_gid) end @@ -78,7 +78,7 @@ it "generates the expected mount command using mount_group directly" do out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_mount_options).to eq("uid=#{mount_uid},gid=#{mount_group}") + expect(out_mount_options).to eq("uid=#{mount_uid},gid=#{mount_group},_netdev") expect(out_mount_uid).to eq(mount_uid) expect(out_mount_gid).to eq(mount_group) end @@ -89,7 +89,7 @@ it "generates the expected mount command using mount_group directly" do out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_mount_options).to eq("uid=#{mount_uid},gid=#{mount_group}") + expect(out_mount_options).to eq("uid=#{mount_uid},gid=#{mount_group},_netdev") expect(out_mount_uid).to eq(mount_uid) expect(out_mount_gid).to eq(mount_group) end @@ -103,7 +103,7 @@ expect(comm).to receive(:execute).with("getent group #{mount_group}", anything).and_raise(Vagrant::Errors::VirtualBoxMountFailed, {command: '', output: ''}) expect(comm).to receive(:execute).with("id -g #{mount_owner}", anything).and_yield(:stdout, "1").and_return(0) out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_mount_options).to eq("uid=#{mount_uid},gid=1") + expect(out_mount_options).to eq("uid=#{mount_uid},gid=1,_netdev") end end @@ -122,16 +122,15 @@ expect(comm).to receive(:execute).with("id -u #{mount_owner}", anything).and_yield(:stdout, mount_uid) expect(comm).to receive(:execute).with("getent group #{mount_group}", anything).and_yield(:stdout, "vagrant:x:#{mount_gid}:") out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options.merge(mount_options: ["ro"])) - expect(out_mount_options).to eq("ro,uid=#{mount_uid},gid=#{mount_gid}") + expect(out_mount_options).to eq("ro,uid=#{mount_uid},gid=#{mount_gid},_netdev") expect(out_mount_uid).to eq(mount_uid) expect(out_mount_gid).to eq(mount_gid) end end context "with custom mount options" do - let(:ui){ double(:ui) } + let(:ui){ Vagrant::UI::Silent.new } before do - allow(ui).to receive(:warn) allow(machine).to receive(:ui).and_return(ui) end @@ -142,7 +141,7 @@ expect(comm).not_to receive(:execute).with("id -u #{mount_owner}", anything).and_yield(:stdout, mount_uid) expect(comm).to receive(:execute).with("getent group #{mount_group}", anything).and_yield(:stdout, "vagrant:x:#{mount_gid}:") out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options.merge(mount_options: ["uid=#{options_uid}"]) ) - expect(out_mount_options).to eq("uid=#{options_uid},gid=#{mount_gid}") + expect(out_mount_options).to eq("uid=#{options_uid},gid=#{mount_gid},_netdev") expect(out_mount_uid).to eq(options_uid) expect(out_mount_gid).to eq(mount_gid) end @@ -155,7 +154,7 @@ expect(comm).to receive(:execute).with("id -u #{mount_owner}", anything).and_yield(:stdout, mount_uid) expect(comm).not_to receive(:execute).with("getent group #{mount_group}", anything).and_yield(:stdout, "vagrant:x:#{mount_gid}:") out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options.merge(mount_options: ["gid=#{options_gid}"]) ) - expect(out_mount_options).to eq("uid=#{mount_uid},gid=#{options_gid}") + expect(out_mount_options).to eq("uid=#{mount_uid},gid=#{options_gid},_netdev") expect(out_mount_uid).to eq(mount_uid) expect(out_mount_gid).to eq(options_gid) end @@ -169,7 +168,7 @@ expect(comm).not_to receive(:execute).with("id -u #{mount_owner}", anything).and_yield(:stdout, mount_uid) expect(comm).not_to receive(:execute).with("getent group #{mount_group}", anything).and_yield(:stdout, "vagrant:x:#{options_gid}:") out_mount_options, out_mount_uid, out_mount_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options.merge(mount_options: ["uid=#{options_uid}", "gid=#{options_gid}"]) ) - expect(out_mount_options).to eq("uid=#{options_uid},gid=#{options_gid}") + expect(out_mount_options).to eq("uid=#{options_uid},gid=#{options_gid},_netdev") expect(out_mount_uid).to eq(options_uid) expect(out_mount_gid).to eq(options_gid) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/providers/virtualbox/synced_folder_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/providers/virtualbox/synced_folder_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/providers/virtualbox/synced_folder_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/providers/virtualbox/synced_folder_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -59,7 +59,7 @@ end describe "#enable" do - let(:ui){ double(:ui) } + let(:ui){ Vagrant::UI::Silent.new } let(:guest) { double("guest") } let(:no_guestpath_folder) { {"/no_guestpath_folder"=> @@ -72,8 +72,6 @@ before do allow(subject).to receive(:share_folders).and_return(true) - allow(ui).to receive(:detail).with(any_args) - allow(ui).to receive(:output).with(any_args) allow(machine).to receive(:ui).and_return(ui) allow(machine).to receive(:ssh_info).and_return({:username => "test"}) allow(machine).to receive(:guest).and_return(guest) @@ -215,7 +213,7 @@ end describe "#display_symlink_create_warning" do - let(:env){ double("env", ui: double("ui"), data_dir: double("data_dir")) } + let(:env){ double("env", ui: Vagrant::UI::Silent.new, data_dir: double("data_dir")) } let(:gate_file){ double("gate") } before{ allow(gate_file).to receive(:to_path).and_return("PATH") } @@ -226,7 +224,6 @@ allow(env.data_dir).to receive(:join).and_return(gate_file) allow(gate_file).to receive(:exist?).and_return(false) allow(FileUtils).to receive(:touch) - allow(env.ui).to receive(:warn) end it "should create file" do @@ -234,7 +231,7 @@ end it "should output warning to user" do - expect(env.ui).to receive(:warn) + expect(env.ui).to receive(:warn).and_call_original end end @@ -243,7 +240,6 @@ allow(env.data_dir).to receive(:join).and_return(gate_file) allow(gate_file).to receive(:exist?).and_return(true) allow(FileUtils).to receive(:touch) - allow(env.ui).to receive(:warn) end it "should not create/update file" do @@ -251,7 +247,7 @@ end it "should not output warning to user" do - expect(env.ui).not_to receive(:warn) + expect(env.ui).not_to receive(:warn).and_call_original end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -31,7 +31,7 @@ describe "when install_mode is :default (or unknown)" do it "installs ansible with 'pkg' package manager" do - expect(communicator).to receive(:sudo).with("pkg install -qy py36-ansible") + expect(communicator).to receive(:sudo).with("pkg install -qy py37-ansible") subject.ansible_install(machine, :default, "", "", "") end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/ansible/provisioner_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/ansible/provisioner_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/ansible/provisioner_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/ansible/provisioner_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -325,6 +325,7 @@ "2.5.0.0-rc1": VagrantPlugins::Ansible::COMPATIBILITY_MODE_V2_0, "2.x.y.z": VagrantPlugins::Ansible::COMPATIBILITY_MODE_V2_0, "4.3.2.1": VagrantPlugins::Ansible::COMPATIBILITY_MODE_V2_0, + "[core 2.11.0]": VagrantPlugins::Ansible::COMPATIBILITY_MODE_V2_0, } valid_versions.each_pair do |ansible_version, mode| describe "and ansible version #{ansible_version}" do @@ -982,6 +983,16 @@ expect(Vagrant::Util::Subprocess).to receive(:execute).with('ansible-playbook', any_args).and_return(default_execute_result) end end + + describe "whitespace in version string" do + before do + allow(subject).to receive(:gather_ansible_version).and_return("ansible #{config.version} \n...\n") + end + + it "sets the correct gathered_version" do + expect(Vagrant::Util::Subprocess).to receive(:execute).with('ansible-playbook', any_args).and_return(default_execute_result) + end + end describe "and there is an ansible version mismatch" do before do diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/chef/cap/freebsd/chef_installed_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/chef/cap/freebsd/chef_installed_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/chef/cap/freebsd/chef_installed_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/chef/cap/freebsd/chef_installed_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -23,19 +23,38 @@ end describe "#chef_installed" do - let(:version) { "15.0.0" } - let(:command) { "test -x /opt/chef_solo/bin/knife&& /opt/chef_solo/bin/knife --version | grep '15.0.0'" } + describe "when chef-workstation" do + let(:version) { "15.0.0" } + let(:command) { "test -x /opt/chef-workstation/bin/chef&& /opt/chef-workstation/bin/chef --version | grep '15.0.0'" } - it "returns true if installed" do - expect(machine.communicate).to receive(:test). - with(command, sudo: true).and_return(true) - subject.chef_installed(machine, "chef_solo", version) + it "returns true if installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(true) + subject.chef_installed(machine, "chef-workstation", version) + end + + it "returns false if not installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(false) + expect(subject.chef_installed(machine, "chef-workstation", version)).to be_falsey + end end - it "returns false if not installed" do - expect(machine.communicate).to receive(:test). - with(command, sudo: true).and_return(false) - expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey + describe "when not chef-workstation" do + let(:version) { "15.0.0" } + let(:command) { "test -x /opt/chef/bin/chef-client&& /opt/chef/bin/chef-client --version | grep '15.0.0'" } + + it "returns true if installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(true) + subject.chef_installed(machine, "chef_solo", version) + end + + it "returns false if not installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(false) + expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey + end end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/chef/cap/linux/chef_installed_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/chef/cap/linux/chef_installed_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/chef/cap/linux/chef_installed_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/chef/cap/linux/chef_installed_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -23,19 +23,38 @@ end describe "#chef_installed" do - let(:version) { "15.0.0" } - let(:command) { "test -x /opt/chef_solo/bin/knife&& /opt/chef_solo/bin/knife --version | grep '15.0.0'" } + describe "when chef-workstation" do + let(:version) { "15.0.0" } + let(:command) { "test -x /opt/chef-workstation/bin/chef&& /opt/chef-workstation/bin/chef --version | grep '15.0.0'" } - it "returns true if installed" do - expect(machine.communicate).to receive(:test). - with(command, sudo: true).and_return(true) - subject.chef_installed(machine, "chef_solo", version) + it "returns true if installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(true) + subject.chef_installed(machine, "chef-workstation", version) + end + + it "returns false if not installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(false) + expect(subject.chef_installed(machine, "chef-workstation", version)).to be_falsey + end end - it "returns false if not installed" do - expect(machine.communicate).to receive(:test). - with(command, sudo: true).and_return(false) - expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey + describe "when not chef-workstation" do + let(:version) { "15.0.0" } + let(:command) { "test -x /opt/chef/bin/chef-client&& /opt/chef/bin/chef-client --version | grep '15.0.0'" } + + it "returns true if installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(true) + subject.chef_installed(machine, "chef_solo", version) + end + + it "returns false if not installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(false) + expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey + end end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/chef/cap/omnios/chef_installed_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/chef/cap/omnios/chef_installed_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/chef/cap/omnios/chef_installed_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/chef/cap/omnios/chef_installed_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -23,19 +23,38 @@ end describe "#chef_installed" do - let(:version) { "15.0.0" } - let(:command) { "test -x /opt/chef_solo/bin/knife&& /opt/chef_solo/bin/knife --version | grep '15.0.0'" } + describe "when chef-workstation" do + let(:version) { "15.0.0" } + let(:command) { "test -x /opt/chef-workstation/bin/chef&& /opt/chef-workstation/bin/chef --version | grep '15.0.0'" } - it "returns true if installed" do - expect(machine.communicate).to receive(:test). - with(command, sudo: true).and_return(true) - subject.chef_installed(machine, "chef_solo", version) + it "returns true if installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(true) + subject.chef_installed(machine, "chef-workstation", version) + end + + it "returns false if not installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(false) + expect(subject.chef_installed(machine, "chef-workstation", version)).to be_falsey + end end - it "returns false if not installed" do - expect(machine.communicate).to receive(:test). - with(command, sudo: true).and_return(false) - expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey + describe "when not chef-workstation" do + let(:version) { "15.0.0" } + let(:command) { "test -x /opt/chef/bin/chef-client&& /opt/chef/bin/chef-client --version | grep '15.0.0'" } + + it "returns true if installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(true) + subject.chef_installed(machine, "chef_solo", version) + end + + it "returns false if not installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(false) + expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey + end end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/chef/cap/windows/chef_installed_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/chef/cap/windows/chef_installed_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/chef/cap/windows/chef_installed_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/chef/cap/windows/chef_installed_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -23,19 +23,38 @@ end describe "#chef_installed" do - let(:version) { "15.0.0" } - let(:command) { "if ((&knife --version) -Match \"15.0.0\"){ exit 0 } else { exit 1 }" } + describe "when chef-workstation" do + let(:version) { "15.0.0" } + let(:command) { "if ((&chef --version) -Match \"15.0.0\"){ exit 0 } else { exit 1 }" } - it "returns true if installed" do - expect(machine.communicate).to receive(:test). - with(command, sudo: true).and_return(true) - subject.chef_installed(machine, "chef_solo", version) + it "returns true if installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(true) + subject.chef_installed(machine, "chef-workstation", version) + end + + it "returns false if not installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(false) + expect(subject.chef_installed(machine, "chef-workstation", version)).to be_falsey + end end - it "returns false if not installed" do - expect(machine.communicate).to receive(:test). - with(command, sudo: true).and_return(false) - expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey + describe "when chef-workstation" do + let(:version) { "15.0.0" } + let(:command) { "if ((&chef-client --version) -Match \"15.0.0\"){ exit 0 } else { exit 1 }" } + + it "returns true if installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(true) + subject.chef_installed(machine, "chef_solo", version) + end + + it "returns false if not installed" do + expect(machine.communicate).to receive(:test). + with(command, sudo: true).and_return(false) + expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey + end end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/container/client_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/container/client_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/container/client_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/container/client_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -3,9 +3,11 @@ require Vagrant.source_root.join("plugins/provisioners/container/client") describe VagrantPlugins::ContainerProvisioner::Client do - - let(:machine) { double("machine") } - let(:container_command) { double("docker") } + + let(:machine) { double("machine", communicate: communicator, ui: ui) } + let(:ui) { Vagrant::UI::Silent.new } + let(:communicator) { double("communicator") } + let(:container_command) { "CONTAINER_COMMAND" } subject { described_class.new(machine, container_command) } describe "#container_name" do @@ -14,4 +16,40 @@ expect(subject.container_name(config)).to eq("test-test-1.1.1") end end + + describe "#build_images" do + before { allow(communicator).to receive(:sudo) } + + it "should use sudo to run command" do + expect(communicator).to receive(:sudo).with(/#{Regexp.escape(container_command)}/) + subject.build_images([["path", {}]]) + end + + it "should output information to use" do + expect(ui).to receive(:info).and_call_original + subject.build_images([["path", {}]]) + end + + it "should handle communicator output" do + expect(communicator).to receive(:sudo).with(/#{Regexp.escape(container_command)}/). + and_yield(:stdout, "some output") + subject.build_images([["path", {}]]) + end + end + + describe "#pull_images" do + before do + allow(communicator).to receive(:sudo) + end + + it "should use sudo to run command" do + expect(communicator).to receive(:sudo).with(/#{Regexp.escape(container_command)}/) + subject.pull_images(:image) + end + + it "should output information to use" do + expect(ui).to receive(:info).and_call_original + subject.pull_images(:image) + end + end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/puppet/provisioner/puppet_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/puppet/provisioner/puppet_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/puppet/provisioner/puppet_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/puppet/provisioner/puppet_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -81,7 +81,7 @@ let(:environment_paths) { ["/etc/puppet/environment"] } it "builds structured facts if set" do - allow(machine).to receive(:guest).and_return(true) + allow(machine).to receive(:guest).and_return(double("guest")) allow(machine.guest).to receive(:capability?).and_return(false) allow(config).to receive(:environment_path).and_return(environment_paths) allow(config).to receive(:environment).and_return("production") @@ -105,7 +105,7 @@ end it "does not build structured facts if not set" do - allow(machine).to receive(:guest).and_return(true) + allow(machine).to receive(:guest).and_return(double("guest")) allow(machine.guest).to receive(:capability?).and_return(false) allow(config).to receive(:environment_path).and_return(environment_paths) allow(config).to receive(:environment).and_return("production") diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/shell/provisioner_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/shell/provisioner_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/provisioners/shell/provisioner_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/provisioners/shell/provisioner_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -438,7 +438,8 @@ :powershell_args => "", :name => nil, :privileged => false, - :powershell_elevated_interactive => false + :powershell_elevated_interactive => false, + :keep_color => true, ) } @@ -448,17 +449,34 @@ let(:communicator) { double("communicator") } let(:guest) { double("guest") } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } before { allow(guest).to receive(:capability?).with(:wait_for_reboot).and_return(false) - allow(ui).to receive(:detail) allow(communicator).to receive(:sudo) allow(machine).to receive(:communicate).and_return(communicator) allow(machine).to receive(:guest).and_return(guest) allow(machine).to receive(:ui).and_return(ui) + allow(vsp).to receive(:with_script_file).and_yield(config.path) + allow(communicator).to receive(:upload).with(config.path, /arbitrary.ps1$/) } + it "should output all received output" do + stdout = ["two lines\n", "from stdout\n"] + stderr = ["one line\n", "and partial from stderr"] + expect(communicator).to receive(:sudo). + and_yield(:stdout, stdout.first). + and_yield(:stderr, stderr.first). + and_yield(:stderr, stderr.last). + and_yield(:stdout, stdout.last) + allow(ui).to receive(:detail) + expect(ui).to receive(:detail).with("two lines", any_args) + expect(ui).to receive(:detail).with("from stdout", any_args) + expect(ui).to receive(:detail).with("one line", any_args) + expect(ui).to receive(:detail).with("and partial from stderr", any_args) + vsp.send(:provision_winrm, "") + end + it "ensures that files are uploaded with an extension" do allow(vsp).to receive(:with_script_file).and_yield(config.path) expect(communicator).to receive(:upload).with(config.path, /arbitrary.ps1$/) @@ -502,7 +520,7 @@ :powershell_elevated_interactive => false ) } - + it "creates an executable with an extension" do allow(machine).to receive_message_chain(:config, :winssh, :shell).and_return(nil) allow(vsp).to receive(:with_script_file).and_yield(default_win_path) @@ -534,7 +552,8 @@ :powershell_args => "", :name => nil, :privileged => false, - :powershell_elevated_interactive => false + :powershell_elevated_interactive => false, + :keep_color => true, ) } @@ -544,12 +563,12 @@ let(:communicator) { double("communicator") } let(:guest) { double("guest") } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } before { allow(guest).to receive(:capability?).with(:wait_for_reboot).and_return(false) - allow(ui).to receive(:detail) allow(communicator).to receive(:sudo) + allow(communicator).to receive(:upload) allow(communicator).to receive_message_chain(:machine_config_ssh, :shell) allow(machine).to receive(:communicate).and_return(communicator) allow(machine).to receive(:guest).and_return(guest) @@ -562,13 +581,29 @@ allow(config).to receive(:path).and_return("script/info.ps1") allow(vsp).to receive(:with_script_file).and_yield(config.path) end - + it "ensures that files are uploaded same extension as provided path.ps1" do allow(machine).to receive_message_chain(:config, :winssh, :shell).and_return("cmd") expect(communicator).to receive(:upload).with(config.path, /arbitrary.ps1/) expect(communicator).to receive(:execute).with(/powershell.*arbitrary.ps1/, anything) vsp.send(:provision_winssh, "") end + + it "should output all received output" do + stdout = ["two lines\n", "from stdout\n"] + stderr = ["one line\n", "and partial from stderr"] + expect(communicator).to receive(:execute). + and_yield(:stdout, stdout.first). + and_yield(:stderr, stderr.first). + and_yield(:stderr, stderr.last). + and_yield(:stdout, stdout.last) + allow(ui).to receive(:detail) + expect(ui).to receive(:detail).with("two lines", any_args) + expect(ui).to receive(:detail).with("from stdout", any_args) + expect(ui).to receive(:detail).with("one line", any_args) + expect(ui).to receive(:detail).with("and partial from stderr", any_args) + vsp.send(:provision_winssh, "") + end end context "bat file being uploaded" do @@ -645,4 +680,90 @@ end end end + + describe "#handle_comm" do + let(:ui) { Vagrant::UI::Silent.new } + let(:keep_color) { false } + let(:config) { + double( + :config, + :keep_color => keep_color, + ) + } + let(:env){ isolated_environment } + let(:machine) { double(:machine, env: env, id: "ID") } + let(:vsp) { + VagrantPlugins::Shell::Provisioner.new(machine, config) + } + + before do + allow(machine).to receive(:ui).and_return(ui) + end + + context "when type is stdout" do + let(:type) { :stdout } + let(:data) { "output data" } + + it "should output data through the ui" do + expect(ui).to receive(:detail).and_call_original + vsp.send(:handle_comm, type, data) + end + + it "should color the output" do + expect(ui).to receive(:detail).with(data, hash_including(color: :green)). + and_call_original + vsp.send(:handle_comm, type, data) + end + + context "when configured to keep color" do + let(:keep_color) { true } + + it "should not color the output" do + expect(ui).to receive(:detail) do |msg, **opts| + expect(msg).to eq(data) + expect(opts).to be_empty + end + vsp.send(:handle_comm, type, data) + end + end + end + + context "when type is stderr" do + let(:type) { :stderr } + let(:data) { "output data" } + + it "should output data through the ui" do + expect(ui).to receive(:detail).and_call_original + vsp.send(:handle_comm, type, data) + end + + it "should color the output" do + expect(ui).to receive(:detail).with(data, hash_including(color: :red)). + and_call_original + vsp.send(:handle_comm, type, data) + end + + context "when configured to keep color" do + let(:keep_color) { true } + + it "should not color the output" do + expect(ui).to receive(:detail) do |msg, **opts| + expect(msg).to eq(data) + expect(opts).to be_empty + end + vsp.send(:handle_comm, type, data) + end + end + end + + context "when type is not stdout or stderr" do + let(:type) { :stdnull } + let(:data) { "output data" } + + it "should not output data through the ui" do + expect(ui).not_to receive(:detail) + vsp.send(:handle_comm, type, data) + end + end + end end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/pushes/ftp/push_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/pushes/ftp/push_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/pushes/ftp/push_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/pushes/ftp/push_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -17,11 +17,7 @@ destination: "/var/www/site", ) end - let(:ui) do - double("ui", - info: nil, - ) - end + let(:ui) { Vagrant::UI::Silent.new } subject { described_class.new(env, config) } diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/synced_folders/rsync/command/rsync_auto_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/synced_folders/rsync/command/rsync_auto_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/synced_folders/rsync/command/rsync_auto_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/synced_folders/rsync/command/rsync_auto_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -42,9 +42,6 @@ allow(m).to receive(:state).and_return(double("state", id: :not_created)) allow(m).to receive(:env).and_return(iso_env) allow(m).to receive(:config).and_return(double("config")) - - - allow(m.ui).to receive(:error).and_return(nil) end end @@ -76,12 +73,11 @@ before do allow(subject).to receive(:with_target_vms) { |&block| block.call machine } - allow(machine.ui).to receive(:info) allow(machine.state).to receive(:id).and_return(:created) allow(machine.env).to receive(:cwd). and_return("/Users/brian/code/vagrant-sandbox") allow(machine.provider).to receive(:capability?).and_return(false) - allow(machine.config).to receive(:vm).and_return(true) + allow(machine.config).to receive(:vm).and_return(double("vm")) allow(machine.config.vm).to receive(:synced_folders).and_return(config_synced_folders) allow(subject).to receive(:synced_folders). @@ -92,12 +88,16 @@ end it "does not sync folders outside of the cwd" do + allow(machine.ui).to receive(:info).and_call_original expect(machine.ui).to receive(:info). - with("Not syncing /Not/The/Same/Path as it is not part of the current working directory.") + with("Not syncing /Not/The/Same/Path as it is not part of the current working directory."). + and_call_original expect(machine.ui).to receive(:info). - with("Watching: /Users/brian/code/vagrant-sandbox") + with("Watching: /Users/brian/code/vagrant-sandbox"). + and_call_original expect(machine.ui).to receive(:info). - with("Watching: /Users/brian/code/relative-dir") + with("Watching: /Users/brian/code/relative-dir"). + and_call_original expect(helper_class).to receive(:rsync_single) expect(Listen).to receive(:to). @@ -237,7 +237,6 @@ before do allow_any_instance_of(Vagrant::Errors::VagrantError). to receive(:translate_error) - allow(machine.ui).to receive(:error) end context "when rsync command fails" do @@ -247,7 +246,7 @@ end it "should notify on error" do - expect(machine.ui).to receive(:error) + expect(machine.ui).to receive(:error).and_call_original subject.callback(*args) end @@ -263,7 +262,7 @@ end it "should notify on error" do - expect(machine.ui).to receive(:error) + expect(machine.ui).to receive(:error).and_call_original subject.callback(*args) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/synced_folders/smb/caps/mount_options_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/synced_folders/smb/caps/mount_options_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/synced_folders/smb/caps/mount_options_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/synced_folders/smb/caps/mount_options_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -44,7 +44,7 @@ it "generates the expected default mount command" do out_opts, out_uid, out_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_opts).to eq("sec=ntlmssp,credentials=/etc/smb_creds_vagrant,uid=1000,gid=1000,_netdev") + expect(out_opts).to eq("sec=ntlmssp,credentials=/etc/smb_creds_vagrant,uid=1000,gid=1000,_netdev,nofail") expect(out_uid).to eq(mount_uid) expect(out_gid).to eq(mount_gid) end @@ -52,7 +52,7 @@ it "includes provided mount options" do folder_options[:mount_options] =["ro"] out_opts, out_uid, out_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_opts).to eq("sec=ntlmssp,credentials=/etc/smb_creds_vagrant,uid=1000,gid=1000,_netdev,ro") + expect(out_opts).to eq("sec=ntlmssp,credentials=/etc/smb_creds_vagrant,uid=1000,gid=1000,_netdev,ro,nofail") expect(out_uid).to eq(mount_uid) expect(out_gid).to eq(mount_gid) end @@ -60,7 +60,7 @@ it "overwrites default mount options" do folder_options[:mount_options] =["ro", "sec=custom"] out_opts, out_uid, out_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_opts).to eq("sec=custom,credentials=/etc/smb_creds_vagrant,uid=1000,gid=1000,_netdev,ro") + expect(out_opts).to eq("sec=custom,credentials=/etc/smb_creds_vagrant,uid=1000,gid=1000,_netdev,ro,nofail") expect(out_uid).to eq(mount_uid) expect(out_gid).to eq(mount_gid) end @@ -68,7 +68,7 @@ it "does not add mfsymlinks option if env var VAGRANT_DISABLE_SMBMFSYMLINKS exists" do expect(ENV).to receive(:[]).with("VAGRANT_DISABLE_SMBMFSYMLINKS").and_return(false) out_opts, out_uid, out_gid = cap.mount_options(machine, mount_name, mount_guest_path, folder_options) - expect(out_opts).to eq("sec=ntlmssp,credentials=/etc/smb_creds_vagrant,uid=1000,gid=1000,mfsymlinks,_netdev") + expect(out_opts).to eq("sec=ntlmssp,credentials=/etc/smb_creds_vagrant,uid=1000,gid=1000,mfsymlinks,_netdev,nofail") expect(out_uid).to eq(mount_uid) expect(out_gid).to eq(mount_gid) end diff -Nru vagrant-2.2.14+dfsg/test/unit/plugins/synced_folders/unix_mount_helpers_test.rb vagrant-2.2.19+dfsg/test/unit/plugins/synced_folders/unix_mount_helpers_test.rb --- vagrant-2.2.14+dfsg/test/unit/plugins/synced_folders/unix_mount_helpers_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/plugins/synced_folders/unix_mount_helpers_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -5,11 +5,11 @@ describe VagrantPlugins::SyncedFolder::UnixMountHelpers do include_context "unit" - subject{ - Class.new do - @@logger = nil - extend VagrantPlugins::SyncedFolder::UnixMountHelpers - end + subject{ + Class.new do |c| + def self.name; "UnixMountHelpersTest"; end + extend VagrantPlugins::SyncedFolder::UnixMountHelpers + end } diff -Nru vagrant-2.2.14+dfsg/test/unit/templates/guests/nixos/network_test.rb vagrant-2.2.19+dfsg/test/unit/templates/guests/nixos/network_test.rb --- vagrant-2.2.14+dfsg/test/unit/templates/guests/nixos/network_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/templates/guests/nixos/network_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,27 @@ +require_relative "../../../base" + +require "vagrant/util/template_renderer" + +describe "templates/guests/nixos/network" do + let(:template) { "guests/nixos/network" } + + it "renders the template" do + result = Vagrant::Util::TemplateRenderer.render(template, networks: [{ + device: "en0", + ip: "1.1.1.1", + prefix_length: "24", + type: :static, + }]) + expect(result).to eq <<-EOH.gsub(/^ {6}/, "") + { config, pkgs, ... }: + { + networking.interfaces = { + en0.ipv4.addresses = [{ + address = "1.1.1.1"; + prefixLength = 24; + }]; + }; + } + EOH + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/box_add_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/box_add_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/box_add_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/box_add_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -209,6 +209,25 @@ to raise_error(Vagrant::Errors::BoxChecksumMismatch) end + it "strips space if checksum specified ends or begins with blank space" do + box_path = iso_env.box2_file(:virtualbox) + + box = double( + name: "foo", + version: "1.2.3", + provider: "virtualbox", + ) + + env[:box_name] = "foo" + env[:box_url] = box_path.to_s + env[:box_checksum] = " #{checksum(box_path)} " + env[:box_checksum_type] = "sha1" + + expect(box_collection).to receive(:add).and_return(box) + + expect { subject.call(env) }.to_not raise_error + end + it "ignores checksums if empty string" do box_path = iso_env.box2_file(:virtualbox) with_web_server(box_path) do |port| @@ -320,7 +339,7 @@ expect(app).to receive(:call).with(env) - expect(env[:ui]).to receive(:warn) + expect(env[:ui]).to receive(:warn).and_call_original .with(/It looks like you attempted to add a box with a URL for the name/) subject.call(env) @@ -364,8 +383,9 @@ true }.and_return(box) - allow(env[:ui]).to receive(:detail) - expect(env[:ui]).to receive(:detail).with(%r{.*http://(?!#{username}).+?:(?!#{password}).+?@127\.0\.0\.1:#{port}/#{box_path.basename}.*}) + allow(env[:ui]).to receive(:detail).and_call_original + expect(env[:ui]).to receive(:detail).with(%r{.*http://(?!#{username}).+?:(?!#{password}).+?@127\.0\.0\.1:#{port}/#{box_path.basename}.*}). + and_call_original expect(app).to receive(:call).with(env) subject.call(env) @@ -622,6 +642,41 @@ end end + it "authenticates HTTP URLs and adds them directly" do + box_path = iso_env.box2_file(:virtualbox) + tf = Tempfile.new(["vagrant-test-http", ".box"]).tap do |f| + f.write() + f.close + end + + md_path = Pathname.new(tf.path) + with_web_server(md_path) do |port| + real_url = "http://127.0.0.1:#{port}/#{md_path.basename}" + + # Set the box URL to something fake so we can modify it in place + env[:box_url] = "foo" + env[:hook] = double("hook") + env[:box_name] = "foo/bar" + env[:box_provider] = "virtualbox" + env[:box_checksum] = checksum(box_path) + + expect(env[:hook]).to receive(:call).with(:authenticate_box_downloader, any_args).at_least(:once) + + allow(env[:hook]).to receive(:call).with(:authenticate_box_url, any_args).at_least(:once) do |name, opts| + if opts[:box_urls] == ["foo"] + next { box_urls: [real_url] } + else + raise "UNKNOWN: #{opts[:box_urls].inspect}" + end + end + + expect(subject).to receive(:add_direct).with([real_url], anything) + expect(app).to receive(:call).with(env) + + subject.call(env) + end + end + it "adds from HTTP URL with a checksum" do box_path = iso_env.box2_file(:virtualbox) tf = Tempfile.new(["vagrant-test-http-checksum", ".json"]).tap do |f| @@ -735,6 +790,20 @@ end end + it "raises an error if downloading metadata fails" do + path = Dir::Tmpname.create("vagrant-shorthand-invalid") {} + + with_web_server(Pathname.new(path)) do |port| + env[:box_url] = "http://127.0.0.1:#{port}/bad" + + expect(box_collection).to receive(:add).never + expect(app).to receive(:call).never + + expect { subject.call(env) }. + to raise_error(Vagrant::Errors::BoxMetadataDownloadError) + end + end + it "raises an error if multiple metadata URLs are given" do box_path = iso_env.box2_file(:virtualbox) tf = Tempfile.new(["vagrant-box-multi-metadata", ".json"]).tap do |f| diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/box_check_outdated_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/box_check_outdated_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/box_check_outdated_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/box_check_outdated_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -129,7 +129,7 @@ expect(box).to receive(:has_update?).with(machine.config.vm.box_version, {download_options: - {automatic_check: true, ca_cert: nil, ca_path: nil, client_cert: nil, insecure: false}}). + {automatic_check: true, ca_cert: nil, ca_path: nil, client_cert: nil, insecure: false, box_extra_download_options: []}}). and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")]) expect(app).to receive(:call).with(env).once @@ -172,10 +172,13 @@ } RAW - expect(box).to receive(:has_update?).with(machine.config.vm.box_version, - {download_options: - {automatic_check: true, ca_cert: nil, ca_path: nil, client_cert: nil, insecure: false}}). - and_return([md, md.version("1.2"), md.version("1.2").provider("virtualbox")]) + expect(box).to receive(:has_update?).with( + machine.config.vm.box_version, + { download_options: { automatic_check: true, ca_cert: nil, ca_path: nil, + client_cert: nil, insecure: false, box_extra_download_options: [] + }}).and_return( + [md, md.version("1.2"), md.version("1.2").provider("virtualbox")] + ) allow(I18n).to receive(:t) { :ok } expect(I18n).to receive(:t).with(/box_outdated_single/, hash_including(latest: "1.2")).once @@ -245,12 +248,15 @@ machine.config.vm.box_download_ca_path = "bar" machine.config.vm.box_download_client_cert = "baz" machine.config.vm.box_download_insecure = true + machine.config.vm.box_download_options = {"opt": "val"} + machine.config.vm.finalize! end it "uses download options from machine" do expect(box).to receive(:has_update?).with(machine.config.vm.box_version, - {download_options: - {automatic_check: true, ca_cert: "foo", ca_path: "bar", client_cert: "baz", insecure: true}}) + { download_options: { + automatic_check: true, ca_cert: "foo", ca_path: "bar", client_cert: "baz", + insecure: true, box_extra_download_options: ["--opt", "val"]}}) expect(app).to receive(:call).with(env).once @@ -258,14 +264,17 @@ end it "overrides download options from machine with options from env" do - expect(box).to receive(:has_update?).with(machine.config.vm.box_version, - {download_options: - {automatic_check: true, ca_cert: "oof", ca_path: "rab", client_cert: "zab", insecure: false}}) + expect(box).to receive(:has_update?).with( + machine.config.vm.box_version, + { download_options: {automatic_check: true, ca_cert: "oof", ca_path: "rab", client_cert: "zab", + insecure: false, box_extra_download_options: ["--tpo"], + }}) env[:ca_cert] = "oof" env[:ca_path] = "rab" env[:client_cert] = "zab" env[:insecure] = false + env[:box_extra_download_options] = ["--tpo"] expect(app).to receive(:call).with(env).once subject.call(env) diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/cleanup_disks_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/cleanup_disks_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/cleanup_disks_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/cleanup_disks_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -11,7 +11,7 @@ let(:disks) { [double("disk")] } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:disk_meta_file) { {disk: [{uuid: "123456789", name: "storage"}], floppy: [], dvd: []} } diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/cloud_init_setup_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/cloud_init_setup_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/cloud_init_setup_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/cloud_init_setup_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -15,7 +15,7 @@ let(:machine_env) { double("machine_env", root_path: "root", host: host) } let(:env) { { ui: ui, machine: machine, env: machine_env} } - let(:ui) { double("ui", info: true, warn: true) } + let(:ui) { Vagrant::UI::Silent.new } let(:cfg) { double("cfg", type: :user_data, content_type: "text/cloud-config", content_disposition_filename: nil, path: "my/path", diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/cloud_init_wait_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/cloud_init_wait_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/cloud_init_wait_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/cloud_init_wait_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -1,30 +1,26 @@ require File.expand_path("../../../../base", __FILE__) describe Vagrant::Action::Builtin::CloudInitWait do - + let(:app) { lambda { |env| } } let(:config) { double("config", :vm => vm) } let(:comm) { double("comm") } let(:machine) { double("machie", :config => config, :communicate => comm, :name => "test") } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:env) { { machine: machine, ui: ui} } let(:subject) { described_class.new(app, env) } describe "#call" do - before do - allow(ui).to receive(:output) - end - context "cloud init configuration exists" do - + let(:vm) { double("vm", cloud_init_configs: ["some config"]) } before do allow(comm).to receive(:test).with("command -v cloud-init").and_return(true) end - + it "waits for cloud init to be executed" do expect(comm).to receive(:sudo).with("cloud-init status --wait", any_args).and_return(0) subject.call(env) @@ -44,7 +40,7 @@ end context "no cloud init configuration" do - + let(:vm) { double("vm", cloud_init_configs: []) } before do diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/confirm_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/confirm_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/confirm_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/confirm_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -2,7 +2,7 @@ describe Vagrant::Action::Builtin::Confirm do let(:app) { lambda { |env| } } - let(:env) { { ui: double("ui") } } + let(:env) { { ui: Vagrant::UI::Silent.new } } let(:message) { "foo" } ["y", "Y"].each do |valid| diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/disk_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/disk_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/disk_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/disk_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -11,7 +11,7 @@ let(:disks) { [double("disk")] } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:disk_data) { {disk: [{uuid: "123456789", name: "storage"}], floppy: [], dvd: []} } diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/graceful_halt_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/graceful_halt_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/graceful_halt_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/graceful_halt_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -2,7 +2,7 @@ describe Vagrant::Action::Builtin::GracefulHalt do let(:app) { lambda { |env| } } - let(:env) { { machine: machine, ui: ui } } + let(:env) { { machine: machine, ui: Vagrant::UI::Silent.new } } let(:machine) do result = double("machine") allow(result).to receive(:config).and_return(machine_config) diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -48,11 +48,7 @@ end end - let(:ui) do - double("ui").tap do |result| - allow(result).to receive(:info) - end - end + let(:ui){ Vagrant::UI::Silent.new } let(:instance){ described_class.new(app, env) } diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/has_provisioner_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/has_provisioner_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/has_provisioner_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/has_provisioner_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -8,14 +8,14 @@ let(:provisioner_two) { double("provisioner_two") } let(:provisioners) { [provisioner_one, provisioner_two] } let(:machine) { double("machine") } - let(:ui) {double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:env) {{ machine: machine, ui: ui, root_path: Pathname.new(".") }} let(:app) { lambda { |*args| }} subject { described_class.new(app, env) } describe "#call" do - before do + before do allow(provisioner_one).to receive(:communicator_required).and_return(true) allow(provisioner_one).to receive(:name) allow(provisioner_one).to receive(:type) @@ -25,16 +25,16 @@ allow(machine).to receive_message_chain(:config, :vm, :provisioners).and_return(provisioners) end - context "provider has capability :has_communicator" do + context "provider has capability :has_communicator" do before do allow(machine).to receive_message_chain(:provider, :capability?).with(:has_communicator).and_return(true) end - + it "does not skip any provisioners if provider has ssh" do allow(machine).to receive_message_chain(:provider, :capability).with(:has_communicator).and_return(true) expect(provisioner_one).to_not receive(:communicator_required) expect(provisioner_two).to_not receive(:communicator_required) - + subject.call(env) expect(env[:skip]).to eq([]) end @@ -44,13 +44,13 @@ expect(provisioner_one).to receive(:communicator_required) expect(provisioner_two).to receive(:communicator_required) expect(provisioner_one).to receive(:run=).with(:never) - + subject.call(env) expect(env[:skip]).to eq([provisioner_one]) end end - context "provider does not have capability :has_communicator" do + context "provider does not have capability :has_communicator" do before do allow(machine).to receive_message_chain(:provider, :capability?).with(:has_communicator).and_return(false) end diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/message_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/message_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/message_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/message_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -7,7 +7,7 @@ let(:app) { lambda { |env| } } let(:env) { { ui: ui } } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } describe "#call" do it "outputs the given message" do diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/mixin_provisioners_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/mixin_provisioners_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/mixin_provisioners_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/mixin_provisioners_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -33,7 +33,7 @@ let(:provisioner_instances) { [provisioner_one,provisioner_two,provisioner_three] } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:vm) { double("vm", provisioners: provisioner_instances) } let(:config) { double("config", vm: vm) } let(:machine) { double("machine", ui: ui, config: config) } diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/provisioner_cleanup_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/provisioner_cleanup_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/provisioner_cleanup_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/provisioner_cleanup_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -20,12 +20,7 @@ end let(:vm_config) { double("machine_vm_config") } - - let(:ui) do - double("ui").tap do |result| - allow(result).to receive(:info) - end - end + let(:ui) { Vagrant::UI::Silent.new } let(:provisioner) do Class.new(Vagrant.plugin("2", :provisioner)) diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/provision_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/provision_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/provision_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/provision_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -41,11 +41,7 @@ end end - let(:ui) do - double("ui").tap do |result| - allow(result).to receive(:info) - end - end + let(:ui) { Vagrant::UI::Silent.new } let(:instance){ described_class.new(app, env) } diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/set_hostname_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/set_hostname_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/set_hostname_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/set_hostname_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -4,14 +4,13 @@ let(:env) { { machine: machine, ui: ui } } let(:app) { lambda { |env| } } let(:machine) { double("machine") } - let(:ui) { double("ui") } - + let(:ui) { Vagrant::UI::Silent.new } + subject { described_class.new(app, env) } - before do + before do allow(machine).to receive_message_chain(:config, :vm, :hostname).and_return("whatever") allow(machine).to receive_message_chain(:guest, :capability) - allow(ui).to receive(:info) end it "should change hostname if hosts modification enabled" do diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/synced_folder_cleanup_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/synced_folder_cleanup_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/synced_folder_cleanup_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/synced_folder_cleanup_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -22,11 +22,7 @@ let(:vm_config) { double("machine_vm_config") } - let(:ui) do - double("ui").tap do |result| - allow(result).to receive(:info) - end - end + let(:ui) { Vagrant::UI::Silent.new } subject { described_class.new(app, env) } diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/synced_folders_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/synced_folders_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/builtin/synced_folders_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/builtin/synced_folders_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -25,11 +25,7 @@ let(:vm_config) { double("machine_vm_config") } - let(:ui) do - double("ui").tap do |result| - allow(result).to receive(:info) - end - end + let(:ui) { Vagrant::UI::Silent.new } subject { described_class.new(app, env) } diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/action/general/package_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/action/general/package_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/action/general/package_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/action/general/package_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -9,7 +9,7 @@ } let(:environment) { double("environment") } let(:machine) { double("machine") } - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:subject) { described_class.new(app, env) } @@ -87,7 +87,6 @@ let(:path) { double("path") } before do - allow(ui).to receive(:info) allow(FileUtils).to receive(:mkdir_p) subject.instance_variable_set(:@env, env) end @@ -158,8 +157,6 @@ env["package.files"] = package_files env["package.directory"] = package_directory subject.instance_variable_set(:@env, env) - - allow(ui).to receive(:info) end after do @@ -178,11 +175,39 @@ end it "should notify user of copy" do - expect(ui).to receive(:info) + expect(ui).to receive(:info).at_least(1).and_call_original subject.copy_include_files end end + describe "#copy_info" do + let(:package_directory) { @package_directory } + let(:package_info) { File.join(@package_info_directory, "info.json") } + + before do + @package_directory = Dir.mktmpdir + @package_info_directory = Dir.mktmpdir + FileUtils.touch(File.join(@package_info_directory, "info.json")) + env["package.info"] = package_info + env["package.directory"] = package_directory + subject.instance_variable_set(:@env, env) + + allow(ui).to receive(:info) + end + + after do + FileUtils.rm_rf(@package_directory) + FileUtils.rm_rf(@package_info_directory) + end + + it "should copy the specified info.json to package directory" do + subject.copy_info + expected_info = File.join(package_directory, "info.json") + + expect(File.file? expected_info).to be_truthy + end + end + describe "#compress" do let(:package_directory) { @package_directory } let(:fullpath) { "PATH" } @@ -333,8 +358,6 @@ let(:fullpath) { "FULLPATH" } before do - allow(ui).to receive(:info) - allow(described_class).to receive(:validate!) allow(subject).to receive(:fullpath).and_return(fullpath) allow(subject).to receive(:package_with_folder_path) @@ -362,7 +385,7 @@ end it "should notify of package compressing" do - expect(ui).to receive(:info) + expect(ui).to receive(:info).and_call_original subject.call(env) end diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/box_collection_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/box_collection_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/box_collection_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/box_collection_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -16,7 +16,7 @@ end describe "#all" do - let(:ui) { double("ui", warn: true) } + let(:ui) { Vagrant::UI::Silent.new } it "should return an empty array when no boxes are there" do expect(subject.all).to eq([]) @@ -49,7 +49,7 @@ environment.box3("foo-VAGRANTSLASH-bar", "1.0", :virtualbox) environment.box3("foo-VAGRANTCOLON-colon", "1.0", :virtualbox) - expect(ui).to receive(:warn).once + expect(ui).to receive(:warn).once.and_call_original # Verify some output results = subject.all diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/bundler_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/bundler_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/bundler_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/bundler_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -778,42 +778,46 @@ end end - context "when run time dependencies are defined" do - let(:vagrant_dep_specs) { [double("spec", name: "vagrant-dep", requirement: double("spec-req", as_list: []))] } - - it "should call #gem to activate the dependencies" do - expect(subject).to receive(:gem).with("vagrant-dep", any_args) - subject.send(:vagrant_internal_specs) - end - end - context "when bundler is not defined" do - before { expect(Object).to receive(:const_defined?).with(:Bundler).and_return(false) } + before { expect(Vagrant).to receive(:in_bundler?).and_return(false) } - it "should load gem specification directories" do - expect(Gem::Specification).to receive(:dirs).and_return(spec_dirs) - subject.send(:vagrant_internal_specs) - end - - context "when checking paths" do - let(:spec_dirs) { [double("spec-dir", start_with?: in_user_dir)] } - let(:in_user_dir) { true } - let(:user_dir) { double("user-dir") } + context "when running inside the installer" do + before { expect(Vagrant).to receive(:in_installer?).and_return(true) } - before { allow(Gem).to receive(:user_dir).and_return(user_dir) } - - it "should check if path is within local user directory" do - expect(spec_dirs.first).to receive(:start_with?).with(user_dir).and_return(false) + it "should load gem specification directories" do + expect(Gem::Specification).to receive(:dirs).and_return(spec_dirs) subject.send(:vagrant_internal_specs) end - context "when path is not within user directory" do - let(:in_user_dir) { false } + context "when checking paths" do + let(:spec_dirs) { [double("spec-dir", start_with?: in_user_dir)] } + let(:in_user_dir) { true } + let(:user_dir) { double("user-dir") } + + before { allow(Gem).to receive(:user_dir).and_return(user_dir) } - it "should use path when loading specs" do - expect(Gem::Specification).to receive(:each_spec) { |arg| expect(arg).to include(spec_dirs.first) } + it "should check if path is within local user directory" do + expect(spec_dirs.first).to receive(:start_with?).with(user_dir).and_return(false) subject.send(:vagrant_internal_specs) end + + context "when path is not within user directory" do + let(:in_user_dir) { false } + + it "should use path when loading specs" do + expect(Gem::Specification).to receive(:each_spec) { |arg| expect(arg).to include(spec_dirs.first) } + subject.send(:vagrant_internal_specs) + end + end + end + end + + context "when running outside the installer" do + before { expect(Vagrant).to receive(:in_installer?).and_return(false) } + + it "should not load gem specification directories" do + expect(Gem::Specification).not_to receive(:dirs) + subject.send(:vagrant_internal_specs) end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/machine_index_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/machine_index_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/machine_index_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/machine_index_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -108,6 +108,11 @@ expect(subject.get(nil)).to be_nil end + it "returns nil if the machine doesn't exist (is an empty string)" do + expect(subject.get("")).to be_nil + expect(subject.get(nil)).to be_nil + end + it "returns a valid entry if the machine exists" do result = subject.get("bar") @@ -144,7 +149,6 @@ expect(subject.include?(nil)).to be(false) end - it "locks the entry so subsequent gets fail" do result = subject.get("bar") expect(result).to_not be_nil diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/machine_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/machine_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/machine_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/machine_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -335,7 +335,6 @@ initial_action_name = :destroy second_action_name = :reload callable = lambda { |_env| } - original_cwd = env.cwd.to_s allow(provider).to receive(:action).with(initial_action_name).and_return(callable) allow(provider).to receive(:action).with(second_action_name).and_return(callable) diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/plugin/v2/trigger_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/plugin/v2/trigger_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/plugin/v2/trigger_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/plugin/v2/trigger_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -224,13 +224,9 @@ let(:message) { "Printing some info" } it "prints messages at INFO" do - output = "" - allow(ui).to receive(:info) do |data| - output << data - end + expect(ui).to receive(:info).with(message).and_call_original subject.send(:info, message) - expect(output).to include(message) end end @@ -238,13 +234,9 @@ let(:message) { "Printing some warnings" } it "prints messages at WARN" do - output = "" - allow(ui).to receive(:warn) do |data| - output << data - end + expect(ui).to receive(:warn).with(message).and_call_original subject.send(:warn, message) - expect(output).to include(message) end end @@ -297,6 +289,7 @@ it "executes an inline script with powershell if windows" do allow(Vagrant::Util::Platform).to receive(:windows?).and_return(true) allow(Vagrant::Util::PowerShell).to receive(:execute_inline). + and_yield(:stderr, "some output"). and_return(subprocess_result) trigger = trigger_run.after_triggers.first @@ -309,9 +302,10 @@ subject.send(:run, shell_config, on_error, exit_codes) end - it "executes an path script with powershell if windows" do + it "executes a path script with powershell if windows" do allow(Vagrant::Util::Platform).to receive(:windows?).and_return(true) allow(Vagrant::Util::PowerShell).to receive(:execute). + and_yield(:stdout, "more output"). and_return(subprocess_result) allow(env).to receive(:root_path).and_return("/vagrant/home") @@ -339,7 +333,7 @@ subject.send(:run, shell_config, on_error, exit_codes) end - it "executes an path script" do + it "executes a path script" do allow(Vagrant::Util::Subprocess).to receive(:execute). and_return(subprocess_result) allow(env).to receive(:root_path).and_return("/vagrant/home") @@ -524,10 +518,6 @@ describe "#trigger_abort" do it "system exits when called" do allow(Process).to receive(:exit!).and_return(true) - output = "" - allow(machine.ui).to receive(:warn) do |data| - output << data - end expect(Process).to receive(:exit!).with(3) subject.send(:trigger_abort, 3) diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/util/downloader_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/util/downloader_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/util/downloader_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/util/downloader_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -30,18 +30,12 @@ } context "with UI" do - let(:ui) { double("ui") } + let(:ui) { Vagrant::UI::Silent.new } let(:options) { {ui: ui} } let(:source) { "http://example.org/vagrant.box" } let(:redirect) { nil } let(:progress_data) { "Location: #{redirect}" } - before do - allow(ui).to receive(:clear_line) - allow(ui).to receive(:detail) - allow(ui).to receive(:rewriting).and_yield(ui) - end - after do expect(subject).to receive(:execute_curl) do |*_, &data_proc| expect(data_proc).not_to be_nil @@ -62,7 +56,7 @@ let(:redirect) { "http://example.com/vagrant.box" } it "should output redirection information" do - expect(ui).to receive(:detail).with(/example.com/) + expect(ui).to receive(:detail).with(/example.com/).and_call_original end end @@ -70,7 +64,7 @@ let(:redirect) { "http://downloads.example.org/vagrant.box" } it "should output redirection information" do - expect(ui).to receive(:detail).with(/downloads.example.org/) + expect(ui).to receive(:detail).with(/downloads.example.org/).and_call_original end end @@ -87,7 +81,7 @@ let(:progress_data) { "X-Custom-Location: #{custom_redirect}\nLocation: #{redirect}" } it "should output redirection information" do - expect(ui).to receive(:detail).with(/downloads.example.com/) + expect(ui).to receive(:detail).with(/downloads.example.com/).and_call_original end end end diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/util/guest_hosts_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/util/guest_hosts_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/util/guest_hosts_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/util/guest_hosts_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -20,8 +20,8 @@ end it "can add hostname to loopback interface" do - subject.add_hostname_to_loopback_interface(comm, "test.end", 40) - expect(comm.received_commands[0]).to match(/for i in {1..40}; do/) + subject.add_hostname_to_loopback_interface(comm, "test.end", 4) + expect(comm.received_commands[0]).to match(/for i in 1 2 3 4; do/) expect(comm.received_commands[0]).to match(/echo \"127.0.\${i}.1 test.end test\" >> \/etc\/hosts/) end end @@ -35,8 +35,8 @@ end it "can add hostname to loopback interface" do - subject.add_hostname_to_loopback_interface(comm, "test.end", 40) - expect(comm.received_commands[0]).to match(/for i in {1..40}; do/) + subject.add_hostname_to_loopback_interface(comm, "test.end", 4) + expect(comm.received_commands[0]).to match(/for i in 1 2 3 4; do/) expect(comm.received_commands[0]).to match(/echo \"127.0.\${i}.1 test.end test\" >> \/etc\/hosts/) end end diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/util/line_buffer_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/util/line_buffer_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/util/line_buffer_test.rb 1970-01-01 00:00:00.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/util/line_buffer_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -0,0 +1,60 @@ +require File.expand_path("../../../base", __FILE__) +require "vagrant/util/line_buffer" + +describe Vagrant::Util::LineBuffer do + it "should raise error when no callback is provided" do + expect { subject }.to raise_error(ArgumentError) + end + + context "with block defined" do + let(:block) { proc{ |l| output << l } } + let(:output) { [] } + let(:partial) { "this is part of a line. " } + let(:line) { "this is a full line\n" } + + subject { described_class.new(&block) } + + it "should not raise an error when callback is provided" do + expect { subject }.not_to raise_error + end + + describe "#<<" do + it "should add line to the output" do + subject << line + expect(output).to eq([line.rstrip]) + end + + it "should not add partial line to output" do + subject << partial + expect(output).to be_empty + end + + it "should add partial line to output once full line is given" do + subject << partial + expect(output).to be_empty + subject << line + expect(output).to eq([partial + line.rstrip]) + end + + it "should add line once it has surpassed max line length" do + overflow = "a" * (described_class.const_get(:MAX_LINE_LENGTH) + 1) + subject << overflow + expect(output).to eq([overflow]) + end + end + + describe "#close" do + it "should output any partial data left in buffer" do + subject << partial + expect(output).to be_empty + subject.close + expect(output).to eq([partial]) + end + + it "should not be writable after closing" do + subject.close + expect { subject << partial }.to raise_error(FrozenError) + end + end + end +end diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/util/powershell_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/util/powershell_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/util/powershell_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/util/powershell_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -45,47 +45,50 @@ end describe ".executable" do - before{ allow(Vagrant::Util::Platform).to receive(:wsl?).and_return(false) } + before do + allow(Vagrant::Util::Which).to receive(:which).and_return(nil) + allow(Vagrant::Util::Subprocess).to receive(:execute) do |*args| + Vagrant::Util::Subprocess::Result.new(0, args.last.sub("echo ", ""), "") + end + end - context "when found in PATH" do - before{ expect(Vagrant::Util::Which).to receive(:which).with("powershell").and_return(true) } + context "when powershell found in PATH" do + before{ expect(Vagrant::Util::Which).to receive(:which). + with("powershell").and_return(true) } it "should return powershell string" do expect(described_class.executable).to eq("powershell") end end - context "when not found in PATH" do - before{ expect(Vagrant::Util::Which).to receive(:which).with("powershell").and_return(nil) } + context "when pwsh found in PATH" do + before { expect(Vagrant::Util::Which).to receive(:which). + with("pwsh").and_return(true) } + + it "should return pwsh string" do + expect(described_class.executable).to eq("pwsh") + end + end + context "when not found in PATH" do it "should return nil" do expect(described_class.executable).to be_nil end - context "when within WSL" do - before do - allow(Vagrant::Util::Which).to receive(:which).with(/powershell/).and_return(nil) - expect(Vagrant::Util::Platform).to receive(:wsl?).and_return(true) - end - - it "should check PATH with .exe extension" do - expect(Vagrant::Util::Which).to receive(:which).with("powershell.exe") - described_class.executable - end - - it "should return powershell.exe when found" do - expect(Vagrant::Util::Which).to receive(:which).with("powershell.exe").and_return(true) - expect(described_class.executable).to eq("powershell.exe") - end - - it "should return nil when not found" do - expect(described_class.executable).to be_nil - end - - it "should check for powershell with full path" do - expect(Vagrant::Util::Which).to receive(:which).with(/Windows\/System32.+powershell.exe/) - described_class.executable - end + it "should check PATH with .exe extension" do + expect(Vagrant::Util::Which).to receive(:which).with("powershell.exe") + described_class.executable + end + + it "should return powershell.exe when found" do + expect(Vagrant::Util::Which).to receive(:which). + with("powershell.exe").and_return(true) + expect(described_class.executable).to eq("powershell.exe") + end + + it "should check for powershell with full path" do + expect(Vagrant::Util::Which).to receive(:which).with(/WindowsPowerShell\/v1.0\/powershell.exe/) + described_class.executable end end end @@ -111,6 +114,8 @@ describe ".execute" do before do allow(described_class).to receive(:validate_install!) + allow(described_class).to receive(:executable) + .and_return("powershell") allow(Vagrant::Util::Subprocess).to receive(:execute) end @@ -156,6 +161,7 @@ before do allow(described_class).to receive(:validate_install!) allow(Vagrant::Util::Subprocess).to receive(:execute).and_return(result) + allow(described_class).to receive(:executable).and_return("powershell") end it "should validate installation before use" do @@ -220,6 +226,7 @@ before do allow(described_class).to receive(:validate_install!) allow(Vagrant::Util::Subprocess).to receive(:execute).and_return(result) + allow(described_class).to receive(:executable).and_return("powershell") end it "should validate installation before use" do diff -Nru vagrant-2.2.14+dfsg/test/unit/vagrant/util/ssh_test.rb vagrant-2.2.19+dfsg/test/unit/vagrant/util/ssh_test.rb --- vagrant-2.2.14+dfsg/test/unit/vagrant/util/ssh_test.rb 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/test/unit/vagrant/util/ssh_test.rb 2021-11-05 21:15:44.000000000 +0000 @@ -270,7 +270,7 @@ # mock out ChildProcess process = double() allow(ChildProcess).to receive(:build).and_return(process) - allow(process).to receive(:io).and_return(true) + allow(process).to receive(:io).and_return(double("process-io")) allow(process.io).to receive(:inherit!).and_return(true) allow(process).to receive(:start).and_return(true) allow(process).to receive(:wait).and_return(true) diff -Nru vagrant-2.2.14+dfsg/Vagrantfile vagrant-2.2.19+dfsg/Vagrantfile --- vagrant-2.2.14+dfsg/Vagrantfile 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/Vagrantfile 2021-11-05 21:15:44.000000000 +0000 @@ -14,7 +14,12 @@ end end - config.vm.provision "shell", inline: $shell + # We split apart `install_rvm` from `setup_tests` because rvm says to + # logout and log back in just after installing RVM. + # https://github.com/rvm/ubuntu_rvm#3-reboot + config.vm.provision "shell", path: "scripts/install_rvm" + + config.vm.provision "shell", path: "scripts/setup_tests" config.push.define "www", strategy: "local-exec" do |push| push.script = "scripts/website_push_www.sh" @@ -24,54 +29,3 @@ push.script = "scripts/website_push_docs.sh" end end - -$shell = <<-'CONTENTS' -export DEBIAN_FRONTEND=noninteractive -MARKER_FILE="/usr/local/etc/vagrant_provision_marker" -RUBY_VER_REQ=$(awk '$1 == "s.required_ruby_version" { print $4 }' /vagrant/vagrant.gemspec | tr -d '"') - -# Only provision once -if [ -f "${MARKER_FILE}" ]; then - exit 0 -fi - -# Add ubuntu_rvm repo -apt-add-repository -y ppa:rael-gc/rvm - -# Update apt -apt-get update --quiet - -# Add vagrant user to sudo group: -# ubuntu_rvm only adds users in group sudo to group rvm -usermod -a -G sudo vagrant - -# Install basic dependencies and RVM -apt-get install -qy build-essential bsdtar rvm - -# Import the mpapis public key to verify downloaded releases -su -l -c 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3' vagrant - -# Install next-to-last Ruby that complies with Vagrant's version constraint -RUBY_VER=$(su -l -c 'rvm list known' vagrant | tr '[]-' ' ' | awk "/^ ruby ${RUBY_VER_REQ:0:1}\./ { print \$2 }" | sort -r | sed -n '2p') -su -l -c "rvm install ${RUBY_VER}" vagrant -su -l -c "rvm --default use ${RUBY_VER}" vagrant - -# Output the Ruby version (for sanity) -su -l -c 'ruby --version' vagrant - -# Install Git -apt-get install -qy git - -# Upgrade Rubygems -su -l -c "rvm ${RUBY_VER} do gem update --system" vagrant - -# Prepare to run unit tests -su -l -c 'cd /vagrant; bundle install' vagrant - -# Automatically move into the shared folder, but only add the command -# if it's not already there. -grep -q 'cd /vagrant' /home/vagrant/.bash_profile 2>/dev/null || echo 'cd /vagrant' >> /home/vagrant/.bash_profile - -# Touch the marker file so we don't do this again -touch ${MARKER_FILE} -CONTENTS diff -Nru vagrant-2.2.14+dfsg/vagrant.gemspec vagrant-2.2.19+dfsg/vagrant.gemspec --- vagrant-2.2.14+dfsg/vagrant.gemspec 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/vagrant.gemspec 2021-11-05 21:15:44.000000000 +0000 @@ -12,42 +12,37 @@ s.summary = "Build and distribute virtualized development environments." s.description = "Vagrant is a tool for building and distributing virtualized development environments." - s.required_ruby_version = "~> 2.5", "< 2.8" + s.required_ruby_version = ">= 2.6", "< 3.1" s.required_rubygems_version = ">= 1.3.6" - s.add_dependency "bcrypt_pbkdf", "~> 1.0.0" - s.add_dependency "childprocess", "~> 4.0.0" + s.add_dependency "bcrypt_pbkdf", "~> 1.1" + s.add_dependency "childprocess", "~> 4.1.0" s.add_dependency "ed25519", "~> 1.2.4" s.add_dependency "erubi" s.add_dependency "hashicorp-checkpoint", "~> 0.1.5" s.add_dependency "i18n", "~> 1.8" - s.add_dependency "listen", "~> 3.1" + s.add_dependency "listen", "~> 3.6" s.add_dependency "log4r", "~> 1.1.9", "< 1.1.11" s.add_dependency "mime-types", "~> 3.3" - s.add_dependency "net-ssh", ">= 6.2.0.rc1", "< 7" + s.add_dependency "net-ssh", ">= 6.1.0", "< 6.2" s.add_dependency "net-sftp", "~> 3.0" - s.add_dependency "net-scp", "~> 1.2.0" + s.add_dependency "net-scp", "~> 3.0.0" s.add_dependency "rb-kqueue", "~> 0.2.0" + s.add_dependency "rexml", "~> 3.2" s.add_dependency "rubyzip", "~> 2.0" - s.add_dependency "vagrant_cloud", "~> 3.0.2" + s.add_dependency "vagrant_cloud", "~> 3.0.5" s.add_dependency "wdm", "~> 0.1.0" s.add_dependency "winrm", ">= 2.3.4", "< 3.0" s.add_dependency "winrm-elevated", ">= 1.2.1", "< 2.0" s.add_dependency "winrm-fs", ">= 1.3.4", "< 2.0" - # NOTE: The ruby_dep gem is an implicit dependency from the listen gem. Later versions - # of the ruby_dep gem impose an aggressive constraint on the required ruby version (>= 2.2.5). - # Explicit constraint is defined to provide required dependency to listen without imposing - # tighter restrictions on valid ruby versions - s.add_dependency "ruby_dep", "<= 1.3.1" - # Constraint rake to properly handle deprecated method usage # from within rspec - s.add_development_dependency "rake", "~> 12.3.3" - s.add_development_dependency "rspec", "~> 3.5.0" + s.add_development_dependency "rake", "~> 13.0" + s.add_development_dependency "rspec", "~> 3.10.0" s.add_development_dependency "rspec-its", "~> 1.3.0" - s.add_development_dependency "webmock", "~> 2.3.1" s.add_development_dependency "fake_ftp", "~> 0.1.1" + s.add_development_dependency "webrick", "~> 1.7.0" # The following block of code determines the files that should be included # in the gem. It does this by reading all the files in the directory where diff -Nru vagrant-2.2.14+dfsg/version.txt vagrant-2.2.19+dfsg/version.txt --- vagrant-2.2.14+dfsg/version.txt 2020-11-20 17:38:35.000000000 +0000 +++ vagrant-2.2.19+dfsg/version.txt 2021-11-05 21:15:44.000000000 +0000 @@ -1 +1 @@ -2.2.14 +2.2.19