chef 11.12.8-x86-mingw32 → 11.14.0.alpha.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -2
  3. data/distro/common/html/_sources/index.txt +6 -0
  4. data/distro/common/html/_sources/knife_ssl_check.txt +41 -0
  5. data/distro/common/html/_sources/knife_ssl_fetch.txt +41 -0
  6. data/distro/common/html/_static/basic.css +2 -5
  7. data/distro/common/html/_static/doctools.js +5 -14
  8. data/distro/common/html/_static/jquery.js +2 -154
  9. data/distro/common/html/_static/pygments.css +2 -2
  10. data/distro/common/html/_static/searchtools.js +212 -150
  11. data/distro/common/html/_static/underscore.js +29 -21
  12. data/distro/common/html/_static/websupport.js +1 -1
  13. data/distro/common/html/ctl_chef_client.html +15 -18
  14. data/distro/common/html/ctl_chef_server.html +7 -7
  15. data/distro/common/html/ctl_chef_shell.html +6 -6
  16. data/distro/common/html/ctl_chef_solo.html +7 -8
  17. data/distro/common/html/index.html +34 -24
  18. data/distro/common/html/knife.html +23 -24
  19. data/distro/common/html/knife_bootstrap.html +13 -9
  20. data/distro/common/html/knife_client.html +10 -11
  21. data/distro/common/html/knife_common_options.html +6 -7
  22. data/distro/common/html/knife_configure.html +3 -4
  23. data/distro/common/html/knife_cookbook.html +18 -11
  24. data/distro/common/html/knife_cookbook_site.html +14 -14
  25. data/distro/common/html/knife_data_bag.html +24 -23
  26. data/distro/common/html/knife_delete.html +4 -5
  27. data/distro/common/html/knife_deps.html +4 -5
  28. data/distro/common/html/knife_diff.html +6 -7
  29. data/distro/common/html/knife_download.html +12 -13
  30. data/distro/common/html/knife_edit.html +4 -5
  31. data/distro/common/html/knife_environment.html +8 -9
  32. data/distro/common/html/knife_exec.html +9 -10
  33. data/distro/common/html/knife_index_rebuild.html +4 -5
  34. data/distro/common/html/knife_list.html +8 -9
  35. data/distro/common/html/knife_node.html +34 -33
  36. data/distro/common/html/knife_raw.html +2 -3
  37. data/distro/common/html/knife_recipe_list.html +3 -4
  38. data/distro/common/html/knife_role.html +30 -29
  39. data/distro/common/html/knife_search.html +7 -7
  40. data/distro/common/html/knife_show.html +4 -5
  41. data/distro/common/html/knife_ssh.html +2 -3
  42. data/distro/common/html/knife_ssl_check.html +148 -0
  43. data/distro/common/html/knife_ssl_fetch.html +152 -0
  44. data/distro/common/html/knife_status.html +4 -5
  45. data/distro/common/html/knife_tag.html +2 -3
  46. data/distro/common/html/knife_upload.html +5 -6
  47. data/distro/common/html/knife_user.html +9 -10
  48. data/distro/common/html/knife_using.html +12 -12
  49. data/distro/common/html/knife_xargs.html +11 -12
  50. data/distro/common/html/search.html +1 -2
  51. data/distro/common/html/searchindex.js +1 -1
  52. data/distro/common/man/man1/chef-shell.1 +19 -11
  53. data/distro/common/man/man1/knife-bootstrap.1 +35 -19
  54. data/distro/common/man/man1/knife-client.1 +111 -28
  55. data/distro/common/man/man1/knife-configure.1 +30 -14
  56. data/distro/common/man/man1/knife-cookbook-site.1 +105 -22
  57. data/distro/common/man/man1/knife-cookbook.1 +164 -23
  58. data/distro/common/man/man1/knife-data-bag.1 +157 -33
  59. data/distro/common/man/man1/knife-delete.1 +21 -17
  60. data/distro/common/man/man1/knife-deps.1 +60 -16
  61. data/distro/common/man/man1/knife-diff.1 +37 -17
  62. data/distro/common/man/man1/knife-download.1 +68 -24
  63. data/distro/common/man/man1/knife-edit.1 +19 -15
  64. data/distro/common/man/man1/knife-environment.1 +105 -17
  65. data/distro/common/man/man1/knife-exec.1 +78 -18
  66. data/distro/common/man/man1/knife-index-rebuild.1 +16 -8
  67. data/distro/common/man/man1/knife-list.1 +39 -23
  68. data/distro/common/man/man1/knife-node.1 +170 -22
  69. data/distro/common/man/man1/knife-raw.1 +33 -13
  70. data/distro/common/man/man1/knife-recipe-list.1 +17 -5
  71. data/distro/common/man/man1/knife-role.1 +86 -18
  72. data/distro/common/man/man1/knife-search.1 +80 -16
  73. data/distro/common/man/man1/knife-show.1 +30 -14
  74. data/distro/common/man/man1/knife-ssh.1 +54 -14
  75. data/distro/common/man/man1/knife-ssl-check.1 +207 -0
  76. data/distro/common/man/man1/knife-ssl-fetch.1 +207 -0
  77. data/distro/common/man/man1/knife-status.1 +48 -12
  78. data/distro/common/man/man1/knife-tag.1 +30 -10
  79. data/distro/common/man/man1/knife-upload.1 +72 -20
  80. data/distro/common/man/man1/knife-user.1 +79 -23
  81. data/distro/common/man/man1/knife-xargs.1 +61 -53
  82. data/distro/common/man/man8/chef-client.8 +87 -29
  83. data/distro/common/man/man8/chef-solo.8 +36 -15
  84. data/lib/chef/application.rb +19 -14
  85. data/lib/chef/application/client.rb +5 -0
  86. data/lib/chef/application/solo.rb +5 -0
  87. data/lib/chef/application/windows_service_manager.rb +3 -0
  88. data/lib/chef/chef_fs/chef_fs_data_store.rb +72 -24
  89. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +20 -4
  90. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +20 -1
  91. data/lib/chef/chef_fs/file_system/file_system_entry.rb +10 -2
  92. data/lib/chef/client.rb +2 -3
  93. data/lib/chef/config.rb +34 -8
  94. data/lib/chef/cookbook/cookbook_version_loader.rb +45 -4
  95. data/lib/chef/cookbook_version.rb +38 -30
  96. data/lib/chef/dsl/recipe.rb +4 -1
  97. data/lib/chef/event_dispatch/base.rb +14 -0
  98. data/lib/chef/event_dispatch/events_output_stream.rb +29 -0
  99. data/lib/chef/exceptions.rb +8 -0
  100. data/lib/chef/formatters/base.rb +16 -45
  101. data/lib/chef/formatters/doc.rb +51 -26
  102. data/lib/chef/formatters/indentable_output_stream.rb +165 -0
  103. data/lib/chef/knife/node_environment_set.rb +54 -0
  104. data/lib/chef/knife/user_create.rb +1 -1
  105. data/lib/chef/monkey_patches/pathname.rb +32 -0
  106. data/lib/chef/node.rb +1 -1
  107. data/lib/chef/platform/provider_mapping.rb +345 -338
  108. data/lib/chef/policy_builder/expand_node_object.rb +1 -1
  109. data/lib/chef/policy_builder/policyfile.rb +1 -1
  110. data/lib/chef/provider.rb +1 -0
  111. data/lib/chef/provider/git.rb +1 -1
  112. data/lib/chef/provider/link.rb +2 -2
  113. data/lib/chef/provider/remote_file/content.rb +1 -1
  114. data/lib/chef/provider/remote_file/local_file.rb +8 -2
  115. data/lib/chef/provider/service/arch.rb +0 -1
  116. data/lib/chef/provider/service/debian.rb +0 -2
  117. data/lib/chef/provider/service/freebsd.rb +2 -1
  118. data/lib/chef/provider/service/gentoo.rb +1 -1
  119. data/lib/chef/provider/service/init.rb +0 -1
  120. data/lib/chef/provider/service/insserv.rb +0 -2
  121. data/lib/chef/provider/service/invokercd.rb +0 -2
  122. data/lib/chef/provider/service/macosx.rb +2 -1
  123. data/lib/chef/provider/service/redhat.rb +0 -1
  124. data/lib/chef/provider/service/simple.rb +1 -0
  125. data/lib/chef/provider/service/solaris.rb +1 -0
  126. data/lib/chef/provider/service/systemd.rb +1 -1
  127. data/lib/chef/provider/service/upstart.rb +1 -1
  128. data/lib/chef/provider/user.rb +9 -9
  129. data/lib/chef/provider/user/solaris.rb +2 -0
  130. data/lib/chef/resource.rb +1 -0
  131. data/lib/chef/resource/remote_file.rb +32 -6
  132. data/lib/chef/run_context.rb +22 -0
  133. data/lib/chef/run_lock.rb +43 -4
  134. data/lib/chef/version.rb +2 -2
  135. data/spec/functional/http/simple_spec.rb +84 -0
  136. data/spec/functional/resource/remote_file_spec.rb +107 -43
  137. data/spec/functional/rest_spec.rb +94 -0
  138. data/spec/functional/run_lock_spec.rb +1 -1
  139. data/spec/functional/win32/service_manager_spec.rb +6 -0
  140. data/spec/integration/knife/chef_fs_data_store_spec.rb +2 -0
  141. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +76 -0
  142. data/spec/spec_helper.rb +2 -0
  143. data/spec/support/mock/platform.rb +7 -0
  144. data/spec/support/pedant/pedant_config.rb +121 -0
  145. data/spec/support/pedant/run_pedant.rb +63 -0
  146. data/spec/support/pedant/stickywicket.pem +27 -0
  147. data/spec/support/shared/functional/http.rb +242 -0
  148. data/spec/support/shared/unit/api_error_inspector.rb +2 -2
  149. data/spec/unit/api_client_spec.rb +2 -2
  150. data/spec/unit/application/client_spec.rb +6 -1
  151. data/spec/unit/application/knife_spec.rb +4 -0
  152. data/spec/unit/application/solo_spec.rb +2 -0
  153. data/spec/unit/application_spec.rb +7 -0
  154. data/spec/unit/client_spec.rb +16 -0
  155. data/spec/unit/config_spec.rb +3 -20
  156. data/spec/unit/cookbook_version_spec.rb +224 -122
  157. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +2 -2
  158. data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +2 -2
  159. data/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +2 -2
  160. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +2 -2
  161. data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +2 -2
  162. data/spec/unit/handler_spec.rb +0 -1
  163. data/spec/unit/knife/client_bulk_delete_spec.rb +3 -0
  164. data/spec/unit/knife/cookbook_bulk_delete_spec.rb +2 -0
  165. data/spec/unit/knife/cookbook_metadata_spec.rb +2 -2
  166. data/spec/unit/knife/cookbook_site_install_spec.rb +3 -1
  167. data/spec/unit/knife/cookbook_upload_spec.rb +10 -10
  168. data/spec/unit/knife/node_environment_set_spec.rb +80 -0
  169. data/spec/unit/knife/user_create_spec.rb +6 -4
  170. data/spec/unit/knife/user_edit_spec.rb +5 -0
  171. data/spec/unit/knife_spec.rb +3 -0
  172. data/spec/unit/mixin/securable_spec.rb +18 -20
  173. data/spec/unit/node/attribute_spec.rb +15 -2
  174. data/spec/unit/node/immutable_collections_spec.rb +4 -4
  175. data/spec/unit/provider/cron_spec.rb +14 -14
  176. data/spec/unit/provider/git_spec.rb +4 -4
  177. data/spec/unit/provider/group_spec.rb +1 -1
  178. data/spec/unit/provider/ohai_spec.rb +2 -2
  179. data/spec/unit/provider/remote_file/content_spec.rb +58 -35
  180. data/spec/unit/provider/remote_file/local_file_spec.rb +23 -0
  181. data/spec/unit/provider/service/solaris_smf_service_spec.rb +13 -13
  182. data/spec/unit/resource/mount_spec.rb +0 -1
  183. data/spec/unit/resource/remote_file_spec.rb +29 -0
  184. data/spec/unit/resource_spec.rb +1 -1
  185. data/spec/unit/run_context_spec.rb +7 -0
  186. data/spec/unit/run_lock_spec.rb +98 -0
  187. data/spec/unit/version_constraint_spec.rb +1 -1
  188. metadata +166 -153
  189. data/distro/common/html/_static/chef.css +0 -507
  190. data/distro/common/html/_static/chef_logo.png +0 -0
  191. data/lib/chef/checksum/storage.rb +0 -18
  192. data/lib/chef/checksum/storage/filesystem.rb +0 -56
  193. data/spec/unit/checksum/storage/filesystem_spec.rb +0 -70
@@ -24,7 +24,7 @@ describe Chef::Provider::Cron do
24
24
  @node = Chef::Node.new
25
25
  @events = Chef::EventDispatch::Dispatcher.new
26
26
  @run_context = Chef::RunContext.new(@node, {}, @events)
27
-
27
+
28
28
  @new_resource = Chef::Resource::Cron.new("cronhole some stuff", @run_context)
29
29
  @new_resource.user "root"
30
30
  @new_resource.minute "30"
@@ -32,10 +32,10 @@ describe Chef::Provider::Cron do
32
32
  @new_resource.time :reboot
33
33
  @provider = Chef::Provider::Cron.new(@new_resource, @run_context)
34
34
  end
35
-
35
+
36
36
  context "with a matching entry in the user's crontab" do
37
37
  before :each do
38
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
38
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
39
39
  0 2 * * * /some/other/command
40
40
 
41
41
  # Chef Name: cronhole some stuff
@@ -46,7 +46,7 @@ describe Chef::Provider::Cron do
46
46
  # Another comment
47
47
  CRONTAB
48
48
  end
49
-
49
+
50
50
  it "should set cron_exists" do
51
51
  @provider.load_current_resource
52
52
  @provider.cron_exists.should == true
@@ -60,7 +60,7 @@ CRONTAB
60
60
  end
61
61
 
62
62
  it "should pull env vars out" do
63
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
63
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
64
64
  0 2 * * * /some/other/command
65
65
 
66
66
  # Chef Name: cronhole some stuff
@@ -84,7 +84,7 @@ CRONTAB
84
84
  end
85
85
 
86
86
  it "should parse and load generic and standard environment variables from cron entry" do
87
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
87
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
88
88
  # Chef Name: cronhole some stuff
89
89
  MAILTO=warn@example.com
90
90
  TEST=lol
@@ -98,7 +98,7 @@ CRONTAB
98
98
  end
99
99
 
100
100
  it "should not break with variables that match the cron resource internals" do
101
- @provider.stub!(:read_crontab).and_return(<<-CRONTAB)
101
+ @provider.stub(:read_crontab).and_return(<<-CRONTAB)
102
102
  # Chef Name: cronhole some stuff
103
103
  MINUTE=40
104
104
  REBOOT=midnight
@@ -116,11 +116,11 @@ CRONTAB
116
116
  Chef::Log.should_receive(:debug).with("Found cron '#{@new_resource.name}'")
117
117
  @provider.load_current_resource
118
118
  end
119
-
119
+
120
120
  describe "action_create" do
121
121
  before :each do
122
- @provider.stub!(:write_crontab)
123
- @provider.stub!(:read_crontab).and_return(nil)
122
+ @provider.stub(:write_crontab)
123
+ @provider.stub(:read_crontab).and_return(nil)
124
124
  end
125
125
 
126
126
  context "when there is no existing crontab" do
@@ -128,7 +128,7 @@ CRONTAB
128
128
  @provider.cron_exists = false
129
129
  @provider.cron_empty = true
130
130
  end
131
-
131
+
132
132
  it "should create a crontab with the entry" do
133
133
  @provider.should_receive(:write_crontab).with(<<-ENDCRON)
134
134
  # Chef Name: cronhole some stuff
@@ -140,12 +140,12 @@ CRONTAB
140
140
  end
141
141
  end
142
142
  end
143
-
143
+
144
144
  before do
145
145
  @node = Chef::Node.new
146
146
  @events = Chef::EventDispatch::Dispatcher.new
147
147
  @run_context = Chef::RunContext.new(@node, {}, @events)
148
-
148
+
149
149
  @new_resource = Chef::Resource::Cron.new("cronhole some stuff", @run_context)
150
150
  @new_resource.user "root"
151
151
  @new_resource.minute "30"
@@ -417,7 +417,7 @@ CRONTAB
417
417
  @new_resource.send(:time, :reboot)
418
418
  @provider.cron_different?.should eql(true)
419
419
  end
420
-
420
+
421
421
  it "should return true if environment doesn't match" do
422
422
  @new_resource.environment "FOO" => "something_else"
423
423
  @provider.cron_different?.should eql(true)
@@ -93,7 +93,7 @@ describe Chef::Provider::Git do
93
93
  @resource.revision "v1.0"
94
94
  @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
95
95
  "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
96
- @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
96
+ @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
97
97
  @provider.target_revision.should eql("503c22a5e41f5ae3193460cca044ed1435029f53")
98
98
  end
99
99
 
@@ -102,7 +102,7 @@ describe Chef::Provider::Git do
102
102
  @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
103
103
  "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" +
104
104
  "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n")
105
- @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
105
+ @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
106
106
  @provider.target_revision.should eql("663c22a5e41f5ae3193460cca044ed1435029f53")
107
107
  end
108
108
 
@@ -131,7 +131,7 @@ describe Chef::Provider::Git do
131
131
  it "does not raise an error when the revision is valid and assertions are run." do
132
132
  @resource.revision "0.8-alpha"
133
133
  @stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n"
134
- @provider.should_receive(:shell_out!).with(@git_ls_remote + "0.8-alpha*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
134
+ @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
135
135
  @provider.action = :checkout
136
136
  ::File.stub(:directory?).with("/my/deploy").and_return(true)
137
137
  @provider.define_resource_requirements
@@ -156,7 +156,7 @@ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{}
156
156
  ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package
157
157
  SHAS
158
158
  @resource.revision ''
159
- @provider.should_receive(:shell_out!).with(@git_ls_remote + "HEAD", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
159
+ @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
160
160
  @provider.target_revision.should eql("28af684d8460ba4793eda3e7ac238c864a5d029a")
161
161
  end
162
162
  end
@@ -97,7 +97,7 @@ describe Chef::Provider::User do
97
97
  end
98
98
 
99
99
  it "should coerce an integer to a string for comparison" do
100
- @current_resource.stub!(:gid).and_return("500")
100
+ @current_resource.stub(:gid).and_return("500")
101
101
  @provider.compare_group.should be_false
102
102
  end
103
103
 
@@ -41,8 +41,8 @@ describe Chef::Provider::Ohai do
41
41
  :newdata => "somevalue"
42
42
  }
43
43
  }
44
- mock_ohai.stub!(:all_plugins).and_return(true)
45
- mock_ohai.stub!(:data).and_return(mock_ohai[:data],
44
+ mock_ohai.stub(:all_plugins).and_return(true)
45
+ mock_ohai.stub(:data).and_return(mock_ohai[:data],
46
46
  mock_ohai[:data2])
47
47
  Ohai::System.stub(:new).and_return(mock_ohai)
48
48
  Chef::Platform.stub(:find_platform_and_version).and_return({ "platform" => @platform,
@@ -160,44 +160,68 @@ describe Chef::Provider::RemoteFile::Content do
160
160
 
161
161
  describe "when there is an array of sources and the first fails" do
162
162
 
163
- let(:source) { [ "http://opscode.com/seattle.txt", "http://opscode.com/nyc.txt" ] }
164
- before do
165
- new_resource.stub(:checksum).and_return(nil)
166
- current_resource.stub(:checksum).and_return(nil)
167
- @uri0 = double("URI0")
168
- @uri1 = double("URI1")
169
- URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri0)
170
- URI.should_receive(:parse).with(new_resource.source[1]).and_return(@uri1)
171
- @http_fetcher_throws_exception = double("Chef::Provider::RemoteFile::HTTP")
172
- @http_fetcher_throws_exception.should_receive(:fetch).at_least(:once).and_raise(Errno::ECONNREFUSED)
173
- Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(@http_fetcher_throws_exception)
174
- end
175
-
176
- describe "when the second url succeeds" do
177
- before do
178
- @tempfile = double("Tempfile")
179
- mtime = Time.now
180
- http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile)
181
- Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works)
182
- end
183
-
184
- it "should return a valid tempfile" do
185
- content.tempfile.should == @tempfile
186
- end
187
-
188
- it "should not mutate the new_resource" do
189
- content.tempfile
190
- new_resource.source.length.should == 2
163
+ # https://github.com/opscode/chef/pull/1358#issuecomment-40853299
164
+ def create_exception(exception_class)
165
+ if [ Net::HTTPServerException, Net::HTTPFatalError ].include? exception_class
166
+ exception_class.new("message", {"something" => 1})
167
+ else
168
+ exception_class.new
191
169
  end
192
170
  end
193
171
 
194
- describe "when both urls fail" do
195
- before do
196
- Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(@http_fetcher_throws_exception)
197
- end
172
+ let(:source) { [ "http://opscode.com/seattle.txt", "http://opscode.com/nyc.txt" ] }
198
173
 
199
- it "should propagate the error back to the caller" do
200
- lambda { content.tempfile }.should raise_error(Errno::ECONNREFUSED)
174
+ ### Test each exception we care about and make sure they all behave properly
175
+ [
176
+ SocketError,
177
+ Errno::ECONNREFUSED,
178
+ Errno::ENOENT,
179
+ Errno::EACCES,
180
+ Timeout::Error,
181
+ Net::HTTPServerException,
182
+ Net::HTTPFatalError,
183
+ Net::FTPError
184
+ ].each do |exception|
185
+ describe "with an exception of #{exception}" do
186
+ before do
187
+ new_resource.stub(:checksum).and_return(nil)
188
+ current_resource.stub(:checksum).and_return(nil)
189
+ @uri0 = double("URI0")
190
+ @uri1 = double("URI1")
191
+ URI.should_receive(:parse).with(new_resource.source[0]).and_return(@uri0)
192
+ URI.should_receive(:parse).with(new_resource.source[1]).and_return(@uri1)
193
+ @http_fetcher_throws_exception = double("Chef::Provider::RemoteFile::HTTP")
194
+ @http_fetcher_throws_exception.should_receive(:fetch).at_least(:once).and_raise(create_exception(exception))
195
+ Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(@http_fetcher_throws_exception)
196
+ end
197
+
198
+ describe "the second url should succeed" do
199
+ before do
200
+ @tempfile = double("Tempfile")
201
+ mtime = Time.now
202
+ http_fetcher_works = double("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile)
203
+ Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works)
204
+ end
205
+
206
+ it "should return a valid tempfile" do
207
+ content.tempfile.should == @tempfile
208
+ end
209
+
210
+ it "should not mutate the new_resource" do
211
+ content.tempfile
212
+ new_resource.source.length.should == 2
213
+ end
214
+ end
215
+
216
+ describe "when both urls fail" do
217
+ before do
218
+ Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(@http_fetcher_throws_exception)
219
+ end
220
+
221
+ it "should propagate the error back to the caller" do
222
+ lambda { content.tempfile }.should raise_error(exception)
223
+ end
224
+ end
201
225
  end
202
226
  end
203
227
  end
@@ -227,4 +251,3 @@ describe Chef::Provider::RemoteFile::Content do
227
251
  end
228
252
 
229
253
  end
230
-
@@ -25,6 +25,29 @@ describe Chef::Provider::RemoteFile::LocalFile do
25
25
  let(:new_resource) { Chef::Resource::RemoteFile.new("local file backend test (new_resource)") }
26
26
  let(:current_resource) { Chef::Resource::RemoteFile.new("local file backend test (current_resource)") }
27
27
  subject(:fetcher) { Chef::Provider::RemoteFile::LocalFile.new(uri, new_resource, current_resource) }
28
+
29
+ context "when parsing source path" do
30
+ describe "when given local unix path" do
31
+ let(:uri) { URI.parse("file:///nyan_cat.png") }
32
+ it "returns a correct unix path" do
33
+ fetcher.fix_windows_path(uri.path).should == "/nyan_cat.png"
34
+ end
35
+ end
36
+
37
+ describe "when given local windows path" do
38
+ let(:uri) { URI.parse("file:///z:/windows/path/file.txt") }
39
+ it "returns a valid windows local path" do
40
+ fetcher.fix_windows_path(uri.path).should == "z:/windows/path/file.txt"
41
+ end
42
+ end
43
+
44
+ describe "when given unc windows path" do
45
+ let(:uri) { URI.parse("file:////server/share/windows/path/file.txt") }
46
+ it "returns a valid windows unc path" do
47
+ fetcher.fix_windows_path(uri.path).should == "//server/share/windows/path/file.txt"
48
+ end
49
+ end
50
+ end
28
51
 
29
52
  context "when first created" do
30
53
 
@@ -54,14 +54,14 @@ describe Chef::Provider::Service::Solaris do
54
54
 
55
55
  describe "when discovering the current service state" do
56
56
  it "should create a current resource with the name of the new resource" do
57
- @provider.stub!(:shell_out!).with("/bin/svcs -l chef").and_return(@status)
57
+ @provider.stub(:shell_out!).with("/bin/svcs -l chef").and_return(@status)
58
58
  Chef::Resource::Service.should_receive(:new).and_return(@current_resource)
59
59
  @provider.load_current_resource
60
60
  end
61
61
 
62
62
 
63
63
  it "should return the current resource" do
64
- @provider.stub!(:shell_out!).with("/bin/svcs -l chef").and_return(@status)
64
+ @provider.stub(:shell_out!).with("/bin/svcs -l chef").and_return(@status)
65
65
  @provider.load_current_resource.should eql(@current_resource)
66
66
  end
67
67
 
@@ -71,27 +71,27 @@ describe Chef::Provider::Service::Solaris do
71
71
  end
72
72
 
73
73
  it "should mark service as not running" do
74
- @provider.stub!(:shell_out!).and_return(@status)
74
+ @provider.stub(:shell_out!).and_return(@status)
75
75
  @current_resource.should_receive(:running).with(false)
76
76
  @provider.load_current_resource
77
77
  end
78
78
 
79
79
  it "should mark service as running" do
80
- @status = mock("Status", :exitstatus => 0, :stdout => 'state online')
81
- @provider.stub!(:shell_out!).and_return(@status)
80
+ @status = double("Status", :exitstatus => 0, :stdout => 'state online')
81
+ @provider.stub(:shell_out!).and_return(@status)
82
82
  @current_resource.should_receive(:running).with(true)
83
83
  @provider.load_current_resource
84
84
  end
85
85
 
86
86
  it "should not mark service as maintenance" do
87
- @provider.stub!(:shell_out!).and_return(@status)
87
+ @provider.stub(:shell_out!).and_return(@status)
88
88
  @provider.load_current_resource
89
89
  @provider.maintenance.should be_false
90
90
  end
91
91
 
92
92
  it "should mark service as maintenance" do
93
- @status = mock("Status", :exitstatus => 0, :stdout => 'state maintenance')
94
- @provider.stub!(:shell_out!).and_return(@status)
93
+ @status = double("Status", :exitstatus => 0, :stdout => 'state maintenance')
94
+ @provider.stub(:shell_out!).and_return(@status)
95
95
  @provider.load_current_resource
96
96
  @provider.maintenance.should be_true
97
97
  end
@@ -104,7 +104,7 @@ describe Chef::Provider::Service::Solaris do
104
104
  end
105
105
 
106
106
  it "should call svcadm enable -s chef" do
107
- @new_resource.stub!(:enable_command).and_return("#{@new_resource.enable_command}")
107
+ @new_resource.stub(:enable_command).and_return("#{@new_resource.enable_command}")
108
108
  @provider.should_not_receive(:shell_out!).with("/usr/sbin/svcadm clear #{@current_resource.service_name}")
109
109
  @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm enable -s #{@current_resource.service_name}").and_return(@status)
110
110
  @provider.enable_service.should be_true
@@ -112,7 +112,7 @@ describe Chef::Provider::Service::Solaris do
112
112
  end
113
113
 
114
114
  it "should call svcadm enable -s chef for start_service" do
115
- @new_resource.stub!(:start_command).and_return("#{@new_resource.start_command}")
115
+ @new_resource.stub(:start_command).and_return("#{@new_resource.start_command}")
116
116
  @provider.should_not_receive(:shell_out!).with("/usr/sbin/svcadm clear #{@current_resource.service_name}")
117
117
  @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm enable -s #{@current_resource.service_name}").and_return(@status)
118
118
  @provider.start_service.should be_true
@@ -120,10 +120,10 @@ describe Chef::Provider::Service::Solaris do
120
120
  end
121
121
 
122
122
  it "should call svcadm clear chef for start_service when state maintenance" do
123
- @status = mock("Status", :exitstatus => 0, :stdout => 'state maintenance')
124
- @provider.stub!(:shell_out!).and_return(@status)
123
+ @status = double("Status", :exitstatus => 0, :stdout => 'state maintenance')
124
+ @provider.stub(:shell_out!).and_return(@status)
125
125
  @provider.load_current_resource
126
- @new_resource.stub!(:enable_command).and_return("#{@new_resource.enable_command}")
126
+ @new_resource.stub(:enable_command).and_return("#{@new_resource.enable_command}")
127
127
  @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm clear #{@current_resource.service_name}").and_return(@status)
128
128
  @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm enable -s #{@current_resource.service_name}").and_return(@status)
129
129
  @provider.enable_service.should be_true
@@ -182,7 +182,6 @@ describe Chef::Resource::Mount do
182
182
 
183
183
  it "describes its state" do
184
184
  state = @resource.state
185
- puts state
186
185
  state[:mount_point].should == "T:"
187
186
  state[:username].should == "Administrator"
188
187
  state[:password].should == "Jetstream123!"
@@ -50,20 +50,49 @@ describe Chef::Resource::RemoteFile do
50
50
  @resource.source.should eql([ "http://opscode.com/" ])
51
51
  end
52
52
 
53
+ it "should accept a delayed evalutator (string) for the remote file source" do
54
+ @resource.source Chef::DelayedEvaluator.new {"http://opscode.com/"}
55
+ @resource.source.should eql([ "http://opscode.com/" ])
56
+ end
57
+
53
58
  it "should accept an array of URIs for the remote file source" do
54
59
  @resource.source([ "http://opscode.com/", "http://puppetlabs.com/" ])
55
60
  @resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
56
61
  end
57
62
 
63
+ it "should accept a delated evaluator (array) for the remote file source" do
64
+ @resource.source Chef::DelayedEvaluator.new { [ "http://opscode.com/", "http://puppetlabs.com/" ] }
65
+ @resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
66
+ end
67
+
58
68
  it "should accept an multiple URIs as arguments for the remote file source" do
59
69
  @resource.source("http://opscode.com/", "http://puppetlabs.com/")
60
70
  @resource.source.should eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
61
71
  end
62
72
 
73
+ it "should only accept a single argument if a delayed evalutor is used" do
74
+ lambda {
75
+ @resource.source("http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"})
76
+ }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
77
+ end
78
+
79
+ it "should only accept a single array item if a delayed evalutor is used" do
80
+ lambda {
81
+ @resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new {"http://opscode.com/"}])
82
+ }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
83
+ end
84
+
63
85
  it "does not accept a non-URI as the source" do
64
86
  lambda { @resource.source("not-a-uri") }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
65
87
  end
66
88
 
89
+ it "does not accept a non-URI as the source when read from a delayed evaluator" do
90
+ lambda {
91
+ @resource.source(Chef::DelayedEvaluator.new {"not-a-uri"})
92
+ @resource.source
93
+ }.should raise_error(Chef::Exceptions::InvalidRemoteFileURI)
94
+ end
95
+
67
96
  it "should raise an exception when source is an empty array" do
68
97
  lambda { @resource.source([]) }.should raise_error(ArgumentError)
69
98
  end
@@ -612,7 +612,7 @@ describe Chef::Resource do
612
612
  it "should print \"skipped due to action :nothing\" message for doc formatter when action is :nothing" do
613
613
  fdoc = Chef::Formatters.new(:doc, STDOUT, STDERR)
614
614
  @run_context.stub(:events).and_return(fdoc)
615
- fdoc.should_receive(:puts).with(" (skipped due to action :nothing)")
615
+ fdoc.should_receive(:puts).with(" (skipped due to action :nothing)", anything())
616
616
  @resource.should_skip?(:nothing)
617
617
  end
618
618