test-kitchen 1.11.1 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +10 -0
- data/Gemfile +3 -1
- data/features/step_definitions/gem_steps.rb +27 -27
- data/lib/kitchen/provisioner/chef/berkshelf.rb +12 -9
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +13 -9
- data/lib/kitchen/provisioner/chef/librarian.rb +2 -2
- data/lib/kitchen/provisioner/chef/policyfile.rb +24 -4
- data/lib/kitchen/provisioner/chef_base.rb +11 -3
- data/lib/kitchen/rake_tasks.rb +2 -2
- data/lib/kitchen/transport/winrm.rb +43 -91
- data/lib/kitchen/version.rb +1 -1
- data/spec/kitchen/provisioner/chef/policyfile_spec.rb +1 -1
- data/spec/kitchen/provisioner/chef_base_spec.rb +11 -2
- data/spec/kitchen/transport/winrm_spec.rb +90 -113
- data/test-kitchen.gemspec +3 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81b8adb0709ab4a153dcc6a0eba1c51e871d7dde
|
4
|
+
data.tar.gz: 97fbf58b65c2696f67dfae8c70ba089f14ef0ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d21fba7803bdf1592b7d1554cf4897f98817470d7559422f72f6fb8fbba38257484acf12dc89ee4f20cf7a0146053016a5f7c7b517ef7d8bf2591366e268a31
|
7
|
+
data.tar.gz: 32d72aac0d92f2c8dc12e0d1a4e66589d126c90f3c6f937230d28ef591a33e4e722a91613c6b316183360634457858f9f4e0c7bdc76f1afc88e024b49514600d
|
data/.travis.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
4
|
+
- 2.1.9
|
5
|
+
- 2.2.5
|
6
|
+
- 2.3.1
|
6
7
|
- ruby-head
|
7
8
|
|
8
9
|
env:
|
@@ -32,7 +33,7 @@ branches:
|
|
32
33
|
|
33
34
|
matrix:
|
34
35
|
include:
|
35
|
-
- rvm: 2.2.
|
36
|
+
- rvm: 2.2.5
|
36
37
|
# To run the proxy tests we need additional gems than what Test Kitchen normally uses
|
37
38
|
# for testing
|
38
39
|
gemfile: Gemfile.proxy_tests
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v1.12.0](https://github.com/test-kitchen/test-kitchen/tree/v1.12.0) (2016-09-02)
|
4
|
+
[Full Changelog](https://github.com/test-kitchen/test-kitchen/compare/v1.11.1...v1.12.0)
|
5
|
+
|
6
|
+
**Implemented enhancements:**
|
7
|
+
|
8
|
+
- Use winrm v2 release gems [\#1061](https://github.com/test-kitchen/test-kitchen/pull/1061) ([mwrock](https://github.com/mwrock))
|
9
|
+
- Add a new config option always\_update\_cookbooks [\#1107](https://github.com/test-kitchen/test-kitchen/pull/1107) ([coderanger](https://github.com/coderanger))
|
10
|
+
- Always run `chef install` even if the lock file exists. [\#1103](https://github.com/test-kitchen/test-kitchen/pull/1103) ([coderanger](https://github.com/coderanger))
|
11
|
+
- support passing Kitchen::Config Hash keys to Kitchen::RakeTasks.new [\#1102](https://github.com/test-kitchen/test-kitchen/pull/1102) ([theckman](https://github.com/theckman))
|
12
|
+
|
3
13
|
## [v1.11.1](https://github.com/test-kitchen/test-kitchen/tree/v1.11.1) (2016-08-13)
|
4
14
|
[Full Changelog](https://github.com/test-kitchen/test-kitchen/compare/v1.11.0...v1.11.1)
|
5
15
|
|
data/Gemfile
CHANGED
@@ -3,9 +3,11 @@ source "https://rubygems.org"
|
|
3
3
|
gemspec
|
4
4
|
gem "rack", "< 2.0"
|
5
5
|
|
6
|
+
gem "train", :github => "chef/train", :branch => "winrm-v2"
|
7
|
+
|
6
8
|
group :integration do
|
7
9
|
gem "berkshelf", "~> 4.3"
|
8
|
-
gem "kitchen-inspec", "
|
10
|
+
gem "kitchen-inspec", :git => "https://github.com/mwrock/kitchen-inspec", :branch => "winrm-v2"
|
9
11
|
end
|
10
12
|
|
11
13
|
group :test do
|
@@ -3,34 +3,34 @@
|
|
3
3
|
require "tmpdir"
|
4
4
|
require "pathname"
|
5
5
|
|
6
|
-
Given(/^a sandboxed GEM_HOME directory named "(.*?)"$/) do |name|
|
7
|
-
|
8
|
-
|
6
|
+
# Given(/^a sandboxed GEM_HOME directory named "(.*?)"$/) do |name|
|
7
|
+
# backup_envvar("GEM_HOME")
|
8
|
+
# backup_envvar("GEM_PATH")
|
9
9
|
|
10
|
-
|
10
|
+
# @aruba_timeout_seconds = 30
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
12
|
+
# gem_home = Pathname.new(Dir.mktmpdir(name))
|
13
|
+
# aruba.environment["GEM_HOME"] = gem_home.to_s
|
14
|
+
# aruba.environment["GEM_PATH"] = [gem_home.to_s, ENV["GEM_PATH"]].join(":")
|
15
|
+
# @cleanup_dirs << gem_home
|
16
|
+
# end
|
17
17
|
|
18
|
-
Then(/^a gem named "(.*?)" is installed with version "(.*?)"$/) do |name, version|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
18
|
+
# Then(/^a gem named "(.*?)" is installed with version "(.*?)"$/) do |name, version|
|
19
|
+
# unbundlerize do
|
20
|
+
# run_simple(
|
21
|
+
# sanitize_text("gem list #{name} --version #{version} -i"),
|
22
|
+
# :fail_on_error => true,
|
23
|
+
# :exit_timeout => nil
|
24
|
+
# )
|
25
|
+
# end
|
26
|
+
# end
|
27
27
|
|
28
|
-
Then(/^a gem named "(.*?)" is installed$/) do |name|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
28
|
+
# Then(/^a gem named "(.*?)" is installed$/) do |name|
|
29
|
+
# unbundlerize do
|
30
|
+
# run_simple(
|
31
|
+
# sanitize_text("gem list #{name} -i"),
|
32
|
+
# :fail_on_error => true,
|
33
|
+
# :exit_timeout => nil
|
34
|
+
# )
|
35
|
+
# end
|
36
|
+
# end
|
@@ -40,17 +40,18 @@ module Kitchen
|
|
40
40
|
# cookbooks
|
41
41
|
# @param logger [Kitchen::Logger] a logger to use for output, defaults
|
42
42
|
# to `Kitchen.logger`
|
43
|
-
def initialize(berksfile, path, logger
|
43
|
+
def initialize(berksfile, path, logger: Kitchen.logger, always_update: false)
|
44
44
|
@berksfile = berksfile
|
45
45
|
@path = path
|
46
46
|
@logger = logger
|
47
|
+
@always_update = always_update
|
47
48
|
end
|
48
49
|
|
49
50
|
# Loads the library code required to use the resolver.
|
50
51
|
#
|
51
52
|
# @param logger [Kitchen::Logger] a logger to use for output, defaults
|
52
53
|
# to `Kitchen.logger`
|
53
|
-
def self.load!(logger
|
54
|
+
def self.load!(logger: Kitchen.logger)
|
54
55
|
load_berkshelf!(logger)
|
55
56
|
end
|
56
57
|
|
@@ -62,13 +63,11 @@ module Kitchen
|
|
62
63
|
debug("Using Berksfile from #{berksfile}")
|
63
64
|
|
64
65
|
::Berkshelf.ui.mute do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
::Berkshelf::Berksfile.from_file(berksfile).install(:path => path)
|
71
|
-
end
|
66
|
+
berksfile_obj = ::Berkshelf::Berksfile.from_file(berksfile)
|
67
|
+
berksfile_obj.update if always_update
|
68
|
+
# Berkshelf requires the directory to not exist
|
69
|
+
FileUtils.rm_rf(path)
|
70
|
+
berksfile_obj.vendor(path)
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
@@ -86,6 +85,10 @@ module Kitchen
|
|
86
85
|
# @api private
|
87
86
|
attr_reader :logger
|
88
87
|
|
88
|
+
# @return [Boolean] If true, always update cookbooks in Berkshelf.
|
89
|
+
# @api private
|
90
|
+
attr_reader :always_update
|
91
|
+
|
89
92
|
# Load the Berkshelf-specific libary code.
|
90
93
|
#
|
91
94
|
# @param logger [Kitchen::Logger] the logger to use
|
@@ -301,13 +301,13 @@ module Kitchen
|
|
301
301
|
"kitchen config. The run_list in your config will be ignored.")
|
302
302
|
warn("Ignored run_list: #{config[:run_list].inspect}")
|
303
303
|
end
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
304
|
+
policy = Chef::Policyfile.new(policyfile, sandbox_path,
|
305
|
+
:logger => logger,
|
306
|
+
:always_update => config[:always_update_cookbooks])
|
307
|
+
Kitchen.mutex.synchronize do
|
308
|
+
policy.compile
|
309
309
|
end
|
310
|
-
policy_name = JSON.parse(IO.read(
|
310
|
+
policy_name = JSON.parse(IO.read(policy.lockfile))["name"]
|
311
311
|
policy_group = "local"
|
312
312
|
config[:attributes].merge(:policy_name => policy_name, :policy_group => policy_group)
|
313
313
|
end
|
@@ -317,7 +317,9 @@ module Kitchen
|
|
317
317
|
# @api private
|
318
318
|
def resolve_with_policyfile
|
319
319
|
Kitchen.mutex.synchronize do
|
320
|
-
Chef::Policyfile.new(policyfile, sandbox_path,
|
320
|
+
Chef::Policyfile.new(policyfile, sandbox_path,
|
321
|
+
:logger => logger,
|
322
|
+
:always_update => config[:always_update_cookbooks]).resolve
|
321
323
|
end
|
322
324
|
end
|
323
325
|
|
@@ -326,7 +328,9 @@ module Kitchen
|
|
326
328
|
# @api private
|
327
329
|
def resolve_with_berkshelf
|
328
330
|
Kitchen.mutex.synchronize do
|
329
|
-
Chef::Berkshelf.new(berksfile, tmpbooks_dir,
|
331
|
+
Chef::Berkshelf.new(berksfile, tmpbooks_dir,
|
332
|
+
:logger => logger,
|
333
|
+
:always_update => config[:always_update_cookbooks]).resolve
|
330
334
|
end
|
331
335
|
end
|
332
336
|
|
@@ -335,7 +339,7 @@ module Kitchen
|
|
335
339
|
# @api private
|
336
340
|
def resolve_with_librarian
|
337
341
|
Kitchen.mutex.synchronize do
|
338
|
-
Chef::Librarian.new(cheffile, tmpbooks_dir, logger).resolve
|
342
|
+
Chef::Librarian.new(cheffile, tmpbooks_dir, :logger => logger).resolve
|
339
343
|
end
|
340
344
|
end
|
341
345
|
|
@@ -40,7 +40,7 @@ module Kitchen
|
|
40
40
|
# cookbooks
|
41
41
|
# @param logger [Kitchen::Logger] a logger to use for output, defaults
|
42
42
|
# to `Kitchen.logger`
|
43
|
-
def initialize(cheffile, path, logger
|
43
|
+
def initialize(cheffile, path, logger: Kitchen.logger)
|
44
44
|
@cheffile = cheffile
|
45
45
|
@path = path
|
46
46
|
@logger = logger
|
@@ -50,7 +50,7 @@ module Kitchen
|
|
50
50
|
#
|
51
51
|
# @param logger [Kitchen::Logger] a logger to use for output, defaults
|
52
52
|
# to `Kitchen.logger`
|
53
|
-
def self.load!(logger
|
53
|
+
def self.load!(logger: Kitchen.logger)
|
54
54
|
load_librarian!(logger)
|
55
55
|
end
|
56
56
|
|
@@ -44,17 +44,18 @@ module Kitchen
|
|
44
44
|
# cookbooks
|
45
45
|
# @param logger [Kitchen::Logger] a logger to use for output, defaults
|
46
46
|
# to `Kitchen.logger`
|
47
|
-
def initialize(policyfile, path, logger
|
47
|
+
def initialize(policyfile, path, logger: Kitchen.logger, always_update: false)
|
48
48
|
@policyfile = policyfile
|
49
49
|
@path = path
|
50
50
|
@logger = logger
|
51
|
+
@always_update = always_update
|
51
52
|
end
|
52
53
|
|
53
54
|
# Loads the library code required to use the resolver.
|
54
55
|
#
|
55
56
|
# @param logger [Kitchen::Logger] a logger to use for output, defaults
|
56
57
|
# to `Kitchen.logger`
|
57
|
-
def self.load!(logger
|
58
|
+
def self.load!(logger: Kitchen.logger)
|
58
59
|
detect_chef_command!(logger)
|
59
60
|
end
|
60
61
|
|
@@ -68,11 +69,26 @@ module Kitchen
|
|
68
69
|
# Runs `chef install` to determine the correct cookbook set and
|
69
70
|
# generate the policyfile lock.
|
70
71
|
def compile
|
71
|
-
|
72
|
-
|
72
|
+
if always_update
|
73
|
+
info("Updating policy lock using `chef update`")
|
74
|
+
run_command("chef update #{escape_path(policyfile)}")
|
75
|
+
end
|
76
|
+
if File.exist?(lockfile)
|
77
|
+
info("Installing cookbooks for Policyfile #{policyfile} using `chef install`")
|
78
|
+
else
|
79
|
+
info("Policy lock file doesn't exist, running `chef install` for "\
|
80
|
+
"Policyfile #{policyfile}...")
|
81
|
+
end
|
73
82
|
run_command("chef install #{escape_path(policyfile)}")
|
74
83
|
end
|
75
84
|
|
85
|
+
# Return the path to the lockfile corresponding to this policyfile.
|
86
|
+
#
|
87
|
+
# @return [String]
|
88
|
+
def lockfile
|
89
|
+
policyfile.gsub(/\.rb\Z/, ".lock.json")
|
90
|
+
end
|
91
|
+
|
76
92
|
private
|
77
93
|
|
78
94
|
# @return [String] path to a Berksfile
|
@@ -87,6 +103,10 @@ module Kitchen
|
|
87
103
|
# @api private
|
88
104
|
attr_reader :logger
|
89
105
|
|
106
|
+
# @return [Boolean] If true, always update cookbooks in the policy.
|
107
|
+
# @api private
|
108
|
+
attr_reader :always_update
|
109
|
+
|
90
110
|
# Ensure the `chef` command is in the path.
|
91
111
|
#
|
92
112
|
# @param logger [Kitchen::Logger] the logger to use
|
@@ -59,6 +59,9 @@ module Kitchen
|
|
59
59
|
# Will try to autodetect by searching for `Policyfile.rb` if not set.
|
60
60
|
# If set, will error if the file doesn't exist.
|
61
61
|
default_config :policyfile_path, nil
|
62
|
+
# If set to true (which is the default from `chef generate`), try to update
|
63
|
+
# backend cookbook downloader on every kitchen run.
|
64
|
+
default_config :always_update_cookbooks, false
|
62
65
|
default_config :cookbook_files_glob, %w[
|
63
66
|
README.* metadata.{json,rb}
|
64
67
|
attributes/**/* definitions/**/* files/**/* libraries/**/*
|
@@ -281,13 +284,13 @@ module Kitchen
|
|
281
284
|
super
|
282
285
|
if File.exist?(policyfile)
|
283
286
|
debug("Policyfile found at #{policyfile}, using Policyfile to resolve dependencies")
|
284
|
-
Chef::Policyfile.load!(logger)
|
287
|
+
Chef::Policyfile.load!(:logger => logger)
|
285
288
|
elsif File.exist?(berksfile)
|
286
289
|
debug("Berksfile found at #{berksfile}, loading Berkshelf")
|
287
|
-
Chef::Berkshelf.load!(logger)
|
290
|
+
Chef::Berkshelf.load!(:logger => logger)
|
288
291
|
elsif File.exist?(cheffile)
|
289
292
|
debug("Cheffile found at #{cheffile}, loading Librarian-Chef")
|
290
|
-
Chef::Librarian.load!(logger)
|
293
|
+
Chef::Librarian.load!(:logger => logger)
|
291
294
|
end
|
292
295
|
end
|
293
296
|
|
@@ -344,6 +347,11 @@ module Kitchen
|
|
344
347
|
installer.install_command
|
345
348
|
end
|
346
349
|
|
350
|
+
# Hook used in subclasses to indicate support for policyfiles.
|
351
|
+
#
|
352
|
+
# @abstract
|
353
|
+
# @return [Boolean]
|
354
|
+
# @api private
|
347
355
|
def supports_policyfile?
|
348
356
|
false
|
349
357
|
end
|
data/lib/kitchen/rake_tasks.rb
CHANGED
@@ -30,14 +30,14 @@ module Kitchen
|
|
30
30
|
# Creates Kitchen Rake tasks and allows the callee to configure it.
|
31
31
|
#
|
32
32
|
# @yield [self] gives itself to the block
|
33
|
-
def initialize
|
33
|
+
def initialize(cfg = {})
|
34
34
|
@loader = Kitchen::Loader::YAML.new(
|
35
35
|
:project_config => ENV["KITCHEN_YAML"],
|
36
36
|
:local_config => ENV["KITCHEN_LOCAL_YAML"],
|
37
37
|
:global_config => ENV["KITCHEN_GLOBAL_YAML"]
|
38
38
|
)
|
39
39
|
@config = Kitchen::Config.new(
|
40
|
-
:loader => @loader
|
40
|
+
{ :loader => @loader }.merge(cfg)
|
41
41
|
)
|
42
42
|
Kitchen.logger = Kitchen.default_file_logger(nil, false)
|
43
43
|
yield self if block_given?
|
@@ -84,13 +84,12 @@ module Kitchen
|
|
84
84
|
class Connection < Kitchen::Transport::Base::Connection
|
85
85
|
# (see Base::Connection#close)
|
86
86
|
def close
|
87
|
-
|
88
|
-
|
89
|
-
session.close
|
87
|
+
@unelevated_session.close if @unelevated_session
|
88
|
+
@elevated_session.close if @elevated_session
|
90
89
|
ensure
|
90
|
+
@unelevated_session = nil
|
91
|
+
@elevated_session = nil
|
91
92
|
@file_transporter = nil
|
92
|
-
@session = nil
|
93
|
-
@elevated_runner = nil
|
94
93
|
end
|
95
94
|
|
96
95
|
# (see Base::Connection#execute)
|
@@ -98,9 +97,6 @@ module Kitchen
|
|
98
97
|
return if command.nil?
|
99
98
|
logger.debug("[WinRM] #{self} (#{command})")
|
100
99
|
|
101
|
-
if command.length > MAX_COMMAND_SIZE
|
102
|
-
command = run_from_file_command(command)
|
103
|
-
end
|
104
100
|
exit_code, stderr = execute_with_exit_code(command)
|
105
101
|
|
106
102
|
if logger.debug? && exit_code == 0
|
@@ -137,7 +133,7 @@ module Kitchen
|
|
137
133
|
# (see Base::Connection#wait_until_ready)
|
138
134
|
def wait_until_ready
|
139
135
|
delay = 3
|
140
|
-
|
136
|
+
unelevated_session(
|
141
137
|
:retry_limit => max_wait_until_ready / delay,
|
142
138
|
:retry_delay => delay
|
143
139
|
)
|
@@ -148,11 +144,6 @@ module Kitchen
|
|
148
144
|
|
149
145
|
PING_COMMAND = "Write-Host '[WinRM] Established\n'".freeze
|
150
146
|
|
151
|
-
# Maximum string to send to the transport to execute. WinRM has an 8000 character
|
152
|
-
# command line limit. The original command string is coverted to a base 64 encoded
|
153
|
-
# UTF-16 string which will double the string size.
|
154
|
-
MAX_COMMAND_SIZE = 3000
|
155
|
-
|
156
147
|
# @return [Integer] how many times to retry when failing to execute
|
157
148
|
# a command or transfer files
|
158
149
|
# @api private
|
@@ -163,10 +154,6 @@ module Kitchen
|
|
163
154
|
# @api private
|
164
155
|
attr_reader :connection_retry_sleep
|
165
156
|
|
166
|
-
# @return [String] the endpoint URL of the remote WinRM host
|
167
|
-
# @api private
|
168
|
-
attr_reader :endpoint
|
169
|
-
|
170
157
|
# @return [String] display name for the associated instance
|
171
158
|
# @api private
|
172
159
|
attr_reader :instance_name
|
@@ -185,11 +172,6 @@ module Kitchen
|
|
185
172
|
# @api private
|
186
173
|
attr_reader :rdp_port
|
187
174
|
|
188
|
-
# @return [Symbol] the transport strategy to use when constructing a
|
189
|
-
# `WinRM::WinRMWebService`
|
190
|
-
# @api private
|
191
|
-
attr_reader :winrm_transport
|
192
|
-
|
193
175
|
# @return [Boolean] whether to use winrm-elevated for running commands
|
194
176
|
# @api private
|
195
177
|
attr_reader :elevated
|
@@ -202,7 +184,7 @@ module Kitchen
|
|
202
184
|
# @api private
|
203
185
|
def create_rdp_doc(opts = {})
|
204
186
|
content = Util.outdent!(<<-RDP)
|
205
|
-
full address:s:#{URI.parse(endpoint).host}:#{rdp_port}
|
187
|
+
full address:s:#{URI.parse(options[:endpoint]).host}:#{rdp_port}
|
206
188
|
prompt for credentials:i:1
|
207
189
|
username:s:#{options[:user]}
|
208
190
|
RDP
|
@@ -227,33 +209,26 @@ module Kitchen
|
|
227
209
|
# @api private
|
228
210
|
def execute_with_exit_code(command)
|
229
211
|
if elevated
|
230
|
-
|
231
|
-
|
232
|
-
end
|
233
|
-
response = elevated_runner.powershell_elevated(
|
234
|
-
command,
|
235
|
-
options[:elevated_username],
|
236
|
-
options[:elevated_password]
|
237
|
-
) do |stdout, _|
|
238
|
-
logger << stdout if stdout
|
239
|
-
end
|
212
|
+
session = elevated_session
|
213
|
+
command = "$env:temp='#{unelevated_temp_dir}';#{command}"
|
240
214
|
else
|
241
|
-
|
242
|
-
logger << stdout if stdout
|
243
|
-
end
|
215
|
+
session = unelevated_session
|
244
216
|
end
|
245
217
|
|
246
|
-
|
218
|
+
response = session.run(command) do |stdout, _|
|
219
|
+
logger << stdout if stdout
|
220
|
+
end
|
221
|
+
[response.exitcode, response.stderr]
|
247
222
|
end
|
248
223
|
|
249
224
|
def unelevated_temp_dir
|
250
|
-
@unelevated_temp_dir ||=
|
225
|
+
@unelevated_temp_dir ||= unelevated_session.run("$env:temp").stdout.chomp
|
251
226
|
end
|
252
227
|
|
253
228
|
# @return [Winrm::FileTransporter] a file transporter
|
254
229
|
# @api private
|
255
230
|
def file_transporter
|
256
|
-
@file_transporter ||= WinRM::FS::Core::FileTransporter.new(
|
231
|
+
@file_transporter ||= WinRM::FS::Core::FileTransporter.new(unelevated_session)
|
257
232
|
end
|
258
233
|
|
259
234
|
# (see Base#init_options)
|
@@ -261,9 +236,7 @@ module Kitchen
|
|
261
236
|
super
|
262
237
|
@instance_name = @options.delete(:instance_name)
|
263
238
|
@kitchen_root = @options.delete(:kitchen_root)
|
264
|
-
@endpoint = @options.delete(:endpoint)
|
265
239
|
@rdp_port = @options.delete(:rdp_port)
|
266
|
-
@winrm_transport = @options.delete(:winrm_transport)
|
267
240
|
@connection_retries = @options.delete(:connection_retries)
|
268
241
|
@connection_retry_sleep = @options.delete(:connection_retry_sleep)
|
269
242
|
@max_wait_until_ready = @options.delete(:max_wait_until_ready)
|
@@ -297,8 +270,8 @@ module Kitchen
|
|
297
270
|
# @api private
|
298
271
|
def login_command_for_linux
|
299
272
|
args = %W[-u #{options[:user]}]
|
300
|
-
args += %W[-p #{options[:
|
301
|
-
args += %W[#{URI.parse(endpoint).host}:#{rdp_port}]
|
273
|
+
args += %W[-p #{options[:password]}] if options.key?(:password)
|
274
|
+
args += %W[#{URI.parse(options[:endpoint]).host}:#{rdp_port}]
|
302
275
|
|
303
276
|
LoginCommand.new("rdesktop", args)
|
304
277
|
end
|
@@ -333,36 +306,40 @@ module Kitchen
|
|
333
306
|
# the first time.
|
334
307
|
#
|
335
308
|
# @param retry_options [Hash] retry options for the initial connection
|
336
|
-
# @return [Winrm::
|
309
|
+
# @return [Winrm::Shells::Powershell] the command shell session
|
337
310
|
# @api private
|
338
|
-
def
|
339
|
-
@
|
311
|
+
def unelevated_session(retry_options = {})
|
312
|
+
@unelevated_session ||= connection(retry_options).shell(:powershell)
|
340
313
|
end
|
341
314
|
|
342
|
-
# Creates
|
315
|
+
# Creates an elevated session for running commands via a scheduled task
|
343
316
|
#
|
344
|
-
# @return [Winrm::Elevated
|
317
|
+
# @return [Winrm::Shells::Elevated] the elevated shell
|
345
318
|
# @api private
|
346
|
-
def
|
347
|
-
@
|
319
|
+
def elevated_session(retry_options = {})
|
320
|
+
@elevated_session ||= begin
|
321
|
+
connection(retry_options).shell(:elevated).tap do |shell|
|
322
|
+
shell.username = options[:elevated_username]
|
323
|
+
shell.password = options[:elevated_password]
|
324
|
+
end
|
325
|
+
end
|
348
326
|
end
|
349
327
|
|
350
|
-
# Creates a winrm
|
328
|
+
# Creates a winrm Connection instance
|
351
329
|
#
|
352
330
|
# @param retry_options [Hash] retry options for the initial connection
|
353
|
-
# @return [Winrm::
|
331
|
+
# @return [Winrm::Connection] the winrm connection
|
354
332
|
# @api private
|
355
|
-
def
|
356
|
-
@
|
333
|
+
def connection(retry_options = {})
|
334
|
+
@connection ||= begin
|
357
335
|
opts = {
|
358
336
|
:retry_limit => connection_retries.to_i,
|
359
337
|
:retry_delay => connection_retry_sleep.to_i
|
360
338
|
}.merge(retry_options)
|
361
339
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
svc
|
340
|
+
::WinRM::Connection.new(options.merge(opts)).tap do |conn|
|
341
|
+
conn.logger = logger
|
342
|
+
end
|
366
343
|
end
|
367
344
|
end
|
368
345
|
|
@@ -371,40 +348,15 @@ module Kitchen
|
|
371
348
|
#
|
372
349
|
# @api private
|
373
350
|
def to_s
|
374
|
-
"
|
375
|
-
end
|
376
|
-
|
377
|
-
# takes a long (greater than 3000 characters) command and saves it to a
|
378
|
-
# file and uploads it to the test instance.
|
379
|
-
#
|
380
|
-
# @param command [String] a long command to be saved and uploaded
|
381
|
-
# @return [String] a command that executes the uploaded script
|
382
|
-
# @api private
|
383
|
-
def run_from_file_command(command)
|
384
|
-
temp_dir = Dir.mktmpdir("kitchen-long-script")
|
385
|
-
begin
|
386
|
-
script_name = "#{instance_name}-long_script.ps1"
|
387
|
-
script_path = File.join(temp_dir, script_name)
|
388
|
-
|
389
|
-
File.open(script_path, "wb") do |file|
|
390
|
-
file.write(command)
|
391
|
-
end
|
392
|
-
|
393
|
-
target_path = File.join("$env:TEMP", script_name)
|
394
|
-
upload(script_path, target_path)
|
395
|
-
|
396
|
-
%{powershell -ExecutionPolicy Bypass -File "#{target_path}"}
|
397
|
-
ensure
|
398
|
-
FileUtils.rmtree(temp_dir)
|
399
|
-
end
|
351
|
+
"<#{options.inspect}>"
|
400
352
|
end
|
401
353
|
end
|
402
354
|
|
403
355
|
private
|
404
356
|
|
405
|
-
WINRM_SPEC_VERSION = ["~>
|
406
|
-
WINRM_FS_SPEC_VERSION = ["~> 0
|
407
|
-
WINRM_ELEVATED_SPEC_VERSION = ["~>
|
357
|
+
WINRM_SPEC_VERSION = ["~> 2.0"].freeze
|
358
|
+
WINRM_FS_SPEC_VERSION = ["~> 1.0"].freeze
|
359
|
+
WINRM_ELEVATED_SPEC_VERSION = ["~> 1.0"].freeze
|
408
360
|
|
409
361
|
# Builds the hash of options needed by the Connection object on
|
410
362
|
# construction.
|
@@ -422,17 +374,17 @@ module Kitchen
|
|
422
374
|
:logger => logger,
|
423
375
|
:endpoint => data[:endpoint_template] % data,
|
424
376
|
:user => data[:username],
|
425
|
-
:
|
377
|
+
:password => data[:password],
|
426
378
|
:rdp_port => data[:rdp_port],
|
427
379
|
:connection_retries => data[:connection_retries],
|
428
380
|
:connection_retry_sleep => data[:connection_retry_sleep],
|
429
381
|
:max_wait_until_ready => data[:max_wait_until_ready],
|
430
|
-
:
|
382
|
+
:transport => data[:winrm_transport],
|
431
383
|
:elevated => data[:elevated],
|
432
384
|
:elevated_username => data[:elevated_username] || data[:username],
|
433
385
|
:elevated_password => elevated_password
|
434
386
|
}
|
435
|
-
opts.merge!(additional_transport_args(opts[:
|
387
|
+
opts.merge!(additional_transport_args(opts[:transport]))
|
436
388
|
opts
|
437
389
|
end
|
438
390
|
|
data/lib/kitchen/version.rb
CHANGED
@@ -27,7 +27,7 @@ describe Kitchen::Provisioner::Chef::Policyfile do
|
|
27
27
|
:debug => nil, :banner => nil)
|
28
28
|
end
|
29
29
|
let(:described_object) do
|
30
|
-
Kitchen::Provisioner::Chef::Policyfile.new(policyfile, path, null_logger)
|
30
|
+
Kitchen::Provisioner::Chef::Policyfile.new(policyfile, path, :logger => null_logger)
|
31
31
|
end
|
32
32
|
let(:os) { "" }
|
33
33
|
before do
|
@@ -895,7 +895,11 @@ describe Kitchen::Provisioner::ChefBase do
|
|
895
895
|
|
896
896
|
describe "with a Policyfile under kitchen_root" do
|
897
897
|
|
898
|
-
let(:
|
898
|
+
let(:policyfile_path) { "#{kitchen_root}/Policyfile.rb" }
|
899
|
+
let(:policyfile_lock_path) { "#{kitchen_root}/Policyfile.lock.json" }
|
900
|
+
let(:resolver) {
|
901
|
+
stub(:compile => true, :resolve => true, :lockfile => policyfile_lock_path)
|
902
|
+
}
|
899
903
|
|
900
904
|
describe "with the default name `Policyfile.rb`" do
|
901
905
|
before do
|
@@ -948,13 +952,14 @@ POLICYFILE
|
|
948
952
|
end
|
949
953
|
|
950
954
|
it "uses uses the policyfile to resolve dependencies" do
|
955
|
+
resolver.expects(:compile)
|
951
956
|
resolver.expects(:resolve)
|
952
957
|
|
953
958
|
provisioner.create_sandbox
|
954
959
|
end
|
955
960
|
|
956
961
|
it "uses Kitchen.mutex for resolving" do
|
957
|
-
Kitchen.mutex.expects(:synchronize)
|
962
|
+
Kitchen.mutex.expects(:synchronize).twice
|
958
963
|
|
959
964
|
provisioner.create_sandbox
|
960
965
|
end
|
@@ -1014,6 +1019,7 @@ POLICYFILE
|
|
1014
1019
|
|
1015
1020
|
it "uses uses the policyfile to resolve dependencies" do
|
1016
1021
|
Kitchen::Provisioner::Chef::Policyfile.stubs(:load!)
|
1022
|
+
resolver.expects(:compile)
|
1017
1023
|
resolver.expects(:resolve)
|
1018
1024
|
|
1019
1025
|
provisioner.create_sandbox
|
@@ -1026,6 +1032,7 @@ POLICYFILE
|
|
1026
1032
|
returns(resolver)
|
1027
1033
|
|
1028
1034
|
Kitchen::Provisioner::Chef::Policyfile.stubs(:load!)
|
1035
|
+
resolver.expects(:compile)
|
1029
1036
|
resolver.expects(:resolve)
|
1030
1037
|
|
1031
1038
|
provisioner.create_sandbox
|
@@ -1095,6 +1102,7 @@ POLICYFILE
|
|
1095
1102
|
|
1096
1103
|
it "uses uses the policyfile to resolve dependencies" do
|
1097
1104
|
Kitchen::Provisioner::Chef::Policyfile.stubs(:load!)
|
1105
|
+
resolver.expects(:compile)
|
1098
1106
|
resolver.expects(:resolve)
|
1099
1107
|
|
1100
1108
|
provisioner.create_sandbox
|
@@ -1107,6 +1115,7 @@ POLICYFILE
|
|
1107
1115
|
returns(resolver)
|
1108
1116
|
|
1109
1117
|
Kitchen::Provisioner::Chef::Policyfile.stubs(:load!)
|
1118
|
+
resolver.expects(:compile)
|
1110
1119
|
resolver.expects(:resolve)
|
1111
1120
|
|
1112
1121
|
provisioner.create_sandbox
|
@@ -124,6 +124,7 @@ describe Kitchen::Transport::Winrm do
|
|
124
124
|
before do
|
125
125
|
config[:hostname] = "here"
|
126
126
|
config[:kitchen_root] = "/i/am/root"
|
127
|
+
config[:password] = "password"
|
127
128
|
end
|
128
129
|
|
129
130
|
it "returns a Kitchen::Transport::Winrm::Connection object" do
|
@@ -155,7 +156,7 @@ describe Kitchen::Transport::Winrm do
|
|
155
156
|
|
156
157
|
it "sets the :winrm_transport to :negotiate" do
|
157
158
|
klass.expects(:new).with do |hash|
|
158
|
-
hash[:
|
159
|
+
hash[:transport] == :negotiate
|
159
160
|
end
|
160
161
|
|
161
162
|
make_connection
|
@@ -220,7 +221,7 @@ describe Kitchen::Transport::Winrm do
|
|
220
221
|
config[:password] = "pass_from_config"
|
221
222
|
|
222
223
|
klass.expects(:new).with do |hash|
|
223
|
-
hash[:
|
224
|
+
hash[:password] == "pass_from_config"
|
224
225
|
end
|
225
226
|
|
226
227
|
make_connection
|
@@ -231,7 +232,7 @@ describe Kitchen::Transport::Winrm do
|
|
231
232
|
config[:password] = "pass_from_config"
|
232
233
|
|
233
234
|
klass.expects(:new).with do |hash|
|
234
|
-
hash[:
|
235
|
+
hash[:password] == "pass_from_state"
|
235
236
|
end
|
236
237
|
|
237
238
|
make_connection
|
@@ -325,7 +326,7 @@ describe Kitchen::Transport::Winrm do
|
|
325
326
|
config[:winrm_transport] = "ssl"
|
326
327
|
|
327
328
|
klass.expects(:new).with do |hash|
|
328
|
-
hash[:
|
329
|
+
hash[:transport] == :ssl
|
329
330
|
end
|
330
331
|
|
331
332
|
make_connection
|
@@ -392,7 +393,7 @@ describe Kitchen::Transport::Winrm do
|
|
392
393
|
it "sets :winrm_transport to negotiate" do
|
393
394
|
|
394
395
|
klass.expects(:new).with do |hash|
|
395
|
-
hash[:
|
396
|
+
hash[:transport] == :negotiate &&
|
396
397
|
hash[:disable_sspi] == false &&
|
397
398
|
hash[:basic_auth_only] == false
|
398
399
|
end
|
@@ -629,26 +630,31 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
629
630
|
let(:logger) { Logger.new(logged_output) }
|
630
631
|
|
631
632
|
let(:options) do
|
632
|
-
{ :logger => logger, :user => "me", :
|
633
|
+
{ :logger => logger, :user => "me", :password => "haha",
|
633
634
|
:endpoint => "http://foo:5985/wsman", :winrm_transport => :plaintext,
|
634
635
|
:kitchen_root => "/i/am/root", :instance_name => "coolbeans",
|
635
636
|
:rdp_port => "rdpyeah" }
|
636
637
|
end
|
637
638
|
|
638
639
|
let(:info) do
|
639
|
-
copts = {
|
640
|
-
|
640
|
+
copts = {
|
641
|
+
:user => "me",
|
642
|
+
:password => "haha",
|
643
|
+
:endpoint => "http://foo:5985/wsman",
|
644
|
+
:winrm_transport => :plaintext
|
645
|
+
}
|
646
|
+
"<#{copts}>"
|
641
647
|
end
|
642
648
|
|
643
649
|
let(:winrm_session) do
|
644
650
|
s = mock("winrm_session")
|
645
|
-
s.responds_like_instance_of(::WinRM::
|
651
|
+
s.responds_like_instance_of(::WinRM::Connection)
|
646
652
|
s
|
647
653
|
end
|
648
654
|
|
649
655
|
let(:executor) do
|
650
656
|
s = mock("command_executor")
|
651
|
-
s.responds_like_instance_of(WinRM::
|
657
|
+
s.responds_like_instance_of(WinRM::Shells::Powershell)
|
652
658
|
s
|
653
659
|
end
|
654
660
|
|
@@ -660,7 +666,7 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
660
666
|
|
661
667
|
let(:elevated_runner) do
|
662
668
|
r = mock("elevated_runner")
|
663
|
-
r.responds_like_instance_of(WinRM::Elevated
|
669
|
+
r.responds_like_instance_of(WinRM::Shells::Elevated)
|
664
670
|
r
|
665
671
|
end
|
666
672
|
|
@@ -669,7 +675,7 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
669
675
|
end
|
670
676
|
|
671
677
|
before do
|
672
|
-
WinRM::
|
678
|
+
WinRM::Connection.stubs(:new).returns(winrm_session)
|
673
679
|
winrm_session.stubs(:logger=)
|
674
680
|
logger.level = Logger::DEBUG
|
675
681
|
end
|
@@ -678,18 +684,21 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
678
684
|
|
679
685
|
let(:response) do
|
680
686
|
o = WinRM::Output.new
|
681
|
-
o
|
682
|
-
o
|
687
|
+
o.exitcode = 0
|
688
|
+
o << { :stdout => "ok\r\n" }
|
683
689
|
o
|
684
690
|
end
|
685
691
|
|
686
692
|
before do
|
687
|
-
winrm_session.stubs(:create_executor).returns(executor)
|
688
693
|
transporter.stubs(:upload)
|
689
|
-
elevated_runner.stubs(:
|
694
|
+
elevated_runner.stubs(:run).returns(response)
|
695
|
+
winrm_session.stubs(:shell).with(:powershell).returns(executor)
|
690
696
|
executor.stubs(:close)
|
691
|
-
|
697
|
+
elevated_runner.stubs(:close)
|
698
|
+
executor.stubs(:run).
|
692
699
|
with("doit").yields("ok\n", nil).returns(response)
|
700
|
+
executor.stubs(:run).
|
701
|
+
with("$env:temp").yields("ok\n", nil).returns(response)
|
693
702
|
end
|
694
703
|
|
695
704
|
it "only closes the shell once for multiple calls" do
|
@@ -711,9 +720,10 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
711
720
|
|
712
721
|
it "clears the elevated_runner executor" do
|
713
722
|
options[:elevated] = true
|
714
|
-
|
715
|
-
|
716
|
-
|
723
|
+
elevated_runner.stubs(:username=)
|
724
|
+
elevated_runner.stubs(:password=)
|
725
|
+
elevated_runner.expects(:close).once
|
726
|
+
winrm_session.expects(:shell).with(:elevated).returns(elevated_runner).twice
|
717
727
|
|
718
728
|
connection.execute("doit")
|
719
729
|
connection.close
|
@@ -724,23 +734,21 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
724
734
|
describe "#execute" do
|
725
735
|
|
726
736
|
before do
|
727
|
-
winrm_session.stubs(:
|
737
|
+
winrm_session.stubs(:shell).with(:powershell).returns(executor)
|
728
738
|
end
|
729
739
|
|
730
740
|
describe "for a successful command" do
|
731
741
|
|
732
742
|
let(:response) do
|
733
743
|
o = WinRM::Output.new
|
734
|
-
o
|
735
|
-
o
|
736
|
-
|
737
|
-
{ :stderr => "congrats\r\n" }
|
738
|
-
])
|
744
|
+
o.exitcode = 0
|
745
|
+
o << { :stdout => "ok\r\n" }
|
746
|
+
o << { :stderr => "congrats\r\n" }
|
739
747
|
o
|
740
748
|
end
|
741
749
|
|
742
750
|
before do
|
743
|
-
executor.expects(:
|
751
|
+
executor.expects(:run).
|
744
752
|
with("doit").yields("ok\n", nil).returns(response)
|
745
753
|
end
|
746
754
|
|
@@ -775,39 +783,40 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
775
783
|
describe "elevated command" do
|
776
784
|
let(:response) do
|
777
785
|
o = WinRM::Output.new
|
778
|
-
o
|
779
|
-
o
|
780
|
-
|
781
|
-
{ :stderr => "congrats\r\n" }
|
782
|
-
])
|
786
|
+
o.exitcode = 0
|
787
|
+
o << { :stdout => "ok\r\n" }
|
788
|
+
o << { :stderr => "congrats\r\n" }
|
783
789
|
o
|
784
790
|
end
|
785
791
|
let(:env_temp_response) do
|
786
792
|
o = WinRM::Output.new
|
787
|
-
o
|
788
|
-
o
|
789
|
-
{ :stdout => "temp_dir" }
|
790
|
-
])
|
793
|
+
o.exitcode = 0
|
794
|
+
o << { :stdout => "temp_dir" }
|
791
795
|
o
|
792
796
|
end
|
797
|
+
let(:elevated_runner) do
|
798
|
+
r = mock("elevated_runner")
|
799
|
+
r.responds_like_instance_of(WinRM::Shells::Elevated)
|
800
|
+
r
|
801
|
+
end
|
793
802
|
|
794
803
|
before do
|
795
804
|
options[:elevated] = true
|
796
|
-
|
805
|
+
winrm_session.stubs(:shell).with(:elevated).returns(elevated_runner)
|
797
806
|
end
|
798
807
|
|
799
808
|
describe "elevated user is not login user" do
|
800
809
|
before do
|
801
810
|
options[:elevated_username] = "username"
|
802
811
|
options[:elevated_password] = "password"
|
803
|
-
executor.expects(:
|
812
|
+
executor.expects(:run).
|
804
813
|
with("$env:temp").returns(env_temp_response)
|
805
|
-
elevated_runner.expects(:
|
814
|
+
elevated_runner.expects(:run).
|
806
815
|
with(
|
807
|
-
"$env:temp='temp_dir';doit"
|
808
|
-
options[:elevated_username],
|
809
|
-
options[:elevated_password]
|
816
|
+
"$env:temp='temp_dir';doit"
|
810
817
|
).yields("ok\n", nil).returns(response)
|
818
|
+
elevated_runner.expects(:username=).with("username")
|
819
|
+
elevated_runner.expects(:password=).with("password")
|
811
820
|
end
|
812
821
|
|
813
822
|
it "logger captures stdout" do
|
@@ -817,16 +826,18 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
817
826
|
end
|
818
827
|
end
|
819
828
|
|
820
|
-
describe "
|
829
|
+
describe "elevated user is login user" do
|
821
830
|
before do
|
822
831
|
options[:elevated_username] = options[:user]
|
823
|
-
options[:elevated_password] = options[:
|
824
|
-
|
832
|
+
options[:elevated_password] = options[:password]
|
833
|
+
executor.expects(:run).
|
834
|
+
with("$env:temp").returns(env_temp_response)
|
835
|
+
elevated_runner.expects(:run).
|
825
836
|
with(
|
826
|
-
"doit"
|
827
|
-
options[:elevated_username],
|
828
|
-
options[:elevated_password]
|
837
|
+
"$env:temp='temp_dir';doit"
|
829
838
|
).yields("ok\n", nil).returns(response)
|
839
|
+
elevated_runner.expects(:username=).with(options[:user])
|
840
|
+
elevated_runner.expects(:password=).with(options[:password])
|
830
841
|
end
|
831
842
|
|
832
843
|
it "logger captures stdout" do
|
@@ -837,69 +848,35 @@ describe Kitchen::Transport::Winrm::Connection do
|
|
837
848
|
end
|
838
849
|
end
|
839
850
|
|
840
|
-
describe "long command" do
|
841
|
-
let(:command) { %{Write-Host "#{"a" * 4000}"} }
|
842
|
-
|
843
|
-
let(:connection) do
|
844
|
-
Kitchen::Transport::WinRMConnectionDummy.new(options)
|
845
|
-
end
|
846
|
-
|
847
|
-
let(:response) do
|
848
|
-
o = WinRM::Output.new
|
849
|
-
o[:exitcode] = 0
|
850
|
-
o[:data].concat([
|
851
|
-
{ :stdout => "ok\r\n" },
|
852
|
-
{ :stderr => "congrats\r\n" }
|
853
|
-
])
|
854
|
-
o
|
855
|
-
end
|
856
|
-
|
857
|
-
before do
|
858
|
-
executor.expects(:run_powershell_script).with(
|
859
|
-
%{powershell -ExecutionPolicy Bypass -File "$env:TEMP/coolbeans-long_script.ps1"}
|
860
|
-
).yields("ok\n", nil).returns(response)
|
861
|
-
end
|
862
|
-
|
863
|
-
it "uploads the long command" do
|
864
|
-
with_fake_fs do
|
865
|
-
connection.execute(command)
|
866
|
-
|
867
|
-
connection.saved_command.must_equal command
|
868
|
-
end
|
869
|
-
end
|
870
|
-
end
|
871
|
-
|
872
851
|
describe "for a failed command" do
|
873
852
|
|
874
853
|
let(:response) do
|
875
854
|
o = WinRM::Output.new
|
876
|
-
o
|
877
|
-
o
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
{ :stderr => "S></Objs>" }
|
897
|
-
])
|
855
|
+
o.exitcode = 1
|
856
|
+
o << { :stderr => "#< CLIXML\r\n" }
|
857
|
+
o << { :stderr => "<Objs Version=\"1.1.0.1\" xmlns=\"http://schemas." }
|
858
|
+
o << { :stderr => "microsoft.com/powershell/2004/04\"><S S=\"Error\">" }
|
859
|
+
o << { :stderr => "doit : The term 'doit' is not recognized as the " }
|
860
|
+
o << { :stderr => "name of a cmdlet, function, _x000D__x000A_</S>" }
|
861
|
+
o << { :stderr => "<S S=\"Error\">script file, or operable program. " }
|
862
|
+
o << { :stderr => "Check the spelling of" }
|
863
|
+
o << { :stderr => "the name, or if a path _x000D__x000A_</S><S S=\"E" }
|
864
|
+
o << { :stderr => "rror\">was included, verify that the path is corr" }
|
865
|
+
o << { :stderr => "ect and try again._x000D__x000A_</S><S S=\"Error" }
|
866
|
+
o << { :stderr => "\">At line:1 char:1_x000D__x000A_</S><S S=\"Error" }
|
867
|
+
o << { :stderr => "\">+ doit_x000D__x000A_</S><S S=\"Error\">+ ~~~~_" }
|
868
|
+
o << { :stderr => "x000D__x000A_</S><S S=\"Error\"> + CategoryInf" }
|
869
|
+
o << { :stderr => "o : ObjectNotFound: (doit:String) [], Co" }
|
870
|
+
o << { :stderr => "mmandNotFoun _x000D__x000A_</S><S S=\"Error\"> " }
|
871
|
+
o << { :stderr => "dException_x000D__x000A_</S><S S=\"Error\"> + " }
|
872
|
+
o << { :stderr => "FullyQualifiedErrorId : CommandNotFoundException_" }
|
873
|
+
o << { :stderr => "x000D__x000A_</S><S S=\"Error\"> _x000D__x000A_</" }
|
874
|
+
o << { :stderr => "S></Objs>" }
|
898
875
|
o
|
899
876
|
end
|
900
877
|
|
901
878
|
before do
|
902
|
-
executor.expects(:
|
879
|
+
executor.expects(:run).
|
903
880
|
with("doit").yields("nope\n", nil).returns(response)
|
904
881
|
end
|
905
882
|
|
@@ -1002,7 +979,7 @@ MSG
|
|
1002
979
|
|
1003
980
|
options[:connection_retries] = 3
|
1004
981
|
options[:connection_retry_sleep] = 7
|
1005
|
-
winrm_session.stubs(:
|
982
|
+
winrm_session.stubs(:shell).with(:powershell).raises(k)
|
1006
983
|
end
|
1007
984
|
|
1008
985
|
it "reraises the #{klass} exception" do
|
@@ -1160,7 +1137,7 @@ MSG
|
|
1160
1137
|
end
|
1161
1138
|
|
1162
1139
|
it "won't set the pass if not given" do
|
1163
|
-
options.delete(:
|
1140
|
+
options.delete(:password)
|
1164
1141
|
|
1165
1142
|
args.wont_match regexify(" -p haha ")
|
1166
1143
|
end
|
@@ -1183,7 +1160,7 @@ MSG
|
|
1183
1160
|
describe "#upload" do
|
1184
1161
|
|
1185
1162
|
before do
|
1186
|
-
winrm_session.stubs(:
|
1163
|
+
winrm_session.stubs(:shell).with(:powershell).returns(executor)
|
1187
1164
|
|
1188
1165
|
WinRM::FS::Core::FileTransporter.stubs(:new).
|
1189
1166
|
with(executor).returns(transporter)
|
@@ -1234,7 +1211,7 @@ MSG
|
|
1234
1211
|
describe "#wait_until_ready" do
|
1235
1212
|
|
1236
1213
|
before do
|
1237
|
-
winrm_session.stubs(:
|
1214
|
+
winrm_session.stubs(:shell).with(:powershell).returns(executor)
|
1238
1215
|
options[:max_wait_until_ready] = 300
|
1239
1216
|
end
|
1240
1217
|
|
@@ -1242,13 +1219,13 @@ MSG
|
|
1242
1219
|
|
1243
1220
|
let(:response) do
|
1244
1221
|
o = WinRM::Output.new
|
1245
|
-
o
|
1246
|
-
o
|
1222
|
+
o.exitcode = 0
|
1223
|
+
o << { :stdout => "[WinRM] Established\r\n" }
|
1247
1224
|
o
|
1248
1225
|
end
|
1249
1226
|
|
1250
1227
|
before do
|
1251
|
-
executor.expects(:
|
1228
|
+
executor.expects(:run).
|
1252
1229
|
with("Write-Host '[WinRM] Established\n'").returns(response)
|
1253
1230
|
end
|
1254
1231
|
|
@@ -1261,13 +1238,13 @@ MSG
|
|
1261
1238
|
|
1262
1239
|
let(:response) do
|
1263
1240
|
o = WinRM::Output.new
|
1264
|
-
o
|
1265
|
-
o
|
1241
|
+
o.exitcode = 42
|
1242
|
+
o << { :stderr => "Ah crap.\r\n" }
|
1266
1243
|
o
|
1267
1244
|
end
|
1268
1245
|
|
1269
1246
|
before do
|
1270
|
-
executor.expects(:
|
1247
|
+
executor.expects(:run).
|
1271
1248
|
with("Write-Host '[WinRM] Established\n'").returns(response)
|
1272
1249
|
end
|
1273
1250
|
|
data/test-kitchen.gemspec
CHANGED
@@ -36,9 +36,9 @@ Gem::Specification.new do |gem|
|
|
36
36
|
gem.add_development_dependency "pry-stack_explorer"
|
37
37
|
gem.add_development_dependency "rb-readline"
|
38
38
|
gem.add_development_dependency "overcommit", "= 0.33.0"
|
39
|
-
gem.add_development_dependency "winrm", "~>
|
40
|
-
gem.add_development_dependency "winrm-elevated", "~>
|
41
|
-
gem.add_development_dependency "winrm-fs", "~> 0
|
39
|
+
gem.add_development_dependency "winrm", "~> 2.0"
|
40
|
+
gem.add_development_dependency "winrm-elevated", "~> 1.0"
|
41
|
+
gem.add_development_dependency "winrm-fs", "~> 1.0"
|
42
42
|
|
43
43
|
gem.add_development_dependency "bundler", "~> 1.3"
|
44
44
|
gem.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-kitchen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fletcher Nichol
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -202,42 +202,42 @@ dependencies:
|
|
202
202
|
requirements:
|
203
203
|
- - "~>"
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version: '
|
205
|
+
version: '2.0'
|
206
206
|
type: :development
|
207
207
|
prerelease: false
|
208
208
|
version_requirements: !ruby/object:Gem::Requirement
|
209
209
|
requirements:
|
210
210
|
- - "~>"
|
211
211
|
- !ruby/object:Gem::Version
|
212
|
-
version: '
|
212
|
+
version: '2.0'
|
213
213
|
- !ruby/object:Gem::Dependency
|
214
214
|
name: winrm-elevated
|
215
215
|
requirement: !ruby/object:Gem::Requirement
|
216
216
|
requirements:
|
217
217
|
- - "~>"
|
218
218
|
- !ruby/object:Gem::Version
|
219
|
-
version:
|
219
|
+
version: '1.0'
|
220
220
|
type: :development
|
221
221
|
prerelease: false
|
222
222
|
version_requirements: !ruby/object:Gem::Requirement
|
223
223
|
requirements:
|
224
224
|
- - "~>"
|
225
225
|
- !ruby/object:Gem::Version
|
226
|
-
version:
|
226
|
+
version: '1.0'
|
227
227
|
- !ruby/object:Gem::Dependency
|
228
228
|
name: winrm-fs
|
229
229
|
requirement: !ruby/object:Gem::Requirement
|
230
230
|
requirements:
|
231
231
|
- - "~>"
|
232
232
|
- !ruby/object:Gem::Version
|
233
|
-
version: 0
|
233
|
+
version: '1.0'
|
234
234
|
type: :development
|
235
235
|
prerelease: false
|
236
236
|
version_requirements: !ruby/object:Gem::Requirement
|
237
237
|
requirements:
|
238
238
|
- - "~>"
|
239
239
|
- !ruby/object:Gem::Version
|
240
|
-
version: 0
|
240
|
+
version: '1.0'
|
241
241
|
- !ruby/object:Gem::Dependency
|
242
242
|
name: bundler
|
243
243
|
requirement: !ruby/object:Gem::Requirement
|