ansible: Fix broken 'ask_sudo_pass' option
This bug (invalid method call) hasn't been caught by unit tests because Vagrant::Plugin::V2::Config catches all invalid/bad configuration calls and save them for generating error messages during the "validate" stage. This way, the `ask_sudo_pass=(value)` method was not interrupted and the `@ask_become_pass` attribute was (surprisingly) correctly set (allowing the related unit tests to pass). In order to avoid similar problem to happen again, the deprecation message output is now fully verified.
This commit is contained in:
parent
b3b98e77ed
commit
e47deb7fd0
|
@ -16,7 +16,7 @@ module VagrantPlugins
|
||||||
#
|
#
|
||||||
alias :ask_sudo_pass :ask_become_pass
|
alias :ask_sudo_pass :ask_become_pass
|
||||||
def ask_sudo_pass=(value)
|
def ask_sudo_pass=(value)
|
||||||
show_deprecation_warning 'ask_sudo_pass', 'ask_become_pass'
|
show_deprecation_info 'ask_sudo_pass', 'ask_become_pass'
|
||||||
@ask_become_pass = value
|
@ask_become_pass = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ describe VagrantPlugins::Ansible::Config::Host, :skip_windows => true do
|
||||||
allow($stdout).to receive(:puts)
|
allow($stdout).to receive(:puts)
|
||||||
end
|
end
|
||||||
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :ask_sudo_pass, false
|
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :ask_sudo_pass, false
|
||||||
|
it_behaves_like "any deprecated option", :ask_sudo_pass, :ask_become_pass, true
|
||||||
end
|
end
|
||||||
describe "ask_vault_pass option" do
|
describe "ask_vault_pass option" do
|
||||||
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :ask_vault_pass, false
|
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :ask_vault_pass, false
|
||||||
|
|
|
@ -30,6 +30,17 @@ shared_examples_for 'options shared by both Ansible provisioners' do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'any deprecated option' do |deprecated_option, new_option, option_value|
|
||||||
|
it "shows the deprecation message" do
|
||||||
|
expect($stdout).to receive(:puts).with("DEPRECATION: The '#{deprecated_option}' option for the Ansible provisioner is deprecated.").and_return(nil)
|
||||||
|
expect($stdout).to receive(:puts).with("Please use the '#{new_option}' option instead.").and_return(nil)
|
||||||
|
expect($stdout).to receive(:puts).with("The '#{deprecated_option}' option will be removed in a future release of Vagrant.\n\n").and_return(nil)
|
||||||
|
|
||||||
|
subject.send("#{deprecated_option}=", option_value)
|
||||||
|
subject.finalize!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
shared_examples_for 'an Ansible provisioner' do | path_prefix, ansible_setup |
|
shared_examples_for 'an Ansible provisioner' do | path_prefix, ansible_setup |
|
||||||
|
|
||||||
provisioner_label = "ansible #{ansible_setup} provisioner"
|
provisioner_label = "ansible #{ansible_setup} provisioner"
|
||||||
|
@ -158,6 +169,15 @@ shared_examples_for 'an Ansible provisioner' do | path_prefix, ansible_setup |
|
||||||
allow($stdout).to receive(:puts)
|
allow($stdout).to receive(:puts)
|
||||||
end
|
end
|
||||||
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :sudo, false
|
it_behaves_like "any VagrantConfigProvisioner strict boolean attribute", :sudo, false
|
||||||
|
it_behaves_like "any deprecated option", :sudo, :become, true
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "sudo_user option" do
|
||||||
|
before do
|
||||||
|
# Filter the deprecation notice
|
||||||
|
allow($stdout).to receive(:puts)
|
||||||
|
end
|
||||||
|
it_behaves_like "any deprecated option", :sudo_user, :become_user, "foo"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue