Class: CemWinSpec::WinExec::ConnectionOpts
- Inherits:
-
Object
- Object
- CemWinSpec::WinExec::ConnectionOpts
show all
- Includes:
- Logging
- Defined in:
- lib/cem_win_spec/win_exec/connection_opts.rb
Overview
Class for holding and managing WinExec options
Constant Summary
collapse
- CONN_DEFAULTS =
{
transport: :ssl,
max_envelope_size: 307_200,
operation_timeout: 60,
receive_timeout: 70,
retry_limit: 3,
retry_delay: 10,
}.freeze
- TPORT_DEFAULTS =
{
negotiate: {},
ssl: {
no_ssl_peer_verification: true,
},
kerberos: {},
plaintext: {
basic_auth_only: true,
disable_sspi: true,
},
}.freeze
Constants included
from Logging
Logging::LEVEL_MAP
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logging
#current_log_format, current_log_format, current_log_level, #current_log_level, included, log_setup!, #log_setup!, logger, #logger, new_log_formatter, #new_log_formatter, new_log_level, #new_log_level
Constructor Details
#initialize(new_host: nil, new_port: nil, user: nil, pass: nil, **kwargs) ⇒ ConnectionOpts
Returns a new instance of ConnectionOpts.
35
36
37
38
39
40
41
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 35
def initialize(new_host: nil, new_port: nil, user: nil, pass: nil, **kwargs)
@host = new_host
@port = new_port
@user = user || get_user
@pass = pass || get_pass
@kwargs = kwargs
end
|
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
33
34
35
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 33
def user
@user
end
|
Instance Method Details
#==(other) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 63
def ==(other)
raise ArgumentError, 'Can only compare ConnectionOpts with ConnectionOpts' unless other.is_a? ConnectionOpts
host == other.host &&
port == other.port &&
user == other.user &&
pass == other.pass &&
opts == other.opts
end
|
#digest ⇒ Object
77
78
79
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 77
def digest
Digest::SHA256.hexdigest([host, port, user, pt_pass, opts.values].join(':'))
end
|
#endpoint ⇒ Object
55
56
57
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 55
def endpoint
@endpoint ||= endpoint_for_transport(opts[:transport])
end
|
#host ⇒ Object
43
44
45
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 43
def host
@host ||= 'localhost'
end
|
Merge new options into existing options and return a new ConnectionOpts object
84
85
86
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 84
def merge(**new_opts)
self.class.new(**opts_merge(**new_opts))
end
|
#merge!(**new_opts) ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 88
def merge!(**new_opts)
@host = new_opts[:new_host] || host
@port = new_opts[:new_port] || port
@user = new_opts[:user] || user
@pass = new_opts[:pass] || pt_pass
@opts = new_opts(opts.merge(new_opts.reject { |k, _v| %i[new_host new_port user pass].include? k }.to_h))
self
end
|
#opts ⇒ Object
59
60
61
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 59
def opts
@opts ||= create_new_opts(@kwargs)
end
|
#pass ⇒ Object
51
52
53
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 51
def pass
Digest::SHA256.hexdigest(pt_pass) unless pt_pass.nil?
end
|
#port ⇒ Object
47
48
49
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 47
def port
@port ||= port_for_transport(opts[:transport])
end
|
#to_h ⇒ Object
73
74
75
|
# File 'lib/cem_win_spec/win_exec/connection_opts.rb', line 73
def to_h
opts.dup.merge({ user: user, password: pt_pass, endpoint: endpoint })
end
|