chef 10.14.4 → 10.16.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/distro/common/html/chef-client.8.html +4 -4
- data/distro/common/html/chef-expander.8.html +4 -4
- data/distro/common/html/chef-expanderctl.8.html +4 -4
- data/distro/common/html/chef-server-webui.8.html +4 -4
- data/distro/common/html/chef-server.8.html +182 -0
- data/distro/common/html/chef-solo.8.html +4 -4
- data/distro/common/html/chef-solr.8.html +4 -4
- data/distro/common/html/knife-bootstrap.1.html +5 -5
- data/distro/common/html/knife-client.1.html +4 -4
- data/distro/common/html/knife-configure.1.html +5 -5
- data/distro/common/html/knife-cookbook-site.1.html +4 -4
- data/distro/common/html/knife-cookbook.1.html +8 -8
- data/distro/common/html/knife-data-bag.1.html +4 -4
- data/distro/common/html/knife-environment.1.html +7 -7
- data/distro/common/html/knife-exec.1.html +4 -4
- data/distro/common/html/knife-index.1.html +4 -4
- data/distro/common/html/knife-node.1.html +5 -5
- data/distro/common/html/knife-role.1.html +4 -4
- data/distro/common/html/knife-search.1.html +6 -6
- data/distro/common/html/knife-ssh.1.html +4 -4
- data/distro/common/html/knife-status.1.html +5 -5
- data/distro/common/html/knife-tag.1.html +4 -4
- data/distro/common/html/knife.1.html +4 -4
- data/distro/common/html/shef.1.html +4 -4
- data/distro/common/man/man1/knife-bootstrap.1 +1 -1
- data/distro/common/man/man1/knife-client.1 +1 -1
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
- data/distro/common/man/man1/knife-cookbook.1 +1 -1
- data/distro/common/man/man1/knife-data-bag.1 +1 -1
- data/distro/common/man/man1/knife-environment.1 +1 -1
- data/distro/common/man/man1/knife-exec.1 +1 -1
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +1 -1
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +1 -1
- data/distro/common/man/man1/shef.1 +1 -1
- data/distro/common/man/man8/chef-client.8 +1 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +1 -1
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/distro/debian/etc/init.d/chef-client +1 -1
- data/distro/debian/etc/init.d/chef-expander +1 -1
- data/distro/debian/etc/init.d/chef-server +1 -1
- data/distro/debian/etc/init.d/chef-server-webui +1 -1
- data/distro/debian/etc/init.d/chef-solr +1 -1
- data/lib/chef/application/client.rb +3 -3
- data/lib/chef/client.rb +4 -1
- data/lib/chef/config.rb +2 -1
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -0
- data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -0
- data/lib/chef/knife/bootstrap/chef-full.erb +2 -1
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -0
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -0
- data/lib/chef/knife/configure.rb +19 -0
- data/lib/chef/knife/data_bag_from_file.rb +1 -1
- data/lib/chef/knife/environment_from_file.rb +41 -8
- data/lib/chef/knife/ssh.rb +5 -1
- data/lib/chef/provider/cookbook_file.rb +4 -4
- data/lib/chef/provider/directory.rb +3 -0
- data/lib/chef/provider/file.rb +49 -3
- data/lib/chef/provider/ifconfig.rb +1 -1
- data/lib/chef/provider/package.rb +2 -0
- data/lib/chef/provider/package/pacman.rb +10 -1
- data/lib/chef/provider/remote_file.rb +1 -1
- data/lib/chef/provider/service.rb +22 -0
- data/lib/chef/provider/template.rb +9 -1
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/resource/cookbook_file.rb +1 -0
- data/lib/chef/resource/cron.rb +5 -0
- data/lib/chef/resource/deploy.rb +6 -1
- data/lib/chef/resource/directory.rb +6 -0
- data/lib/chef/resource/env.rb +5 -0
- data/lib/chef/resource/erl_call.rb +3 -0
- data/lib/chef/resource/execute.rb +3 -0
- data/lib/chef/resource/file.rb +5 -5
- data/lib/chef/resource/group.rb +5 -0
- data/lib/chef/resource/http_request.rb +3 -0
- data/lib/chef/resource/ifconfig.rb +5 -0
- data/lib/chef/resource/link.rb +6 -1
- data/lib/chef/resource/log.rb +19 -16
- data/lib/chef/resource/mdadm.rb +5 -0
- data/lib/chef/resource/mount.rb +5 -0
- data/lib/chef/resource/ohai.rb +14 -0
- data/lib/chef/resource/package.rb +2 -1
- data/lib/chef/resource/remote_directory.rb +5 -0
- data/lib/chef/resource/route.rb +6 -1
- data/lib/chef/resource/ruby_block.rb +11 -0
- data/lib/chef/resource/scm.rb +4 -0
- data/lib/chef/resource/script.rb +3 -0
- data/lib/chef/resource/service.rb +5 -0
- data/lib/chef/resource/subversion.rb +2 -1
- data/lib/chef/resource/template.rb +1 -0
- data/lib/chef/resource/user.rb +4 -0
- data/lib/chef/resource_reporter.rb +71 -27
- data/lib/chef/rest.rb +8 -4
- data/lib/chef/run_list.rb +2 -2
- data/lib/chef/scan_access_control.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/unit/client_spec.rb +6 -2
- data/spec/unit/knife/configure_spec.rb +121 -25
- data/spec/unit/knife/data_bag_from_file_spec.rb +5 -3
- data/spec/unit/knife/environment_from_file_spec.rb +23 -0
- data/spec/unit/provider/cookbook_file_spec.rb +3 -0
- data/spec/unit/provider/directory_spec.rb +16 -17
- data/spec/unit/provider/file_spec.rb +75 -0
- data/spec/unit/provider/ifconfig_spec.rb +2 -2
- data/spec/unit/provider/package/pacman_spec.rb +29 -0
- data/spec/unit/provider/package_spec.rb +4 -0
- data/spec/unit/provider/remote_directory_spec.rb +6 -1
- data/spec/unit/provider/remote_file_spec.rb +7 -0
- data/spec/unit/resource/cookbook_file_spec.rb +42 -1
- data/spec/unit/resource/cron_spec.rb +27 -0
- data/spec/unit/resource/deploy_spec.rb +27 -0
- data/spec/unit/resource/directory_spec.rb +20 -0
- data/spec/unit/resource/env_spec.rb +19 -0
- data/spec/unit/resource/erl_call_spec.rb +12 -0
- data/spec/unit/resource/execute_spec.rb +16 -0
- data/spec/unit/resource/group_spec.rb +17 -1
- data/spec/unit/resource/http_request_spec.rb +13 -0
- data/spec/unit/resource/ifconfig_spec.rb +46 -0
- data/spec/unit/resource/link_spec.rb +21 -0
- data/spec/unit/resource/log_spec.rb +10 -0
- data/spec/unit/resource/mdadm_spec.rb +22 -0
- data/spec/unit/resource/mount_spec.rb +20 -0
- data/spec/unit/resource/ohai_spec.rb +18 -0
- data/spec/unit/resource/package_spec.rb +3 -0
- data/spec/unit/resource/remote_directory_spec.rb +22 -0
- data/spec/unit/resource/remote_file_spec.rb +40 -0
- data/spec/unit/resource/route_spec.rb +19 -0
- data/spec/unit/resource/ruby_block_spec.rb +11 -0
- data/spec/unit/resource/scm_spec.rb +20 -0
- data/spec/unit/resource/script_spec.rb +14 -0
- data/spec/unit/resource/service_spec.rb +21 -0
- data/spec/unit/resource/user_spec.rb +21 -0
- data/spec/unit/resource_reporter_spec.rb +260 -134
- data/spec/unit/run_list_spec.rb +14 -0
- metadata +15 -10
@@ -29,6 +29,7 @@ describe Chef::Provider::File do
|
|
29
29
|
|
30
30
|
@resource = Chef::Resource::File.new("seattle")
|
31
31
|
@resource.path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates", "seattle.txt")))
|
32
|
+
|
32
33
|
@provider = Chef::Provider::File.new(@resource, @run_context)
|
33
34
|
end
|
34
35
|
|
@@ -52,6 +53,76 @@ describe Chef::Provider::File do
|
|
52
53
|
@provider.current_resource.content.should eql(nil)
|
53
54
|
end
|
54
55
|
|
56
|
+
it "should collect the current state of the file on the filesystem and populate current_resource" do
|
57
|
+
# test setup
|
58
|
+
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
59
|
+
::File.should_receive(:stat).exactly(3).with(@resource.path).and_return(stat_struct)
|
60
|
+
|
61
|
+
# test execution
|
62
|
+
@provider.load_current_resource
|
63
|
+
|
64
|
+
# post-condition checks
|
65
|
+
@provider.current_resource.mode.should == 0600
|
66
|
+
@provider.current_resource.owner.should == 0
|
67
|
+
@provider.current_resource.group.should == 0
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should NOT update the new_resource state with the current_resourse state if new_resource state is already specified" do
|
71
|
+
# test setup
|
72
|
+
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
73
|
+
::File.should_receive(:stat).exactly(3).with(@resource.path).and_return(stat_struct)
|
74
|
+
|
75
|
+
@provider.new_resource.group(1)
|
76
|
+
@provider.new_resource.owner(1)
|
77
|
+
@provider.new_resource.mode(0644)
|
78
|
+
|
79
|
+
# test execution
|
80
|
+
@provider.load_current_resource
|
81
|
+
|
82
|
+
# post-condition checks
|
83
|
+
@provider.new_resource.group.should == 1
|
84
|
+
@provider.new_resource.owner.should == 1
|
85
|
+
@provider.new_resource.mode.should == 0644
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should update the new_resource state with the current_resource state if the new_resource state is not specified." do
|
89
|
+
# test setup
|
90
|
+
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
91
|
+
::File.should_receive(:stat).exactly(3).with(@resource.path).and_return(stat_struct)
|
92
|
+
|
93
|
+
@provider.new_resource.group(nil)
|
94
|
+
@provider.new_resource.owner(nil)
|
95
|
+
@provider.new_resource.mode(nil)
|
96
|
+
|
97
|
+
# test execution
|
98
|
+
@provider.load_current_resource
|
99
|
+
|
100
|
+
# post-condition checks
|
101
|
+
@provider.new_resource.group.should eql(@provider.current_resource.group)
|
102
|
+
@provider.new_resource.owner.should eql(@provider.current_resource.owner)
|
103
|
+
@provider.new_resource.mode.should eql(@provider.current_resource.mode)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should update the new_resource when attempting to set the new state" do
|
107
|
+
# test setup
|
108
|
+
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
109
|
+
# called once in update_new_file_state and once in checksum
|
110
|
+
::File.should_receive(:stat).twice.with(@provider.new_resource.path).and_return(stat_struct)
|
111
|
+
::File.should_receive(:directory?).once.with(@provider.new_resource.path).and_return(false)
|
112
|
+
|
113
|
+
@provider.new_resource.group(nil)
|
114
|
+
@provider.new_resource.owner(nil)
|
115
|
+
@provider.new_resource.mode(nil)
|
116
|
+
|
117
|
+
# test exectution
|
118
|
+
@provider.update_new_file_state
|
119
|
+
|
120
|
+
# post-condition checks
|
121
|
+
@provider.new_resource.group.should == 0
|
122
|
+
@provider.new_resource.owner.should == 0
|
123
|
+
@provider.new_resource.mode.should == 0600
|
124
|
+
end
|
125
|
+
|
55
126
|
it "should load a mostly blank current resource if the file specified in new_resource doesn't exist/isn't readable" do
|
56
127
|
resource = Chef::Resource::File.new("seattle")
|
57
128
|
resource.path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates", "woot.txt")))
|
@@ -114,6 +185,7 @@ describe Chef::Provider::File do
|
|
114
185
|
|
115
186
|
it "should create the file if it is missing, then set the attributes on action_create" do
|
116
187
|
@provider.load_current_resource
|
188
|
+
@provider.stub!(:update_new_file_state)
|
117
189
|
@provider.new_resource.stub!(:path).and_return(File.join(Dir.tmpdir, "monkeyfoo"))
|
118
190
|
@provider.access_controls.should_receive(:set_all)
|
119
191
|
@provider.should_receive(:diff_current_from_content).and_return("")
|
@@ -130,6 +202,7 @@ describe Chef::Provider::File do
|
|
130
202
|
@provider.new_resource.content "foobar"
|
131
203
|
@provider.new_resource.stub!(:path).and_return(File.join(Dir.tmpdir, "monkeyfoo"))
|
132
204
|
@provider.should_receive(:diff_current_from_content).and_return("")
|
205
|
+
@provider.stub!(:update_new_file_state)
|
133
206
|
File.should_receive(:open).with(@provider.new_resource.path, "w+").and_yield(io)
|
134
207
|
@provider.access_controls.should_receive(:set_all)
|
135
208
|
@provider.run_action(:create)
|
@@ -159,6 +232,7 @@ describe Chef::Provider::File do
|
|
159
232
|
@provider.load_current_resource
|
160
233
|
@provider.new_resource.stub!(:path).and_return(File.join(Dir.tmpdir, "monkeyfoo"))
|
161
234
|
@provider.should_receive(:diff_current_from_content).and_return("")
|
235
|
+
@provider.stub!(:update_new_file_state)
|
162
236
|
File.should_receive(:utime).once.and_return(1)
|
163
237
|
File.stub!(:open).and_return(1)
|
164
238
|
@provider.access_controls.should_receive(:set_all).once
|
@@ -267,6 +341,7 @@ describe Chef::Provider::File do
|
|
267
341
|
@provider = Chef::Provider::File.new(@resource, @run_context)
|
268
342
|
@provider.should_receive(:diff_current_from_content).and_return("")
|
269
343
|
::File.stub!(:exists?).with(@resource.path).and_return(false)
|
344
|
+
@provider.stub!(:update_new_file_state)
|
270
345
|
io = StringIO.new
|
271
346
|
File.should_receive(:open).with(@provider.new_resource.path, "w+").and_yield(io)
|
272
347
|
#@provider.should_receive(:action_create).and_return(true)
|
@@ -205,8 +205,8 @@ describe Chef::Provider::Ifconfig do
|
|
205
205
|
@provider.stub!(:run_command)
|
206
206
|
config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}"
|
207
207
|
File.should_receive(:exist?).with(config_filename).and_return(true)
|
208
|
-
FileUtils.should_receive(:rm_f)
|
209
|
-
|
208
|
+
FileUtils.should_receive(:rm_f).with(config_filename, :verbose => false)
|
209
|
+
|
210
210
|
@provider.run_action(:delete)
|
211
211
|
end
|
212
212
|
end
|
@@ -103,6 +103,35 @@ PACMAN
|
|
103
103
|
@provider.candidate_version.should eql("2.2.3-1")
|
104
104
|
end
|
105
105
|
|
106
|
+
it "should use pacman.conf to determine valid repo names for package versions" do
|
107
|
+
@pacman_conf = <<-PACMAN_CONF
|
108
|
+
[options]
|
109
|
+
HoldPkg = pacman glibc
|
110
|
+
Architecture = auto
|
111
|
+
|
112
|
+
[customrepo]
|
113
|
+
Server = https://my.custom.repo
|
114
|
+
|
115
|
+
[core]
|
116
|
+
Include = /etc/pacman.d/mirrorlist
|
117
|
+
|
118
|
+
[extra]
|
119
|
+
Include = /etc/pacman.d/mirrorlist
|
120
|
+
|
121
|
+
[community]
|
122
|
+
Include = /etc/pacman.d/mirrorlist
|
123
|
+
PACMAN_CONF
|
124
|
+
|
125
|
+
::File.stub!(:exists?).with("/etc/pacman.conf").and_return(true)
|
126
|
+
::File.stub!(:read).with("/etc/pacman.conf").and_return(@pacman_conf)
|
127
|
+
@stdout.stub!(:each).and_yield("customrepo/nano 1.2.3-4").
|
128
|
+
and_yield(" My custom package")
|
129
|
+
@provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
130
|
+
|
131
|
+
@provider.load_current_resource
|
132
|
+
@provider.candidate_version.should eql("1.2.3-4")
|
133
|
+
end
|
134
|
+
|
106
135
|
it "should raise an exception if pacman fails" do
|
107
136
|
@status.should_receive(:exitstatus).and_return(2)
|
108
137
|
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Package)
|
@@ -20,6 +20,10 @@ require 'spec_helper'
|
|
20
20
|
|
21
21
|
describe Chef::Provider::Package do
|
22
22
|
before do
|
23
|
+
#Terrible, but we need to implement a pseduo-filesystem for testing
|
24
|
+
#to not have this line. Only affects updating state fields.
|
25
|
+
Chef::Provider::CookbookFile.any_instance.stub(:update_new_file_state)
|
26
|
+
|
23
27
|
@node = Chef::Node.new
|
24
28
|
@events = Chef::EventDispatch::Dispatcher.new
|
25
29
|
@run_context = Chef::RunContext.new(@node, {}, @events)
|
@@ -28,6 +28,10 @@ end
|
|
28
28
|
describe Chef::Provider::RemoteDirectory do
|
29
29
|
before do
|
30
30
|
Chef::FileAccessControl.any_instance.stub(:set_all)
|
31
|
+
#Terrible, but we need to implement a pseduo-filesystem for testing
|
32
|
+
#to not have this line. Only affects updating state fields.
|
33
|
+
Chef::Provider::CookbookFile.any_instance.stub(:update_new_file_state)
|
34
|
+
|
31
35
|
@resource = Chef::Resource::RemoteDirectory.new("/tmp/tafty")
|
32
36
|
# in CHEF_SPEC_DATA/cookbooks/openldap/files/default/remotedir
|
33
37
|
@resource.source "remotedir"
|
@@ -88,7 +92,7 @@ describe Chef::Provider::RemoteDirectory do
|
|
88
92
|
@node[:platform] = :just_testing
|
89
93
|
@node[:platform_version] = :just_testing
|
90
94
|
|
91
|
-
@destination_dir = Dir.
|
95
|
+
@destination_dir = Dir.mktmpdir << "/remote_directory_test"
|
92
96
|
@resource.path(@destination_dir)
|
93
97
|
end
|
94
98
|
|
@@ -186,6 +190,7 @@ describe Chef::Provider::RemoteDirectory do
|
|
186
190
|
::File.open(@destination_dir + '/remotesubdir/remote_subdir_file1.txt', 'a') {|f| f.puts "blah blah blah" }
|
187
191
|
file1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + '/remote_dir_file1.txt'))
|
188
192
|
subdirfile1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt'))
|
193
|
+
@provider.stub!(:update_new_file_state)
|
189
194
|
@provider.run_action(:create)
|
190
195
|
file1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + '/remote_dir_file1.txt'))).should be_true
|
191
196
|
subdirfile1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt'))).should be_true
|
@@ -119,6 +119,7 @@ describe Chef::Provider::RemoteFile, "action_create" do
|
|
119
119
|
it "downloads the file" do
|
120
120
|
@resource.checksum("this hash doesn't match")
|
121
121
|
@rest.should_receive(:streaming_request).with("http://opscode.com/seattle.txt", {}).and_return(@tempfile)
|
122
|
+
@provider.stub!(:update_new_file_state)
|
122
123
|
@provider.run_action(:create)
|
123
124
|
end
|
124
125
|
|
@@ -126,6 +127,7 @@ describe Chef::Provider::RemoteFile, "action_create" do
|
|
126
127
|
# i.e., the existing file is "0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa"
|
127
128
|
@resource.checksum("fd012fd")
|
128
129
|
@rest.should_receive(:streaming_request).with("http://opscode.com/seattle.txt", {}).and_return(@tempfile)
|
130
|
+
@provider.stub!(:update_new_file_state)
|
129
131
|
@provider.run_action(:create)
|
130
132
|
end
|
131
133
|
end
|
@@ -199,10 +201,12 @@ describe Chef::Provider::RemoteFile, "action_create" do
|
|
199
201
|
|
200
202
|
it "should copy the raw file to the new resource" do
|
201
203
|
FileUtils.should_receive(:cp).with(@tempfile.path, @resource.path).and_return(true)
|
204
|
+
@provider.stub!(:update_new_file_state)
|
202
205
|
@provider.run_action(:create)
|
203
206
|
end
|
204
207
|
|
205
208
|
it "should set the new resource to updated" do
|
209
|
+
@provider.stub!(:update_new_file_state)
|
206
210
|
@provider.run_action(:create)
|
207
211
|
@resource.should be_updated
|
208
212
|
end
|
@@ -254,16 +258,19 @@ describe Chef::Provider::RemoteFile, "action_create" do
|
|
254
258
|
end
|
255
259
|
|
256
260
|
it "should backup the original file" do
|
261
|
+
@provider.stub!(:update_new_file_state)
|
257
262
|
@provider.should_receive(:backup).with(@resource.path).and_return(true)
|
258
263
|
@provider.run_action(:create)
|
259
264
|
end
|
260
265
|
|
261
266
|
it "should copy the raw file to the new resource" do
|
267
|
+
@provider.stub!(:update_new_file_state)
|
262
268
|
FileUtils.should_receive(:cp).with(@tempfile.path, @resource.path).and_return(true)
|
263
269
|
@provider.run_action(:create)
|
264
270
|
end
|
265
271
|
|
266
272
|
it "should set the new resource to updated" do
|
273
|
+
@provider.stub!(:update_new_file_state)
|
267
274
|
@provider.run_action(:create)
|
268
275
|
@resource.should be_updated
|
269
276
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
3
|
+
# Author:: Tyler Cloke (<tyler@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
+
#p License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
8
|
# you may not use this file except in compliance with the License.
|
@@ -44,5 +45,45 @@ describe Chef::Resource::CookbookFile do
|
|
44
45
|
it "sets the provider to Chef::Provider::CookbookFile" do
|
45
46
|
@cookbook_file.provider.should == Chef::Provider::CookbookFile
|
46
47
|
end
|
48
|
+
|
49
|
+
describe "when it has a backup number, group, mode, owner, source, checksum, and cookbook on nix or path, rights, deny_rights, checksum on windows" do
|
50
|
+
before do
|
51
|
+
if Chef::Platform.windows?
|
52
|
+
@cookbook_file.path("C:/temp/origin/file.txt")
|
53
|
+
@cookbook_file.rights(:read, "Everyone")
|
54
|
+
@cookbook_file.deny_rights(:full_control, "Clumsy_Sam")
|
55
|
+
else
|
56
|
+
@cookbook_file.path("/tmp/origin/file.txt")
|
57
|
+
@cookbook_file.group("wheel")
|
58
|
+
@cookbook_file.mode("0664")
|
59
|
+
@cookbook_file.owner("root")
|
60
|
+
@cookbook_file.source("/tmp/foo.txt")
|
61
|
+
@cookbook_file.cookbook("/tmp/cookbooks/cooked.rb")
|
62
|
+
end
|
63
|
+
@cookbook_file.checksum("1" * 64)
|
64
|
+
end
|
47
65
|
|
66
|
+
|
67
|
+
it "describes the state" do
|
68
|
+
state = @cookbook_file.state
|
69
|
+
if Chef::Platform.windows?
|
70
|
+
puts state
|
71
|
+
state[:rights].should == [{:permissions => :read, :principals => "Everyone"}]
|
72
|
+
state[:deny_rights].should == [{:permissions => :full_control, :principals => "Clumsy_Sam"}]
|
73
|
+
else
|
74
|
+
state[:group].should == "wheel"
|
75
|
+
state[:mode].should == "0664"
|
76
|
+
state[:owner].should == "root"
|
77
|
+
end
|
78
|
+
state[:checksum].should == "1" * 64
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns the path as its identity" do
|
82
|
+
if Chef::Platform.windows?
|
83
|
+
@cookbook_file.identity.should == "C:/temp/origin/file.txt"
|
84
|
+
else
|
85
|
+
@cookbook_file.identity.should == "/tmp/origin/file.txt"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
48
89
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Author:: Tyler Cloke (<tyler@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
@@ -151,4 +152,30 @@ describe Chef::Resource::Cron do
|
|
151
152
|
@resource.send(x, 5).should eql("5")
|
152
153
|
end
|
153
154
|
end
|
155
|
+
|
156
|
+
describe "when it has a time (minute, hour, day, month, weeekend) and user" do
|
157
|
+
before do
|
158
|
+
@resource.command("tackle")
|
159
|
+
@resource.minute("1")
|
160
|
+
@resource.hour("2")
|
161
|
+
@resource.day("3")
|
162
|
+
@resource.month("4")
|
163
|
+
@resource.weekday("5")
|
164
|
+
@resource.user("root")
|
165
|
+
end
|
166
|
+
|
167
|
+
it "describes the state" do
|
168
|
+
state = @resource.state
|
169
|
+
state[:minute].should == "1"
|
170
|
+
state[:hour].should == "2"
|
171
|
+
state[:day].should == "3"
|
172
|
+
state[:month].should == "4"
|
173
|
+
state[:weekday].should == "5"
|
174
|
+
state[:user].should == "root"
|
175
|
+
end
|
176
|
+
|
177
|
+
it "returns the command as its identity" do
|
178
|
+
@resource.identity.should == "tackle"
|
179
|
+
end
|
180
|
+
end
|
154
181
|
end
|
@@ -229,4 +229,31 @@ describe Chef::Resource::Deploy do
|
|
229
229
|
@resource.keep_releases.should == 1
|
230
230
|
end
|
231
231
|
|
232
|
+
describe "when it has meta application root, revision, user, group,
|
233
|
+
scm provider, repository cache, environment, simlinks and migrate" do
|
234
|
+
before do
|
235
|
+
@resource.repository("http://uri.org")
|
236
|
+
@resource.deploy_to("/")
|
237
|
+
@resource.revision("1.2.3")
|
238
|
+
@resource.user("root")
|
239
|
+
@resource.group("pokemon")
|
240
|
+
@resource.scm_provider(Chef::Provider::Git)
|
241
|
+
@resource.repository_cache("cached-copy")
|
242
|
+
@resource.environment({"SUDO" => "TRUE"})
|
243
|
+
@resource.symlinks({"system" => "public/system"})
|
244
|
+
@resource.migrate(false)
|
245
|
+
|
246
|
+
end
|
247
|
+
|
248
|
+
it "describes its state" do
|
249
|
+
state = @resource.state
|
250
|
+
state[:deploy_to].should == "/"
|
251
|
+
state[:revision].should == "1.2.3"
|
252
|
+
end
|
253
|
+
|
254
|
+
it "returns the repository URI as its identity" do
|
255
|
+
@resource.identity.should == "http://uri.org"
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
232
259
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Tyler Cloke (<tyler@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
@@ -59,4 +60,23 @@ describe Chef::Resource::Directory do
|
|
59
60
|
lambda { @resource.recursive "monkey" }.should raise_error(ArgumentError)
|
60
61
|
end
|
61
62
|
|
63
|
+
describe "when it has group, mode, and owner" do
|
64
|
+
before do
|
65
|
+
@resource.path("/tmp/foo/bar/")
|
66
|
+
@resource.group("wheel")
|
67
|
+
@resource.mode("0664")
|
68
|
+
@resource.owner("root")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "describes its state" do
|
72
|
+
state = @resource.state
|
73
|
+
state[:group].should == "wheel"
|
74
|
+
state[:mode].should == "0664"
|
75
|
+
state[:owner].should == "root"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns the directory path as its identity" do
|
79
|
+
@resource.identity.should == "/tmp/foo/bar/"
|
80
|
+
end
|
81
|
+
end
|
62
82
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
3
|
+
# Author:: Tyler Cloke (<tyler@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2010 VMware, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
@@ -63,4 +64,22 @@ describe Chef::Resource::Env do
|
|
63
64
|
@resource.value "bar"
|
64
65
|
@resource.value.should eql("bar")
|
65
66
|
end
|
67
|
+
|
68
|
+
describe "when it has key name and value" do
|
69
|
+
before do
|
70
|
+
@resource.key_name("charmander")
|
71
|
+
@resource.value("level7")
|
72
|
+
@resource.delim("hi")
|
73
|
+
end
|
74
|
+
|
75
|
+
it "describes its state" do
|
76
|
+
state = @resource.state
|
77
|
+
state[:value].should == "level7"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns the key name as its identity" do
|
81
|
+
@resource.identity.should == "charmander"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
66
85
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Joe Williams (<joe@joetify.com>)
|
3
|
+
# Author:: Tyler Cloke (<tyler@opscode.com>)
|
3
4
|
# Copyright:: Copyright (c) 2009 Joe Williams
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
@@ -66,4 +67,15 @@ describe Chef::Resource::ErlCall do
|
|
66
67
|
@resource.node_name.should eql("chef@erlang")
|
67
68
|
end
|
68
69
|
|
70
|
+
describe "when it has cookie and node_name" do
|
71
|
+
before do
|
72
|
+
@resource.code("erl-call:function()")
|
73
|
+
@resource.cookie("cookie")
|
74
|
+
@resource.node_name("raster")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "returns the code as its identity" do
|
78
|
+
@resource.identity.should == "erl-call:function()"
|
79
|
+
end
|
80
|
+
end
|
69
81
|
end
|