test-kitchen 1.23.3 → 1.23.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kitchen/version.rb +1 -1
  3. data/support/chef-client-zero.rb +1 -1
  4. metadata +5 -324
  5. data/.gitattributes +0 -3
  6. data/.github/ISSUE_TEMPLATE.md +0 -56
  7. data/.github/lock.yml +0 -1
  8. data/.gitignore +0 -38
  9. data/.gitmodules +0 -0
  10. data/.kitchen.appveyor.yml +0 -25
  11. data/.kitchen.dokken.yml +0 -31
  12. data/.kitchen.proxy.yml +0 -27
  13. data/.rubocop.yml +0 -5
  14. data/.travis.yml +0 -57
  15. data/.yardopts +0 -3
  16. data/Berksfile +0 -3
  17. data/CHANGELOG.md +0 -1510
  18. data/CONTRIBUTING.md +0 -14
  19. data/ECOSYSTEM.md +0 -93
  20. data/Gemfile +0 -40
  21. data/Gemfile.proxy_tests +0 -4
  22. data/Guardfile +0 -42
  23. data/MAINTAINERS.md +0 -29
  24. data/README.md +0 -138
  25. data/RELEASE_NOTES.md +0 -167
  26. data/Rakefile +0 -77
  27. data/appveyor.yml +0 -47
  28. data/docs/CONTRIBUTING.md +0 -8
  29. data/docs/LICENSE +0 -22
  30. data/docs/README.md +0 -78
  31. data/docs/archetypes/default.md +0 -6
  32. data/docs/config.toml +0 -36
  33. data/docs/content/docs/_index.md +0 -5
  34. data/docs/content/docs/drivers/_index.md +0 -27
  35. data/docs/content/docs/drivers/azurerm.md +0 -44
  36. data/docs/content/docs/drivers/vagrant.md +0 -39
  37. data/docs/content/docs/getting-started/00-introduction.md +0 -14
  38. data/docs/content/docs/getting-started/01-installing.md +0 -64
  39. data/docs/content/docs/getting-started/02-getting-help.md +0 -59
  40. data/docs/content/docs/getting-started/03-creating-cookbook.md +0 -46
  41. data/docs/content/docs/getting-started/04-kitchen-yml.md +0 -56
  42. data/docs/content/docs/getting-started/05-instances.md +0 -79
  43. data/docs/content/docs/getting-started/06-writing-recipe.md +0 -21
  44. data/docs/content/docs/getting-started/07-running-converge.md +0 -134
  45. data/docs/content/docs/getting-started/08-manually-verifying.md +0 -55
  46. data/docs/content/docs/getting-started/09-writing-test.md +0 -49
  47. data/docs/content/docs/getting-started/10-running-verify.md +0 -120
  48. data/docs/content/docs/getting-started/11-running-test.md +0 -168
  49. data/docs/content/docs/getting-started/12-adding-platform.md +0 -206
  50. data/docs/content/docs/getting-started/13-adding-feature.md +0 -30
  51. data/docs/content/docs/getting-started/14-adding-suite.md +0 -60
  52. data/docs/content/docs/getting-started/15-adding-test.md +0 -66
  53. data/docs/content/docs/getting-started/16-adding-recipe.md +0 -53
  54. data/docs/content/docs/getting-started/17-excluding-platforms.md +0 -101
  55. data/docs/content/docs/getting-started/18-next-steps.md +0 -23
  56. data/docs/content/docs/getting-started/_index.md +0 -5
  57. data/docs/content/docs/provisioners/_index.md +0 -36
  58. data/docs/content/docs/provisioners/chef.md +0 -69
  59. data/docs/content/docs/provisioners/shell.md +0 -31
  60. data/docs/content/docs/reference/_index.md +0 -5
  61. data/docs/content/docs/reference/configuration.md +0 -53
  62. data/docs/content/docs/reference/examples.md +0 -97
  63. data/docs/content/docs/reference/faq.md +0 -58
  64. data/docs/content/docs/reference/fixtures.md +0 -32
  65. data/docs/content/docs/reference/glossary.md +0 -34
  66. data/docs/content/docs/reference/lifecycle-hooks.md +0 -68
  67. data/docs/content/docs/reference/reboots.md +0 -24
  68. data/docs/content/docs/verifiers/_index.md +0 -14
  69. data/docs/content/docs/verifiers/inspec.md +0 -44
  70. data/docs/content/docs/verifiers/serverspec.md +0 -20
  71. data/docs/static/images/chef-logo.png +0 -0
  72. data/docs/static/images/chef-logo.svg +0 -1
  73. data/docs/static/images/github-banner.png +0 -0
  74. data/docs/static/images/github-banner.svg +0 -71
  75. data/docs/static/images/kitchen-logo.png +0 -0
  76. data/docs/static/images/logo-block.svg +0 -222
  77. data/docs/static/images/logo.png +0 -0
  78. data/docs/static/images/logos-group.png +0 -0
  79. data/docs/static/images/terminal-1.png +0 -0
  80. data/docs/static/images/terminal-1.svg +0 -589
  81. data/docs/static/images/terminal-2.png +0 -0
  82. data/docs/static/images/terminal-2.svg +0 -235
  83. data/docs/static/images/terminal-3.png +0 -0
  84. data/docs/static/images/terminal-3.svg +0 -439
  85. data/docs/static/index.html +0 -59
  86. data/docs/static/javascripts/all.js +0 -348
  87. data/docs/static/javascripts/vendor/foundation.min.js +0 -4
  88. data/docs/static/javascripts/vendor/jquery.min.js +0 -5
  89. data/docs/static/javascripts/vendor/what-input.js +0 -336
  90. data/docs/static/stylesheets/site.css +0 -4667
  91. data/docs/themes/kitchen/layouts/_default/baseof.html +0 -53
  92. data/docs/themes/kitchen/layouts/_default/list.html +0 -4
  93. data/docs/themes/kitchen/layouts/_default/redirect.html +0 -10
  94. data/docs/themes/kitchen/layouts/_default/single.html +0 -6
  95. data/docs/themes/kitchen/layouts/partials/core/head.html +0 -6
  96. data/docs/themes/kitchen/layouts/partials/kitchen/footer.html +0 -18
  97. data/docs/themes/kitchen/layouts/partials/kitchen/head.html +0 -4
  98. data/docs/themes/kitchen/layouts/partials/kitchen/header.html +0 -26
  99. data/docs/themes/kitchen/layouts/partials/search-docs.html +0 -3
  100. data/docs/themes/kitchen/layouts/partials/sidebar.html +0 -33
  101. data/docs/themes/kitchen/layouts/shortcodes/button.html +0 -1
  102. data/docs/themes/kitchen/layouts/shortcodes/codeblock.html +0 -8
  103. data/docs/themes/kitchen/layouts/shortcodes/cta.html +0 -5
  104. data/docs/themes/kitchen/layouts/shortcodes/danger.html +0 -1
  105. data/docs/themes/kitchen/layouts/shortcodes/example_fqdn.html +0 -1
  106. data/docs/themes/kitchen/layouts/shortcodes/info.html +0 -1
  107. data/docs/themes/kitchen/layouts/shortcodes/ol-styled.html +0 -3
  108. data/docs/themes/kitchen/layouts/shortcodes/success.html +0 -1
  109. data/docs/themes/kitchen/layouts/shortcodes/tip.html +0 -1
  110. data/docs/themes/kitchen/layouts/shortcodes/warning.html +0 -1
  111. data/docs/themes/kitchen/static/css/kitchen.css +0 -10
  112. data/docs/themes/kitchen/static/css/kitchen.css.map +0 -7
  113. data/docs/themes/kitchen/static/fonts/Muli-Bold.ttf +0 -0
  114. data/docs/themes/kitchen/static/fonts/Muli-Regular.ttf +0 -0
  115. data/docs/themes/kitchen/static/fonts/Muli-SemiBold.ttf +0 -0
  116. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.eot +0 -0
  117. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.svg +0 -1104
  118. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.ttf +0 -0
  119. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff +0 -0
  120. data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff2 +0 -0
  121. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.eot +0 -0
  122. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.svg +0 -372
  123. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.ttf +0 -0
  124. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff +0 -0
  125. data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff2 +0 -0
  126. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.eot +0 -0
  127. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.svg +0 -1896
  128. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.ttf +0 -0
  129. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff +0 -0
  130. data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff2 +0 -0
  131. data/docs/themes/kitchen/static/images/chef-logo-light.svg +0 -36
  132. data/docs/themes/kitchen/static/images/chef-logo-white.svg +0 -38
  133. data/docs/themes/kitchen/static/images/chef-logo.svg +0 -37
  134. data/docs/themes/kitchen/static/images/favicon.ico +0 -0
  135. data/docs/themes/kitchen/static/js/scripts-all.js +0 -7
  136. data/docs/themes/kitchen/static/js/source/chef-hugo.js +0 -116
  137. data/docs/themes/kitchen/static/js/source/omnitruck.js +0 -82
  138. data/docs/themes/kitchen/static/js/source/segment.js +0 -52
  139. data/docs/themes/kitchen/static/sass/_buttons.scss +0 -161
  140. data/docs/themes/kitchen/static/sass/_core.scss +0 -24
  141. data/docs/themes/kitchen/static/sass/_forms.scss +0 -14
  142. data/docs/themes/kitchen/static/sass/_mixins.scss +0 -133
  143. data/docs/themes/kitchen/static/sass/_typography.scss +0 -34
  144. data/docs/themes/kitchen/static/sass/_variables.scss +0 -82
  145. data/docs/themes/kitchen/static/sass/kitchen.scss +0 -7
  146. data/docs/themes/kitchen/static/sass/kitchen/_footer.scss +0 -50
  147. data/docs/themes/kitchen/static/sass/kitchen/_header.scss +0 -187
  148. data/docs/themes/kitchen/static/sass/kitchen/_homepage.scss +0 -27
  149. data/docs/themes/kitchen/static/sass/kitchen/_utility-bar.scss +0 -173
  150. data/docs/themes/kitchen/static/sass/partials/_alerts.scss +0 -32
  151. data/docs/themes/kitchen/static/sass/partials/_bg.scss +0 -19
  152. data/docs/themes/kitchen/static/sass/partials/_blurbs.scss +0 -25
  153. data/docs/themes/kitchen/static/sass/partials/_callout.scss +0 -15
  154. data/docs/themes/kitchen/static/sass/partials/_cards.scss +0 -54
  155. data/docs/themes/kitchen/static/sass/partials/_dropdown.scss +0 -77
  156. data/docs/themes/kitchen/static/sass/partials/_grid.scss +0 -87
  157. data/docs/themes/kitchen/static/sass/partials/_padding.scss +0 -73
  158. data/docs/themes/kitchen/static/sass/partials/_sidebar.scss +0 -71
  159. data/docs/themes/kitchen/static/sass/partials/_tabs.scss +0 -125
  160. data/docs/themes/kitchen/static/sass/typography/_chroma.scss +0 -366
  161. data/docs/themes/kitchen/static/sass/typography/_code.scss +0 -72
  162. data/docs/themes/kitchen/static/sass/typography/_headers.scss +0 -90
  163. data/docs/themes/kitchen/static/sass/typography/_links.scss +0 -127
  164. data/docs/themes/kitchen/static/sass/typography/_lists.scss +0 -155
  165. data/docs/themes/kitchen/static/sass/typography/_prose.scss +0 -29
  166. data/docs/themes/kitchen/static/sass/typography/_text.scss +0 -221
  167. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_animated.scss +0 -20
  168. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_bordered-pulled.scss +0 -20
  169. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_core.scss +0 -16
  170. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_fixed-width.scss +0 -6
  171. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_icons.scss +0 -992
  172. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_larger.scss +0 -23
  173. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_list.scss +0 -18
  174. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_mixins.scss +0 -57
  175. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_rotated-flipped.scss +0 -23
  176. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_screen-reader.scss +0 -5
  177. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_stacked.scss +0 -31
  178. data/docs/themes/kitchen/static/sass/vendor/fontawesome/_variables.scss +0 -1005
  179. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-brands.scss +0 -21
  180. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-regular.scss +0 -22
  181. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-solid.scss +0 -23
  182. data/docs/themes/kitchen/static/sass/vendor/fontawesome/fontawesome.scss +0 -16
  183. data/docs/themes/kitchen/theme.toml +0 -8
  184. data/features/kitchen_action_commands.feature +0 -164
  185. data/features/kitchen_command.feature +0 -16
  186. data/features/kitchen_console_command.feature +0 -35
  187. data/features/kitchen_defaults.feature +0 -38
  188. data/features/kitchen_diagnose_command.feature +0 -96
  189. data/features/kitchen_help_command.feature +0 -16
  190. data/features/kitchen_init_command.feature +0 -254
  191. data/features/kitchen_list_command.feature +0 -140
  192. data/features/kitchen_login_command.feature +0 -62
  193. data/features/kitchen_sink_command.feature +0 -30
  194. data/features/kitchen_test_command.feature +0 -88
  195. data/features/step_definitions/gem_steps.rb +0 -24
  196. data/features/step_definitions/git_steps.rb +0 -5
  197. data/features/step_definitions/output_steps.rb +0 -5
  198. data/features/support/env.rb +0 -74
  199. data/spec/kitchen/base64_stream_spec.rb +0 -74
  200. data/spec/kitchen/cli_spec.rb +0 -54
  201. data/spec/kitchen/collection_spec.rb +0 -76
  202. data/spec/kitchen/color_spec.rb +0 -51
  203. data/spec/kitchen/config_spec.rb +0 -434
  204. data/spec/kitchen/configurable_spec.rb +0 -1113
  205. data/spec/kitchen/data_munger_spec.rb +0 -2800
  206. data/spec/kitchen/diagnostic_spec.rb +0 -128
  207. data/spec/kitchen/driver/base_spec.rb +0 -132
  208. data/spec/kitchen/driver/dummy_spec.rb +0 -193
  209. data/spec/kitchen/driver/exec_spec.rb +0 -75
  210. data/spec/kitchen/driver/proxy_spec.rb +0 -127
  211. data/spec/kitchen/driver/ssh_base_spec.rb +0 -1136
  212. data/spec/kitchen/driver_spec.rb +0 -106
  213. data/spec/kitchen/errors_spec.rb +0 -317
  214. data/spec/kitchen/instance_spec.rb +0 -1372
  215. data/spec/kitchen/lazy_hash_spec.rb +0 -113
  216. data/spec/kitchen/lifecycle_hooks_spec.rb +0 -171
  217. data/spec/kitchen/loader/yaml_spec.rb +0 -787
  218. data/spec/kitchen/logger_spec.rb +0 -425
  219. data/spec/kitchen/logging_spec.rb +0 -56
  220. data/spec/kitchen/login_command_spec.rb +0 -67
  221. data/spec/kitchen/metadata_chopper_spec.rb +0 -79
  222. data/spec/kitchen/platform_spec.rb +0 -88
  223. data/spec/kitchen/provisioner/base_spec.rb +0 -393
  224. data/spec/kitchen/provisioner/chef/policyfile_spec.rb +0 -140
  225. data/spec/kitchen/provisioner/chef_apply_spec.rb +0 -131
  226. data/spec/kitchen/provisioner/chef_base_spec.rb +0 -1565
  227. data/spec/kitchen/provisioner/chef_solo_spec.rb +0 -602
  228. data/spec/kitchen/provisioner/chef_zero_spec.rb +0 -1013
  229. data/spec/kitchen/provisioner/dummy_spec.rb +0 -96
  230. data/spec/kitchen/provisioner/shell_spec.rb +0 -623
  231. data/spec/kitchen/provisioner_spec.rb +0 -101
  232. data/spec/kitchen/shell_out_spec.rb +0 -146
  233. data/spec/kitchen/ssh_spec.rb +0 -584
  234. data/spec/kitchen/state_file_spec.rb +0 -122
  235. data/spec/kitchen/suite_spec.rb +0 -61
  236. data/spec/kitchen/transport/base_spec.rb +0 -140
  237. data/spec/kitchen/transport/exec_spec.rb +0 -79
  238. data/spec/kitchen/transport/ssh_spec.rb +0 -1317
  239. data/spec/kitchen/transport/winrm_spec.rb +0 -1320
  240. data/spec/kitchen/transport_spec.rb +0 -106
  241. data/spec/kitchen/util_spec.rb +0 -250
  242. data/spec/kitchen/verifier/base_spec.rb +0 -346
  243. data/spec/kitchen/verifier/busser_spec.rb +0 -580
  244. data/spec/kitchen/verifier/dummy_spec.rb +0 -96
  245. data/spec/kitchen/verifier/shell_spec.rb +0 -157
  246. data/spec/kitchen/verifier_spec.rb +0 -114
  247. data/spec/kitchen_spec.rb +0 -112
  248. data/spec/spec_helper.rb +0 -110
  249. data/spec/support/powershell_max_size_spec.rb +0 -39
  250. data/test-kitchen.gemspec +0 -49
  251. data/test/cookbooks/test_cookbook/metadata.rb +0 -6
  252. data/test/cookbooks/test_cookbook/recipes/default.rb +0 -1
  253. data/test/integration/default/default_spec.rb +0 -3
  254. data/testing_windows.md +0 -38
@@ -1,1013 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
- #
5
- # Copyright (C) 2014, Fletcher Nichol
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require_relative "../../spec_helper"
20
-
21
- require "kitchen"
22
- require "kitchen/provisioner/chef_zero"
23
-
24
- describe Kitchen::Provisioner::ChefZero do
25
- let(:logged_output) { StringIO.new }
26
- let(:logger) { Logger.new(logged_output) }
27
- let(:platform) { stub(os_type: nil) }
28
- let(:suite) { stub(name: "fries") }
29
-
30
- let(:config) do
31
- { test_base_path: "/b", kitchen_root: "/r" }
32
- end
33
-
34
- let(:instance) do
35
- stub(
36
- name: "coolbeans",
37
- logger: logger,
38
- suite: suite,
39
- platform: platform
40
- )
41
- end
42
-
43
- let(:provisioner) do
44
- Kitchen::Provisioner::ChefZero.new(config).finalize_config!(instance)
45
- end
46
-
47
- it "provisioner api_version is 2" do
48
- provisioner.diagnose_plugin[:api_version].must_equal 2
49
- end
50
-
51
- it "plugin_version is set to Kitchen::VERSION" do
52
- provisioner.diagnose_plugin[:version].must_equal Kitchen::VERSION
53
- end
54
-
55
- describe "default config" do
56
- describe "for unix operating systems" do
57
- before { platform.stubs(:os_type).returns("unix") }
58
-
59
- it "sets :chef_client_path to a path using :chef_omnibus_root" do
60
- config[:chef_omnibus_root] = "/nice/place"
61
-
62
- provisioner[:chef_client_path]
63
- .must_equal "/nice/place/bin/chef-client"
64
- end
65
-
66
- it "sets :ruby_bindir to use an Omnibus Ruby" do
67
- config[:chef_omnibus_root] = "/nice"
68
-
69
- provisioner[:ruby_bindir].must_equal "/nice/embedded/bin"
70
- end
71
- end
72
-
73
- describe "for windows operating systems" do
74
- before { platform.stubs(:os_type).returns("windows") }
75
-
76
- it "sets :chef_client_path to a path using :chef_omnibus_root" do
77
- config[:chef_omnibus_root] = '$env:systemdrive\\nice\\place'
78
-
79
- provisioner[:chef_client_path]
80
- .must_equal '$env:systemdrive\\nice\\place\\bin\\chef-client.bat'
81
- end
82
-
83
- it "sets :ruby_bindir to use an Omnibus Ruby" do
84
- config[:chef_omnibus_root] = 'c:\\nice'
85
-
86
- provisioner[:ruby_bindir].must_equal 'c:\\nice\\embedded\\bin'
87
- end
88
- end
89
-
90
- it "sets :client_rb to an empty Hash" do
91
- provisioner[:client_rb].must_equal Hash.new
92
- end
93
-
94
- it "sets :json_attributes to true" do
95
- provisioner[:json_attributes].must_equal true
96
- end
97
-
98
- it "does not set :chef_zero_host" do
99
- provisioner[:chef_zero_host].must_be_nil
100
- end
101
-
102
- it "sets :chef_zero_port to 8889" do
103
- provisioner[:chef_zero_port].must_equal 8889
104
- end
105
- end
106
-
107
- describe "#create_sandbox" do
108
- before do
109
- @root = Dir.mktmpdir
110
- config[:kitchen_root] = @root
111
- end
112
-
113
- after do
114
- FileUtils.remove_entry(@root)
115
- begin
116
- provisioner.cleanup_sandbox
117
- rescue # rubocop:disable Lint/HandleExceptions
118
- end
119
- end
120
-
121
- describe "client.rb file" do
122
- let(:file) do
123
- IO.read(sandbox_path("client.rb")).lines.map(&:chomp)
124
- end
125
-
126
- let(:file_no_updated_resources) do
127
- IO.read(sandbox_path("client_no_updated_resources.rb")).lines.map(&:chomp)
128
- end
129
-
130
- it "creates a client.rb" do
131
- provisioner.create_sandbox
132
-
133
- sandbox_path("client.rb").file?.must_equal true
134
- end
135
-
136
- it "logs a message on info" do
137
- provisioner.create_sandbox
138
-
139
- logged_output.string.must_match info_line("Preparing client.rb")
140
- end
141
-
142
- it "logs a message on debug" do
143
- provisioner.create_sandbox
144
-
145
- logged_output.string
146
- .must_match debug_line_starting_with("Creating client.rb from {")
147
- end
148
-
149
- describe "defaults" do
150
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
151
- def self.common_client_rb_specs
152
- it "sets node_name to the instance name" do
153
- file.must_include %{node_name "#{instance.name}"}
154
- end
155
-
156
- it "sets checksum_path" do
157
- file.must_include %{checksum_path "#{base}checksums"}
158
- end
159
-
160
- it "sets file_backup_path" do
161
- file.must_include %{file_backup_path "#{base}backup"}
162
- end
163
-
164
- it "sets cookbook_path" do
165
- file.must_include %{cookbook_path } +
166
- %{["#{base}cookbooks", "#{base}site-cookbooks"]}
167
- end
168
-
169
- it "sets data_bag_path" do
170
- file.must_include %{data_bag_path "#{base}data_bags"}
171
- end
172
-
173
- it "sets environment_path" do
174
- file.must_include %{environment_path "#{base}environments"}
175
- end
176
-
177
- it "sets node_path" do
178
- file.must_include %{node_path "#{base}nodes"}
179
- end
180
-
181
- it "sets role_path" do
182
- file.must_include %{role_path "#{base}roles"}
183
- end
184
-
185
- it "sets client_path" do
186
- file.must_include %{client_path "#{base}clients"}
187
- end
188
-
189
- it "sets user_path" do
190
- file.must_include %{user_path "#{base}users"}
191
- end
192
-
193
- it "sets validation_key" do
194
- file.must_include %{validation_key "#{base}validation.pem"}
195
- end
196
-
197
- it "sets client_key" do
198
- file.must_include %{client_key "#{base}client.pem"}
199
- end
200
-
201
- it "sets chef_server_url" do
202
- file.must_include %{chef_server_url "http://127.0.0.1:8889"}
203
- end
204
-
205
- it "sets encrypted_data_bag_secret" do
206
- file.must_include %{encrypted_data_bag_secret } +
207
- %{"#{base}encrypted_data_bag_secret"}
208
- end
209
- end
210
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
211
-
212
- describe "for unix os types" do
213
- before do
214
- platform.stubs(:os_type).returns("unix")
215
- provisioner.create_sandbox
216
- end
217
-
218
- let(:base) { "/tmp/kitchen/" }
219
-
220
- common_client_rb_specs
221
- end
222
-
223
- describe "for windows os types with full path" do
224
- before do
225
- platform.stubs(:os_type).returns("windows")
226
- config[:root_path] = '\\a\\b'
227
- provisioner.create_sandbox
228
- end
229
-
230
- let(:base) { '\\\\a\\\\b\\\\' }
231
-
232
- common_client_rb_specs
233
- end
234
-
235
- describe "for windows os types with $env:TEMP prefixed paths" do
236
- before do
237
- platform.stubs(:os_type).returns("windows")
238
- config[:root_path] = '$env:TEMP\\a'
239
- provisioner.create_sandbox
240
- end
241
-
242
- let(:base) { "\#{ENV['TEMP']}\\\\a\\\\" }
243
-
244
- common_client_rb_specs
245
- end
246
- end
247
-
248
- it "supports overwriting defaults" do
249
- config[:client_rb] = {
250
- node_name: "eagles",
251
- user_path: "/a/b/c/u",
252
- client_key: "lol",
253
- }
254
- provisioner.create_sandbox
255
-
256
- file.must_include %{node_name "eagles"}
257
- file.must_include %{user_path "/a/b/c/u"}
258
- file.must_include %{client_key "lol"}
259
- end
260
-
261
- it " supports adding new configuration" do
262
- config[:client_rb] = {
263
- dark_secret: "golang",
264
- }
265
- provisioner.create_sandbox
266
-
267
- file.must_include %{dark_secret "golang"}
268
- end
269
-
270
- it "formats array values correctly" do
271
- config[:client_rb] = {
272
- foos: %w{foo1 foo2},
273
- }
274
- provisioner.create_sandbox
275
-
276
- file.must_include %{foos ["foo1", "foo2"]}
277
- end
278
-
279
- it "formats integer values correctly" do
280
- config[:client_rb] = {
281
- foo: 7,
282
- }
283
- provisioner.create_sandbox
284
-
285
- file.must_include %{foo 7}
286
- end
287
-
288
- it "formats symbol-looking string values correctly" do
289
- config[:client_rb] = {
290
- foo: ":bar",
291
- }
292
- provisioner.create_sandbox
293
-
294
- file.must_include %{foo :bar}
295
- end
296
-
297
- it "formats boolean values correctly" do
298
- config[:client_rb] = {
299
- foo: false,
300
- bar: true,
301
- }
302
- provisioner.create_sandbox
303
-
304
- file.must_include %{foo false}
305
- file.must_include %{bar true}
306
- end
307
-
308
- it "supports idempotency check " do
309
- config[:multiple_converge] = 2
310
- config[:enforce_idempotency] = true
311
- provisioner.create_sandbox
312
-
313
- file_no_updated_resources.join.must_match(/handler_file =.*chef-client-fail-if-update-handler.rb/)
314
- end
315
- end
316
-
317
- describe "validation.pem file" do
318
- it "creates file" do
319
- provisioner.create_sandbox
320
-
321
- sandbox_path("validation.pem").file?.must_equal true
322
- end
323
-
324
- it "logs a message on info" do
325
- provisioner.create_sandbox
326
-
327
- logged_output.string.must_match info_line("Preparing validation.pem")
328
- end
329
-
330
- it "logs a message on debug" do
331
- provisioner.create_sandbox
332
-
333
- logged_output.string
334
- .must_match debug_line_starting_with("Using a dummy validation.pem")
335
- end
336
- end
337
-
338
- describe "chef-client-zero.rb file" do
339
- describe "for modern Chef versions" do
340
- before { config[:require_chef_omnibus] = "11.10" }
341
-
342
- it "does not create the file" do
343
- provisioner.create_sandbox
344
-
345
- sandbox_path("chef-client-zero.rb").file?.must_equal false
346
- end
347
-
348
- it "a version of '11' is still considered modern" do
349
- config[:require_chef_omnibus] = "11"
350
- provisioner.create_sandbox
351
-
352
- sandbox_path("chef-client-zero.rb").file?.must_equal false
353
- end
354
-
355
- it "a version of 11 is still considered modern" do
356
- config[:require_chef_omnibus] = 11
357
- provisioner.create_sandbox
358
-
359
- sandbox_path("chef-client-zero.rb").file?.must_equal false
360
- end
361
- end
362
-
363
- describe "for old Chef versions" do
364
- before { config[:require_chef_omnibus] = "10.20" }
365
-
366
- it "creates the file when using an old Chef version" do
367
- provisioner.create_sandbox
368
-
369
- sandbox_path("chef-client-zero.rb").file?.must_equal true
370
- end
371
-
372
- it "logs a message on info" do
373
- provisioner.create_sandbox
374
-
375
- logged_output.string
376
- .must_match info_line("Preparing chef-client-zero.rb")
377
- end
378
-
379
- it "logs a message on debug" do
380
- provisioner.create_sandbox
381
-
382
- logged_output.string.must_match debug_line_starting_with(
383
- "Using a vendored chef-client-zero.rb")
384
- end
385
- end
386
- end
387
-
388
- def sandbox_path(path)
389
- Pathname.new(provisioner.sandbox_path).join(path)
390
- end
391
- end
392
-
393
- describe "#prepare_command" do
394
- let(:cmd) { provisioner.prepare_command }
395
-
396
- describe "for modern Chef versions" do
397
- before { config[:require_chef_omnibus] = "11.10" }
398
-
399
- it "returns nil" do
400
- cmd.must_be_nil
401
- end
402
- end
403
-
404
- describe "for old Chef versions" do
405
- before { config[:require_chef_omnibus] = "10.20" }
406
-
407
- describe "for bourne shells" do
408
- before do
409
- platform.stubs(:shell_type).returns("bourne")
410
- config[:ruby_bindir] = "/rbd"
411
- end
412
-
413
- it "uses bourne shell" do
414
- cmd.must_match(/\Ash -c '$/)
415
- cmd.must_match(/'\Z/)
416
- end
417
-
418
- it "ends with a single quote" do
419
- cmd.must_match(/'\Z/)
420
- end
421
-
422
- it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
423
- config[:http_proxy] = "http://proxy"
424
-
425
- cmd.lines.to_a[1..2].must_equal([
426
- %{http_proxy="http://proxy"; export http_proxy\n},
427
- %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
428
- ])
429
- end
430
-
431
- it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
432
- config[:https_proxy] = "https://proxy"
433
-
434
- cmd.lines.to_a[1..2].must_equal([
435
- %{https_proxy="https://proxy"; export https_proxy\n},
436
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
437
- ])
438
- end
439
-
440
- it "exports all http proxy variables when both are set" do
441
- config[:http_proxy] = "http://proxy"
442
- config[:https_proxy] = "https://proxy"
443
-
444
- cmd.lines.to_a[1..4].must_equal([
445
- %{http_proxy="http://proxy"; export http_proxy\n},
446
- %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
447
- %{https_proxy="https://proxy"; export https_proxy\n},
448
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
449
- ])
450
- end
451
-
452
- it "sets the CHEF_REPO_PATH environment variable" do
453
- config[:root_path] = "/r"
454
-
455
- cmd.must_match regexify(
456
- %{CHEF_REPO_PATH="/r"; export CHEF_REPO_PATH})
457
- end
458
-
459
- it "sets the GEM_HOME environment variable" do
460
- config[:root_path] = "/r"
461
-
462
- cmd.must_match regexify(
463
- %{GEM_HOME="/r/chef-client-zero-gems"; export GEM_HOME})
464
- end
465
-
466
- it "sets the GEM_PATH environment variable" do
467
- config[:root_path] = "/r"
468
-
469
- cmd.must_match regexify(
470
- %{GEM_PATH="/r/chef-client-zero-gems"; export GEM_PATH})
471
- end
472
-
473
- it "sets the GEM_CACHE environment variable" do
474
- config[:root_path] = "/r"
475
-
476
- cmd.must_match regexify(
477
- %{GEM_CACHE="/r/chef-client-zero-gems/cache"; export GEM_CACHE})
478
- end
479
-
480
- it "prepends sudo for gem command when :sudo is set" do
481
- config[:sudo] = true
482
-
483
- cmd.must_match regexify(%{gem="sudo -E /rbd/gem"})
484
- end
485
-
486
- it "does not sudo for gem commands when :sudo is falsey" do
487
- config[:sudo] = false
488
-
489
- cmd.must_match regexify(%{gem="/rbd/gem"})
490
- end
491
- end
492
-
493
- describe "for powershell shells on windows os types" do
494
- before do
495
- platform.stubs(:shell_type).returns("powershell")
496
- platform.stubs(:os_type).returns("windows")
497
- config[:root_path] = '\\r'
498
- config[:ruby_bindir] = '\\rbd'
499
- end
500
-
501
- it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
502
- config[:http_proxy] = "http://proxy"
503
-
504
- cmd.lines.to_a[0..1].must_equal([
505
- %{$env:http_proxy = "http://proxy"\n},
506
- %{$env:HTTP_PROXY = "http://proxy"\n},
507
- ])
508
- end
509
-
510
- it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
511
- config[:https_proxy] = "https://proxy"
512
-
513
- cmd.lines.to_a[0..1].must_equal([
514
- %{$env:https_proxy = "https://proxy"\n},
515
- %{$env:HTTPS_PROXY = "https://proxy"\n},
516
- ])
517
- end
518
-
519
- it "exports all http proxy variables when both are set" do
520
- config[:http_proxy] = "http://proxy"
521
- config[:https_proxy] = "https://proxy"
522
-
523
- cmd.lines.to_a[0..3].must_equal([
524
- %{$env:http_proxy = "http://proxy"\n},
525
- %{$env:HTTP_PROXY = "http://proxy"\n},
526
- %{$env:https_proxy = "https://proxy"\n},
527
- %{$env:HTTPS_PROXY = "https://proxy"\n},
528
- ])
529
- end
530
-
531
- it "sets the CHEF_REPO_PATH environment variable" do
532
- config[:root_path] = '\\r'
533
-
534
- cmd.must_match regexify(
535
- %{$env:CHEF_REPO_PATH = "\\r"})
536
- end
537
-
538
- it "sets the GEM_HOME environment variable" do
539
- config[:root_path] = '\\r'
540
-
541
- cmd.must_match regexify(
542
- %{$env:GEM_HOME = "\\r\\chef-client-zero-gems"})
543
- end
544
-
545
- it "sets the GEM_PATH environment variable" do
546
- config[:root_path] = '\\r'
547
-
548
- cmd.must_match regexify(
549
- %{$env:GEM_PATH = "\\r\\chef-client-zero-gems"})
550
- end
551
-
552
- it "sets the GEM_CACHE environment variable" do
553
- config[:root_path] = '\\r'
554
-
555
- cmd.must_match regexify(
556
- %{$env:GEM_CACHE = "\\r\\chef-client-zero-gems\\cache"})
557
- end
558
-
559
- it "sets the path to the gem command" do
560
- cmd.must_match regexify(%{$gem = "\\rbd\\gem.bat"})
561
- end
562
- end
563
- end
564
- end
565
-
566
- describe "#run_command" do
567
- let(:cmd) { provisioner.run_command }
568
-
569
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
570
- def self.common_shell_specs
571
- it "sets config flag on chef-client" do
572
- cmd.must_match regexify(
573
- " --config #{base}client.rb", :partial_line)
574
- end
575
-
576
- it "sets config flag for custom root_path" do
577
- config[:root_path] = custom_root
578
-
579
- cmd.must_match regexify(
580
- " --config #{custom_base}client.rb", :partial_line)
581
- end
582
-
583
- it "sets log level flag on chef-client to auto by default" do
584
- cmd.must_match regexify(" --log_level auto", :partial_line)
585
- end
586
-
587
- it "set log level flag for custom level" do
588
- config[:log_level] = :extreme
589
-
590
- cmd.must_match regexify(" --log_level extreme", :partial_line)
591
- end
592
-
593
- it "sets force formatter flag on chef-solo" do
594
- cmd.must_match regexify(" --force-formatter", :partial_line)
595
- end
596
-
597
- it "sets no color flag on chef-solo" do
598
- cmd.must_match regexify(" --no-color", :partial_line)
599
- end
600
-
601
- it "sets json attributes flag on chef-client" do
602
- cmd.must_match regexify(
603
- " --json-attributes #{base}dna.json", :partial_line)
604
- end
605
-
606
- it "sets json attribtes flag for custom root_path" do
607
- config[:root_path] = custom_root
608
-
609
- cmd.must_match regexify(
610
- " --json-attributes #{custom_base}dna.json", :partial_line)
611
- end
612
-
613
- it "does not set json attributes flag if config is falsey" do
614
- config[:json_attributes] = false
615
-
616
- cmd.wont_match regexify(" --json-attributes ", :partial_line)
617
- end
618
-
619
- it "sets logfile flag for custom value" do
620
- config[:log_file] = "#{custom_base}out.log"
621
-
622
- cmd.must_match regexify(
623
- " --logfile #{custom_base}out.log", :partial_line)
624
- end
625
-
626
- it "does not set logfile flag by default" do
627
- cmd.wont_match regexify(" --logfile ", :partial_line)
628
- end
629
-
630
- it "prefixs the whole command with the command_prefix if set" do
631
- config[:command_prefix] = "my_prefix"
632
-
633
- cmd.must_match(/\Amy_prefix /)
634
- end
635
-
636
- it "does not prefix the command if command_prefix is not set" do
637
- config[:command_prefix] = nil
638
-
639
- cmd.wont_match(/\Amy_prefix /)
640
- end
641
- end
642
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
643
-
644
- describe "for modern Chef versions" do
645
- before { config[:require_chef_omnibus] = "11.10" }
646
-
647
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
648
- def self.common_modern_shell_specs
649
- it "sets local mode flag on chef-client" do
650
- cmd.must_match regexify(" --local-mode", :partial_line)
651
- end
652
-
653
- it "sets chef zero port flag on chef-client" do
654
- cmd.must_match regexify(" --chef-zero-port 8889", :partial_line)
655
- end
656
-
657
- it "sets chef zero host flag for custom host" do
658
- config[:chef_zero_host] = "192.168.0.1"
659
-
660
- cmd.must_match regexify(" --chef-zero-host 192.168.0.1", :partial_line)
661
- end
662
-
663
- it "sets chef zero port flag for custom port" do
664
- config[:chef_zero_port] = 123
665
-
666
- cmd.must_match regexify(" --chef-zero-port 123", :partial_line)
667
- end
668
-
669
- it "does not set chef zero host flag when value is falsey" do
670
- config[:chef_zero_host] = nil
671
-
672
- cmd.wont_match regexify(" --chef-zero-host ", :partial_line)
673
- end
674
-
675
- it "does not set chef zero port flag when value is falsey" do
676
- config[:chef_zero_port] = nil
677
-
678
- cmd.wont_match regexify(" --chef-zero-port ", :partial_line)
679
- end
680
-
681
- it "sets profile-ruby flag when config element is set" do
682
- config[:profile_ruby] = true
683
-
684
- cmd.must_match regexify(
685
- " --profile-ruby", :partial_line)
686
- end
687
-
688
- it "does not set profile-ruby flag when config element is falsey" do
689
- config[:profile_ruby] = false
690
-
691
- cmd.wont_match regexify(" --profile-ruby", :partial_line)
692
- end
693
- end
694
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
695
-
696
- describe "for bourne shells" do
697
- before { platform.stubs(:shell_type).returns("bourne") }
698
-
699
- let(:base) { "/tmp/kitchen/" }
700
- let(:custom_base) { "/a/b/" }
701
- let(:custom_root) { "/a/b" }
702
-
703
- common_shell_specs
704
- common_modern_shell_specs
705
-
706
- it "uses bourne shell" do
707
- cmd.must_match(/\Ash -c '$/)
708
- cmd.must_match(/'\Z/)
709
- end
710
-
711
- it "ends with a single quote" do
712
- cmd.must_match(/'\Z/)
713
- end
714
-
715
- it "contains a standard second run if multiple_converge is set to 2" do
716
- config[:multiple_converge] = 2
717
- cmd.must_match(/chef-client.*&&.*chef-client.*/m)
718
- cmd.wont_match(/chef-client.*&&.*chef-client.*client_no_updated_resources.rb/m)
719
- end
720
-
721
- it "contains a specific second run if enforce_idempotency is set" do
722
- config[:multiple_converge] = 2
723
- config[:enforce_idempotency] = true
724
- cmd.must_match(/chef-client.*&&.*chef-client.*client_no_updated_resources.rb/m)
725
- end
726
-
727
- it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
728
- config[:http_proxy] = "http://proxy"
729
-
730
- cmd.lines.to_a[1..2].must_equal([
731
- %{http_proxy="http://proxy"; export http_proxy\n},
732
- %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
733
- ])
734
- end
735
-
736
- it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
737
- config[:https_proxy] = "https://proxy"
738
-
739
- cmd.lines.to_a[1..2].must_equal([
740
- %{https_proxy="https://proxy"; export https_proxy\n},
741
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
742
- ])
743
- end
744
-
745
- it "exports all http proxy variables when both are set" do
746
- config[:http_proxy] = "http://proxy"
747
- config[:https_proxy] = "https://proxy"
748
-
749
- cmd.lines.to_a[1..4].must_equal([
750
- %{http_proxy="http://proxy"; export http_proxy\n},
751
- %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
752
- %{https_proxy="https://proxy"; export https_proxy\n},
753
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
754
- ])
755
- end
756
-
757
- it "does no powershell PATH reloading for older chef packages" do
758
- cmd.wont_match regexify(%{[System.Environment]::})
759
- end
760
-
761
- it "uses sudo for chef-client when configured" do
762
- config[:chef_omnibus_root] = "/c"
763
- config[:sudo] = true
764
-
765
- cmd.must_match regexify("sudo -E /c/bin/chef-client ", :partial_line)
766
- end
767
-
768
- it "does not use sudo for chef-client when configured" do
769
- config[:chef_omnibus_root] = "/c"
770
- config[:sudo] = false
771
-
772
- cmd.must_match regexify("/c/bin/chef-client ", :partial_line)
773
- cmd.wont_match regexify("sudo -E /c/bin/chef-client ", :partial_line)
774
- end
775
- end
776
-
777
- describe "for powershell shells on windows os types" do
778
- before do
779
- platform.stubs(:shell_type).returns("powershell")
780
- platform.stubs(:os_type).returns("windows")
781
- end
782
-
783
- let(:base) { '$env:TEMP\\kitchen\\' }
784
- let(:custom_base) { '\\a\\b\\' }
785
- let(:custom_root) { '\\a\\b' }
786
-
787
- common_shell_specs
788
- common_modern_shell_specs
789
-
790
- it "contains a standard second run if multiple_converge is set to 2" do
791
- config[:multiple_converge] = 2
792
- cmd.must_match(/chef-client.*;.*chef-client.*/m)
793
- cmd.wont_match(/chef-client.*;.*chef-client.*client_no_updated_resources.rb/m)
794
- end
795
-
796
- it "contains a specific second run if enforce_idempotency is set" do
797
- config[:multiple_converge] = 2
798
- config[:enforce_idempotency] = true
799
- cmd.must_match(/chef-client.*;.*chef-client.*client_no_updated_resources.rb/m)
800
- end
801
-
802
- it "exports http_proxy & HTTP_PROXY when :http_proxy is set" do
803
- config[:http_proxy] = "http://proxy"
804
-
805
- cmd.lines.to_a[0..1].must_equal([
806
- %{$env:http_proxy = "http://proxy"\n},
807
- %{$env:HTTP_PROXY = "http://proxy"\n},
808
- ])
809
- end
810
-
811
- it "exports https_proxy & HTTPS_PROXY when :https_proxy is set" do
812
- config[:https_proxy] = "https://proxy"
813
-
814
- cmd.lines.to_a[0..1].must_equal([
815
- %{$env:https_proxy = "https://proxy"\n},
816
- %{$env:HTTPS_PROXY = "https://proxy"\n},
817
- ])
818
- end
819
-
820
- it "exports all http proxy variables when both are set" do
821
- config[:http_proxy] = "http://proxy"
822
- config[:https_proxy] = "https://proxy"
823
-
824
- cmd.lines.to_a[0..3].must_equal([
825
- %{$env:http_proxy = "http://proxy"\n},
826
- %{$env:HTTP_PROXY = "http://proxy"\n},
827
- %{$env:https_proxy = "https://proxy"\n},
828
- %{$env:HTTPS_PROXY = "https://proxy"\n},
829
- ])
830
- end
831
-
832
- it "reloads PATH for older chef packages" do
833
- cmd.must_match regexify("$env:PATH = try {\n" \
834
- "[System.Environment]::GetEnvironmentVariable('PATH','Machine')\n" \
835
- "} catch { $env:PATH }")
836
- end
837
-
838
- it "calls the chef-client command from :chef_client_path" do
839
- config[:chef_client_path] = '\\r\\chef-client.bat'
840
-
841
- cmd.must_match regexify('& \\r\\chef-client.bat ', :partial_line)
842
- end
843
- end
844
- end
845
-
846
- describe "for old Chef versions" do
847
- before do
848
- config[:require_chef_omnibus] = "10.20"
849
- end
850
-
851
- def self.common_old_shell_specs
852
- it "does not set local mode flag" do
853
- cmd.wont_match regexify(" --local-mode", :partial_line)
854
- end
855
-
856
- it "does not set chef zero host flag for custom host" do
857
- config[:chef_zero_host] = "192.168.0.1"
858
-
859
- cmd.wont_match regexify(" --chef-zero-host 192.168.0.1", :partial_line)
860
- end
861
-
862
- it "does not set chef zero port flag for custom port" do
863
- config[:chef_zero_port] = 123
864
-
865
- cmd.wont_match regexify(" --chef-zero-port 123", :partial_line)
866
- end
867
- end
868
-
869
- describe "for bourne shells" do
870
- before do
871
- platform.stubs(:shell_type).returns("bourne")
872
- config[:ruby_bindir] = "/r/bin"
873
- end
874
-
875
- let(:base) { "/tmp/kitchen/" }
876
- let(:custom_base) { "/a/b/" }
877
- let(:custom_root) { "/a/b" }
878
-
879
- common_shell_specs
880
- common_old_shell_specs
881
-
882
- it "uses bourne shell" do
883
- cmd.must_match(/\Ash -c '$/)
884
- cmd.must_match(/'\Z/)
885
- end
886
-
887
- it "ends with a single quote" do
888
- cmd.must_match(/'\Z/)
889
- end
890
-
891
- it "uses sudo for ruby when configured" do
892
- config[:root_path] = "/x"
893
- config[:sudo] = true
894
-
895
- cmd.must_match regexify(
896
- "sudo -E /r/bin/ruby /x/chef-client-zero.rb ", :partial_line)
897
- end
898
-
899
- it "does not use sudo for ruby when configured" do
900
- config[:root_path] = "/x"
901
- config[:sudo] = false
902
-
903
- cmd.must_match regexify(
904
- "/r/bin/ruby /x/chef-client-zero.rb ", :partial_line)
905
- cmd.wont_match regexify(
906
- "sudo -E /r/bin/ruby /x/chef-client-zero.rb ", :partial_line)
907
- end
908
-
909
- it "sets the CHEF_REPO_PATH environment variable" do
910
- config[:root_path] = "/r"
911
-
912
- cmd.must_match regexify(
913
- %{CHEF_REPO_PATH="/r"; export CHEF_REPO_PATH})
914
- end
915
-
916
- it "sets the GEM_HOME environment variable" do
917
- config[:root_path] = "/r"
918
-
919
- cmd.must_match regexify(
920
- %{GEM_HOME="/r/chef-client-zero-gems"; export GEM_HOME})
921
- end
922
-
923
- it "sets the GEM_PATH environment variable" do
924
- config[:root_path] = "/r"
925
-
926
- cmd.must_match regexify(
927
- %{GEM_PATH="/r/chef-client-zero-gems"; export GEM_PATH})
928
- end
929
-
930
- it "sets the GEM_CACHE environment variable" do
931
- config[:root_path] = "/r"
932
-
933
- cmd.must_match regexify(
934
- %{GEM_CACHE="/r/chef-client-zero-gems/cache"; export GEM_CACHE})
935
- end
936
-
937
- it "does no powershell PATH reloading for older chef packages" do
938
- cmd.wont_match regexify(%{[System.Environment]::})
939
- end
940
- end
941
-
942
- describe "for powershell shells on windows os types" do
943
- before do
944
- platform.stubs(:shell_type).returns("powershell")
945
- platform.stubs(:os_type).returns("windows")
946
- config[:ruby_bindir] = '\\r\\bin'
947
- end
948
-
949
- let(:base) { '$env:TEMP\\kitchen\\' }
950
- let(:custom_base) { '\\a\\b\\' }
951
- let(:custom_root) { '\\a\\b' }
952
-
953
- common_shell_specs
954
- common_old_shell_specs
955
-
956
- it "calls ruby from :ruby_bindir" do
957
- config[:root_path] = '\\x'
958
-
959
- cmd.must_match regexify(
960
- '\\r\\bin\\ruby.exe \\x\\chef-client-zero.rb ', :partial_line)
961
- end
962
-
963
- it "sets the CHEF_REPO_PATH environment variable" do
964
- config[:root_path] = '\\r'
965
-
966
- cmd.must_match regexify(
967
- %{$env:CHEF_REPO_PATH = "\\r"})
968
- end
969
-
970
- it "sets the GEM_HOME environment variable" do
971
- config[:root_path] = '\\r'
972
-
973
- cmd.must_match regexify(
974
- %{$env:GEM_HOME = "\\r\\chef-client-zero-gems"})
975
- end
976
-
977
- it "sets the GEM_PATH environment variable" do
978
- config[:root_path] = '\\r'
979
-
980
- cmd.must_match regexify(
981
- %{$env:GEM_PATH = "\\r\\chef-client-zero-gems"})
982
- end
983
-
984
- it "sets the GEM_CACHE environment variable" do
985
- config[:root_path] = '\\r'
986
-
987
- cmd.must_match regexify(
988
- %{$env:GEM_CACHE = "\\r\\chef-client-zero-gems\\cache"})
989
- end
990
-
991
- it "reloads PATH for older chef packages" do
992
- cmd.must_match regexify("$env:PATH = try {\n" \
993
- "[System.Environment]::GetEnvironmentVariable('PATH','Machine')\n" \
994
- "} catch { $env:PATH }")
995
- end
996
- end
997
- end
998
- end
999
-
1000
- def info_line(msg)
1001
- /^I, .* : #{Regexp.escape(msg)}$/
1002
- end
1003
-
1004
- def debug_line_starting_with(msg)
1005
- /^D, .* : #{Regexp.escape(msg)}/
1006
- end
1007
-
1008
- def regexify(str, line = :whole_line)
1009
- r = Regexp.escape(str)
1010
- r = "^\s*#{r}$" if line == :whole_line
1011
- Regexp.new(r)
1012
- end
1013
- end