Rename no_ssl_peer_verification to ssl_peer_verification, and make it configurable
This commit is contained in:
parent
2b9626f19c
commit
1beb221bf3
|
@ -11,14 +11,15 @@ module VagrantPlugins
|
|||
attr_accessor :ssl
|
||||
|
||||
def initialize
|
||||
@username = UNSET_VALUE
|
||||
@password = UNSET_VALUE
|
||||
@host = UNSET_VALUE
|
||||
@port = UNSET_VALUE
|
||||
@guest_port = UNSET_VALUE
|
||||
@max_tries = UNSET_VALUE
|
||||
@timeout = UNSET_VALUE
|
||||
@ssl = UNSET_VALUE
|
||||
@username = UNSET_VALUE
|
||||
@password = UNSET_VALUE
|
||||
@host = UNSET_VALUE
|
||||
@port = UNSET_VALUE
|
||||
@guest_port = UNSET_VALUE
|
||||
@max_tries = UNSET_VALUE
|
||||
@timeout = UNSET_VALUE
|
||||
@ssl = UNSET_VALUE
|
||||
@ssl_peer_verification = UNSET_VALUE
|
||||
end
|
||||
|
||||
def finalize!
|
||||
|
@ -30,6 +31,7 @@ module VagrantPlugins
|
|||
@max_tries = 20 if @max_tries == UNSET_VALUE
|
||||
@timeout = 1800 if @timeout == UNSET_VALUE
|
||||
@ssl = false if @ssl == UNSET_VALUE
|
||||
@ssl_peer_verification = true if @ssl_peer_verification == UNSET_VALUE
|
||||
end
|
||||
|
||||
def validate(machine)
|
||||
|
@ -41,6 +43,9 @@ module VagrantPlugins
|
|||
errors << "winrm.guest_port cannot be nil." if @guest_port.nil?
|
||||
errors << "winrm.max_tries cannot be nil." if @max_tries.nil?
|
||||
errors << "winrm.timeout cannot be nil." if @timeout.nil?
|
||||
unless @ssl_peer_verification == true || @ssl_peer_verification == false
|
||||
errors << "winrm.ssl_peer_verification must be a boolean."
|
||||
end
|
||||
|
||||
{ "WinRM" => errors }
|
||||
end
|
||||
|
|
|
@ -39,18 +39,20 @@ module VagrantPlugins
|
|||
attr_reader :timeout_in_seconds
|
||||
attr_reader :max_tries
|
||||
attr_reader :ssl
|
||||
attr_reader :ssl_peer_verification
|
||||
|
||||
def initialize(host, username, password, options = {})
|
||||
@logger = Log4r::Logger.new("vagrant::communication::winrmshell")
|
||||
@logger.debug("initializing WinRMShell")
|
||||
|
||||
@host = host
|
||||
@port = options[:port] || (options[:ssl] ? 5986 : 5985)
|
||||
@username = username
|
||||
@password = password
|
||||
@timeout_in_seconds = options[:timeout_in_seconds] || 60
|
||||
@max_tries = options[:max_tries] || 20
|
||||
@ssl = options[:ssl] || false
|
||||
@host = host
|
||||
@port = options[:port] || (options[:ssl] ? 5986 : 5985)
|
||||
@username = username
|
||||
@password = password
|
||||
@timeout_in_seconds = options[:timeout_in_seconds] || 60
|
||||
@max_tries = options[:max_tries] || 20
|
||||
@ssl = options[:ssl] || false
|
||||
@ssl_peer_verification = options[:ssl_peer_verification] || true
|
||||
end
|
||||
|
||||
def powershell(command, &block)
|
||||
|
@ -144,7 +146,7 @@ module VagrantPlugins
|
|||
port: @port,
|
||||
operation_timeout: @timeout_in_seconds,
|
||||
basic_auth_only: true,
|
||||
no_ssl_peer_verification: true }
|
||||
no_ssl_peer_verification: !@ssl_peer_verification }
|
||||
end
|
||||
end #WinShell class
|
||||
end
|
||||
|
|
|
@ -51,7 +51,7 @@ describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
|
|||
it "should create endpoint options" do
|
||||
expect(subject.send(:endpoint_options)).to eq(
|
||||
{ user: "username", pass: "password", host: "localhost", port: 5985,
|
||||
operation_timeout: 60, basic_auth_only: true, no_ssl_peer_verification: true })
|
||||
operation_timeout: 60, basic_auth_only: true, no_ssl_peer_verification: false })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue