tests passing
This commit is contained in:
parent
ac5a0cf326
commit
e52556b5f5
|
@ -36,7 +36,14 @@ describe VagrantPlugins::CommandSSHConfig::Command do
|
||||||
|
|
||||||
describe "execute" do
|
describe "execute" do
|
||||||
it "prints out the ssh config for the given machine" do
|
it "prints out the ssh config for the given machine" do
|
||||||
expect(subject).to receive(:safe_puts).with(<<-SSHCONFIG)
|
output = ""
|
||||||
|
allow(subject).to receive(:safe_puts) do |data|
|
||||||
|
output += data if data
|
||||||
|
end
|
||||||
|
|
||||||
|
subject.execute
|
||||||
|
|
||||||
|
expect(output).to eq(<<-SSHCONFIG)
|
||||||
Host #{machine.name}
|
Host #{machine.name}
|
||||||
HostName testhost.vagrant.dev
|
HostName testhost.vagrant.dev
|
||||||
User testuser
|
User testuser
|
||||||
|
@ -47,40 +54,58 @@ Host #{machine.name}
|
||||||
IdentitiesOnly yes
|
IdentitiesOnly yes
|
||||||
LogLevel FATAL
|
LogLevel FATAL
|
||||||
SSHCONFIG
|
SSHCONFIG
|
||||||
subject.execute
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "turns on agent forwarding when it is configured" do
|
it "turns on agent forwarding when it is configured" do
|
||||||
allow(machine).to receive(:ssh_info) { ssh_info.merge(:forward_agent => true) }
|
allow(machine).to receive(:ssh_info) { ssh_info.merge(:forward_agent => true) }
|
||||||
expect(subject).to receive(:safe_puts).with { |ssh_config|
|
|
||||||
expect(ssh_config).to include("ForwardAgent yes")
|
output = ""
|
||||||
}
|
allow(subject).to receive(:safe_puts) do |data|
|
||||||
|
output += data if data
|
||||||
|
end
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
|
|
||||||
|
expect(output).to include("ForwardAgent yes")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "turns on x11 forwarding when it is configured" do
|
it "turns on x11 forwarding when it is configured" do
|
||||||
allow(machine).to receive(:ssh_info) { ssh_info.merge(:forward_x11 => true) }
|
allow(machine).to receive(:ssh_info) { ssh_info.merge(:forward_x11 => true) }
|
||||||
expect(subject).to receive(:safe_puts).with { |ssh_config|
|
|
||||||
expect(ssh_config).to include("ForwardX11 yes")
|
output = ""
|
||||||
}
|
allow(subject).to receive(:safe_puts) do |data|
|
||||||
|
output += data if data
|
||||||
|
end
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
|
|
||||||
|
expect(output).to include("ForwardX11 yes")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handles multiple private key paths" do
|
it "handles multiple private key paths" do
|
||||||
allow(machine).to receive(:ssh_info) { ssh_info.merge(:private_key_path => ["foo", "bar"]) }
|
allow(machine).to receive(:ssh_info) { ssh_info.merge(:private_key_path => ["foo", "bar"]) }
|
||||||
expect(subject).to receive(:safe_puts).with { |ssh_config|
|
|
||||||
expect(ssh_config).to include("IdentityFile foo")
|
output = ""
|
||||||
expect(ssh_config).to include("IdentityFile bar")
|
allow(subject).to receive(:safe_puts) do |data|
|
||||||
}
|
output += data if data
|
||||||
|
end
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
|
|
||||||
|
expect(output).to include("IdentityFile foo")
|
||||||
|
expect(output).to include("IdentityFile bar")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "puts quotes around an identityfile path if it has a space" do
|
it "puts quotes around an identityfile path if it has a space" do
|
||||||
allow(machine).to receive(:ssh_info) { ssh_info.merge(:private_key_path => ["with a space"]) }
|
allow(machine).to receive(:ssh_info) { ssh_info.merge(:private_key_path => ["with a space"]) }
|
||||||
expect(subject).to receive(:safe_puts).with { |ssh_config|
|
output = ""
|
||||||
expect(ssh_config).to include('IdentityFile "with a space"')
|
allow(subject).to receive(:safe_puts) do |data|
|
||||||
}
|
output += data if data
|
||||||
|
end
|
||||||
|
|
||||||
subject.execute
|
subject.execute
|
||||||
|
|
||||||
|
expect(output).to include('IdentityFile "with a space"')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue