winrm 2.2.3 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +13 -1
  3. data/.travis.yml +10 -11
  4. data/Gemfile +2 -3
  5. data/README.md +1 -1
  6. data/Rakefile +3 -4
  7. data/appveyor.yml +1 -2
  8. data/bin/rwinrm +90 -97
  9. data/changelog.md +5 -0
  10. data/lib/winrm.rb +3 -5
  11. data/lib/winrm/connection.rb +84 -86
  12. data/lib/winrm/connection_opts.rb +90 -91
  13. data/lib/winrm/exceptions.rb +14 -2
  14. data/lib/winrm/http/response_handler.rb +127 -96
  15. data/lib/winrm/http/transport.rb +462 -427
  16. data/lib/winrm/http/transport_factory.rb +1 -5
  17. data/lib/winrm/output.rb +1 -2
  18. data/lib/winrm/psrp/fragment.rb +0 -2
  19. data/lib/winrm/psrp/message.rb +1 -3
  20. data/lib/winrm/psrp/message_data.rb +0 -2
  21. data/lib/winrm/psrp/message_data/base.rb +0 -2
  22. data/lib/winrm/psrp/message_data/error_record.rb +0 -2
  23. data/lib/winrm/psrp/message_data/pipeline_host_call.rb +0 -2
  24. data/lib/winrm/psrp/message_data/pipeline_output.rb +48 -54
  25. data/lib/winrm/psrp/message_data/pipeline_state.rb +0 -2
  26. data/lib/winrm/psrp/message_data/runspacepool_host_call.rb +0 -2
  27. data/lib/winrm/psrp/message_data/runspacepool_state.rb +0 -2
  28. data/lib/winrm/psrp/message_data/session_capability.rb +0 -2
  29. data/lib/winrm/psrp/message_defragmenter.rb +2 -2
  30. data/lib/winrm/psrp/message_factory.rb +2 -3
  31. data/lib/winrm/psrp/message_fragmenter.rb +1 -3
  32. data/lib/winrm/psrp/powershell_output_decoder.rb +0 -2
  33. data/lib/winrm/psrp/receive_response_reader.rb +3 -5
  34. data/lib/winrm/psrp/uuid.rb +1 -2
  35. data/lib/winrm/shells/base.rb +6 -4
  36. data/lib/winrm/shells/cmd.rb +63 -65
  37. data/lib/winrm/shells/power_shell.rb +207 -202
  38. data/lib/winrm/shells/retryable.rb +44 -45
  39. data/lib/winrm/shells/shell_factory.rb +0 -2
  40. data/lib/winrm/version.rb +1 -3
  41. data/lib/winrm/wsmv/base.rb +0 -2
  42. data/lib/winrm/wsmv/cleanup_command.rb +1 -2
  43. data/lib/winrm/wsmv/close_shell.rb +1 -2
  44. data/lib/winrm/wsmv/command.rb +2 -3
  45. data/lib/winrm/wsmv/command_output.rb +2 -3
  46. data/lib/winrm/wsmv/command_output_decoder.rb +1 -2
  47. data/lib/winrm/wsmv/configuration.rb +0 -2
  48. data/lib/winrm/wsmv/create_pipeline.rb +0 -2
  49. data/lib/winrm/wsmv/create_shell.rb +2 -6
  50. data/lib/winrm/wsmv/header.rb +213 -215
  51. data/lib/winrm/wsmv/init_runspace_pool.rb +96 -95
  52. data/lib/winrm/wsmv/iso8601_duration.rb +0 -2
  53. data/lib/winrm/wsmv/keep_alive.rb +0 -2
  54. data/lib/winrm/wsmv/receive_response_reader.rb +128 -126
  55. data/lib/winrm/wsmv/send_data.rb +0 -2
  56. data/lib/winrm/wsmv/soap.rb +0 -2
  57. data/lib/winrm/wsmv/wql_pull.rb +54 -56
  58. data/lib/winrm/wsmv/wql_query.rb +98 -99
  59. data/lib/winrm/wsmv/write_stdin.rb +0 -2
  60. data/tests/integration/auth_timeout_spec.rb +0 -1
  61. data/tests/integration/cmd_spec.rb +2 -3
  62. data/tests/integration/issue_59_spec.rb +0 -1
  63. data/tests/integration/powershell_spec.rb +4 -5
  64. data/tests/integration/spec_helper.rb +3 -6
  65. data/tests/integration/transport_spec.rb +0 -1
  66. data/tests/integration/wql_spec.rb +33 -34
  67. data/tests/matchers.rb +2 -3
  68. data/tests/spec/configuration_spec.rb +0 -1
  69. data/tests/spec/connection_spec.rb +0 -2
  70. data/tests/spec/exception_spec.rb +0 -1
  71. data/tests/spec/http/transport_factory_spec.rb +1 -3
  72. data/tests/spec/http/transport_spec.rb +0 -1
  73. data/tests/spec/output_spec.rb +4 -3
  74. data/tests/spec/psrp/fragment_spec.rb +0 -2
  75. data/tests/spec/psrp/message_data/base_spec.rb +0 -2
  76. data/tests/spec/psrp/message_data/error_record_spec.rb +0 -2
  77. data/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +0 -2
  78. data/tests/spec/psrp/message_data/pipeline_output_spec.rb +0 -2
  79. data/tests/spec/psrp/message_data/pipeline_state_spec.rb +0 -2
  80. data/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +0 -2
  81. data/tests/spec/psrp/message_data/runspacepool_state_spec.rb +0 -2
  82. data/tests/spec/psrp/message_data/session_capability_spec.rb +0 -2
  83. data/tests/spec/psrp/message_data_spec.rb +0 -2
  84. data/tests/spec/psrp/message_defragmenter_spec.rb +0 -2
  85. data/tests/spec/psrp/message_fragmenter_spec.rb +0 -2
  86. data/tests/spec/psrp/powershell_output_decoder_spec.rb +0 -2
  87. data/tests/spec/psrp/psrp_message_spec.rb +10 -7
  88. data/tests/spec/psrp/recieve_response_reader_spec.rb +0 -2
  89. data/tests/spec/psrp/uuid_spec.rb +2 -2
  90. data/tests/spec/response_handler_spec.rb +69 -61
  91. data/tests/spec/shells/base_spec.rb +7 -5
  92. data/tests/spec/shells/cmd_spec.rb +4 -4
  93. data/tests/spec/shells/powershell_spec.rb +221 -175
  94. data/tests/spec/spec_helper.rb +0 -1
  95. data/tests/spec/stubs/responses/get_omi_command_output_response.xml.erb +23 -0
  96. data/tests/spec/stubs/responses/get_omi_command_output_response_not_done.xml.erb +24 -0
  97. data/tests/spec/stubs/responses/get_omi_config_response.xml +45 -0
  98. data/tests/spec/stubs/responses/get_omi_powershell_keepalive_response.xml.erb +33 -0
  99. data/tests/spec/stubs/responses/open_shell_omi.xml +43 -0
  100. data/tests/spec/stubs/responses/soap_fault_omi.xml +31 -0
  101. data/tests/spec/wsmv/cleanup_command_spec.rb +0 -2
  102. data/tests/spec/wsmv/close_shell_spec.rb +0 -2
  103. data/tests/spec/wsmv/command_output_decoder_spec.rb +0 -2
  104. data/tests/spec/wsmv/command_output_spec.rb +1 -3
  105. data/tests/spec/wsmv/command_spec.rb +0 -2
  106. data/tests/spec/wsmv/configuration_spec.rb +0 -2
  107. data/tests/spec/wsmv/create_pipeline_spec.rb +2 -3
  108. data/tests/spec/wsmv/create_shell_spec.rb +6 -5
  109. data/tests/spec/wsmv/init_runspace_pool_spec.rb +38 -36
  110. data/tests/spec/wsmv/keep_alive_spec.rb +4 -4
  111. data/tests/spec/wsmv/receive_response_reader_spec.rb +124 -123
  112. data/tests/spec/wsmv/send_data_spec.rb +4 -4
  113. data/tests/spec/wsmv/wql_query_spec.rb +11 -13
  114. data/tests/spec/wsmv/write_stdin_spec.rb +0 -2
  115. data/winrm.gemspec +11 -12
  116. metadata +73 -67
@@ -1,5 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
1
  # Copyright 2016 Matt Wrock <matt@mattwrock.com>
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
1
  # Copyright 2010 Dan Wanek <dan.wanek@gmail.com>
4
2
  # Copyright 2016 Shawn Neal <sneal@sneal.net>
5
3
  #
@@ -1,56 +1,54 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'nori'
4
- require_relative 'base'
5
-
6
- module WinRM
7
- module WSMV
8
- # WSMV message to 'pull' rest of enumeration results from Windows via WQL
9
- class WqlPull < Base
10
- def initialize(session_opts, namespace, enumeration_context)
11
- @session_opts = session_opts
12
- @namespace = namespace
13
- @enumeration_context = enumeration_context
14
- end
15
-
16
- def process_response(response)
17
- parser = Nori.new(
18
- parser: :rexml,
19
- advanced_typecasting: false,
20
- convert_tags_to: ->(tag) { tag.snakecase.to_sym },
21
- strip_namespaces: true
22
- )
23
- parser.parse(response.to_s)[:envelope][:body]
24
- end
25
-
26
- protected
27
-
28
- def create_header(header)
29
- header << Gyoku.xml(wql_header)
30
- end
31
-
32
- def create_body(body)
33
- body.tag!("#{NS_ENUM}:Pull") { |en| en << Gyoku.xml(wql_body) }
34
- end
35
-
36
- private
37
-
38
- def wql_header
39
- merge_headers(
40
- shared_headers(@session_opts),
41
- resource_uri_wmi(@namespace),
42
- action_enumerate_pull
43
- )
44
- end
45
-
46
- def wql_body
47
- {
48
- "#{NS_ENUM}:EnumerationContext" => @enumeration_context,
49
- "#{NS_WSMAN_DMTF}:OptimizeEnumeration" => nil,
50
- "#{NS_ENUM}:MaxElements" => '32000',
51
- "#{NS_WSMAN_MSFT}:SessionId" => "uuid:#{@session_opts[:session_id]}"
52
- }
53
- end
54
- end
55
- end
56
- end
1
+ require 'nori'
2
+ require_relative 'base'
3
+
4
+ module WinRM
5
+ module WSMV
6
+ # WSMV message to 'pull' rest of enumeration results from Windows via WQL
7
+ class WqlPull < Base
8
+ def initialize(session_opts, namespace, enumeration_context)
9
+ @session_opts = session_opts
10
+ @namespace = namespace
11
+ @enumeration_context = enumeration_context
12
+ end
13
+
14
+ def process_response(response)
15
+ parser = Nori.new(
16
+ parser: :rexml,
17
+ advanced_typecasting: false,
18
+ convert_tags_to: ->(tag) { tag.snakecase.to_sym },
19
+ strip_namespaces: true
20
+ )
21
+ parser.parse(response.to_s)[:envelope][:body]
22
+ end
23
+
24
+ protected
25
+
26
+ def create_header(header)
27
+ header << Gyoku.xml(wql_header)
28
+ end
29
+
30
+ def create_body(body)
31
+ body.tag!("#{NS_ENUM}:Pull") { |en| en << Gyoku.xml(wql_body) }
32
+ end
33
+
34
+ private
35
+
36
+ def wql_header
37
+ merge_headers(
38
+ shared_headers(@session_opts),
39
+ resource_uri_wmi(@namespace),
40
+ action_enumerate_pull
41
+ )
42
+ end
43
+
44
+ def wql_body
45
+ {
46
+ "#{NS_ENUM}:EnumerationContext" => @enumeration_context,
47
+ "#{NS_WSMAN_DMTF}:OptimizeEnumeration" => nil,
48
+ "#{NS_ENUM}:MaxElements" => '32000',
49
+ "#{NS_WSMAN_MSFT}:SessionId" => "uuid:#{@session_opts[:session_id]}"
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,99 +1,98 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Copyright 2016 Shawn Neal <sneal@sneal.net>
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- require 'nori'
18
- require_relative 'base'
19
-
20
- module WinRM
21
- module WSMV
22
- # WSMV message to query Windows via WQL
23
- class WqlQuery < Base
24
- def initialize(transport, session_opts, wql, namespace = nil)
25
- @session_opts = session_opts
26
- @wql = wql
27
- @namespace = namespace
28
- @transport = transport
29
- end
30
-
31
- def process_response(response, &block)
32
- parser = Nori.new(
33
- parser: :rexml,
34
- advanced_typecasting: false,
35
- convert_tags_to: ->(tag) { tag.snakecase.to_sym },
36
- strip_namespaces: true
37
- )
38
- @items = Hash.new { |h, k| h[k] = [] }
39
-
40
- hresp = parser.parse(response.to_s)[:envelope][:body][:enumerate_response]
41
- process_items hresp[:items], &block
42
-
43
- # Perform WS-Enum PULL's until we have all the elements
44
- enumeration_context = hresp[:enumeration_context]
45
- until enumeration_context.nil?
46
- query = WqlPull.new(@session_opts, @namespace, enumeration_context)
47
- hresp = query.process_response(@transport.send_request(query.build))[:pull_response]
48
- process_items hresp[:items], &block
49
- enumeration_context = hresp[:enumeration_context]
50
- end
51
-
52
- @items
53
- end
54
-
55
- protected
56
-
57
- def create_header(header)
58
- header << Gyoku.xml(wql_header)
59
- end
60
-
61
- def create_body(body)
62
- body.tag!("#{NS_ENUM}:Enumerate") { |en| en << Gyoku.xml(wql_body) }
63
- end
64
-
65
- private
66
-
67
- def process_items(items, &block)
68
- return if items.nil?
69
- items.each_pair do |k, v|
70
- # Normalize items so the type always has an array even if it's just a single item.
71
- v_ary = v.is_a?(Array) ? v : [v]
72
- if block
73
- v_ary.each { |val| yield k, val }
74
- else
75
- @items[k] += v_ary
76
- end
77
- end
78
- end
79
-
80
- def wql_header
81
- merge_headers(shared_headers(@session_opts), resource_uri_wmi(@namespace), action_enumerate)
82
- end
83
-
84
- def wql_body
85
- {
86
- "#{NS_WSMAN_DMTF}:OptimizeEnumeration" => nil,
87
- "#{NS_WSMAN_DMTF}:MaxElements" => '32000',
88
- "#{NS_WSMAN_DMTF}:Filter" => @wql,
89
- "#{NS_WSMAN_MSFT}:SessionId" => "uuid:#{@session_opts[:session_id]}",
90
- :attributes! => {
91
- "#{NS_WSMAN_DMTF}:Filter" => {
92
- 'Dialect' => 'http://schemas.microsoft.com/wbem/wsman/1/WQL'
93
- }
94
- }
95
- }
96
- end
97
- end
98
- end
99
- end
1
+ # Copyright 2016 Shawn Neal <sneal@sneal.net>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'nori'
16
+ require_relative 'base'
17
+
18
+ module WinRM
19
+ module WSMV
20
+ # WSMV message to query Windows via WQL
21
+ class WqlQuery < Base
22
+ def initialize(transport, session_opts, wql, namespace = nil)
23
+ @session_opts = session_opts
24
+ @wql = wql
25
+ @namespace = namespace
26
+ @transport = transport
27
+ end
28
+
29
+ def process_response(response, &block)
30
+ parser = Nori.new(
31
+ parser: :rexml,
32
+ advanced_typecasting: false,
33
+ convert_tags_to: ->(tag) { tag.snakecase.to_sym },
34
+ strip_namespaces: true
35
+ )
36
+ @items = Hash.new { |h, k| h[k] = [] }
37
+
38
+ hresp = parser.parse(response.to_s)[:envelope][:body][:enumerate_response]
39
+ process_items hresp[:items], &block
40
+
41
+ # Perform WS-Enum PULL's until we have all the elements
42
+ enumeration_context = hresp[:enumeration_context]
43
+ until enumeration_context.nil?
44
+ query = WqlPull.new(@session_opts, @namespace, enumeration_context)
45
+ hresp = query.process_response(@transport.send_request(query.build))[:pull_response]
46
+ process_items hresp[:items], &block
47
+ enumeration_context = hresp[:enumeration_context]
48
+ end
49
+
50
+ @items
51
+ end
52
+
53
+ protected
54
+
55
+ def create_header(header)
56
+ header << Gyoku.xml(wql_header)
57
+ end
58
+
59
+ def create_body(body)
60
+ body.tag!("#{NS_ENUM}:Enumerate") { |en| en << Gyoku.xml(wql_body) }
61
+ end
62
+
63
+ private
64
+
65
+ def process_items(items, &block)
66
+ return if items.nil?
67
+
68
+ items.each_pair do |k, v|
69
+ # Normalize items so the type always has an array even if it's just a single item.
70
+ v_ary = v.is_a?(Array) ? v : [v]
71
+ if block
72
+ v_ary.each { |val| yield k, val }
73
+ else
74
+ @items[k] += v_ary
75
+ end
76
+ end
77
+ end
78
+
79
+ def wql_header
80
+ merge_headers(shared_headers(@session_opts), resource_uri_wmi(@namespace), action_enumerate)
81
+ end
82
+
83
+ def wql_body
84
+ {
85
+ "#{NS_WSMAN_DMTF}:OptimizeEnumeration" => nil,
86
+ "#{NS_WSMAN_DMTF}:MaxElements" => '32000',
87
+ "#{NS_WSMAN_DMTF}:Filter" => @wql,
88
+ "#{NS_WSMAN_MSFT}:SessionId" => "uuid:#{@session_opts[:session_id]}",
89
+ :attributes! => {
90
+ "#{NS_WSMAN_DMTF}:Filter" => {
91
+ 'Dialect' => 'http://schemas.microsoft.com/wbem/wsman/1/WQL'
92
+ }
93
+ }
94
+ }
95
+ end
96
+ end
97
+ end
98
+ end
@@ -1,5 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
1
  # Copyright 2016 Shawn Neal <sneal@sneal.net>
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require_relative 'spec_helper'
3
2
 
4
3
  # This test may only be meaningful with kerberos auth
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require_relative 'spec_helper'
3
2
 
4
3
  describe 'winrm client cmd' do
@@ -21,7 +20,7 @@ describe 'winrm client cmd' do
21
20
  end
22
21
 
23
22
  describe 'codepage' do
24
- let(:options) { Hash.new }
23
+ let(:options) { {} }
25
24
  let(:shell) { winrm_connection.shell(:cmd, options) }
26
25
 
27
26
  after { shell.close }
@@ -98,7 +97,7 @@ describe 'winrm client cmd' do
98
97
  end
99
98
 
100
99
  describe 'ipconfig with /all argument' do
101
- subject(:output) { @cmd_shell.run('ipconfig', %w(/all)) }
100
+ subject(:output) { @cmd_shell.run('ipconfig', %w[/all]) }
102
101
  it { should have_exit_code 0 }
103
102
  it { should have_stdout_match(/Windows IP Configuration/) }
104
103
  it { should have_no_stderr }
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require_relative 'spec_helper'
3
2
 
4
3
  describe 'issue 59' do
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require_relative 'spec_helper'
3
2
 
4
3
  describe 'winrm client powershell' do
@@ -75,10 +74,10 @@ describe 'winrm client powershell' do
75
74
 
76
75
  describe 'capturing output from Write-Host and Write-Error' do
77
76
  subject(:output) do
78
- script = <<-eos
77
+ script = <<-EOS
79
78
  Write-Host 'Hello'
80
79
  $host.ui.WriteErrorLine(', world!')
81
- eos
80
+ EOS
82
81
 
83
82
  @captured_stdout = ''
84
83
  @captured_stderr = ''
@@ -105,10 +104,10 @@ describe 'winrm client powershell' do
105
104
 
106
105
  describe 'capturing output from pipeline followed by Host' do
107
106
  subject(:output) do
108
- script = <<-eos
107
+ script = <<-EOS
109
108
  Write-Output 'output'
110
109
  $host.UI.Writeline('host')
111
- eos
110
+ EOS
112
111
 
113
112
  @captured_stdout = ''
114
113
  @captured_stderr = ''
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require 'rubygems'
3
2
  require 'bundler/setup'
4
3
  require 'winrm'
@@ -12,8 +11,8 @@ module ConnectionHelper
12
11
  end
13
12
 
14
13
  def connection_opts
15
- @config ||= begin
16
- cfg = symbolize_keys(YAML.load(File.read(winrm_config_path)))
14
+ @connection_opts ||= begin
15
+ cfg = symbolize_keys(YAML.safe_load(File.read(winrm_config_path)))
17
16
  merge_environment(cfg)
18
17
  end
19
18
  end
@@ -22,9 +21,7 @@ module ConnectionHelper
22
21
  merge_config_option_from_environment(config, 'user')
23
22
  merge_config_option_from_environment(config, 'password')
24
23
  merge_config_option_from_environment(config, 'no_ssl_peer_verification')
25
- if ENV['use_ssl_peer_fingerprint']
26
- config[:ssl_peer_fingerprint] = ENV['winrm_cert']
27
- end
24
+ config[:ssl_peer_fingerprint] = ENV['winrm_cert'] if ENV['use_ssl_peer_fingerprint']
28
25
  config[:endpoint] = ENV['winrm_endpoint'] if ENV['winrm_endpoint']
29
26
  config
30
27
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  require_relative 'spec_helper'
3
2
 
4
3
  describe 'WinRM connection' do
@@ -1,34 +1,33 @@
1
- # encoding: UTF-8
2
- require_relative 'spec_helper'
3
-
4
- describe 'winrm client wql' do
5
- before(:all) do
6
- @winrm = winrm_connection
7
- end
8
-
9
- it 'should query Win32_OperatingSystem' do
10
- output = @winrm.run_wql('select * from Win32_OperatingSystem')
11
- expect(output).to_not be_empty
12
- output_caption = output[:win32_operating_system][0][:caption]
13
- expect(output_caption).to include('Microsoft')
14
- expect(output_caption).to include('Windows')
15
- end
16
-
17
- it 'should query Win32_Process' do
18
- output = @winrm.run_wql('select * from Win32_Process')
19
- expect(output).to_not be_empty
20
- process_count = output[:win32_process].count
21
- expect(process_count).to be > 1
22
- expect(output[:win32_process]).to all(include(:command_line))
23
- end
24
-
25
- it 'should query Win32_Process with block' do
26
- count = 0
27
- @winrm.run_wql('select * from Win32_Process') do |type, item|
28
- expect(type).to eq(:win32_process)
29
- expect(item).to include(:command_line)
30
- count += 1
31
- end
32
- expect(count).to be > 1
33
- end
34
- end
1
+ require_relative 'spec_helper'
2
+
3
+ describe 'winrm client wql' do
4
+ before(:all) do
5
+ @winrm = winrm_connection
6
+ end
7
+
8
+ it 'should query Win32_OperatingSystem' do
9
+ output = @winrm.run_wql('select * from Win32_OperatingSystem')
10
+ expect(output).to_not be_empty
11
+ output_caption = output[:win32_operating_system][0][:caption]
12
+ expect(output_caption).to include('Microsoft')
13
+ expect(output_caption).to include('Windows')
14
+ end
15
+
16
+ it 'should query Win32_Process' do
17
+ output = @winrm.run_wql('select * from Win32_Process')
18
+ expect(output).to_not be_empty
19
+ process_count = output[:win32_process].count
20
+ expect(process_count).to be > 1
21
+ expect(output[:win32_process]).to all(include(:command_line))
22
+ end
23
+
24
+ it 'should query Win32_Process with block' do
25
+ count = 0
26
+ @winrm.run_wql('select * from Win32_Process') do |type, item|
27
+ expect(type).to eq(:win32_process)
28
+ expect(item).to include(:command_line)
29
+ count += 1
30
+ end
31
+ expect(count).to be > 1
32
+ end
33
+ end