From de96b54272f0d7eb717df0f5d7d2c065cd8b1786 Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Mon, 23 Nov 2015 09:05:36 +0100 Subject: [PATCH] provisioners/ansible: full test coverage of winrm At the moment, the vagrant ssh username is used as default username when force_remote_user option is disabled, even for winrm-communiating machines. This could be improved in the future, but people hitting this problem can easily work around it by syncing `config.ssh.unsername` and `config.winrm.username` in their Vagrantfile. ref #5086 --- .../provisioners/ansible/provisioner_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/unit/plugins/provisioners/ansible/provisioner_test.rb b/test/unit/plugins/provisioners/ansible/provisioner_test.rb index d937dacff..08e01dc9d 100644 --- a/test/unit/plugins/provisioners/ansible/provisioner_test.rb +++ b/test/unit/plugins/provisioners/ansible/provisioner_test.rb @@ -406,6 +406,21 @@ VF 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 + + describe "with force_remote_user option disabled" do + before do + config.force_remote_user = false + end + + it "doesn't set ansiber user in inventory and use '--user' arguemnt with the vagrant ssh username" do + expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args| + 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_pass='winword'\n") + expect(args).to include("--user=testuser") + } + end + end end describe "with inventory_path option" do