provisioners/ansible: add a unit test for winrm

ref #5086
This commit is contained in:
Gilles Cornu 2015-11-22 20:48:21 +01:00
parent ee55379736
commit e2f0d2ebb7
1 changed files with 36 additions and 1 deletions

View File

@ -129,7 +129,7 @@ VF
}
end
it "enables '#{expected_transport_mode}' transport mode" do
it "enables '#{expected_transport_mode}' as default transport mode" do
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
index = args.rindex("--connection=#{expected_transport_mode}")
expect(index).to be > 0
@ -373,6 +373,41 @@ VF
end
end
context "with winrm communicator" do
let(:iso_winrm_env) do
env = isolated_environment
env.vagrantfile <<-VF
Vagrant.configure("2") do |config|
config.winrm.username = 'winner'
config.winrm.password = 'winword'
config.winrm.transport = :ssl
config.vm.define :machine1 do |machine|
machine.vm.box = "winbox"
machine.vm.communicator = :winrm
end
end
VF
env.create_vagrant_env
end
let(:machine) { iso_winrm_env.machine(iso_winrm_env.machine_names[0], :dummy) }
it_should_set_arguments_and_environment_variables
it "generates an inventory with winrm connection settings" do
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
expect(config.inventory_path).to be_nil
expect(File.exists?(generated_inventory_file)).to be_true
inventory_content = File.read(generated_inventory_file)
expect(inventory_content).to include("machine1 ansible_connection=winrm ansible_ssh_host=127.0.0.1 ansible_ssh_port=55986 ansible_ssh_user='winner' ansible_ssh_pass='winword'\n")
}
end
end
describe "with inventory_path option" do
before do
config.inventory_path = existing_file