Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation to winrm shell type option #28

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/train-winrm/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Transport < Train.plugin(1) # rubocop:disable Metrics/ClassLength

# ref: https://github.com/winrb/winrm#transports
SUPPORTED_WINRM_TRANSPORTS = %i{negotiate ssl plaintext kerberos}.freeze
SUPPORTED_WINRM_SHELL_TYPES = %i{powershell elevated cmd}.freeze

# common target configuration
option :host, required: true
Expand Down Expand Up @@ -106,6 +107,11 @@ def validate_options(opts)
raise Train::ClientError, "Unsupported transport type: #{winrm_transport.inspect}"
end

winrm_shell_type = opts[:winrm_shell_type].to_sym
unless SUPPORTED_WINRM_SHELL_TYPES.include?(winrm_shell_type)
raise Train::ClientError, "Unsupported winrm shell type: #{winrm_shell_type.inspect}"
end

# remove leading '/'
path = (opts[:path] || "").sub(%r{^/+}, "")

Expand Down