chef 12.5.1-universal-mingw32 → 12.6.0-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -1
- data/README.md +6 -4
- data/Rakefile +1 -4
- data/chef-windows.gemspec +21 -0
- data/chef.gemspec +58 -0
- data/lib/chef/api_client/registration.rb +9 -4
- data/lib/chef/application.rb +3 -84
- data/lib/chef/application/apply.rb +9 -2
- data/lib/chef/application/client.rb +8 -3
- data/lib/chef/application/solo.rb +7 -1
- data/lib/chef/application/windows_service.rb +21 -6
- data/lib/chef/application/windows_service_manager.rb +2 -3
- data/lib/chef/audit/runner.rb +1 -0
- data/lib/chef/chef_class.rb +1 -11
- data/lib/chef/chef_fs/chef_fs_data_store.rb +181 -2
- data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +5 -0
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +11 -7
- data/lib/chef/client.rb +28 -1
- data/lib/chef/cookbook/cookbook_collection.rb +14 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +115 -9
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
- data/lib/chef/cookbook_version.rb +6 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/digester.rb +5 -1
- data/lib/chef/dsl/chef_provisioning.rb +57 -0
- data/lib/chef/dsl/cheffish.rb +64 -0
- data/lib/chef/dsl/declare_resource.rb +108 -0
- data/lib/chef/dsl/platform_introspection.rb +3 -3
- data/lib/chef/dsl/recipe.rb +3 -73
- data/lib/chef/dsl/resources.rb +27 -1
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/event_dispatch/dispatcher.rb +5 -0
- data/lib/chef/event_dispatch/events_output_stream.rb +8 -0
- data/lib/chef/exceptions.rb +21 -1
- data/lib/chef/file_access_control/unix.rb +12 -12
- data/lib/chef/file_content_management/deploy/cp.rb +2 -2
- data/lib/chef/file_content_management/deploy/mv_unix.rb +4 -4
- data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
- data/lib/chef/formatters/base.rb +7 -0
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
- data/lib/chef/formatters/indentable_output_stream.rb +5 -0
- data/lib/chef/http.rb +19 -3
- data/lib/chef/http/decompressor.rb +2 -2
- data/lib/chef/json_compat.rb +1 -0
- data/lib/chef/knife.rb +16 -2
- data/lib/chef/knife/bootstrap.rb +55 -10
- data/lib/chef/knife/cookbook_site_install.rb +5 -1
- data/lib/chef/knife/core/bootstrap_context.rb +2 -1
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +30 -16
- data/lib/chef/knife/ssl_check.rb +4 -2
- data/lib/chef/knife/ssl_fetch.rb +3 -2
- data/lib/chef/knife/status.rb +14 -1
- data/lib/chef/log.rb +14 -0
- data/lib/chef/mixin/get_source_from_package.rb +7 -2
- data/lib/chef/mixin/properties.rb +302 -0
- data/lib/chef/mixin/proxified_socket.rb +38 -0
- data/lib/chef/mixin/subclass_directive.rb +37 -0
- data/lib/chef/node.rb +13 -5
- data/lib/chef/platform/query_helpers.rb +14 -3
- data/lib/chef/platform/service_helpers.rb +20 -38
- data/lib/chef/policy_builder/expand_node_object.rb +3 -0
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +51 -12
- data/lib/chef/provider.rb +40 -35
- data/lib/chef/provider/deploy.rb +1 -1
- data/lib/chef/provider/dsc_resource.rb +54 -20
- data/lib/chef/provider/execute.rb +25 -4
- data/lib/chef/provider/group.rb +1 -1
- data/lib/chef/provider/lwrp_base.rb +1 -0
- data/lib/chef/provider/package.rb +76 -30
- data/lib/chef/provider/package/dpkg.rb +152 -69
- data/lib/chef/provider/package/openbsd.rb +6 -8
- data/lib/chef/provider/package/solaris.rb +2 -0
- data/lib/chef/provider/package/windows.rb +95 -14
- data/lib/chef/provider/package/windows/exe.rb +129 -0
- data/lib/chef/provider/package/windows/msi.rb +37 -13
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +89 -0
- data/lib/chef/provider/package/yum.rb +13 -3
- data/lib/chef/provider/powershell_script.rb +3 -0
- data/lib/chef/provider/remote_file/cache_control_data.rb +37 -4
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/script.rb +1 -0
- data/lib/chef/provider/service.rb +13 -10
- data/lib/chef/provider/service/solaris.rb +43 -17
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +111 -100
- data/lib/chef/provider/user/windows.rb +5 -3
- data/lib/chef/recipe.rb +3 -5
- data/lib/chef/resource.rb +77 -320
- data/lib/chef/resource/action_class.rb +4 -0
- data/lib/chef/resource/dpkg_package.rb +4 -3
- data/lib/chef/resource/dsc_resource.rb +40 -2
- data/lib/chef/resource/execute.rb +9 -1
- data/lib/chef/resource/ksh.rb +32 -0
- data/lib/chef/resource/lwrp_base.rb +6 -10
- data/lib/chef/resource/package.rb +8 -9
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/resource_notification.rb +14 -1
- data/lib/chef/resource/script.rb +1 -1
- data/lib/chef/resource/windows_package.rb +1 -1
- data/lib/chef/resource_builder.rb +14 -7
- data/lib/chef/resource_reporter.rb +6 -0
- data/lib/chef/resources.rb +1 -7
- data/lib/chef/rest.rb +1 -1
- data/lib/chef/run_context.rb +45 -2
- data/lib/chef/run_list/run_list_expansion.rb +47 -0
- data/lib/chef/runner.rb +25 -0
- data/lib/chef/search/query.rb +16 -2
- data/lib/chef/util/diff.rb +2 -2
- data/lib/chef/util/powershell/ps_credential.rb +2 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +51 -1
- data/lib/chef/win32/file.rb +5 -0
- data/lib/chef/win32/file/version_info.rb +93 -0
- data/lib/chef/win32/mutex.rb +1 -1
- data/spec/data/apt/chef-integration-test2-1.0/debian/changelog +5 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.debhelper.log +45 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.substvars +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/conffiles +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/control +10 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/md5sums +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/compat +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/conffiles +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/control +13 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/copyright +34 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/files +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/rules +13 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/source/format +1 -0
- data/spec/data/apt/chef-integration-test2_1.0-1.debian.tar.gz +0 -0
- data/spec/data/apt/chef-integration-test2_1.0-1.dsc +18 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.build +91 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.changes +31 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.deb +0 -0
- data/spec/data/apt/chef-integration-test2_1.0.orig.tar.gz +0 -0
- data/spec/functional/application_spec.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +4 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/notifications_spec.rb +74 -4
- data/spec/functional/resource/aix_service_spec.rb +2 -2
- data/spec/functional/resource/dpkg_package_spec.rb +339 -0
- data/spec/functional/resource/ifconfig_spec.rb +3 -1
- data/spec/functional/resource/mount_spec.rb +5 -2
- data/spec/functional/resource/package_spec.rb +1 -1
- data/spec/functional/resource/user/windows_spec.rb +8 -0
- data/spec/functional/resource/windows_package_spec.rb +177 -0
- data/spec/functional/win32/version_info_spec.rb +50 -0
- data/spec/integration/client/client_spec.rb +80 -0
- data/spec/integration/knife/download_spec.rb +9 -0
- data/spec/integration/knife/upload_spec.rb +28 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +93 -23
- data/spec/integration/recipes/resource_action_spec.rb +211 -116
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +72 -0
- data/spec/integration/solo/solo_spec.rb +34 -0
- data/spec/spec_helper.rb +11 -1
- data/spec/support/platform_helpers.rb +8 -0
- data/spec/support/shared/integration/integration_helper.rb +6 -0
- data/spec/support/shared/unit/execute_resource.rb +5 -0
- data/spec/support/shared/unit/platform_introspector.rb +7 -0
- data/spec/tiny_server.rb +6 -2
- data/spec/unit/api_client/registration_spec.rb +5 -4
- data/spec/unit/application_spec.rb +1 -181
- data/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +34 -0
- data/spec/unit/cookbook/metadata_spec.rb +122 -2
- data/spec/unit/http_spec.rb +102 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -13
- data/spec/unit/knife/core/bootstrap_context_spec.rb +10 -3
- data/spec/unit/knife/ssl_check_spec.rb +7 -3
- data/spec/unit/knife/ssl_fetch_spec.rb +2 -2
- data/spec/unit/knife/status_spec.rb +13 -13
- data/spec/unit/knife_spec.rb +26 -2
- data/spec/unit/lwrp_spec.rb +1 -1
- data/spec/unit/mixin/properties_spec.rb +97 -0
- data/spec/unit/mixin/proxified_socket_spec.rb +94 -0
- data/spec/unit/mixin/subclass_directive_spec.rb +45 -0
- data/spec/unit/node_spec.rb +9 -1
- data/spec/unit/policy_builder/policyfile_spec.rb +2 -0
- data/spec/unit/property/validation_spec.rb +14 -12
- data/spec/unit/property_spec.rb +56 -0
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/dsc_resource_spec.rb +63 -24
- data/spec/unit/provider/execute_spec.rb +95 -28
- data/spec/unit/provider/package/dpkg_spec.rb +185 -96
- data/spec/unit/provider/package/windows/exe_spec.rb +251 -0
- data/spec/unit/provider/package/windows/msi_spec.rb +94 -10
- data/spec/unit/provider/package/windows_spec.rb +227 -26
- data/spec/unit/provider/package/yum_spec.rb +6 -0
- data/spec/unit/provider/package_spec.rb +495 -366
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +62 -36
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +110 -39
- data/spec/unit/provider/service/upstart_service_spec.rb +19 -0
- data/spec/unit/provider/user/dscl_spec.rb +14 -0
- data/spec/unit/provider/user/windows_spec.rb +2 -2
- data/spec/unit/provider/user_spec.rb +9 -0
- data/spec/unit/provider_resolver_spec.rb +6 -30
- data/spec/unit/recipe_spec.rb +46 -20
- data/spec/unit/resource/chef_gem_spec.rb +1 -1
- data/spec/unit/resource/dsc_resource_spec.rb +14 -3
- data/spec/unit/resource/ksh_spec.rb +40 -0
- data/spec/unit/resource/registry_key_spec.rb +2 -2
- data/spec/unit/resource/resource_notification_spec.rb +44 -45
- data/spec/unit/resource_reporter_spec.rb +7 -0
- data/spec/unit/resource_spec.rb +268 -253
- data/spec/unit/rest_spec.rb +2 -2
- data/spec/unit/run_list/run_list_expansion_spec.rb +18 -3
- data/spec/unit/search/query_spec.rb +19 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +8 -1
- data/spec/unit/windows_service_spec.rb +83 -38
- data/tasks/external_tests.rb +19 -9
- data/tasks/rspec.rb +1 -1
- metadata +70 -21
- data/spec/support/pedant/Gemfile +0 -3
- data/spec/support/pedant/pedant_config.rb +0 -129
- data/spec/support/pedant/run_pedant.rb +0 -63
- data/spec/support/pedant/stickywicket.pem +0 -27
- data/spec/unit/provider/package_spec.rbe +0 -0
@@ -139,7 +139,7 @@ E
|
|
139
139
|
context "when the TLS connection is successful" do
|
140
140
|
|
141
141
|
before do
|
142
|
-
expect(
|
142
|
+
expect(ssl_fetch).to receive(:proxified_socket).with("foo.example.com", 8443).and_return(tcp_socket)
|
143
143
|
expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(tcp_socket, ssl_fetch.noverify_peer_ssl_context).and_return(ssl_socket)
|
144
144
|
expect(ssl_socket).to receive(:connect)
|
145
145
|
expect(ssl_socket).to receive(:peer_cert_chain).and_return([self_signed_crt])
|
@@ -161,7 +161,7 @@ E
|
|
161
161
|
let(:unknown_protocol_error) { OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol") }
|
162
162
|
|
163
163
|
before do
|
164
|
-
expect(
|
164
|
+
expect(ssl_fetch).to receive(:proxified_socket).with("foo.example.com", 80).and_return(tcp_socket)
|
165
165
|
expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(tcp_socket, ssl_fetch.noverify_peer_ssl_context).and_return(ssl_socket)
|
166
166
|
expect(ssl_socket).to receive(:connect).and_raise(unknown_protocol_error)
|
167
167
|
|
@@ -44,9 +44,9 @@ describe Chef::Knife::Status do
|
|
44
44
|
@knife.run
|
45
45
|
end
|
46
46
|
|
47
|
-
it "should filter
|
48
|
-
@knife.config[:
|
49
|
-
expect(@query).to receive(:search).with(:node, "NOT ohai_time:[
|
47
|
+
it "should filter by nodes older than some mins" do
|
48
|
+
@knife.config[:hide_by_mins] = 59
|
49
|
+
expect(@query).to receive(:search).with(:node, "NOT ohai_time:[1428569880 TO 1428573420]", opts)
|
50
50
|
@knife.run
|
51
51
|
end
|
52
52
|
|
@@ -56,10 +56,10 @@ describe Chef::Knife::Status do
|
|
56
56
|
@knife.run
|
57
57
|
end
|
58
58
|
|
59
|
-
it "should filter by environment and
|
59
|
+
it "should filter by environment and nodes older than some mins" do
|
60
60
|
@knife.config[:environment] = "production"
|
61
|
-
@knife.config[:
|
62
|
-
expect(@query).to receive(:search).with(:node, "chef_environment:production NOT ohai_time:[
|
61
|
+
@knife.config[:hide_by_mins] = 59
|
62
|
+
expect(@query).to receive(:search).with(:node, "chef_environment:production NOT ohai_time:[1428569880 TO 1428573420]", opts)
|
63
63
|
@knife.run
|
64
64
|
end
|
65
65
|
|
@@ -79,22 +79,22 @@ describe Chef::Knife::Status do
|
|
79
79
|
@knife.run
|
80
80
|
end
|
81
81
|
|
82
|
-
it "should filter
|
83
|
-
@knife.config[:
|
84
|
-
expect(@query).to receive(:search).with(:node, "name:my_custom_name NOT ohai_time:[
|
82
|
+
it "should filter by nodes older than some mins with nodename specified" do
|
83
|
+
@knife.config[:hide_by_mins] = 59
|
84
|
+
expect(@query).to receive(:search).with(:node, "name:my_custom_name NOT ohai_time:[1428569880 TO 1428573420]", opts)
|
85
85
|
@knife.run
|
86
86
|
end
|
87
87
|
|
88
|
-
it "should filter by environment" do
|
88
|
+
it "should filter by environment with nodename specified" do
|
89
89
|
@knife.config[:environment] = "production"
|
90
90
|
expect(@query).to receive(:search).with(:node, "name:my_custom_name AND chef_environment:production", opts)
|
91
91
|
@knife.run
|
92
92
|
end
|
93
93
|
|
94
|
-
it "should filter by environment and
|
94
|
+
it "should filter by environment and nodes older than some mins with nodename specified" do
|
95
95
|
@knife.config[:environment] = "production"
|
96
|
-
@knife.config[:
|
97
|
-
expect(@query).to receive(:search).with(:node, "name:my_custom_name AND chef_environment:production NOT ohai_time:[
|
96
|
+
@knife.config[:hide_by_mins] = 59
|
97
|
+
expect(@query).to receive(:search).with(:node, "name:my_custom_name AND chef_environment:production NOT ohai_time:[1428569880 TO 1428573420]", opts)
|
98
98
|
@knife.run
|
99
99
|
end
|
100
100
|
end
|
data/spec/unit/knife_spec.rb
CHANGED
@@ -33,7 +33,10 @@ describe Chef::Knife do
|
|
33
33
|
let(:config_location) { File.expand_path("~/.chef/config.rb") }
|
34
34
|
|
35
35
|
let(:config_loader) do
|
36
|
-
instance_double("WorkstationConfigLoader",
|
36
|
+
instance_double("WorkstationConfigLoader",
|
37
|
+
load: nil, no_config_found?: false,
|
38
|
+
config_location: config_location,
|
39
|
+
:chef_config_dir => "/etc/chef")
|
37
40
|
end
|
38
41
|
|
39
42
|
before(:each) do
|
@@ -60,6 +63,12 @@ describe Chef::Knife do
|
|
60
63
|
Chef::Knife.reset_config_loader!
|
61
64
|
end
|
62
65
|
|
66
|
+
it "does not reset Chef::Config[:verbosity to nil if config[:verbosity] is nil" do
|
67
|
+
Chef::Config[:verbosity] = 2
|
68
|
+
Chef::Knife.new
|
69
|
+
expect(Chef::Config[:verbosity]).to eq(2)
|
70
|
+
end
|
71
|
+
|
63
72
|
describe "after loading a subcommand" do
|
64
73
|
before do
|
65
74
|
Chef::Knife.reset_subcommands!
|
@@ -117,6 +126,14 @@ describe Chef::Knife do
|
|
117
126
|
expect(Chef::Knife.subcommands["super_awesome_command"]).to eq(SuperAwesomeCommand)
|
118
127
|
end
|
119
128
|
|
129
|
+
it "records the location of ChefFS-based commands correctly" do
|
130
|
+
class AwesomeCheffsCommand < Chef::ChefFS::Knife
|
131
|
+
end
|
132
|
+
|
133
|
+
Chef::Knife.load_commands
|
134
|
+
expect(Chef::Knife.subcommand_files["awesome_cheffs_command"]).to eq([__FILE__])
|
135
|
+
end
|
136
|
+
|
120
137
|
it "guesses a category from a given ARGV" do
|
121
138
|
Chef::Knife.subcommands_by_category["cookbook"] << :cookbook
|
122
139
|
Chef::Knife.subcommands_by_category["cookbook site"] << :cookbook_site
|
@@ -298,7 +315,7 @@ describe Chef::Knife do
|
|
298
315
|
expect(Chef::Config[:listen]).to be(false)
|
299
316
|
end
|
300
317
|
|
301
|
-
context "verbosity is
|
318
|
+
context "verbosity is one" do
|
302
319
|
let(:fake_config) { "/does/not/exist/knife.rb" }
|
303
320
|
|
304
321
|
before do
|
@@ -316,6 +333,13 @@ describe Chef::Knife do
|
|
316
333
|
knife.configure_chef
|
317
334
|
end
|
318
335
|
end
|
336
|
+
|
337
|
+
it "does not humanize the exception if Chef::Config[:verbosity] is two" do
|
338
|
+
Chef::Config[:verbosity] = 2
|
339
|
+
allow(knife).to receive(:run).and_raise(Exception)
|
340
|
+
expect(knife).not_to receive(:humanize_exception)
|
341
|
+
expect { knife.run_with_pretty_exceptions }.to raise_error(Exception)
|
342
|
+
end
|
319
343
|
end
|
320
344
|
end
|
321
345
|
|
data/spec/unit/lwrp_spec.rb
CHANGED
@@ -190,7 +190,7 @@ describe "LWRP" do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should have a class that outputs a reasonable string" do
|
193
|
-
expect(get_lwrp(:lwrp_foo).to_s).to eq "
|
193
|
+
expect(get_lwrp(:lwrp_foo).to_s).to eq "Custom resource lwrp_foo from cookbook lwrp"
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should add the specified actions to the allowed_actions array" do
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'support/shared/integration/integration_helper'
|
2
|
+
require 'chef/mixin/properties'
|
3
|
+
|
4
|
+
module ChefMixinPropertiesSpec
|
5
|
+
describe "Chef::Resource.property" do
|
6
|
+
include IntegrationSupport
|
7
|
+
|
8
|
+
context "with a base class A with properties a, ab, and ac" do
|
9
|
+
class A
|
10
|
+
include Chef::Mixin::Properties
|
11
|
+
property :a, 'a', default: 'a'
|
12
|
+
property :ab, ['a', 'b'], default: 'a'
|
13
|
+
property :ac, ['a', 'c'], default: 'a'
|
14
|
+
end
|
15
|
+
|
16
|
+
context "and a module B with properties b, ab and bc" do
|
17
|
+
module B
|
18
|
+
include Chef::Mixin::Properties
|
19
|
+
property :b, 'b', default: 'b'
|
20
|
+
property :ab, default: 'b'
|
21
|
+
property :bc, ['b', 'c'], default: 'c'
|
22
|
+
end
|
23
|
+
|
24
|
+
context "and a derived class C < A with properties c, ac and bc" do
|
25
|
+
class C < A
|
26
|
+
include B
|
27
|
+
property :c, 'c', default: 'c'
|
28
|
+
property :ac, default: 'c'
|
29
|
+
property :bc, default: 'c'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "A.properties has a, ab, and ac with types 'a', ['a', 'b'], and ['b', 'c']" do
|
33
|
+
expect(A.properties.keys).to eq [ :a, :ab, :ac ]
|
34
|
+
expect(A.properties[:a].validation_options[:is]).to eq 'a'
|
35
|
+
expect(A.properties[:ab].validation_options[:is]).to eq [ 'a', 'b' ]
|
36
|
+
expect(A.properties[:ac].validation_options[:is]).to eq [ 'a', 'c' ]
|
37
|
+
end
|
38
|
+
it "B.properties has b, ab, and bc with types 'b', nil and ['b', 'c']" do
|
39
|
+
expect(B.properties.keys).to eq [ :b, :ab, :bc ]
|
40
|
+
expect(B.properties[:b].validation_options[:is]).to eq 'b'
|
41
|
+
expect(B.properties[:ab].validation_options[:is]).to be_nil
|
42
|
+
expect(B.properties[:bc].validation_options[:is]).to eq [ 'b', 'c' ]
|
43
|
+
end
|
44
|
+
it "C.properties has a, b, c, ac and bc with merged types" do
|
45
|
+
expect(C.properties.keys).to eq [ :a, :ab, :ac, :b, :bc, :c ]
|
46
|
+
expect(C.properties[:a].validation_options[:is]).to eq 'a'
|
47
|
+
expect(C.properties[:b].validation_options[:is]).to eq 'b'
|
48
|
+
expect(C.properties[:c].validation_options[:is]).to eq 'c'
|
49
|
+
expect(C.properties[:ac].validation_options[:is]).to eq [ 'a', 'c' ]
|
50
|
+
expect(C.properties[:bc].validation_options[:is]).to eq [ 'b', 'c' ]
|
51
|
+
end
|
52
|
+
it "C.properties has ab with a non-merged type (from B)" do
|
53
|
+
expect(C.properties[:ab].validation_options[:is]).to be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
context "and an instance of C" do
|
57
|
+
let(:c) { C.new }
|
58
|
+
|
59
|
+
it "all properties can be retrieved and merged properties default to ab->b, ac->c, bc->c" do
|
60
|
+
expect(c.a).to eq('a')
|
61
|
+
expect(c.b).to eq('b')
|
62
|
+
expect(c.c).to eq('c')
|
63
|
+
expect(c.ab).to eq('b')
|
64
|
+
expect(c.ac).to eq('c')
|
65
|
+
expect(c.bc).to eq('c')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "with an Inner module" do
|
74
|
+
module Inner
|
75
|
+
include Chef::Mixin::Properties
|
76
|
+
property :inner
|
77
|
+
end
|
78
|
+
|
79
|
+
context "and an Outer module including it" do
|
80
|
+
module Outer
|
81
|
+
include Inner
|
82
|
+
property :outer
|
83
|
+
end
|
84
|
+
|
85
|
+
context "and an Outerest class including that" do
|
86
|
+
class Outerest
|
87
|
+
include Outer
|
88
|
+
property :outerest
|
89
|
+
end
|
90
|
+
|
91
|
+
it "Outerest.properties.validation_options[:is] inner, outer, outerest" do
|
92
|
+
expect(Outerest.properties.keys).to eq [:inner, :outer, :outerest]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Tyler Ball (<tball@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2014 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 "spec_helper"
|
20
|
+
require "chef/mixin/proxified_socket"
|
21
|
+
require "proxifier/proxy"
|
22
|
+
|
23
|
+
class TestProxifiedSocket
|
24
|
+
include Chef::Mixin::ProxifiedSocket
|
25
|
+
end
|
26
|
+
|
27
|
+
describe Chef::Mixin::ProxifiedSocket do
|
28
|
+
|
29
|
+
before do
|
30
|
+
@original_env = ENV.to_hash
|
31
|
+
end
|
32
|
+
|
33
|
+
after do
|
34
|
+
ENV.clear
|
35
|
+
ENV.update(@original_env)
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:host) { "host" }
|
39
|
+
let(:port) { 7979 }
|
40
|
+
let(:test_instance) { TestProxifiedSocket.new }
|
41
|
+
let(:socket_double) { instance_double(TCPSocket)}
|
42
|
+
let(:proxifier_double) { instance_double(Proxifier::Proxy) }
|
43
|
+
let(:http_uri) { "http://somehost:1" }
|
44
|
+
let(:https_uri) { "https://somehost:1" }
|
45
|
+
let(:no_proxy_spec) { nil }
|
46
|
+
|
47
|
+
shared_examples "proxified socket" do
|
48
|
+
it "wraps the Socket in a Proxifier::Proxy" do
|
49
|
+
expect(Proxifier).to receive(:Proxy).with(proxy_uri, no_proxy: no_proxy_spec).and_return(proxifier_double)
|
50
|
+
expect(proxifier_double).to receive(:open).with(host, port).and_return(socket_double)
|
51
|
+
expect(test_instance.proxified_socket(host, port)).to eq(socket_double)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when no proxy is set" do
|
56
|
+
it "returns a plain TCPSocket" do
|
57
|
+
expect(TCPSocket).to receive(:new).with(host, port).and_return(socket_double)
|
58
|
+
expect(test_instance.proxified_socket(host, port)).to eq(socket_double)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when https_proxy is set" do
|
63
|
+
before do
|
64
|
+
# I'm purposefully setting both of these because we prefer the https
|
65
|
+
# variable
|
66
|
+
ENV['https_proxy'] = https_uri
|
67
|
+
ENV['http_proxy'] = http_uri
|
68
|
+
end
|
69
|
+
|
70
|
+
let(:proxy_uri) { https_uri }
|
71
|
+
include_examples "proxified socket"
|
72
|
+
|
73
|
+
context "when no_proxy is set" do
|
74
|
+
# This is testing that no_proxy is also provided to Proxified
|
75
|
+
# when it is set
|
76
|
+
before do
|
77
|
+
ENV['no_proxy'] = no_proxy_spec
|
78
|
+
end
|
79
|
+
|
80
|
+
let(:no_proxy_spec) { "somehost1,somehost2" }
|
81
|
+
include_examples "proxified socket"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when http_proxy is set" do
|
86
|
+
before do
|
87
|
+
ENV['http_proxy'] = http_uri
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:proxy_uri) { http_uri }
|
91
|
+
include_examples "proxified socket"
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) 2015 Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
class SubclassDirectiveParent
|
21
|
+
extend Chef::Mixin::SubclassDirective
|
22
|
+
|
23
|
+
subclass_directive :behave_differently
|
24
|
+
end
|
25
|
+
|
26
|
+
class SubclassDirectiveChild < SubclassDirectiveParent
|
27
|
+
behave_differently
|
28
|
+
end
|
29
|
+
|
30
|
+
class ChildWithoutDirective < SubclassDirectiveParent
|
31
|
+
end
|
32
|
+
|
33
|
+
describe Chef::Mixin::Uris do
|
34
|
+
let (:child) { SubclassDirectiveChild.new }
|
35
|
+
|
36
|
+
let (:other_child) { ChildWithoutDirective.new }
|
37
|
+
|
38
|
+
it "the child instance has the directive set" do
|
39
|
+
expect(child.behave_differently?).to be true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "a child that does not declare it does not have it set" do
|
43
|
+
expect(other_child.behave_differently?).to be false
|
44
|
+
end
|
45
|
+
end
|
data/spec/unit/node_spec.rb
CHANGED
@@ -42,6 +42,14 @@ describe Chef::Node do
|
|
42
42
|
expect([n3, n1, n2].sort).to eq([n1, n2, n3])
|
43
43
|
end
|
44
44
|
|
45
|
+
it "should share identity only with others of the same name" do
|
46
|
+
n1 = Chef::Node.build('foo')
|
47
|
+
n2 = Chef::Node.build('foo')
|
48
|
+
n3 = Chef::Node.build('bar')
|
49
|
+
expect(n1).to eq(n2)
|
50
|
+
expect(n1).not_to eq(n3)
|
51
|
+
end
|
52
|
+
|
45
53
|
describe "when the node does not exist on the server" do
|
46
54
|
before do
|
47
55
|
response = OpenStruct.new(:code => '404')
|
@@ -785,7 +793,7 @@ describe Chef::Node do
|
|
785
793
|
end
|
786
794
|
|
787
795
|
it "should not set the tags attribute to an empty array if it is already defined" do
|
788
|
-
node.
|
796
|
+
node.tag("radiohead")
|
789
797
|
node.consume_external_attrs(@ohai_data, {})
|
790
798
|
expect(node.tags).to eql([ "radiohead" ])
|
791
799
|
end
|
@@ -662,6 +662,7 @@ describe Chef::PolicyBuilder::Policyfile do
|
|
662
662
|
it "builds a run context" do
|
663
663
|
expect(cookbook_synchronizer).to receive(:sync_cookbooks)
|
664
664
|
expect_any_instance_of(Chef::RunContext).to receive(:load).with(policy_builder.run_list_expansion_ish)
|
665
|
+
expect_any_instance_of(Chef::CookbookCollection).to receive(:validate!)
|
665
666
|
run_context = policy_builder.setup_run_context
|
666
667
|
expect(run_context.node).to eq(node)
|
667
668
|
expect(run_context.cookbook_collection.keys).to match_array(["example1", "example2"])
|
@@ -670,6 +671,7 @@ describe Chef::PolicyBuilder::Policyfile do
|
|
670
671
|
it "makes the run context available via static method on Chef" do
|
671
672
|
expect(cookbook_synchronizer).to receive(:sync_cookbooks)
|
672
673
|
expect_any_instance_of(Chef::RunContext).to receive(:load).with(policy_builder.run_list_expansion_ish)
|
674
|
+
expect_any_instance_of(Chef::CookbookCollection).to receive(:validate!)
|
673
675
|
run_context = policy_builder.setup_run_context
|
674
676
|
expect(Chef.run_context).to eq(run_context)
|
675
677
|
end
|
@@ -137,12 +137,8 @@ describe "Chef::Resource.property validation" do
|
|
137
137
|
it "set to invalid value raises ValidationFailed" do
|
138
138
|
expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed
|
139
139
|
end
|
140
|
-
it "set to nil emits
|
141
|
-
expect
|
142
|
-
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
143
|
-
resource.x 'str'
|
144
|
-
expect(resource.x nil).to eq 'str'
|
145
|
-
expect(resource.x).to eq 'str'
|
140
|
+
it "set to nil emits no warning because the value would not change" do
|
141
|
+
expect(resource.x nil).to be_nil
|
146
142
|
end
|
147
143
|
end
|
148
144
|
end
|
@@ -534,12 +530,18 @@ describe "Chef::Resource.property validation" do
|
|
534
530
|
expect(resource.x 1).to eq 1
|
535
531
|
expect(resource.x).to eq 1
|
536
532
|
end
|
537
|
-
it "value nil emits a
|
538
|
-
expect { resource.x nil }.to raise_error Chef::Exceptions::
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
533
|
+
it "value nil emits a validation failed error because it must have a value" do
|
534
|
+
expect { resource.x nil }.to raise_error Chef::Exceptions::ValidationFailed
|
535
|
+
end
|
536
|
+
context "and value is set to something other than nil" do
|
537
|
+
before { resource.x 10 }
|
538
|
+
it "value nil emits a deprecation warning and does a get" do
|
539
|
+
expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError
|
540
|
+
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
541
|
+
resource.x 1
|
542
|
+
expect(resource.x nil).to eq 1
|
543
|
+
expect(resource.x).to eq 1
|
544
|
+
end
|
543
545
|
end
|
544
546
|
end
|
545
547
|
|