chef 11.8.4.ohai7.0-x86-mingw32 → 11.10.0.alpha.1-x86-mingw32
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.
- checksums.yaml +7 -0
- data/distro/common/html/chef-client.8.html +3 -3
- data/distro/common/html/chef-expander.8.html +3 -3
- data/distro/common/html/chef-expanderctl.8.html +3 -3
- data/distro/common/html/chef-server-webui.8.html +3 -3
- data/distro/common/html/chef-server.8.html +3 -3
- data/distro/common/html/chef-shell.1.html +3 -3
- data/distro/common/html/chef-solo.8.html +3 -3
- data/distro/common/html/chef-solr.8.html +4 -4
- data/distro/common/html/knife-bootstrap.1.html +3 -3
- data/distro/common/html/knife-client.1.html +3 -3
- data/distro/common/html/knife-configure.1.html +3 -3
- data/distro/common/html/knife-cookbook-site.1.html +3 -3
- data/distro/common/html/knife-cookbook.1.html +3 -3
- data/distro/common/html/knife-data-bag.1.html +3 -3
- data/distro/common/html/knife-environment.1.html +3 -3
- data/distro/common/html/knife-exec.1.html +3 -3
- data/distro/common/html/knife-index.1.html +3 -3
- data/distro/common/html/knife-node.1.html +3 -3
- data/distro/common/html/knife-role.1.html +3 -3
- data/distro/common/html/knife-search.1.html +3 -3
- data/distro/common/html/knife-ssh.1.html +3 -3
- data/distro/common/html/knife-status.1.html +3 -3
- data/distro/common/html/knife-tag.1.html +3 -3
- data/distro/common/html/knife.1.html +3 -3
- data/distro/common/man/man8/chef-client.8 +3 -3
- data/distro/common/man/man8/chef-solo.8 +5 -2
- data/lib/chef.rb +2 -0
- data/lib/chef/application.rb +7 -2
- data/lib/chef/application/apply.rb +6 -0
- data/lib/chef/application/client.rb +3 -1
- data/lib/chef/application/knife.rb +2 -0
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/client.rb +14 -11
- data/lib/chef/config.rb +4 -1
- data/lib/chef/cookbook_uploader.rb +14 -7
- data/lib/chef/encrypted_data_bag_item.rb +6 -303
- data/lib/chef/encrypted_data_bag_item/decryption_failure.rb +22 -0
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +201 -0
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +142 -0
- data/lib/chef/encrypted_data_bag_item/unacceptable_encrypted_data_bag_item_format.rb +22 -0
- data/lib/chef/encrypted_data_bag_item/unsupported_cipher.rb +22 -0
- data/lib/chef/encrypted_data_bag_item/unsupported_encrypted_data_bag_item_format.rb +22 -0
- data/lib/chef/exceptions.rb +1 -0
- data/lib/chef/formatters/doc.rb +19 -3
- data/lib/chef/http/basic_client.rb +1 -1
- data/lib/chef/http/http_request.rb +7 -0
- data/lib/chef/knife.rb +8 -1
- data/lib/chef/knife/bootstrap.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +2 -2
- data/lib/chef/knife/cookbook_upload.rb +7 -1
- data/lib/chef/knife/core/subcommand_loader.rb +2 -2
- data/lib/chef/knife/data_bag_create.rb +7 -0
- data/lib/chef/knife/environment_compare.rb +127 -0
- data/lib/chef/mixin/command.rb +11 -12
- data/lib/chef/mixin/deep_merge.rb +4 -4
- data/lib/chef/monkey_patches/net_http.rb +34 -0
- data/lib/chef/monkey_patches/uri.rb +70 -0
- data/lib/chef/platform/provider_mapping.rb +1 -0
- data/lib/chef/provider/cookbook_file.rb +8 -0
- data/lib/chef/provider/cron.rb +1 -1
- data/lib/chef/provider/directory.rb +7 -0
- data/lib/chef/provider/file.rb +17 -4
- data/lib/chef/provider/git.rb +23 -5
- data/lib/chef/provider/group.rb +30 -11
- data/lib/chef/provider/group/dscl.rb +26 -4
- data/lib/chef/provider/group/gpasswd.rb +14 -19
- data/lib/chef/provider/group/groupadd.rb +41 -1
- data/lib/chef/provider/group/groupmod.rb +46 -36
- data/lib/chef/provider/group/pw.rb +59 -16
- data/lib/chef/provider/group/suse.rb +16 -13
- data/lib/chef/provider/group/usermod.rb +38 -15
- data/lib/chef/provider/group/windows.rb +13 -6
- data/lib/chef/provider/ohai.rb +5 -6
- data/lib/chef/provider/remote_file.rb +8 -0
- data/lib/chef/provider/template.rb +8 -0
- data/lib/chef/provider/user.rb +5 -1
- data/lib/chef/provider/user/useradd.rb +7 -0
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +30 -0
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource/deploy.rb +18 -0
- data/lib/chef/resource/group.rb +11 -0
- data/lib/chef/resource/scm.rb +18 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +31 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +11 -0
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/util/windows/net_group.rb +5 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/base.rb +3 -1
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/git_spec.rb +1 -1
- data/spec/functional/resource/group_spec.rb +257 -118
- data/spec/integration/client/client_spec.rb +82 -8
- data/spec/integration/client/ipv6_spec.rb +133 -0
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +111 -0
- data/spec/scripts/ssl-serve.rb +52 -0
- data/spec/spec_helper.rb +7 -6
- data/spec/support/platform_helpers.rb +21 -0
- data/spec/support/shared/functional/windows_script.rb +2 -1
- data/spec/support/shared/unit/provider/file.rb +181 -43
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +18 -0
- data/spec/unit/application/client_spec.rb +1 -0
- data/spec/unit/client_spec.rb +14 -1
- data/spec/unit/config_spec.rb +20 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +32 -18
- data/spec/unit/knife/cookbook_upload_spec.rb +14 -0
- data/spec/unit/knife/core/subcommand_loader_spec.rb +2 -2
- data/spec/unit/knife/data_bag_create_spec.rb +7 -0
- data/spec/unit/knife/environment_compare_spec.rb +112 -0
- data/spec/unit/knife_spec.rb +6 -1
- data/spec/unit/monkey_patches/uri_spec.rb +34 -0
- data/spec/unit/provider/cookbook_file_spec.rb +2 -1
- data/spec/unit/provider/cron_spec.rb +6 -0
- data/spec/unit/provider/file_spec.rb +3 -1
- data/spec/unit/provider/git_spec.rb +28 -4
- data/spec/unit/provider/group/dscl_spec.rb +1 -0
- data/spec/unit/provider/group/gpasswd_spec.rb +16 -9
- data/spec/unit/provider/group/groupadd_spec.rb +3 -4
- data/spec/unit/provider/group/groupmod_spec.rb +0 -1
- data/spec/unit/provider/group/pw_spec.rb +11 -14
- data/spec/unit/provider/group/usermod_spec.rb +19 -4
- data/spec/unit/provider/group/windows_spec.rb +0 -8
- data/spec/unit/provider/group_spec.rb +26 -4
- data/spec/unit/provider/ohai_spec.rb +1 -0
- data/spec/unit/provider/remote_file_spec.rb +4 -3
- data/spec/unit/provider/template_spec.rb +5 -3
- data/spec/unit/provider/user_spec.rb +6 -0
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +47 -0
- data/spec/unit/resource/scm_spec.rb +10 -0
- data/spec/unit/rest/auth_credentials_spec.rb +4 -1
- data/spec/unit/rest_spec.rb +12 -3
- metadata +69 -121
- data/spec/functional/resource/ohai_spec.rb +0 -65
@@ -76,8 +76,7 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
|
|
76
76
|
@new_resource.members([])
|
77
77
|
end
|
78
78
|
|
79
|
-
it "
|
80
|
-
Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members to add")
|
79
|
+
it "does not modify group membership" do
|
81
80
|
@provider.should_not_receive(:shell_out!)
|
82
81
|
@provider.modify_group_members
|
83
82
|
end
|
@@ -85,7 +84,7 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
|
|
85
84
|
|
86
85
|
describe "when the resource specifies group members" do
|
87
86
|
it "should log an appropriate debug message" do
|
88
|
-
Chef::Log.should_receive(:debug).with("group[wheel] setting group members to lobster, rage, fist")
|
87
|
+
Chef::Log.should_receive(:debug).with("group[wheel] setting group members to: lobster, rage, fist")
|
89
88
|
@provider.stub!(:shell_out!)
|
90
89
|
@provider.modify_group_members
|
91
90
|
end
|
@@ -95,12 +94,20 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
|
|
95
94
|
@provider.modify_group_members
|
96
95
|
end
|
97
96
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
97
|
+
describe "when no user exists in the system" do
|
98
|
+
before do
|
99
|
+
current_resource = @new_resource.dup
|
100
|
+
current_resource.members([ ])
|
101
|
+
@provider.current_resource = current_resource
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should run gpasswd individually for each user when the append option is set" do
|
105
|
+
@new_resource.append(true)
|
106
|
+
@provider.should_receive(:shell_out!).with("gpasswd -a lobster wheel")
|
107
|
+
@provider.should_receive(:shell_out!).with("gpasswd -a rage wheel")
|
108
|
+
@provider.should_receive(:shell_out!).with("gpasswd -a fist wheel")
|
109
|
+
@provider.modify_group_members
|
110
|
+
end
|
104
111
|
end
|
105
112
|
|
106
113
|
end
|
@@ -143,10 +143,9 @@ describe Chef::Provider::Group::Groupadd do
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
lambda { @provider.modify_group_members }.should raise_error(Chef::Exceptions::Group, "you must override modify_group_members in #{@provider.to_s}")
|
146
|
+
[:add_member, :remove_member, :set_members].each do |m|
|
147
|
+
it "should raise an error when calling #{m}" do
|
148
|
+
lambda { @provider.send(m, [ ]) }.should raise_error(Chef::Exceptions::Group, "you must override #{m} in #{@provider.to_s}")
|
150
149
|
end
|
151
150
|
end
|
152
151
|
|
@@ -62,7 +62,6 @@ describe Chef::Provider::Group::Groupmod do
|
|
62
62
|
|
63
63
|
it "logs a message and sets group's members to 'none', then removes existing group members" do
|
64
64
|
Chef::Log.should_receive(:debug).with("group[wheel] setting group members to: none")
|
65
|
-
Chef::Log.should_receive(:debug).with("group[wheel] removing members lobster, rage, fist")
|
66
65
|
@provider.should_receive(:shell_out!).with("group mod -n wheel_bak wheel")
|
67
66
|
@provider.should_receive(:shell_out!).with("group add -g '123' -o wheel")
|
68
67
|
@provider.should_receive(:shell_out!).with("group del wheel_bak")
|
@@ -49,7 +49,7 @@ describe Chef::Provider::Group::Pw do
|
|
49
49
|
describe "when creating a group" do
|
50
50
|
it "should run pw groupadd with the return of set_options and set_members_option" do
|
51
51
|
@new_resource.gid(23)
|
52
|
-
@provider.should_receive(:run_command).with({ :command => "pw groupadd wheel -g '23'
|
52
|
+
@provider.should_receive(:run_command).with({ :command => "pw groupadd wheel -g '23'" }).and_return(true)
|
53
53
|
@provider.create_group
|
54
54
|
end
|
55
55
|
end
|
@@ -58,7 +58,9 @@ describe Chef::Provider::Group::Pw do
|
|
58
58
|
|
59
59
|
it "should run pw groupmod with the return of set_options" do
|
60
60
|
@new_resource.gid(42)
|
61
|
-
@
|
61
|
+
@new_resource.members(["someone"])
|
62
|
+
@provider.should_receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -m someone" }).and_return(true)
|
63
|
+
@provider.should_receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -d root,aj" }).and_return(true)
|
62
64
|
@provider.manage_group
|
63
65
|
end
|
64
66
|
|
@@ -79,13 +81,8 @@ describe Chef::Provider::Group::Pw do
|
|
79
81
|
@current_resource.stub!(:members).and_return([])
|
80
82
|
end
|
81
83
|
|
82
|
-
it "should log an appropriate message" do
|
83
|
-
Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members")
|
84
|
-
@provider.set_members_option
|
85
|
-
end
|
86
|
-
|
87
84
|
it "should set no options" do
|
88
|
-
@provider.
|
85
|
+
@provider.set_members_options.should eql([ ])
|
89
86
|
end
|
90
87
|
end
|
91
88
|
|
@@ -96,12 +93,12 @@ describe Chef::Provider::Group::Pw do
|
|
96
93
|
end
|
97
94
|
|
98
95
|
it "should log an appropriate message" do
|
99
|
-
Chef::Log.should_receive(:debug).with("group[wheel] removing group members all,
|
100
|
-
@provider.
|
96
|
+
Chef::Log.should_receive(:debug).with("group[wheel] removing group members: all,your,base")
|
97
|
+
@provider.set_members_options
|
101
98
|
end
|
102
99
|
|
103
100
|
it "should set the -d option with the members joined by ','" do
|
104
|
-
@provider.
|
101
|
+
@provider.set_members_options.should eql([ " -d all,your,base" ])
|
105
102
|
end
|
106
103
|
end
|
107
104
|
|
@@ -112,12 +109,12 @@ describe Chef::Provider::Group::Pw do
|
|
112
109
|
end
|
113
110
|
|
114
111
|
it "should log an appropriate debug message" do
|
115
|
-
Chef::Log.should_receive(:debug).with("group[wheel]
|
116
|
-
@provider.
|
112
|
+
Chef::Log.should_receive(:debug).with("group[wheel] adding group members: all,your,base")
|
113
|
+
@provider.set_members_options
|
117
114
|
end
|
118
115
|
|
119
116
|
it "should set the -M option with the members joined by ','" do
|
120
|
-
@provider.
|
117
|
+
@provider.set_members_options.should eql([ " -m all,your,base" ])
|
121
118
|
end
|
122
119
|
end
|
123
120
|
end
|
@@ -25,6 +25,7 @@ describe Chef::Provider::Group::Usermod do
|
|
25
25
|
@run_context = Chef::RunContext.new(@node, {}, @events)
|
26
26
|
@new_resource = Chef::Resource::Group.new("wheel")
|
27
27
|
@new_resource.members [ "all", "your", "base" ]
|
28
|
+
@new_resource.excluded_members [ ]
|
28
29
|
@provider = Chef::Provider::Group::Usermod.new(@new_resource, @run_context)
|
29
30
|
@provider.stub!(:run_command)
|
30
31
|
end
|
@@ -33,11 +34,12 @@ describe Chef::Provider::Group::Usermod do
|
|
33
34
|
|
34
35
|
describe "with an empty members array" do
|
35
36
|
before do
|
37
|
+
@new_resource.stub!(:append).and_return(true)
|
36
38
|
@new_resource.stub!(:members).and_return([])
|
37
39
|
end
|
38
40
|
|
39
41
|
it "should log an appropriate message" do
|
40
|
-
|
42
|
+
@provider.should_not_receive(:shell_out!)
|
41
43
|
@provider.modify_group_members
|
42
44
|
end
|
43
45
|
end
|
@@ -65,13 +67,26 @@ describe Chef::Provider::Group::Usermod do
|
|
65
67
|
lambda { @provider.run_action(@provider.process_resource_requirements) }.should raise_error(Chef::Exceptions::Group, "setting group members directly is not supported by #{@provider.to_s}, must set append true in group")
|
66
68
|
end
|
67
69
|
|
70
|
+
it "should raise an error when excluded_members are set" do
|
71
|
+
@provider.define_resource_requirements
|
72
|
+
@provider.load_current_resource
|
73
|
+
@provider.instance_variable_set("@group_exists", true)
|
74
|
+
@provider.action = :modify
|
75
|
+
@new_resource.stub!(:append).and_return(true)
|
76
|
+
@new_resource.stub!(:excluded_members).and_return(["someone"])
|
77
|
+
lambda { @provider.run_action(@provider.process_resource_requirements) }.should raise_error(Chef::Exceptions::Group, "excluded_members is not supported by #{@provider.to_s}")
|
78
|
+
end
|
79
|
+
|
68
80
|
platforms.each do |platform, flags|
|
69
81
|
it "should usermod each user when the append option is set on #{platform}" do
|
82
|
+
current_resource = @new_resource.dup
|
83
|
+
current_resource.members([ ])
|
84
|
+
@provider.current_resource = current_resource
|
70
85
|
@node.automatic_attrs[:platform] = platform
|
71
86
|
@new_resource.stub!(:append).and_return(true)
|
72
|
-
@provider.should_receive(:
|
73
|
-
@provider.should_receive(:
|
74
|
-
@provider.should_receive(:
|
87
|
+
@provider.should_receive(:shell_out!).with("usermod #{flags} wheel all")
|
88
|
+
@provider.should_receive(:shell_out!).with("usermod #{flags} wheel your")
|
89
|
+
@provider.should_receive(:shell_out!).with("usermod #{flags} wheel base")
|
75
90
|
@provider.modify_group_members
|
76
91
|
end
|
77
92
|
end
|
@@ -70,14 +70,6 @@ describe Chef::Provider::Group::Windows do
|
|
70
70
|
@provider.manage_group
|
71
71
|
end
|
72
72
|
|
73
|
-
it "should call @net_group.local_set_members if append fails" do
|
74
|
-
@new_resource.stub!(:append).and_return(true)
|
75
|
-
@net_group.stub!(:local_add_members).and_raise(ArgumentError)
|
76
|
-
@net_group.should_receive(:local_add_members).with(@new_resource.members)
|
77
|
-
@net_group.should_receive(:local_set_members).with(@new_resource.members + @current_resource.members)
|
78
|
-
@provider.manage_group
|
79
|
-
end
|
80
|
-
|
81
73
|
end
|
82
74
|
|
83
75
|
describe "remove_group" do
|
@@ -108,6 +108,19 @@ describe Chef::Provider::User do
|
|
108
108
|
@provider.compare_group.should be_true
|
109
109
|
end
|
110
110
|
|
111
|
+
it "should return false if append is true and excluded_members include a non existing member" do
|
112
|
+
@new_resource.excluded_members << "extra_user"
|
113
|
+
@new_resource.stub!(:append).and_return(true)
|
114
|
+
@provider.compare_group.should be_false
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should return true if the append is true and excluded_members include an existing user" do
|
118
|
+
@new_resource.members.each {|m| @new_resource.excluded_members << m }
|
119
|
+
@new_resource.members.clear
|
120
|
+
@new_resource.stub!(:append).and_return(true)
|
121
|
+
@provider.compare_group.should be_true
|
122
|
+
end
|
123
|
+
|
111
124
|
end
|
112
125
|
|
113
126
|
describe "when creating a group" do
|
@@ -127,6 +140,7 @@ describe Chef::Provider::User do
|
|
127
140
|
it "should check to see if the group has mismatched attributes if the group exists" do
|
128
141
|
@provider.group_exists = true
|
129
142
|
@provider.stub!(:compare_group).and_return(false)
|
143
|
+
@provider.stub!(:change_desc).and_return([ ])
|
130
144
|
@provider.run_action(:create)
|
131
145
|
@provider.new_resource.should_not be_updated
|
132
146
|
end
|
@@ -134,6 +148,7 @@ describe Chef::Provider::User do
|
|
134
148
|
it "should call manage_group if the group exists and has mismatched attributes" do
|
135
149
|
@provider.group_exists = true
|
136
150
|
@provider.stub!(:compare_group).and_return(true)
|
151
|
+
@provider.stub!(:change_desc).and_return([ ])
|
137
152
|
@provider.should_receive(:manage_group).and_return(true)
|
138
153
|
@provider.run_action(:create)
|
139
154
|
end
|
@@ -141,6 +156,7 @@ describe Chef::Provider::User do
|
|
141
156
|
it "should set the new_resources updated flag when it creates the group if we call manage_group" do
|
142
157
|
@provider.group_exists = true
|
143
158
|
@provider.stub!(:compare_group).and_return(true)
|
159
|
+
@provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
|
144
160
|
@provider.stub!(:manage_group).and_return(true)
|
145
161
|
@provider.run_action(:create)
|
146
162
|
@new_resource.should be_updated
|
@@ -172,12 +188,14 @@ describe Chef::Provider::User do
|
|
172
188
|
|
173
189
|
it "should run manage_group if the group exists and has mismatched attributes" do
|
174
190
|
@provider.should_receive(:compare_group).and_return(true)
|
191
|
+
@provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
|
175
192
|
@provider.should_receive(:manage_group).and_return(true)
|
176
193
|
@provider.run_action(:manage)
|
177
194
|
end
|
178
195
|
|
179
196
|
it "should set the new resources updated flag to true if manage_group is called" do
|
180
197
|
@provider.stub!(:compare_group).and_return(true)
|
198
|
+
@provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
|
181
199
|
@provider.stub!(:manage_group).and_return(true)
|
182
200
|
@provider.run_action(:manage)
|
183
201
|
@new_resource.should be_updated
|
@@ -191,6 +209,7 @@ describe Chef::Provider::User do
|
|
191
209
|
|
192
210
|
it "should not run manage_group if the group exists but has no differing attributes" do
|
193
211
|
@provider.should_receive(:compare_group).and_return(false)
|
212
|
+
@provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
|
194
213
|
@provider.should_not_receive(:manage_group)
|
195
214
|
@provider.run_action(:manage)
|
196
215
|
end
|
@@ -204,12 +223,14 @@ describe Chef::Provider::User do
|
|
204
223
|
|
205
224
|
it "should run manage_group if the group exists and has mismatched attributes" do
|
206
225
|
@provider.should_receive(:compare_group).and_return(true)
|
226
|
+
@provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
|
207
227
|
@provider.should_receive(:manage_group).and_return(true)
|
208
228
|
@provider.run_action(:modify)
|
209
229
|
end
|
210
230
|
|
211
231
|
it "should set the new resources updated flag to true if manage_group is called" do
|
212
232
|
@provider.stub!(:compare_group).and_return(true)
|
233
|
+
@provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
|
213
234
|
@provider.stub!(:manage_group).and_return(true)
|
214
235
|
@provider.run_action(:modify)
|
215
236
|
@new_resource.should be_updated
|
@@ -217,6 +238,7 @@ describe Chef::Provider::User do
|
|
217
238
|
|
218
239
|
it "should not run manage_group if the group exists but has no differing attributes" do
|
219
240
|
@provider.should_receive(:compare_group).and_return(false)
|
241
|
+
@provider.stub!(:change_desc).and_return(["Some changes are going to be done."])
|
220
242
|
@provider.should_not_receive(:manage_group)
|
221
243
|
@provider.run_action(:modify)
|
222
244
|
end
|
@@ -233,26 +255,26 @@ describe Chef::Provider::User do
|
|
233
255
|
@new_resource.members << "user2"
|
234
256
|
@new_resource.stub!(:append).and_return true
|
235
257
|
@provider.compare_group.should be_true
|
236
|
-
@provider.change_desc.should == "add missing member(s): user1, user2"
|
258
|
+
@provider.change_desc.should == [ "add missing member(s): user1, user2" ]
|
237
259
|
end
|
238
260
|
|
239
261
|
it "should report that the group members will be overwritten if not appending" do
|
240
262
|
@new_resource.members << "user1"
|
241
263
|
@new_resource.stub!(:append).and_return false
|
242
264
|
@provider.compare_group.should be_true
|
243
|
-
@provider.change_desc.should == "replace group members with new list of members"
|
265
|
+
@provider.change_desc.should == [ "replace group members with new list of members" ]
|
244
266
|
end
|
245
267
|
|
246
268
|
it "should report the gid will be changed when it does not match" do
|
247
269
|
@current_resource.stub!(:gid).and_return("BADF00D")
|
248
270
|
@provider.compare_group.should be_true
|
249
|
-
@provider.change_desc.should == "change gid #{@current_resource.gid} to #{@new_resource.gid}"
|
271
|
+
@provider.change_desc.should == [ "change gid #{@current_resource.gid} to #{@new_resource.gid}" ]
|
250
272
|
|
251
273
|
end
|
252
274
|
|
253
275
|
it "should report no change reason when no change is required" do
|
254
276
|
@provider.compare_group.should be_false
|
255
|
-
@provider.change_desc.should ==
|
277
|
+
@provider.change_desc.should == [ ]
|
256
278
|
end
|
257
279
|
end
|
258
280
|
|
@@ -42,6 +42,7 @@ describe Chef::Provider::Ohai do
|
|
42
42
|
}
|
43
43
|
}
|
44
44
|
mock_ohai.stub!(:all_plugins).and_return(true)
|
45
|
+
mock_ohai.stub!(:require_plugin).and_return(true)
|
45
46
|
mock_ohai.stub!(:data).and_return(mock_ohai[:data],
|
46
47
|
mock_ohai[:data2])
|
47
48
|
Ohai::System.stub!(:new).and_return(mock_ohai)
|
@@ -47,16 +47,17 @@ describe Chef::Provider::RemoteFile do
|
|
47
47
|
|
48
48
|
subject(:provider) do
|
49
49
|
provider = described_class.new(resource, run_context)
|
50
|
-
provider.stub
|
51
|
-
provider.stub
|
50
|
+
provider.stub(:content).and_return(content)
|
51
|
+
provider.stub(:update_new_resource_checksum).and_return(nil) # Otherwise it doesn't behave like a File provider
|
52
52
|
provider
|
53
53
|
end
|
54
54
|
|
55
55
|
before do
|
56
|
-
Chef::FileCache.stub
|
56
|
+
Chef::FileCache.stub(:load).with("remote_file/#{resource.name}").and_raise(Chef::Exceptions::FileNotFound)
|
57
57
|
end
|
58
58
|
|
59
59
|
it_behaves_like Chef::Provider::File
|
60
60
|
|
61
|
+
it_behaves_like "a file provider with source field"
|
61
62
|
end
|
62
63
|
|
@@ -39,7 +39,7 @@ describe Chef::Provider::Template do
|
|
39
39
|
|
40
40
|
let(:provider) do
|
41
41
|
provider = described_class.new(resource, run_context)
|
42
|
-
provider.stub
|
42
|
+
provider.stub(:content).and_return(content)
|
43
43
|
provider
|
44
44
|
end
|
45
45
|
|
@@ -73,16 +73,18 @@ describe Chef::Provider::Template do
|
|
73
73
|
|
74
74
|
let(:provider) do
|
75
75
|
provider = described_class.new(resource, run_context)
|
76
|
-
provider.stub
|
76
|
+
provider.stub(:content).and_return(content)
|
77
77
|
provider
|
78
78
|
end
|
79
79
|
|
80
80
|
it "stops executing when the local template source can't be found" do
|
81
81
|
setup_normal_file
|
82
|
-
content.stub
|
82
|
+
content.stub(:template_location).and_return("/baz/bar/foo")
|
83
83
|
File.stub(:exists?).with("/baz/bar/foo").and_return(false)
|
84
84
|
lambda { provider.run_action(:create) }.should raise_error Chef::Mixin::WhyRun::ResourceRequirements::Assertion::AssertionFailure
|
85
85
|
end
|
86
86
|
|
87
87
|
end
|
88
|
+
|
89
|
+
it_behaves_like "a file provider with source field"
|
88
90
|
end
|
@@ -91,6 +91,12 @@ describe Chef::Provider::User do
|
|
91
91
|
@current_resource.username.should == @new_resource.username
|
92
92
|
end
|
93
93
|
|
94
|
+
it "should change the encoding of gecos to the encoding of the new resource", :ruby_gte_19_only do
|
95
|
+
@pw_user.gecos.force_encoding('ASCII-8BIT')
|
96
|
+
@provider.load_current_resource
|
97
|
+
@provider.current_resource.comment.encoding.should == @new_resource.comment.encoding
|
98
|
+
end
|
99
|
+
|
94
100
|
it "should look up the user in /etc/passwd with getpwnam" do
|
95
101
|
Etc.should_receive(:getpwnam).with(@new_resource.username).and_return(@pw_user)
|
96
102
|
@provider.load_current_resource
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Phil Dibowitz (<phild@fb.com>)
|
3
|
+
# Copyright:: Copyright (c) 2013 Facebook
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'spec_helper'
|
20
|
+
|
21
|
+
describe Chef::Provider::WhyrunSafeRubyBlock, "initialize" do
|
22
|
+
before(:each) do
|
23
|
+
$evil_global_evil_laugh = :wahwah
|
24
|
+
@node = Chef::Node.new
|
25
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
26
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
27
|
+
@new_resource = Chef::Resource::WhyrunSafeRubyBlock.new("bloc party")
|
28
|
+
@new_resource.block { $evil_global_evil_laugh = :mwahahaha}
|
29
|
+
@provider = Chef::Provider::WhyrunSafeRubyBlock.new(@new_resource, @run_context)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should call the block and flag the resource as updated" do
|
33
|
+
@provider.run_action(:create)
|
34
|
+
$evil_global_evil_laugh.should == :mwahahaha
|
35
|
+
@new_resource.should be_updated
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should call the block and flat the resource as updated - even in whyrun" do
|
39
|
+
Chef::Config[:why_run] = true
|
40
|
+
@provider.run_action(:create)
|
41
|
+
$evil_global_evil_laugh.should == :mwahahaha
|
42
|
+
@new_resource.should be_updated
|
43
|
+
Chef::Config[:why_run] = false
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
@@ -118,6 +118,16 @@ describe Chef::Resource::Scm do
|
|
118
118
|
@resource.enable_submodules.should be_false
|
119
119
|
end
|
120
120
|
|
121
|
+
it "takes a boolean for #enable_checkout" do
|
122
|
+
@resource.enable_checkout true
|
123
|
+
@resource.enable_checkout.should be_true
|
124
|
+
lambda {@resource.enable_checkout "lolz"}.should raise_error(ArgumentError)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "defaults to enabling checkout" do
|
128
|
+
@resource.enable_checkout.should be_true
|
129
|
+
end
|
130
|
+
|
121
131
|
it "takes a string for the remote" do
|
122
132
|
@resource.remote "opscode"
|
123
133
|
@resource.remote.should eql("opscode")
|