Add extra_args cap for darwin rdp
This commit fixes GH-5523.
This commit is contained in:
parent
3372ab6d0b
commit
4b4f1fc24c
|
@ -8,6 +8,15 @@ module VagrantPlugins
|
|||
module Cap
|
||||
class RDP
|
||||
def self.rdp_client(env, rdp_info)
|
||||
config_path = self.generate_config_file(rdp_info)
|
||||
Vagrant::Util::Subprocess.execute("open", config_path.to_s)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Generates an RDP connection file and returns the resulting path.
|
||||
# @return [String]
|
||||
def self.generate_config_file(rdp_info)
|
||||
opts = {
|
||||
"drivestoredirect:s" => "*",
|
||||
"full address:s" => "#{rdp_info[:host]}:#{rdp_info[:port]}",
|
||||
|
@ -22,10 +31,15 @@ module VagrantPlugins
|
|||
opts.each do |k, v|
|
||||
f.puts("#{k}:#{v}")
|
||||
end
|
||||
|
||||
if rdp_info[:extra_args]
|
||||
rdp_info[:extra_args].each do |arg|
|
||||
f.puts("#{arg}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Launch it
|
||||
Vagrant::Util::Subprocess.execute("open", config_path.to_s)
|
||||
return config_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
require_relative "../../../../base"
|
||||
|
||||
require_relative "../../../../../../plugins/hosts/darwin/cap/rdp"
|
||||
|
||||
describe VagrantPlugins::HostDarwin::Cap::RDP do
|
||||
let(:rdp_info) do
|
||||
{
|
||||
host: "host",
|
||||
port: "port",
|
||||
username: "username",
|
||||
}
|
||||
end
|
||||
|
||||
it "includes the default options" do
|
||||
path = described_class.generate_config_file(rdp_info)
|
||||
result = File.read(path)
|
||||
expect(result).to match("drivestoredirect:s:*")
|
||||
expect(result).to match("full address:s:host:port")
|
||||
expect(result).to match("prompt for credentials:i:1")
|
||||
expect(result).to match("username:s:username")
|
||||
end
|
||||
|
||||
it "includes extra RDP arguments" do
|
||||
rdp_info.merge!(extra_args: ["screen mode id:i:0"])
|
||||
path = described_class.generate_config_file(rdp_info)
|
||||
result = File.read(path)
|
||||
expect(result).to match("screen mode id:i:0")
|
||||
end
|
||||
|
||||
it "opens the RDP file" do
|
||||
env = double(:env)
|
||||
allow(described_class).to receive(:generate_config_file).and_return("/path")
|
||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with("open", "/path")
|
||||
described_class.rdp_client(env, rdp_info)
|
||||
end
|
||||
end
|
|
@ -23,8 +23,21 @@ these through. For example:
|
|||
|
||||
```
|
||||
$ vagrant rdp -- /span
|
||||
...
|
||||
```
|
||||
|
||||
The above command on Windows will execute `mstsc.exe /span config.rdp`,
|
||||
allowing your RDP to span multiple desktops.
|
||||
|
||||
|
||||
On Darwin hosts, such as Mac OS X, the additional arguments are added to the
|
||||
generated RDP configuration file. Since these files can contain multiple options
|
||||
with different spacing, you _must_ quote multiple arguments. For example:
|
||||
|
||||
```
|
||||
$ vagrant rdp -- "screen mode id:i:0" "other config:s:value"
|
||||
```
|
||||
|
||||
Note that as of the publishing of this guide, the Microsoft RDP Client for Mac
|
||||
does _not_ perform validation on the configuration file. This means if you
|
||||
specify an invalid configuration option or make a typographical error, the
|
||||
client will silently ignore the error and continue!
|
||||
|
|
Loading…
Reference in New Issue