chef 12.14.89-universal-mingw32 → 12.15.19-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +76 -51
- data/Gemfile +1 -1
- data/README.md +9 -7
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/acceptance/Gemfile +3 -0
- data/acceptance/Gemfile.lock +19 -18
- data/acceptance/fips/.kitchen.yml +1 -1
- data/lib/chef/application/exit_code.rb +9 -0
- data/lib/chef/cookbook/file_system_file_vendor.rb +7 -8
- data/lib/chef/cookbook/metadata.rb +8 -0
- data/lib/chef/exceptions.rb +5 -0
- data/lib/chef/knife.rb +14 -15
- data/lib/chef/knife/ssh.rb +1 -0
- data/lib/chef/node/attribute.rb +1 -3
- data/lib/chef/node/attribute_collections.rb +20 -0
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/apt_update.rb +1 -1
- data/lib/chef/provider/group/groupadd.rb +2 -1
- data/lib/chef/provider/package/cab.rb +150 -0
- data/lib/chef/provider/package/rubygems.rb +0 -1
- data/lib/chef/provider/registry_key.rb +26 -2
- data/lib/chef/provider/remote_file/content.rb +1 -1
- data/lib/chef/provider/user.rb +10 -0
- data/lib/chef/provider/user/dscl.rb +2 -2
- data/lib/chef/provider/user/linux.rb +4 -14
- data/lib/chef/provider/user/pw.rb +2 -2
- data/lib/chef/provider/user/solaris.rb +15 -0
- data/lib/chef/provider/user/useradd.rb +1 -5
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource/cab_package.rb +44 -0
- data/lib/chef/resource/registry_key.rb +3 -3
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/server_api.rb +1 -1
- data/lib/chef/util/dsc/local_configuration_manager.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/data/templates/chef-seattle20160930-4388-1crv7ef.txt +1 -0
- data/spec/data/templates/chef-seattle20160930-4388-jjfoae.txt +1 -0
- data/spec/data/templates/chef-seattle20160930-4388-umeq2c.txt +1 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +48 -59
- data/spec/functional/resource/ifconfig_spec.rb +6 -0
- data/spec/functional/resource/registry_spec.rb +110 -4
- data/spec/unit/application/exit_code_spec.rb +10 -0
- data/spec/unit/cookbook/file_vendor_spec.rb +15 -0
- data/spec/unit/cookbook/metadata_spec.rb +19 -0
- data/spec/unit/exceptions_spec.rb +2 -0
- data/spec/unit/node/attribute_spec.rb +23 -1
- data/spec/unit/node/vivid_mash_spec.rb +27 -0
- data/spec/unit/provider/group/groupadd_spec.rb +118 -99
- data/spec/unit/provider/package/cab_spec.rb +218 -0
- data/spec/unit/provider/package/rubygems_spec.rb +2 -4
- data/spec/unit/provider/registry_key_spec.rb +94 -0
- data/spec/unit/provider/remote_file/content_spec.rb +1 -0
- data/spec/unit/provider/user/solaris_spec.rb +52 -40
- data/spec/unit/resource/apt_update_spec.rb +25 -17
- data/spec/unit/resource/cab_package_spec.rb +38 -0
- data/spec/unit/resource/registry_key_spec.rb +26 -10
- data/spec/unit/server_api_spec.rb +50 -0
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +10 -4
- metadata +13 -5
@@ -46,7 +46,7 @@ class Chef
|
|
46
46
|
|
47
47
|
def remove_user
|
48
48
|
command = "pw userdel #{@new_resource.username}"
|
49
|
-
command << " -r" if
|
49
|
+
command << " -r" if managing_home_dir?
|
50
50
|
run_command(:command => command)
|
51
51
|
end
|
52
52
|
|
@@ -87,7 +87,7 @@ class Chef
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
|
-
if
|
90
|
+
if managing_home_dir?
|
91
91
|
Chef::Log.debug("#{@new_resource} is managing the users home directory")
|
92
92
|
opts << " -m"
|
93
93
|
end
|
@@ -73,6 +73,21 @@ class Chef
|
|
73
73
|
|
74
74
|
private
|
75
75
|
|
76
|
+
# Override the version from {#Useradd} because Solaris doesn't support
|
77
|
+
# system users and therefore has no `-r` option. This also inverts the
|
78
|
+
# logic for manage_home as Solaris defaults to no-manage-home and only
|
79
|
+
# offers `-m`.
|
80
|
+
#
|
81
|
+
# @since 12.15
|
82
|
+
# @api private
|
83
|
+
# @see Useradd#useradd_options
|
84
|
+
# @return [Array<String>]
|
85
|
+
def useradd_options
|
86
|
+
opts = []
|
87
|
+
opts << "-m" if managing_home_dir?
|
88
|
+
opts
|
89
|
+
end
|
90
|
+
|
76
91
|
def manage_password
|
77
92
|
if @current_resource.password != @new_resource.password && @new_resource.password
|
78
93
|
Chef::Log.debug("#{@new_resource} setting password to #{@new_resource.password}")
|
@@ -124,7 +124,7 @@ class Chef
|
|
124
124
|
Chef::Log.debug("#{new_resource} setting home to #{new_resource.home}")
|
125
125
|
end
|
126
126
|
end
|
127
|
-
opts << "-o" if
|
127
|
+
opts << "-o" if non_unique?
|
128
128
|
opts
|
129
129
|
end
|
130
130
|
end
|
@@ -154,10 +154,6 @@ class Chef
|
|
154
154
|
new_resource.home && Pathname.new(@current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath
|
155
155
|
end
|
156
156
|
|
157
|
-
def managing_home_dir?
|
158
|
-
new_resource.manage_home || new_resource.supports[:manage_home]
|
159
|
-
end
|
160
|
-
|
161
157
|
end
|
162
158
|
end
|
163
159
|
end
|
data/lib/chef/providers.rb
CHANGED
@@ -83,6 +83,7 @@ require "chef/provider/package/zypper"
|
|
83
83
|
require "chef/provider/package/solaris"
|
84
84
|
require "chef/provider/package/smartos"
|
85
85
|
require "chef/provider/package/aix"
|
86
|
+
require "chef/provider/package/cab"
|
86
87
|
|
87
88
|
require "chef/provider/service/arch"
|
88
89
|
require "chef/provider/service/freebsd"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Vasundhara Jagdale (<vasundhara.jagdale@msystechnologies.com>)
|
3
|
+
# Copyright:: Copyright 2008-2016, Chef Software, Inc.
|
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 "chef/resource/package"
|
20
|
+
require "chef/mixin/uris"
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Resource
|
24
|
+
class CabPackage < Chef::Resource::Package
|
25
|
+
include Chef::Mixin::Uris
|
26
|
+
|
27
|
+
provides :cab_package, os: "windows"
|
28
|
+
|
29
|
+
allowed_actions :install, :remove
|
30
|
+
|
31
|
+
def initialize(name, run_context = nil)
|
32
|
+
super
|
33
|
+
@resource_name = :cab_package
|
34
|
+
end
|
35
|
+
|
36
|
+
property :source, String,
|
37
|
+
coerce: (proc do |s|
|
38
|
+
unless s.nil?
|
39
|
+
uri_scheme?(s) ? s : Chef::Util::PathHelper.canonical_path(s, false)
|
40
|
+
end
|
41
|
+
end)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -87,13 +87,13 @@ class Chef
|
|
87
87
|
|
88
88
|
@values.each do |v|
|
89
89
|
raise ArgumentError, "Missing name key in RegistryKey values hash" unless v.has_key?(:name)
|
90
|
-
raise ArgumentError, "Missing type key in RegistryKey values hash" unless v.has_key?(:type)
|
91
|
-
raise ArgumentError, "Missing data key in RegistryKey values hash" unless v.has_key?(:data)
|
92
90
|
v.each_key do |key|
|
93
91
|
raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless [:name, :type, :data].include?(key)
|
94
92
|
end
|
95
93
|
raise ArgumentError, "Type of name => #{v[:name]} should be string" unless v[:name].is_a?(String)
|
96
|
-
|
94
|
+
if v[:type]
|
95
|
+
raise ArgumentError, "Type of type => #{v[:type]} should be symbol" unless v[:type].is_a?(Symbol)
|
96
|
+
end
|
97
97
|
end
|
98
98
|
@unscrubbed_values = @values
|
99
99
|
elsif self.instance_variable_defined?(:@values)
|
@@ -35,7 +35,7 @@ class Chef
|
|
35
35
|
property :exclude, String, regex: /.*/
|
36
36
|
property :failovermethod, String, equal_to: %w{priority roundrobin}
|
37
37
|
property :fastestmirror_enabled, [TrueClass, FalseClass]
|
38
|
-
property :gpgcheck, [TrueClass, FalseClass]
|
38
|
+
property :gpgcheck, [TrueClass, FalseClass], default: true
|
39
39
|
property :gpgkey, [String, Array], regex: /.*/
|
40
40
|
property :http_caching, String, equal_to: %w{packages all none}
|
41
41
|
property :include_config, String, regex: /.*/
|
data/lib/chef/resources.rb
CHANGED
data/lib/chef/server_api.rb
CHANGED
@@ -30,7 +30,7 @@ class Chef
|
|
30
30
|
|
31
31
|
def initialize(url = Chef::Config[:chef_server_url], options = {})
|
32
32
|
options[:client_name] ||= Chef::Config[:node_name]
|
33
|
-
options[:signing_key_filename] ||= Chef::Config[:client_key]
|
33
|
+
options[:signing_key_filename] ||= Chef::Config[:client_key] unless options[:raw_key]
|
34
34
|
options[:signing_key_filename] = nil if chef_zero_uri?(url)
|
35
35
|
options[:inflate_json_class] = false
|
36
36
|
super(url, options)
|
@@ -74,7 +74,7 @@ class Chef::Util::DSC
|
|
74
74
|
|
75
75
|
def lcm_command_code(configuration_path, test_only_parameters)
|
76
76
|
<<-EOH
|
77
|
-
$ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -erroraction '
|
77
|
+
$ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -erroraction 'stop' -force #{test_only_parameters}
|
78
78
|
EOH
|
79
79
|
end
|
80
80
|
|
data/lib/chef/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Do do do do, do do do do, do do do do, do do do do
|
@@ -0,0 +1 @@
|
|
1
|
+
Do do do do, do do do do, do do do do, do do do do
|
@@ -0,0 +1 @@
|
|
1
|
+
Do do do do, do do do do, do do do do, do do do do
|
@@ -20,86 +20,75 @@ require "spec_helper"
|
|
20
20
|
require "tiny_server"
|
21
21
|
|
22
22
|
describe Chef::Knife::CookbookDelete do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
let(:server) { TinyServer::Manager.new }
|
24
|
+
let(:api) { TinyServer::API.instance }
|
25
|
+
let(:knife_stdout) { StringIO.new }
|
26
|
+
let(:knife_stderr) { StringIO.new }
|
27
|
+
let(:knife) do
|
28
|
+
knife = Chef::Knife::CookbookDelete.new
|
29
|
+
allow(knife.ui).to receive(:stdout).and_return(knife_stdout)
|
30
|
+
allow(knife.ui).to receive(:stderr).and_return(knife_stderr)
|
31
|
+
knife
|
30
32
|
end
|
31
33
|
|
32
34
|
before(:each) do
|
33
|
-
|
34
|
-
|
35
|
-
@api.clear
|
35
|
+
server.start
|
36
|
+
api.clear
|
36
37
|
|
37
38
|
Chef::Config[:node_name] = nil
|
38
39
|
Chef::Config[:client_key] = nil
|
39
40
|
Chef::Config[:chef_server_url] = "http://localhost:9000"
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
-
|
43
|
+
after(:each) do
|
44
|
+
server.stop
|
45
|
+
end
|
44
46
|
|
47
|
+
context "when the cookbook doesn't exist" do
|
45
48
|
before do
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
around do |ex|
|
51
|
-
old_logger = Chef::Log.logger
|
52
|
-
old_level = Chef::Log.level
|
53
|
-
begin
|
54
|
-
Chef::Log.logger = Logger.new(log_output)
|
55
|
-
Chef::Log.level = :debug
|
56
|
-
ex.run
|
57
|
-
ensure
|
58
|
-
Chef::Log.logger = old_logger
|
59
|
-
Chef::Log.level = old_level
|
60
|
-
end
|
49
|
+
knife.name_args = %w{no-such-cookbook}
|
50
|
+
api.get("/cookbooks/no-such-cookbook", 404, Chef::JSONCompat.to_json({ "error" => "dear Tim, no. -Sent from my iPad" }))
|
61
51
|
end
|
62
52
|
|
63
53
|
it "logs an error and exits" do
|
64
|
-
|
65
|
-
expect
|
66
|
-
expect(log_output.string).to match(/Cannot find a cookbook named no-such-cookbook to delete/)
|
54
|
+
expect { knife.run }.to raise_error(SystemExit)
|
55
|
+
expect(knife_stderr.string).to match(/Cannot find a cookbook named no-such-cookbook to delete/)
|
67
56
|
end
|
68
57
|
|
69
58
|
end
|
70
59
|
|
71
60
|
context "when there is only one version of a cookbook" do
|
72
61
|
before do
|
73
|
-
|
62
|
+
knife.name_args = %w{obsolete-cookbook}
|
74
63
|
@cookbook_list = { "obsolete-cookbook" => { "versions" => ["version" => "1.0.0"] } }
|
75
|
-
|
64
|
+
api.get("/cookbooks/obsolete-cookbook", 200, Chef::JSONCompat.to_json(@cookbook_list))
|
76
65
|
end
|
77
66
|
|
78
67
|
it "asks for confirmation, then deletes the cookbook" do
|
79
68
|
stdin, stdout = StringIO.new("y\n"), StringIO.new
|
80
|
-
allow(
|
81
|
-
allow(
|
69
|
+
allow(knife.ui).to receive(:stdin).and_return(stdin)
|
70
|
+
allow(knife.ui).to receive(:stdout).and_return(stdout)
|
82
71
|
|
83
72
|
cb100_deleted = false
|
84
|
-
|
73
|
+
api.delete("/cookbooks/obsolete-cookbook/1.0.0", 200) { cb100_deleted = true; "[\"true\"]" }
|
85
74
|
|
86
|
-
|
75
|
+
knife.run
|
87
76
|
|
88
77
|
expect(stdout.string).to match(/#{Regexp.escape('Do you really want to delete obsolete-cookbook version 1.0.0? (Y/N)')}/)
|
89
78
|
expect(cb100_deleted).to be_truthy
|
90
79
|
end
|
91
80
|
|
92
81
|
it "asks for confirmation before purging" do
|
93
|
-
|
82
|
+
knife.config[:purge] = true
|
94
83
|
|
95
84
|
stdin, stdout = StringIO.new("y\ny\n"), StringIO.new
|
96
|
-
allow(
|
97
|
-
allow(
|
85
|
+
allow(knife.ui).to receive(:stdin).and_return(stdin)
|
86
|
+
allow(knife.ui).to receive(:stdout).and_return(stdout)
|
98
87
|
|
99
88
|
cb100_deleted = false
|
100
|
-
|
89
|
+
api.delete("/cookbooks/obsolete-cookbook/1.0.0?purge=true", 200) { cb100_deleted = true; "[\"true\"]" }
|
101
90
|
|
102
|
-
|
91
|
+
knife.run
|
103
92
|
|
104
93
|
expect(stdout.string).to match(/#{Regexp.escape('Are you sure you want to purge files')}/)
|
105
94
|
expect(stdout.string).to match(/#{Regexp.escape('Do you really want to delete obsolete-cookbook version 1.0.0? (Y/N)')}/)
|
@@ -111,21 +100,21 @@ describe Chef::Knife::CookbookDelete do
|
|
111
100
|
|
112
101
|
context "when there are several versions of a cookbook" do
|
113
102
|
before do
|
114
|
-
|
103
|
+
knife.name_args = %w{obsolete-cookbook}
|
115
104
|
versions = ["1.0.0", "1.1.0", "1.2.0"]
|
116
105
|
with_version = lambda { |version| { "version" => version } }
|
117
106
|
@cookbook_list = { "obsolete-cookbook" => { "versions" => versions.map(&with_version) } }
|
118
|
-
|
107
|
+
api.get("/cookbooks/obsolete-cookbook", 200, Chef::JSONCompat.to_json(@cookbook_list))
|
119
108
|
end
|
120
109
|
|
121
110
|
it "deletes all versions of a cookbook when given the '-a' flag" do
|
122
|
-
|
123
|
-
|
111
|
+
knife.config[:all] = true
|
112
|
+
knife.config[:yes] = true
|
124
113
|
cb100_deleted = cb110_deleted = cb120_deleted = nil
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
114
|
+
api.delete("/cookbooks/obsolete-cookbook/1.0.0", 200) { cb100_deleted = true; "[\"true\"]" }
|
115
|
+
api.delete("/cookbooks/obsolete-cookbook/1.1.0", 200) { cb110_deleted = true; "[\"true\"]" }
|
116
|
+
api.delete("/cookbooks/obsolete-cookbook/1.2.0", 200) { cb120_deleted = true; "[\"true\"]" }
|
117
|
+
knife.run
|
129
118
|
|
130
119
|
expect(cb100_deleted).to be_truthy
|
131
120
|
expect(cb110_deleted).to be_truthy
|
@@ -134,28 +123,28 @@ describe Chef::Knife::CookbookDelete do
|
|
134
123
|
|
135
124
|
it "asks which version to delete and deletes that when not given the -a flag" do
|
136
125
|
cb100_deleted = cb110_deleted = cb120_deleted = nil
|
137
|
-
|
126
|
+
api.delete("/cookbooks/obsolete-cookbook/1.0.0", 200) { cb100_deleted = true; "[\"true\"]" }
|
138
127
|
stdin, stdout = StringIO.new, StringIO.new
|
139
|
-
allow(
|
140
|
-
allow(
|
128
|
+
allow(knife.ui).to receive(:stdin).and_return(stdin)
|
129
|
+
allow(knife.ui).to receive(:stdout).and_return(stdout)
|
141
130
|
stdin << "1\n"
|
142
131
|
stdin.rewind
|
143
|
-
|
132
|
+
knife.run
|
144
133
|
expect(cb100_deleted).to be_truthy
|
145
134
|
expect(stdout.string).to match(/Which version\(s\) do you want to delete\?/)
|
146
135
|
end
|
147
136
|
|
148
137
|
it "deletes all versions of the cookbook when not given the -a flag and the user chooses to delete all" do
|
149
138
|
cb100_deleted = cb110_deleted = cb120_deleted = nil
|
150
|
-
|
151
|
-
|
152
|
-
|
139
|
+
api.delete("/cookbooks/obsolete-cookbook/1.0.0", 200) { cb100_deleted = true; "[\"true\"]" }
|
140
|
+
api.delete("/cookbooks/obsolete-cookbook/1.1.0", 200) { cb110_deleted = true; "[\"true\"]" }
|
141
|
+
api.delete("/cookbooks/obsolete-cookbook/1.2.0", 200) { cb120_deleted = true; "[\"true\"]" }
|
153
142
|
|
154
143
|
stdin, stdout = StringIO.new("4\n"), StringIO.new
|
155
|
-
allow(
|
156
|
-
allow(
|
144
|
+
allow(knife.ui).to receive(:stdin).and_return(stdin)
|
145
|
+
allow(knife.ui).to receive(:stdout).and_return(stdout)
|
157
146
|
|
158
|
-
|
147
|
+
knife.run
|
159
148
|
|
160
149
|
expect(cb100_deleted).to be_truthy
|
161
150
|
expect(cb110_deleted).to be_truthy
|
@@ -51,11 +51,17 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
def fetch_first_interface_name
|
55
|
+
shell_out("ifconfig | grep Ethernet | head -1 | cut -d' ' -f1").stdout.strip
|
56
|
+
end
|
57
|
+
|
54
58
|
# **Caution: any updates to core interfaces can be risky.
|
55
59
|
def en0_interface_for_test
|
56
60
|
case ohai[:platform]
|
57
61
|
when "aix"
|
58
62
|
"en0"
|
63
|
+
when "ubuntu"
|
64
|
+
fetch_first_interface_name
|
59
65
|
else
|
60
66
|
"eth0"
|
61
67
|
end
|
@@ -197,13 +197,37 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
|
|
197
197
|
expect(@registry.value_exists?(reg_child + '\OpscodeTest', { :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} })).to eq(true)
|
198
198
|
end
|
199
199
|
|
200
|
-
it "
|
200
|
+
it "raises an error if action create and parent does not exist and recursive is set to false" do
|
201
201
|
@new_resource.key(reg_child + '\Missing1\Missing2')
|
202
202
|
@new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
|
203
203
|
@new_resource.recursive(false)
|
204
204
|
expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
|
205
205
|
end
|
206
206
|
|
207
|
+
it "raises an error if action create and type key missing in values hash" do
|
208
|
+
@new_resource.key(reg_child)
|
209
|
+
@new_resource.values([{ :name => "OC", :data => "my_data" }])
|
210
|
+
expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "raises an error if action create and data key missing in values hash" do
|
214
|
+
@new_resource.key(reg_child)
|
215
|
+
@new_resource.values([{ :name => "OC", :type => :string }])
|
216
|
+
expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesDataMissing)
|
217
|
+
end
|
218
|
+
|
219
|
+
it "raises an error if action create and only name key present in values hash" do
|
220
|
+
@new_resource.key(reg_child)
|
221
|
+
@new_resource.values([{ :name => "OC" }])
|
222
|
+
expect { @new_resource.run_action(:create) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing)
|
223
|
+
end
|
224
|
+
|
225
|
+
it "does not raise an error if action create and all keys are present in values hash" do
|
226
|
+
@new_resource.key(reg_child)
|
227
|
+
@new_resource.values([{ :name => "OC", :type => :string, :data => "my_data" }])
|
228
|
+
expect { @new_resource.run_action(:create) }.to_not raise_error
|
229
|
+
end
|
230
|
+
|
207
231
|
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
|
208
232
|
@new_resource.key(reg_child + '\Missing1\Missing2')
|
209
233
|
@new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
|
@@ -270,7 +294,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
|
|
270
294
|
Chef::Config[:why_run] = true
|
271
295
|
end
|
272
296
|
|
273
|
-
it "does not
|
297
|
+
it "does not raise an exception if the keys do not exist but recursive is set to false" do
|
274
298
|
@new_resource.key(reg_child + '\Slitheen\Raxicoricofallapatorius')
|
275
299
|
@new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
|
276
300
|
@new_resource.recursive(false)
|
@@ -278,6 +302,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
|
|
278
302
|
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
|
279
303
|
expect(@registry.key_exists?(reg_child + '\Slitheen\Raxicoricofallapatorius')).to eq(false)
|
280
304
|
end
|
305
|
+
|
281
306
|
it "does not create key if the action is create" do
|
282
307
|
@new_resource.key(reg_child + '\Slitheen')
|
283
308
|
@new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
|
@@ -285,6 +310,34 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
|
|
285
310
|
@new_resource.run_action(:create)
|
286
311
|
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
|
287
312
|
end
|
313
|
+
|
314
|
+
it "does not raise an exception if the action create and type key missing in values hash" do
|
315
|
+
@new_resource.key(reg_child + '\Slitheen')
|
316
|
+
@new_resource.values([{ :name => "BriskWalk", :data => "my_data" }])
|
317
|
+
@new_resource.run_action(:create) # should not raise_error
|
318
|
+
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
|
319
|
+
end
|
320
|
+
|
321
|
+
it "does not raise an exception if the action create and data key missing in values hash" do
|
322
|
+
@new_resource.key(reg_child + '\Slitheen')
|
323
|
+
@new_resource.values([{ :name => "BriskWalk", :type => :string }])
|
324
|
+
@new_resource.run_action(:create) # should not raise_error
|
325
|
+
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
|
326
|
+
end
|
327
|
+
|
328
|
+
it "does not raise an exception if the action create and only name key present in values hash" do
|
329
|
+
@new_resource.key(reg_child + '\Slitheen')
|
330
|
+
@new_resource.values([{ :name => "BriskWalk" }])
|
331
|
+
@new_resource.run_action(:create) # should not raise_error
|
332
|
+
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
|
333
|
+
end
|
334
|
+
|
335
|
+
it "does not raise an exception if the action create and all keys are present in values hash" do
|
336
|
+
@new_resource.key(reg_child + '\Slitheen')
|
337
|
+
@new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "my_data" }])
|
338
|
+
@new_resource.run_action(:create) # should not raise_error
|
339
|
+
expect(@registry.key_exists?(reg_child + '\Slitheen')).to eq(false)
|
340
|
+
end
|
288
341
|
end
|
289
342
|
end
|
290
343
|
|
@@ -330,13 +383,37 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
|
|
330
383
|
expect(@registry.value_exists?(reg_child + '\Pyrovile', { :name => "Chef", :type => :multi_string, :data => %w{OpscodeOrange Rules} })).to eq(true)
|
331
384
|
end
|
332
385
|
|
333
|
-
it "
|
386
|
+
it "raises an error if action create and parent does not exist and recursive is set to false" do
|
334
387
|
@new_resource.key(reg_child + '\Sontaran\Sontar')
|
335
388
|
@new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
|
336
389
|
@new_resource.recursive(false)
|
337
390
|
expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
|
338
391
|
end
|
339
392
|
|
393
|
+
it "raises an error if action create_if_missing and type key missing in values hash" do
|
394
|
+
@new_resource.key(reg_child)
|
395
|
+
@new_resource.values([{ :name => "OC", :data => "my_data" }])
|
396
|
+
expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing)
|
397
|
+
end
|
398
|
+
|
399
|
+
it "raises an error if action create_if_missing and data key missing in values hash" do
|
400
|
+
@new_resource.key(reg_child)
|
401
|
+
@new_resource.values([{ :name => "OC", :type => :string }])
|
402
|
+
expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesDataMissing)
|
403
|
+
end
|
404
|
+
|
405
|
+
it "raises an error if action create_if_missing and only name key present in values hash" do
|
406
|
+
@new_resource.key(reg_child)
|
407
|
+
@new_resource.values([{ :name => "OC" }])
|
408
|
+
expect { @new_resource.run_action(:create_if_missing) }.to raise_error(Chef::Exceptions::RegKeyValuesTypeMissing)
|
409
|
+
end
|
410
|
+
|
411
|
+
it "does not raise an error if action create_if_missing and all keys are present in values hash" do
|
412
|
+
@new_resource.key(reg_child)
|
413
|
+
@new_resource.values([{ :name => "OC", :type => :string, :data => "my_data" }])
|
414
|
+
expect { @new_resource.run_action(:create_if_missing) }.to_not raise_error
|
415
|
+
end
|
416
|
+
|
340
417
|
it "creates missing keys if action create and parent does not exist and recursive is set to true" do
|
341
418
|
@new_resource.key(reg_child + '\Sontaran\Sontar')
|
342
419
|
@new_resource.values([{ :name => "OC", :type => :string, :data => "MissingData" }])
|
@@ -381,7 +458,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
|
|
381
458
|
Chef::Config[:why_run] = true
|
382
459
|
end
|
383
460
|
|
384
|
-
it "does not
|
461
|
+
it "does not raise an exception if the keys do not exist but recursive is set to false" do
|
385
462
|
@new_resource.key(reg_child + '\Zygons\Zygor')
|
386
463
|
@new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
|
387
464
|
@new_resource.recursive(false)
|
@@ -389,6 +466,7 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
|
|
389
466
|
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
|
390
467
|
expect(@registry.key_exists?(reg_child + '\Zygons\Zygor')).to eq(false)
|
391
468
|
end
|
469
|
+
|
392
470
|
it "does nothing if the action is create_if_missing" do
|
393
471
|
@new_resource.key(reg_child + '\Zygons')
|
394
472
|
@new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "is good for health" }])
|
@@ -396,6 +474,34 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
|
|
396
474
|
@new_resource.run_action(:create_if_missing)
|
397
475
|
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
|
398
476
|
end
|
477
|
+
|
478
|
+
it "does not raise an exception if the action create_if_missing and type key missing in values hash" do
|
479
|
+
@new_resource.key(reg_child + '\Zygons')
|
480
|
+
@new_resource.values([{ :name => "BriskWalk", :data => "my_data" }])
|
481
|
+
@new_resource.run_action(:create_if_missing) # should not raise_error
|
482
|
+
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
|
483
|
+
end
|
484
|
+
|
485
|
+
it "does not raise an exception if the action create_if_missing and data key missing in values hash" do
|
486
|
+
@new_resource.key(reg_child + '\Zygons')
|
487
|
+
@new_resource.values([{ :name => "BriskWalk", :type => :string }])
|
488
|
+
@new_resource.run_action(:create_if_missing) # should not raise_error
|
489
|
+
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
|
490
|
+
end
|
491
|
+
|
492
|
+
it "does not raise an exception if the action create_if_missing and only name key present in values hash" do
|
493
|
+
@new_resource.key(reg_child + '\Zygons')
|
494
|
+
@new_resource.values([{ :name => "BriskWalk" }])
|
495
|
+
@new_resource.run_action(:create_if_missing) # should not raise_error
|
496
|
+
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
|
497
|
+
end
|
498
|
+
|
499
|
+
it "does not raise an exception if the action create_if_missing and all keys are present in values hash" do
|
500
|
+
@new_resource.key(reg_child + '\Zygons')
|
501
|
+
@new_resource.values([{ :name => "BriskWalk", :type => :string, :data => "my_data" }])
|
502
|
+
@new_resource.run_action(:create_if_missing) # should not raise_error
|
503
|
+
expect(@registry.key_exists?(reg_child + '\Zygons')).to eq(false)
|
504
|
+
end
|
399
505
|
end
|
400
506
|
end
|
401
507
|
|