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,75 +0,0 @@
1
- #
2
- # Licensed under the Apache License, Version 2.0 (the "License");
3
- # you may not use this file except in compliance with the License.
4
- # You may obtain a copy of the License at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an "AS IS" BASIS,
10
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- # See the License for the specific language governing permissions and
12
- # limitations under the License.
13
- #
14
-
15
- require_relative "../../spec_helper"
16
-
17
- require "kitchen/driver/exec"
18
-
19
- describe Kitchen::Driver::Exec do
20
- let(:logged_output) { StringIO.new }
21
- let(:logger) { Logger.new(logged_output) }
22
- let(:state) { Hash.new }
23
-
24
- let(:config) do
25
- { reset_command: "mulligan" }
26
- end
27
-
28
- let(:instance) do
29
- stub(name: "coolbeans", logger: logger, to_str: "instance", "transport=": nil)
30
- end
31
-
32
- let(:driver) do
33
- Kitchen::Driver::Exec.new(config).finalize_config!(instance)
34
- end
35
-
36
- it "plugin_version is set to Kitchen::VERSION" do
37
- driver.diagnose_plugin[:version].must_equal Kitchen::VERSION
38
- end
39
-
40
- it "sets the transport to exec" do
41
- instance.expects(:"transport=").with { |v| v.is_a?(Kitchen::Transport::Exec) }
42
- driver
43
- end
44
-
45
- describe "#create" do
46
- it "runs the reset command" do
47
- driver.expects(:run_command).with("mulligan")
48
-
49
- driver.create(state)
50
- end
51
-
52
- it "skips the reset command if :reset_command is falsey" do
53
- config[:reset_command] = false
54
- driver.expects(:run_command).never
55
-
56
- driver.create(state)
57
- end
58
- end
59
-
60
- describe "#destroy" do
61
- it "calls the reset command" do
62
- driver.expects(:run_command).with("mulligan")
63
-
64
- driver.destroy(state)
65
- end
66
-
67
- it "skips reset command if :reset_command is falsey" do
68
- config[:reset_command] = false
69
- driver.expects(:run_command).never
70
-
71
- driver.destroy(state)
72
- end
73
- end
74
-
75
- end
@@ -1,127 +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/driver/proxy"
22
-
23
- describe Kitchen::Driver::Proxy do
24
- let(:logged_output) { StringIO.new }
25
- let(:logger) { Logger.new(logged_output) }
26
- let(:state) { Hash.new }
27
-
28
- let(:config) do
29
- { host: "foobnoobs.com", reset_command: "mulligan" }
30
- end
31
-
32
- let(:instance) do
33
- stub(name: "coolbeans", logger: logger, to_str: "instance")
34
- end
35
-
36
- let(:driver) do
37
- Kitchen::Driver::Proxy.new(config).finalize_config!(instance)
38
- end
39
-
40
- it "plugin_version is set to Kitchen::VERSION" do
41
- driver.diagnose_plugin[:version].must_equal Kitchen::VERSION
42
- end
43
-
44
- describe "non-parallel action" do
45
- it "create must be serially executed" do
46
- Kitchen::Driver::Proxy.serial_actions.must_include :create
47
- end
48
-
49
- it "destroy must be serially executed" do
50
- Kitchen::Driver::Proxy.serial_actions.must_include :destroy
51
- end
52
- end
53
-
54
- describe "required_config" do
55
- it "requires host" do
56
- config.delete(:host)
57
- err = assert_raises(Kitchen::UserError) { driver }
58
- err.message.must_include "config[:host] cannot be blank"
59
- end
60
-
61
- it "does not require reset_command" do
62
- config.delete(:reset_command)
63
- driver # Just make sure it doesn't raise
64
- end
65
- end
66
-
67
- describe "#create" do
68
- it "sets :hostname in state config" do
69
- driver.stubs(:ssh)
70
- driver.create(state)
71
-
72
- state[:hostname].must_equal "foobnoobs.com"
73
- end
74
-
75
- it "calls the reset command over ssh" do
76
- driver.expects(:ssh).with do |ssh_args, cmd|
77
- ssh_args[0].must_equal "foobnoobs.com"
78
- cmd.must_equal "mulligan"
79
- end
80
-
81
- driver.create(state)
82
- end
83
-
84
- it "skips ssh call if :reset_command is falsey" do
85
- config[:reset_command] = false
86
- driver.expects(:ssh).never
87
-
88
- driver.create(state)
89
- end
90
- end
91
-
92
- describe "#destroy" do
93
- before do
94
- state[:hostname] = "beep"
95
- end
96
-
97
- it "deletes :hostname in state config" do
98
- driver.stubs(:ssh)
99
- driver.destroy(state)
100
-
101
- state[:hostname].must_be_nil
102
- end
103
-
104
- it "calls the reset command over ssh" do
105
- driver.expects(:ssh).with do |ssh_args, cmd|
106
- ssh_args[0].must_equal "beep"
107
- cmd.must_equal "mulligan"
108
- end
109
-
110
- driver.destroy(state)
111
- end
112
-
113
- it "skips ssh call if :hostname is not in state config" do
114
- state.delete(:hostname)
115
- driver.expects(:ssh).never
116
-
117
- driver.destroy(state)
118
- end
119
-
120
- it "skips ssh call if :reset_command is falsey" do
121
- config[:reset_command] = false
122
- driver.expects(:ssh).never
123
-
124
- driver.destroy(state)
125
- end
126
- end
127
- end
@@ -1,1136 +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/transport/ssh"
23
- require "kitchen/verifier/busser"
24
-
25
- module Kitchen
26
- module Driver
27
- class BackCompat < Kitchen::Driver::SSHBase
28
- def use_run_remote(state, command)
29
- connection = Kitchen::SSH.new(*build_ssh_args(state))
30
- run_remote(command, connection)
31
- end
32
-
33
- def use_transfer_path(state, locals, remote)
34
- connection = Kitchen::SSH.new(*build_ssh_args(state))
35
- transfer_path(locals, remote, connection)
36
- end
37
- end
38
-
39
- class SpeedyCompat < Kitchen::Driver::SSHBase
40
- end
41
-
42
- class DodgyCompat < Kitchen::Driver::SSHBase
43
- no_parallel_for :converge
44
- end
45
-
46
- class SlowCompat < Kitchen::Driver::SSHBase
47
- no_parallel_for :create, :destroy
48
- no_parallel_for :verify
49
- end
50
- end
51
- end
52
-
53
- describe Kitchen::Driver::SSHBase do
54
- let(:logged_output) { StringIO.new }
55
- let(:logger) { Logger.new(logged_output) }
56
- let(:config) { Hash.new }
57
- let(:state) { Hash.new }
58
-
59
- let(:verifier) do
60
- v = mock("busser")
61
- v.responds_like_instance_of(Kitchen::Verifier::Busser)
62
- v.stubs(:install_command).returns("install")
63
- v.stubs(:init_command).returns("init")
64
- v.stubs(:prepare_command).returns("prepare")
65
- v.stubs(:run_command).returns("run")
66
- v.stubs(:create_sandbox).returns(true)
67
- v.stubs(:cleanup_sandbox).returns(true)
68
- v.stubs(:sandbox_path).returns("/tmp/sandbox")
69
- v.stubs(:[]).with(:root_path).returns("/tmp/verifier")
70
- v
71
- end
72
-
73
- let(:provisioner) do
74
- stub(
75
- install_command: "install",
76
- init_command: "init",
77
- prepare_command: "prepare",
78
- run_command: "run",
79
- create_sandbox: true,
80
- cleanup_sandbox: true,
81
- sandbox_path: "/tmp/sandbox"
82
- )
83
- end
84
-
85
- let(:transport) do
86
- t = mock("transport")
87
- t.responds_like_instance_of(Kitchen::Transport::Base)
88
- t
89
- end
90
-
91
- let(:instance) do
92
- stub(
93
- name: "coolbeans",
94
- logger: logger,
95
- verifier: verifier,
96
- provisioner: provisioner,
97
- transport: transport,
98
- to_str: "instance"
99
- )
100
- end
101
-
102
- let(:driver) do
103
- Kitchen::Driver::SSHBase.new(config).finalize_config!(instance)
104
- end
105
-
106
- it "plugin_version is not set" do
107
- driver.diagnose_plugin[:version].must_be_nil
108
- end
109
-
110
- describe "configuration" do
111
- it ":sudo defaults to true" do
112
- driver[:sudo].must_equal true
113
- end
114
-
115
- it ":port defaults to 22" do
116
- driver[:port].must_equal 22
117
- end
118
- end
119
-
120
- it "#create raises a ClientError" do
121
- proc { driver.create(state) }.must_raise Kitchen::ClientError
122
- end
123
-
124
- it "#destroy raises a ClientError" do
125
- proc { driver.destroy(state) }.must_raise Kitchen::ClientError
126
- end
127
-
128
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
129
- def self.constructs_an_ssh_connection
130
- describe "constructs an SSH connection" do
131
- it "with hostname set from state" do
132
- transport.expects(:connection).with do |state|
133
- state[:hostname].must_equal "fizzy"
134
- end.returns(stub(login_command: stub))
135
-
136
- cmd
137
- end
138
-
139
- it "with username set from state" do
140
- transport.expects(:connection).with do |state|
141
- state[:username].must_equal "bork"
142
- end.returns(stub(login_command: stub))
143
-
144
- cmd
145
- end
146
-
147
- it "with :ssh_key option set from config" do
148
- config[:ssh_key] = "wicked"
149
-
150
- transport.expects(:connection).with do |state|
151
- state[:ssh_key].must_equal "wicked"
152
- end.returns(stub(login_command: stub))
153
-
154
- cmd
155
- end
156
-
157
- it "with :ssh_key option set from state" do
158
- state[:ssh_key] = "wicked"
159
-
160
- transport.expects(:connection).with do |state|
161
- state[:ssh_key].must_equal "wicked"
162
- end.returns(stub(login_command: stub))
163
-
164
- cmd
165
- end
166
-
167
- it "with :password option set to falsey by default" do
168
- transport.expects(:connection).with do |state|
169
- state[:password].nil?
170
- end.returns(stub(login_command: stub))
171
-
172
- cmd
173
- end
174
-
175
- it "with :password option set if given in config" do
176
- config[:password] = "psst"
177
-
178
- transport.expects(:connection).with do |state|
179
- state[:password].must_equal "psst"
180
- end.returns(stub(login_command: stub))
181
-
182
- cmd
183
- end
184
-
185
- it "with :password option set if given in state" do
186
- state[:password] = "psst"
187
-
188
- transport.expects(:connection).with do |state|
189
- state[:password].must_equal "psst"
190
- end.returns(stub(login_command: stub))
191
-
192
- cmd
193
- end
194
-
195
- it "with :forward_agent option set to falsey by default" do
196
- transport.expects(:connection).with do |state|
197
- state[:forward_agent].nil?
198
- end.returns(stub(login_command: stub))
199
-
200
- cmd
201
- end
202
-
203
- it "with :forward_agent option set if given in config" do
204
- config[:forward_agent] = "yeah?"
205
-
206
- transport.expects(:connection).with do |state|
207
- state[:forward_agent].must_equal "yeah?"
208
- end.returns(stub(login_command: stub))
209
-
210
- cmd
211
- end
212
-
213
- it "with :forward_agent option set if given in state" do
214
- state[:forward_agent] = "yeah?"
215
-
216
- transport.expects(:connection).with do |state|
217
- state[:forward_agent].must_equal "yeah?"
218
- end.returns(stub(login_command: stub))
219
-
220
- cmd
221
- end
222
-
223
- it "with :port option set to 22 by default" do
224
- transport.expects(:connection).with do |state|
225
- state[:port].must_equal 22
226
- end.returns(stub(login_command: stub))
227
-
228
- cmd
229
- end
230
-
231
- it "with :port option set if customized in config" do
232
- config[:port] = 1234
233
-
234
- transport.expects(:connection).with do |state|
235
- state[:port].must_equal 1234
236
- end.returns(stub(login_command: stub))
237
-
238
- cmd
239
- end
240
-
241
- it "with :port option set if customized in state" do
242
- state[:port] = 9999
243
-
244
- transport.expects(:connection).with do |state|
245
- state[:port].must_equal 9999
246
- end.returns(stub(login_command: stub))
247
-
248
- cmd
249
- end
250
- end
251
- end
252
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
253
-
254
- describe "#login_command" do
255
- let(:cmd) { driver.login_command(state) }
256
-
257
- before do
258
- state[:hostname] = "fizzy"
259
- state[:username] = "bork"
260
- end
261
-
262
- it "returns a LoginCommand" do
263
- transport.stubs(:connection).returns(stub(login_command: "command"))
264
-
265
- cmd.must_equal "command"
266
- end
267
-
268
- constructs_an_ssh_connection
269
- end
270
-
271
- describe "#converge" do
272
- let(:cmd) { driver.converge(state) }
273
- let(:connection) { stub(execute: true, upload: true, download: true) }
274
-
275
- before do
276
- state[:hostname] = "fizzy"
277
- state[:username] = "bork"
278
- provisioner.stubs(:[]).with(:root_path).returns("/rooty")
279
- provisioner.stubs(:[]).with(:downloads).returns(
280
- ["/tmp/kitchen/nodes", "/tmp/kitchen/data_bags"] => "./test/fixtures",
281
- "/remote" => "/local"
282
- )
283
- FakeFS.activate!
284
- FileUtils.mkdir_p("/tmp")
285
- @original_env = ENV.to_hash
286
- ENV.replace("http_proxy" => nil, "HTTP_PROXY" => nil,
287
- "https_proxy" => nil, "HTTPS_PROXY" => nil,
288
- "ftp_proxy" => nil, "FTP_PROXY" => nil,
289
- "no_proxy" => nil, "NO_PROXY" => nil)
290
- end
291
-
292
- after do
293
- FakeFS.deactivate!
294
- FakeFS::FileSystem.clear
295
- ENV.clear
296
- ENV.replace(@original_env)
297
- end
298
-
299
- constructs_an_ssh_connection
300
-
301
- it "creates the sandbox" do
302
- transport.stubs(:connection).yields(connection)
303
- provisioner.expects(:create_sandbox)
304
-
305
- cmd
306
- end
307
-
308
- it "ensures that the sandbox is cleaned up" do
309
- transport.stubs(:connection).raises
310
- provisioner.expects(:cleanup_sandbox)
311
-
312
- begin
313
- cmd
314
- rescue # rubocop:disable Lint/HandleExceptions
315
- end
316
- end
317
-
318
- it "invokes the provisioner commands over ssh" do
319
- transport.stubs(:connection).yields(connection)
320
- order = sequence("order")
321
- connection.expects(:execute).with("install").in_sequence(order)
322
- connection.expects(:execute).with("init").in_sequence(order)
323
- connection.expects(:execute).with("prepare").in_sequence(order)
324
- connection.expects(:execute).with("run").in_sequence(order)
325
-
326
- cmd
327
- end
328
-
329
- it "invokes the #install_command with :http_proxy set in config" do
330
- config[:http_proxy] = "http://proxy"
331
- transport.stubs(:connection).yields(connection)
332
- connection.expects(:execute).with("env http_proxy=http://proxy install")
333
-
334
- cmd
335
- end
336
-
337
- it 'invokes the #install_command with ENV["http_proxy"] set' do
338
- ENV["http_proxy"] = "http://proxy"
339
- transport.stubs(:connection).yields(connection)
340
- if running_tests_on_windows?
341
- connection.expects(:execute)
342
- .with("env http_proxy=http://proxy HTTP_PROXY=http://proxy install")
343
- else
344
- connection.expects(:execute).with("env http_proxy=http://proxy install")
345
- end
346
- cmd
347
- end
348
-
349
- it 'invokes the #install_command with ENV["http_proxy"] and ENV["no_proxy"] set' do
350
- ENV["http_proxy"] = "http://proxy"
351
- ENV["no_proxy"] = "http://no"
352
- transport.stubs(:connection).yields(connection)
353
- if running_tests_on_windows?
354
- connection.expects(:execute)
355
- .with("env http_proxy=http://proxy HTTP_PROXY=http://proxy " \
356
- "no_proxy=http://no NO_PROXY=http://no install")
357
- else
358
- connection.expects(:execute).with("env http_proxy=http://proxy " \
359
- "no_proxy=http://no install")
360
- end
361
- cmd
362
- end
363
-
364
- it "invokes the #install_command with :https_proxy set in config" do
365
- config[:https_proxy] = "https://proxy"
366
- transport.stubs(:connection).yields(connection)
367
- connection.expects(:execute).with("env https_proxy=https://proxy install")
368
-
369
- cmd
370
- end
371
-
372
- it 'invokes the #install_command with ENV["https_proxy"] set' do
373
- ENV["https_proxy"] = "https://proxy"
374
- transport.stubs(:connection).yields(connection)
375
- if running_tests_on_windows?
376
- connection.expects(:execute)
377
- .with("env https_proxy=https://proxy HTTPS_PROXY=https://proxy install")
378
- else
379
- connection.expects(:execute).with("env https_proxy=https://proxy install")
380
- end
381
- cmd
382
- end
383
-
384
- it 'invokes the #install_command with ENV["https_proxy"] and ENV["no_proxy"] set' do
385
- ENV["https_proxy"] = "https://proxy"
386
- ENV["no_proxy"] = "https://no"
387
- transport.stubs(:connection).yields(connection)
388
- if running_tests_on_windows?
389
- connection.expects(:execute)
390
- .with("env https_proxy=https://proxy HTTPS_PROXY=https://proxy " \
391
- "no_proxy=https://no NO_PROXY=https://no install")
392
- else
393
- connection.expects(:execute).with("env https_proxy=https://proxy " \
394
- "no_proxy=https://no install")
395
- end
396
- cmd
397
- end
398
-
399
- it "invokes the #install_command with :ftp_proxy set in config" do
400
- config[:ftp_proxy] = "ftp://proxy"
401
- transport.stubs(:connection).yields(connection)
402
- connection.expects(:execute).with("env ftp_proxy=ftp://proxy install")
403
-
404
- cmd
405
- end
406
-
407
- it 'invokes the #install_command with ENV["ftp_proxy"] set' do
408
- ENV["ftp_proxy"] = "ftp://proxy"
409
- transport.stubs(:connection).yields(connection)
410
- if running_tests_on_windows?
411
- connection.expects(:execute)
412
- .with("env ftp_proxy=ftp://proxy FTP_PROXY=ftp://proxy install")
413
- else
414
- connection.expects(:execute).with("env ftp_proxy=ftp://proxy install")
415
- end
416
- cmd
417
- end
418
-
419
- it 'invokes the #install_command with ENV["ftp_proxy"] and ENV["no_proxy"] set' do
420
- ENV["ftp_proxy"] = "ftp://proxy"
421
- ENV["no_proxy"] = "http://no"
422
- transport.stubs(:connection).yields(connection)
423
- if running_tests_on_windows?
424
- connection.expects(:execute)
425
- .with("env ftp_proxy=ftp://proxy FTP_PROXY=http://proxy " \
426
- "no_proxy=http://no NO_PROXY=http://no install")
427
- else
428
- connection.expects(:execute).with("env ftp_proxy=ftp://proxy " \
429
- "no_proxy=http://no install")
430
- end
431
- cmd
432
- end
433
-
434
- it "invokes the #install_command with :http_proxy & :https_proxy & :ftp_proxy set" do
435
- config[:http_proxy] = "http://proxy"
436
- config[:https_proxy] = "https://proxy"
437
- config[:ftp_proxy] = "ftp://proxy"
438
- transport.stubs(:connection).yields(connection)
439
- connection.expects(:execute).with(
440
- "env http_proxy=http://proxy https_proxy=https://proxy ftp_proxy=ftp://proxy install")
441
-
442
- cmd
443
- end
444
-
445
- describe "transferring files" do
446
- before do
447
- transport.stubs(:connection).yields(connection)
448
- connection.stubs(:upload)
449
- FileUtils.mkdir_p "/tmp/sandbox/stuff"
450
- end
451
-
452
- it "uploads files" do
453
- connection.expects(:upload).with(["/tmp/sandbox/stuff"], "/rooty")
454
-
455
- cmd
456
- end
457
-
458
- it "logs to info" do
459
- cmd
460
-
461
- logged_output.string
462
- .must_match(/INFO -- : Transferring files to instance$/)
463
- end
464
-
465
- it "logs to debug" do
466
- cmd
467
-
468
- logged_output.string.must_match(/DEBUG -- : Transfer complete$/)
469
- end
470
-
471
- it "raises an ActionFailed on transfer when SshFailed is raised" do
472
- connection.stubs(:upload).raises(Kitchen::Transport::SshFailed.new("dang"))
473
-
474
- proc { cmd }.must_raise Kitchen::ActionFailed
475
- end
476
- end
477
-
478
- describe "downloading files" do
479
- before do
480
- transport.stubs(:connection).yields(connection)
481
- connection.stubs(:download)
482
- end
483
-
484
- it "downloads files" do
485
- connection.expects(:download).with(
486
- ["/tmp/kitchen/nodes", "/tmp/kitchen/data_bags"],
487
- "./test/fixtures"
488
- )
489
- connection.expects(:download).with("/remote", "/local")
490
-
491
- cmd
492
- end
493
-
494
- it "logs to info" do
495
- cmd
496
-
497
- logged_output.string.must_match(
498
- /INFO -- : Downloading files from instance$/
499
- )
500
- end
501
-
502
- it "logs to debug" do
503
- cmd
504
-
505
- logged_output.string.must_match(
506
- %r{DEBUG -- : Downloading /tmp/kitchen/nodes, /tmp/kitchen/data_bags to ./test/fixtures$}
507
- )
508
- logged_output.string.must_match(
509
- %r{DEBUG -- : Downloading /remote to /local$}
510
- )
511
- logged_output.string.must_match(/DEBUG -- : Download complete$/)
512
- end
513
- end
514
-
515
- it "raises an ActionFailed on execute when SshFailed is raised" do
516
- transport.stubs(:connection).yields(connection)
517
- connection.stubs(:execute).raises(Kitchen::Transport::SshFailed.new("dang"))
518
-
519
- proc { cmd }.must_raise Kitchen::ActionFailed
520
- end
521
- end
522
-
523
- describe "#setup" do
524
- let(:cmd) { driver.setup(state) }
525
- let(:connection) { mock }
526
-
527
- before do
528
- state[:hostname] = "fizzy"
529
- state[:username] = "bork"
530
- end
531
-
532
- constructs_an_ssh_connection
533
-
534
- it "invokes the Verifier#install_command over ssh" do
535
- transport.stubs(:connection).yields(connection)
536
- connection.expects(:execute).with("install")
537
-
538
- cmd
539
- end
540
-
541
- it "invokes the Verifier#install_command with :http_proxy set in config" do
542
- config[:http_proxy] = "http://proxy"
543
- transport.stubs(:connection).yields(connection)
544
- connection.expects(:execute).with("env http_proxy=http://proxy install")
545
-
546
- cmd
547
- end
548
-
549
- it "invokes the Verifier#install_command with :https_proxy set in config" do
550
- config[:https_proxy] = "https://proxy"
551
- transport.stubs(:connection).yields(connection)
552
- connection.expects(:execute).with("env https_proxy=https://proxy install")
553
-
554
- cmd
555
- end
556
-
557
- it "invokes the Verifier#install_command with :ftp_proxy set in config" do
558
- config[:ftp_proxy] = "ftp://proxy"
559
- transport.stubs(:connection).yields(connection)
560
- connection.expects(:execute).with("env ftp_proxy=ftp://proxy install")
561
-
562
- cmd
563
- end
564
-
565
- it "invokes the Verifier#install_command with :http_proxy & :https_proxy & :ftp_proxy set" do
566
- config[:http_proxy] = "http://proxy"
567
- config[:https_proxy] = "https://proxy"
568
- config[:ftp_proxy] = "ftp://proxy"
569
- transport.stubs(:connection).yields(connection)
570
- connection.expects(:execute).with(
571
- "env http_proxy=http://proxy https_proxy=https://proxy ftp_proxy=ftp://proxy install")
572
-
573
- cmd
574
- end
575
-
576
- it "raises an ActionFailed when SshFailed is raised" do
577
- transport.stubs(:connection).yields(connection)
578
- connection.stubs(:execute).raises(Kitchen::Transport::SshFailed.new("dang"))
579
-
580
- proc { cmd }.must_raise Kitchen::ActionFailed
581
- end
582
- end
583
-
584
- describe "#verify" do
585
- let(:cmd) { driver.verify(state) }
586
- let(:connection) { stub(execute: true, upload: true) }
587
-
588
- before do
589
- state[:hostname] = "fizzy"
590
- state[:username] = "bork"
591
- transport.stubs(:connection).yields(connection)
592
- end
593
-
594
- constructs_an_ssh_connection
595
-
596
- it "creates the sandbox" do
597
- verifier.expects(:create_sandbox)
598
-
599
- cmd
600
- end
601
-
602
- it "ensures that the sandbox is cleanup up" do
603
- transport.stubs(:connection).raises
604
- verifier.expects(:cleanup_sandbox)
605
-
606
- begin
607
- cmd
608
- rescue # rubocop:disable Lint/HandleExceptions
609
- end
610
- end
611
-
612
- it "invokes the verifier commands over the transport" do
613
- order = sequence("order")
614
- connection.expects(:execute).with("init").in_sequence(order)
615
- connection.expects(:execute).with("prepare").in_sequence(order)
616
- connection.expects(:execute).with("run").in_sequence(order)
617
-
618
- cmd
619
- end
620
-
621
- %w{init prepare run}.each do |phase|
622
- it "invokes Verifier##{phase}_command over ssh" do
623
- connection.expects(:execute).with(phase)
624
-
625
- cmd
626
- end
627
-
628
- it "invokes Verifier##{phase}_command with :http_proxy set in config" do
629
- config[:http_proxy] = "http://proxy"
630
- connection.expects(:execute).with("env http_proxy=http://proxy #{phase}")
631
-
632
- cmd
633
- end
634
-
635
- it "invokes Verifier##{phase}_command with :https_proxy set in config" do
636
- config[:https_proxy] = "https://proxy"
637
- connection.expects(:execute).with("env https_proxy=https://proxy #{phase}")
638
-
639
- cmd
640
- end
641
-
642
- it "invokes Verifier##{phase}_command with :ftp_proxy set in config" do
643
- config[:ftp_proxy] = "ftp://proxy"
644
- connection.expects(:execute).with("env ftp_proxy=ftp://proxy #{phase}")
645
-
646
- cmd
647
- end
648
-
649
- it "invokes Verifier##{phase}_command with :http_proxy & :https_proxy & :ftp_proxy set" do
650
- config[:http_proxy] = "http://proxy"
651
- config[:https_proxy] = "https://proxy"
652
- config[:ftp_proxy] = "ftp://proxy"
653
- connection.expects(:execute).with(
654
- "env http_proxy=http://proxy https_proxy=https://proxy ftp_proxy=ftp://proxy #{phase}")
655
-
656
- cmd
657
- end
658
- end
659
-
660
- it "logs to info" do
661
- cmd
662
-
663
- logged_output.string
664
- .must_match(/INFO -- : Transferring files to instance$/)
665
- end
666
-
667
- it "uploads sandbox files" do
668
- connection.expects(:upload).with([], "/tmp/verifier")
669
-
670
- cmd
671
- end
672
-
673
- it "logs to debug" do
674
- cmd
675
-
676
- logged_output.string.must_match(/DEBUG -- : Transfer complete$/)
677
- end
678
-
679
- it "raises an ActionFailed on transfer when TransportFailed is raised" do
680
- connection.stubs(:upload)
681
- .raises(Kitchen::Transport::TransportFailed.new("dang"))
682
-
683
- proc { cmd }.must_raise Kitchen::ActionFailed
684
- end
685
-
686
- it "raises an ActionFailed when SSHFailed is raised" do
687
- connection.stubs(:execute).raises(Kitchen::Transport::SshFailed.new("dang"))
688
-
689
- proc { cmd }.must_raise Kitchen::ActionFailed
690
- end
691
- end
692
-
693
- describe "#ssh" do
694
- let(:cmd) { driver.ssh(["host", "user", { one: "two" }], "go") }
695
- let(:connection) { mock }
696
-
697
- it "creates an SSH connection" do
698
- connection.stubs(:execute)
699
- transport.expects(:connection).with(
700
- hostname: "host",
701
- username: "user",
702
- port: 22,
703
- one: "two"
704
- ).yields(connection)
705
-
706
- cmd
707
- end
708
-
709
- it "invokes the command over ssh" do
710
- transport.expects(:connection).yields(connection)
711
- connection.expects(:execute).with("go")
712
-
713
- cmd
714
- end
715
- end
716
-
717
- describe "#remote_command" do
718
- let(:cmd) { driver.remote_command(state, "shipit") }
719
- let(:connection) { mock }
720
-
721
- before do
722
- state[:hostname] = "fizzy"
723
- state[:username] = "bork"
724
- end
725
-
726
- it "creates an SSH connection" do
727
- transport.expects(:connection).with(
728
- hostname: "fizzy",
729
- username: "bork",
730
- port: 22
731
- )
732
-
733
- cmd
734
- end
735
-
736
- it "invokes the command over ssh" do
737
- transport.expects(:connection).yields(connection)
738
- connection.expects(:execute).with("shipit")
739
-
740
- cmd
741
- end
742
- end
743
-
744
- describe "#wait_for_sshd" do
745
- let(:cmd) do
746
- driver.send(:wait_for_sshd, "host", "user", one: "two")
747
- end
748
-
749
- it "creates an SSH connection with merged options" do
750
- transport.expects(:connection).with(
751
- hostname: "host",
752
- username: "user",
753
- port: 22,
754
- one: "two"
755
- ).returns(stub(wait_until_ready: true))
756
-
757
- cmd
758
- end
759
-
760
- it "calls wait on the SSH connection" do
761
- connection = mock
762
- transport.expects(:connection).returns(connection)
763
- connection.expects(:wait_until_ready)
764
-
765
- cmd
766
- end
767
- end
768
-
769
- describe "to maintain backwards compatibility" do
770
- let(:driver) do
771
- Kitchen::Driver::BackCompat.new(config).finalize_config!(instance)
772
- end
773
-
774
- it "#instance returns its instance" do
775
- driver.instance.must_equal instance
776
- end
777
-
778
- it "#name returns the name of the driver" do
779
- driver.name.must_equal "BackCompat"
780
- end
781
-
782
- describe "#logger" do
783
- before { @klog = Kitchen.logger }
784
- after { Kitchen.logger = @klog }
785
-
786
- it "returns the instance's logger if defined" do
787
- driver.send(:logger).must_equal logger
788
- end
789
-
790
- it "returns the default logger if instance's logger is not set" do
791
- driver = Kitchen::Driver::BackCompat.new(config)
792
- Kitchen.logger = "yep"
793
-
794
- driver.send(:logger).must_equal Kitchen.logger
795
- end
796
- end
797
-
798
- it "#puts calls logger.info" do
799
- driver.send(:puts, "yo")
800
-
801
- logged_output.string.must_match(/I, /)
802
- logged_output.string.must_match(/yo\n/)
803
- end
804
-
805
- it "#print calls logger.info" do
806
- driver.send(:print, "yo")
807
-
808
- logged_output.string.must_match(/I, /)
809
- logged_output.string.must_match(/yo\n/)
810
- end
811
-
812
- it "has a default verify dependencies method" do
813
- driver.verify_dependencies.must_be_nil
814
- end
815
-
816
- it "#busser returns the instance's verifier" do
817
- driver.send(:busser).must_equal verifier
818
- end
819
-
820
- describe ".no_parallel_for" do
821
- it "registers no serial actions when none are declared" do
822
- Kitchen::Driver::SpeedyCompat.serial_actions.must_be_nil
823
- end
824
-
825
- it "registers a single serial action method" do
826
- Kitchen::Driver::DodgyCompat.serial_actions.must_equal [:converge]
827
- end
828
-
829
- it "registers multiple serial action methods" do
830
- actions = Kitchen::Driver::SlowCompat.serial_actions
831
-
832
- actions.must_include :create
833
- actions.must_include :verify
834
- actions.must_include :destroy
835
- end
836
-
837
- it "raises a ClientError if value is not an action method" do
838
- proc do
839
- Class.new(Kitchen::Driver::BackCompat) do
840
- no_parallel_for :telling_stories
841
- end
842
- end.must_raise Kitchen::ClientError
843
- end
844
- end
845
-
846
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
847
- def self.constructs_an_ssh_object
848
- it "with hostname set from state" do
849
- Kitchen::SSH.expects(:new).with do |hostname, _username, _opts|
850
- hostname.must_equal "fizzy"
851
- end.returns(connection)
852
-
853
- cmd
854
- end
855
-
856
- it "with username set from state" do
857
- Kitchen::SSH.expects(:new).with do |_hostname, username, _opts|
858
- username.must_equal "bork"
859
- end.returns(connection)
860
-
861
- cmd
862
- end
863
-
864
- it "with :user_known_hosts_file option set to /dev/null" do
865
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
866
- opts[:user_known_hosts_file].must_equal "/dev/null"
867
- end.returns(connection)
868
-
869
- cmd
870
- end
871
-
872
- it "with :verify_host_key option set to false" do
873
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
874
- opts[:verify_host_key].must_equal false
875
- end.returns(connection)
876
-
877
- cmd
878
- end
879
-
880
- it "with :keys_only option set to falsey by default" do
881
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
882
- opts[:keys_only].nil?
883
- end.returns(connection)
884
-
885
- cmd
886
- end
887
-
888
- it "with :keys_only option set to true if :ssh_key is set in config" do
889
- config[:ssh_key] = "wicked"
890
-
891
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
892
- opts[:keys_only].must_equal true
893
- end.returns(connection)
894
-
895
- cmd
896
- end
897
-
898
- it "with :keys_only option set to true if :ssh_key is set in state" do
899
- state[:ssh_key] = "wicked"
900
-
901
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
902
- opts[:keys_only].must_equal true
903
- end.returns(connection)
904
-
905
- cmd
906
- end
907
-
908
- it "with :keys option set to falsey by default" do
909
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
910
- opts[:keys].nil?
911
- end.returns(connection)
912
-
913
- cmd
914
- end
915
-
916
- it "with :keys option set to an array if :ssh_key is set in config" do
917
- config[:ssh_key] = "wicked"
918
-
919
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
920
- opts[:keys].must_equal ["wicked"]
921
- end.returns(connection)
922
-
923
- cmd
924
- end
925
-
926
- it "with :keys option set to an array if :ssh_key is set in state" do
927
- state[:ssh_key] = "wicked"
928
-
929
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
930
- opts[:keys].must_equal ["wicked"]
931
- end.returns(connection)
932
-
933
- cmd
934
- end
935
-
936
- it "with :password option set to falsey by default" do
937
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
938
- opts[:password].nil?
939
- end.returns(connection)
940
-
941
- cmd
942
- end
943
-
944
- it "with :password option set if given in config" do
945
- config[:password] = "psst"
946
-
947
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
948
- opts[:password].must_equal "psst"
949
- end.returns(connection)
950
-
951
- cmd
952
- end
953
-
954
- it "with :password option set if given in state" do
955
- state[:password] = "psst"
956
-
957
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
958
- opts[:password].must_equal "psst"
959
- end.returns(connection)
960
-
961
- cmd
962
- end
963
-
964
- it "with :forward_agent option set to falsey by default" do
965
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
966
- opts[:forward_agent].nil?
967
- end.returns(connection)
968
-
969
- cmd
970
- end
971
-
972
- it "with :forward_agent option set if given in config" do
973
- config[:forward_agent] = "yeah?"
974
-
975
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
976
- opts[:forward_agent].must_equal "yeah?"
977
- end.returns(connection)
978
-
979
- cmd
980
- end
981
-
982
- it "with :forward_agent option set if given in state" do
983
- state[:forward_agent] = "yeah?"
984
-
985
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
986
- opts[:forward_agent].must_equal "yeah?"
987
- end.returns(connection)
988
-
989
- cmd
990
- end
991
-
992
- it "with :port option set to 22 by default" do
993
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
994
- opts[:port].must_equal 22
995
- end.returns(connection)
996
-
997
- cmd
998
- end
999
-
1000
- it "with :port option set if customized in config" do
1001
- config[:port] = 1234
1002
-
1003
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
1004
- opts[:port].must_equal 1234
1005
- end.returns(connection)
1006
-
1007
- cmd
1008
- end
1009
-
1010
- it "with :port option set if customized in state" do
1011
- state[:port] = 9999
1012
-
1013
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
1014
- opts[:port].must_equal 9999
1015
- end.returns(connection)
1016
-
1017
- cmd
1018
- end
1019
-
1020
- it "with :logger option set to driver's logger" do
1021
- Kitchen::SSH.expects(:new).with do |_hostname, _username, opts|
1022
- opts[:logger].must_equal logger
1023
- end.returns(connection)
1024
-
1025
- cmd
1026
- end
1027
- end
1028
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
1029
-
1030
- describe "#run_remote" do
1031
- let(:cmd) { driver.use_run_remote(state, "huh") }
1032
- let(:connection) { stub(exec: true) }
1033
-
1034
- before do
1035
- state[:hostname] = "fizzy"
1036
- state[:username] = "bork"
1037
- end
1038
-
1039
- constructs_an_ssh_object
1040
-
1041
- it "invokes the #install_command with :http_proxy set in config" do
1042
- config[:http_proxy] = "http://proxy"
1043
- Kitchen::SSH.stubs(:new).returns(connection)
1044
- connection.expects(:exec).with("env http_proxy=http://proxy huh")
1045
-
1046
- cmd
1047
- end
1048
-
1049
- it "invokes the #install_command with :https_proxy set in config" do
1050
- config[:https_proxy] = "https://proxy"
1051
- Kitchen::SSH.stubs(:new).returns(connection)
1052
- connection.expects(:exec).with("env https_proxy=https://proxy huh")
1053
-
1054
- cmd
1055
- end
1056
-
1057
- it "invokes the #install_command with :ftp_proxy set in config" do
1058
- config[:ftp_proxy] = "ftp://proxy"
1059
- Kitchen::SSH.stubs(:new).returns(connection)
1060
- connection.expects(:exec).with("env ftp_proxy=ftp://proxy huh")
1061
-
1062
- cmd
1063
- end
1064
-
1065
- it "invokes the #install_command with :http_proxy & :https_proxy & :ftp_proxy set" do
1066
- config[:http_proxy] = "http://proxy"
1067
- config[:https_proxy] = "https://proxy"
1068
- config[:ftp_proxy] = "ftp://proxy"
1069
- Kitchen::SSH.stubs(:new).returns(connection)
1070
- connection.expects(:exec).with(
1071
- "env http_proxy=http://proxy https_proxy=https://proxy ftp_proxy=ftp://proxy huh")
1072
-
1073
- cmd
1074
- end
1075
-
1076
- it "doesn't invoke an ssh command if command is nil" do
1077
- Kitchen::SSH.stubs(:new).returns(mock)
1078
-
1079
- driver.use_run_remote(state, nil)
1080
- end
1081
-
1082
- it "raises an ActionFailed on transfer when SSHFailed is raised" do
1083
- Kitchen::SSH.stubs(:new).returns(connection)
1084
- connection.stubs(:exec).raises(Kitchen::SSHFailed.new("dang"))
1085
-
1086
- proc { cmd }.must_raise Kitchen::ActionFailed
1087
- end
1088
-
1089
- it "raises an ActionFailed on exec when Net::SSH:Exception is raised" do
1090
- Kitchen::SSH.stubs(:new).returns(connection)
1091
- connection.stubs(:exec).raises(Net::SSH::Exception.new("dang"))
1092
-
1093
- proc { cmd }.must_raise Kitchen::ActionFailed
1094
- end
1095
- end
1096
-
1097
- describe "#transfer_path" do
1098
- let(:cmd) { driver.use_transfer_path(state, ["nope"], "nadda") }
1099
- let(:channel) { stub(wait: true) }
1100
- let(:connection) { stub(upload_path!: true, upload_path: channel) }
1101
-
1102
- before do
1103
- state[:hostname] = "fizzy"
1104
- state[:username] = "bork"
1105
- end
1106
-
1107
- constructs_an_ssh_object
1108
-
1109
- it "doesn't invoke an scp command if locals is nil" do
1110
- Kitchen::SSH.stubs(:new).returns(mock)
1111
-
1112
- driver.use_transfer_path(state, nil, "nope")
1113
- end
1114
-
1115
- it "doesn't invoke an scp command if locals is an empty array" do
1116
- Kitchen::SSH.stubs(:new).returns(mock)
1117
-
1118
- driver.use_transfer_path(state, [], "nope")
1119
- end
1120
-
1121
- it "raises an ActionFailed on transfer when SSHFailed is raised" do
1122
- Kitchen::SSH.stubs(:new).returns(connection)
1123
- connection.stubs(:upload_path).raises(Kitchen::SSHFailed.new("dang"))
1124
-
1125
- proc { cmd }.must_raise Kitchen::ActionFailed
1126
- end
1127
-
1128
- it "raises an ActionFailed on exec when Net::SSH:Exception is raised" do
1129
- Kitchen::SSH.stubs(:new).returns(connection)
1130
- connection.stubs(:upload_path).raises(Net::SSH::Exception.new("dang"))
1131
-
1132
- proc { cmd }.must_raise Kitchen::ActionFailed
1133
- end
1134
- end
1135
- end
1136
- end