chef 12.4.0.rc.0-universal-mingw32 → 12.4.0.rc.2-universal-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 +4 -4
- data/Rakefile +12 -1
- data/lib/chef/api_client.rb +130 -26
- data/lib/chef/application.rb +0 -1
- data/lib/chef/application/client.rb +8 -19
- data/lib/chef/audit/audit_reporter.rb +12 -7
- data/lib/chef/audit/logger.rb +36 -0
- data/lib/chef/audit/runner.rb +4 -2
- data/lib/chef/chef_class.rb +62 -11
- data/lib/chef/client.rb +587 -207
- data/lib/chef/config.rb +0 -1
- data/lib/chef/dsl/recipe.rb +45 -56
- data/lib/chef/dsl/resources.rb +3 -2
- data/lib/chef/event_dispatch/base.rb +7 -2
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_content_management/deploy/mv_windows.rb +16 -6
- data/lib/chef/formatters/doc.rb +15 -7
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +10 -7
- data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -0
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +4 -1
- data/lib/chef/http/authenticator.rb +7 -2
- data/lib/chef/knife.rb +16 -4
- data/lib/chef/knife/client_create.rb +55 -31
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/osc_user_create.rb +97 -0
- data/lib/chef/knife/osc_user_delete.rb +51 -0
- data/lib/chef/knife/osc_user_edit.rb +58 -0
- data/lib/chef/knife/osc_user_list.rb +47 -0
- data/lib/chef/knife/osc_user_reregister.rb +64 -0
- data/lib/chef/knife/osc_user_show.rb +54 -0
- data/lib/chef/knife/user_create.rb +95 -36
- data/lib/chef/knife/user_delete.rb +52 -2
- data/lib/chef/knife/user_edit.rb +37 -7
- data/lib/chef/knife/user_list.rb +3 -0
- data/lib/chef/knife/user_reregister.rb +39 -8
- data/lib/chef/knife/user_show.rb +30 -1
- data/lib/chef/mixin/api_version_request_handling.rb +66 -0
- data/lib/chef/mixin/convert_to_class_name.rb +10 -4
- data/lib/chef/mixin/deprecation.rb +24 -0
- data/lib/chef/mixin/powershell_out.rb +98 -0
- data/lib/chef/mixin/provides.rb +5 -18
- data/lib/chef/mixin/uris.rb +11 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +5 -2
- data/lib/chef/mixin/windows_env_helper.rb +11 -2
- data/lib/chef/node_map.rb +130 -75
- data/lib/chef/osc_user.rb +194 -0
- data/lib/chef/platform/provider_mapping.rb +2 -269
- data/lib/chef/platform/provider_priority_map.rb +6 -69
- data/lib/chef/platform/query_helpers.rb +5 -0
- data/lib/chef/platform/resource_priority_map.rb +12 -15
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/provider.rb +19 -0
- data/lib/chef/provider/directory.rb +3 -0
- data/lib/chef/provider/dsc_resource.rb +8 -1
- data/lib/chef/provider/file.rb +1 -0
- data/lib/chef/provider/group/aix.rb +1 -0
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/group/gpasswd.rb +1 -0
- data/lib/chef/provider/group/groupmod.rb +1 -1
- data/lib/chef/provider/group/pw.rb +1 -0
- data/lib/chef/provider/group/suse.rb +2 -0
- data/lib/chef/provider/group/usermod.rb +2 -1
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -0
- data/lib/chef/provider/ifconfig/aix.rb +1 -0
- data/lib/chef/provider/ifconfig/debian.rb +2 -0
- data/lib/chef/provider/ifconfig/redhat.rb +1 -0
- data/lib/chef/provider/lwrp_base.rb +4 -0
- data/lib/chef/provider/mount.rb +0 -1
- data/lib/chef/provider/mount/aix.rb +1 -0
- data/lib/chef/provider/mount/mount.rb +2 -0
- data/lib/chef/provider/mount/solaris.rb +2 -0
- data/lib/chef/provider/package.rb +55 -0
- data/lib/chef/provider/package/aix.rb +7 -7
- data/lib/chef/provider/package/apt.rb +3 -3
- data/lib/chef/provider/package/dpkg.rb +4 -4
- data/lib/chef/provider/package/easy_install.rb +5 -5
- data/lib/chef/provider/package/freebsd/base.rb +2 -2
- data/lib/chef/provider/package/freebsd/pkg.rb +6 -6
- data/lib/chef/provider/package/freebsd/pkgng.rb +5 -5
- data/lib/chef/provider/package/freebsd/port.rb +4 -4
- data/lib/chef/provider/package/homebrew.rb +2 -2
- data/lib/chef/provider/package/ips.rb +4 -4
- data/lib/chef/provider/package/macports.rb +5 -6
- data/lib/chef/provider/package/openbsd.rb +4 -5
- data/lib/chef/provider/package/pacman.rb +4 -4
- data/lib/chef/provider/package/portage.rb +2 -0
- data/lib/chef/provider/package/rpm.rb +7 -8
- data/lib/chef/provider/package/rubygems.rb +5 -12
- data/lib/chef/provider/package/smartos.rb +4 -4
- data/lib/chef/provider/package/solaris.rb +7 -7
- data/lib/chef/provider/package/windows/msi.rb +1 -1
- data/lib/chef/provider/package/yum.rb +4 -6
- data/lib/chef/provider/package/zypper.rb +16 -14
- data/lib/chef/provider/powershell_script.rb +129 -47
- data/lib/chef/provider/remote_file/content.rb +4 -1
- data/lib/chef/provider/remote_file/local_file.rb +10 -4
- data/lib/chef/provider/service.rb +44 -0
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/init.rb +1 -0
- data/lib/chef/provider/service/macosx.rb +1 -1
- data/lib/chef/provider/service/windows.rb +0 -1
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/aix.rb +3 -2
- data/lib/chef/provider/user/pw.rb +1 -0
- data/lib/chef/provider/user/solaris.rb +2 -0
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/provider_resolver.rb +87 -134
- data/lib/chef/resource.rb +274 -68
- data/lib/chef/resource/apt_package.rb +0 -2
- data/lib/chef/resource/bash.rb +0 -2
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +0 -7
- data/lib/chef/resource/breakpoint.rb +3 -6
- data/lib/chef/resource/chef_gem.rb +0 -3
- data/lib/chef/resource/cookbook_file.rb +1 -3
- data/lib/chef/resource/cron.rb +2 -4
- data/lib/chef/resource/csh.rb +0 -2
- data/lib/chef/resource/deploy.rb +9 -6
- data/lib/chef/resource/deploy_revision.rb +0 -14
- data/lib/chef/resource/directory.rb +2 -4
- data/lib/chef/resource/dpkg_package.rb +0 -5
- data/lib/chef/resource/dsc_resource.rb +2 -3
- data/lib/chef/resource/dsc_script.rb +2 -3
- data/lib/chef/resource/easy_install_package.rb +0 -7
- data/lib/chef/resource/env.rb +3 -3
- data/lib/chef/resource/erl_call.rb +2 -5
- data/lib/chef/resource/execute.rb +2 -4
- data/lib/chef/resource/file.rb +2 -4
- data/lib/chef/resource/freebsd_package.rb +0 -5
- data/lib/chef/resource/gem_package.rb +0 -3
- data/lib/chef/resource/git.rb +0 -3
- data/lib/chef/resource/group.rb +2 -4
- data/lib/chef/resource/homebrew_package.rb +0 -2
- data/lib/chef/resource/http_request.rb +3 -4
- data/lib/chef/resource/ifconfig.rb +3 -4
- data/lib/chef/resource/ips_package.rb +2 -2
- data/lib/chef/resource/link.rb +3 -5
- data/lib/chef/resource/log.rb +2 -4
- data/lib/chef/resource/lwrp_base.rb +10 -61
- data/lib/chef/resource/macosx_service.rb +1 -2
- data/lib/chef/resource/macports_package.rb +0 -7
- data/lib/chef/resource/mdadm.rb +2 -5
- data/lib/chef/resource/mount.rb +2 -4
- data/lib/chef/resource/ohai.rb +2 -4
- data/lib/chef/resource/openbsd_package.rb +0 -6
- data/lib/chef/resource/package.rb +9 -6
- data/lib/chef/resource/pacman_package.rb +0 -7
- data/lib/chef/resource/paludis_package.rb +2 -3
- data/lib/chef/resource/perl.rb +0 -3
- data/lib/chef/resource/portage_package.rb +0 -3
- data/lib/chef/resource/powershell_script.rb +1 -2
- data/lib/chef/resource/python.rb +0 -3
- data/lib/chef/resource/reboot.rb +1 -3
- data/lib/chef/resource/registry_key.rb +3 -5
- data/lib/chef/resource/remote_directory.rb +3 -5
- data/lib/chef/resource/remote_file.rb +4 -5
- data/lib/chef/resource/route.rb +3 -5
- data/lib/chef/resource/rpm_package.rb +0 -2
- data/lib/chef/resource/ruby.rb +0 -4
- data/lib/chef/resource/ruby_block.rb +2 -4
- data/lib/chef/resource/scm.rb +3 -5
- data/lib/chef/resource/script.rb +0 -3
- data/lib/chef/resource/service.rb +3 -5
- data/lib/chef/resource/smartos_package.rb +0 -9
- data/lib/chef/resource/solaris_package.rb +0 -10
- data/lib/chef/resource/subversion.rb +1 -3
- data/lib/chef/resource/template.rb +0 -4
- data/lib/chef/resource/timestamped_deploy.rb +0 -4
- data/lib/chef/resource/user.rb +2 -5
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -7
- data/lib/chef/resource/windows_package.rb +3 -3
- data/lib/chef/resource/windows_script.rb +2 -2
- data/lib/chef/resource/windows_service.rb +3 -3
- data/lib/chef/resource/yum_package.rb +0 -3
- data/lib/chef/resource/zypper_package.rb +27 -0
- data/lib/chef/resource_builder.rb +7 -0
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resource_resolver.rb +108 -62
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/rest.rb +1 -0
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/user.rb +193 -42
- data/lib/chef/util/backup.rb +9 -1
- data/lib/chef/util/path_helper.rb +0 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +22 -42
- data/spec/functional/mixin/powershell_out_spec.rb +43 -0
- data/spec/functional/resource/execute_spec.rb +9 -2
- data/spec/functional/resource/file_spec.rb +25 -0
- data/spec/functional/resource/group_spec.rb +5 -0
- data/spec/functional/resource/link_spec.rb +5 -11
- data/spec/functional/resource/powershell_spec.rb +40 -5
- data/spec/functional/resource/user/useradd_spec.rb +10 -18
- data/spec/integration/recipes/lwrp_spec.rb +57 -0
- data/spec/integration/recipes/provider_choice.rb +2 -7
- data/spec/integration/recipes/recipe_dsl_spec.rb +517 -19
- data/spec/spec_helper.rb +1 -1
- data/spec/support/lib/chef/provider/openldap_includer.rb +29 -0
- data/spec/support/lib/chef/resource/cat.rb +0 -2
- data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -6
- data/spec/support/lib/chef/resource/openldap_includer.rb +27 -0
- data/spec/support/lib/chef/resource/with_state.rb +0 -9
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -6
- data/spec/support/lib/chef/resource/zen_master.rb +1 -6
- data/spec/support/shared/context/client.rb +277 -0
- data/spec/support/shared/examples/client.rb +53 -0
- data/spec/support/shared/functional/file_resource.rb +0 -4
- data/spec/support/shared/functional/securable_resource.rb +0 -24
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +4 -4
- data/spec/support/shared/functional/windows_script.rb +1 -1
- data/spec/support/shared/unit/api_versioning.rb +77 -0
- data/spec/support/shared/unit/knife_shared.rb +40 -0
- data/spec/support/shared/unit/user_and_client_shared.rb +115 -0
- data/spec/unit/api_client_spec.rb +189 -14
- data/spec/unit/application/client_spec.rb +0 -5
- data/spec/unit/audit/audit_reporter_spec.rb +58 -14
- data/spec/unit/audit/logger_spec.rb +42 -0
- data/spec/unit/audit/runner_spec.rb +2 -2
- data/spec/unit/chef_fs/file_pattern_spec.rb +3 -15
- data/spec/unit/client_spec.rb +58 -374
- data/spec/unit/cookbook_spec.rb +0 -9
- data/spec/unit/cookbook_version_spec.rb +0 -20
- data/spec/unit/deprecation_spec.rb +55 -0
- data/spec/unit/dsl/resources_spec.rb +85 -0
- data/spec/unit/exceptions_spec.rb +2 -2
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +60 -0
- data/spec/unit/formatters/doc_spec.rb +46 -0
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +12 -10
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +8 -0
- data/spec/unit/http/authenticator_spec.rb +11 -2
- data/spec/unit/knife/client_create_spec.rb +122 -51
- data/spec/unit/knife/core/subcommand_loader_spec.rb +19 -3
- data/spec/unit/knife/core/ui_spec.rb +14 -0
- data/spec/unit/knife/osc_user_create_spec.rb +93 -0
- data/spec/unit/knife/osc_user_delete_spec.rb +44 -0
- data/spec/unit/knife/osc_user_edit_spec.rb +52 -0
- data/spec/unit/knife/osc_user_list_spec.rb +37 -0
- data/spec/unit/knife/osc_user_reregister_spec.rb +58 -0
- data/spec/unit/knife/osc_user_show_spec.rb +46 -0
- data/spec/unit/knife/user_create_spec.rb +177 -51
- data/spec/unit/knife/user_delete_spec.rb +34 -8
- data/spec/unit/knife/user_edit_spec.rb +31 -12
- data/spec/unit/knife/user_list_spec.rb +7 -3
- data/spec/unit/knife/user_reregister_spec.rb +38 -17
- data/spec/unit/knife/user_show_spec.rb +35 -11
- data/spec/unit/knife_spec.rb +10 -4
- data/spec/unit/lwrp_spec.rb +228 -54
- data/spec/unit/mixin/api_version_request_handling_spec.rb +127 -0
- data/spec/unit/mixin/command_spec.rb +1 -2
- data/spec/unit/mixin/powershell_out_spec.rb +70 -0
- data/spec/unit/mixin/uris_spec.rb +23 -11
- data/spec/unit/node_map_spec.rb +4 -1
- data/spec/unit/osc_user_spec.rb +276 -0
- data/spec/unit/platform_spec.rb +0 -60
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +199 -135
- data/spec/unit/provider/ifconfig/debian_spec.rb +0 -10
- data/spec/unit/provider/package/aix_spec.rb +16 -16
- data/spec/unit/provider/package/dpkg_spec.rb +2 -2
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +13 -13
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +7 -7
- data/spec/unit/provider/package/ips_spec.rb +22 -22
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +4 -26
- data/spec/unit/provider/package/pacman_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +14 -14
- data/spec/unit/provider/package/rubygems_spec.rb +10 -44
- data/spec/unit/provider/package/smartos_spec.rb +4 -4
- data/spec/unit/provider/package/solaris_spec.rb +11 -11
- data/spec/unit/provider/package/zypper_spec.rb +125 -90
- data/spec/unit/provider/package_spec.rb +34 -0
- data/spec/unit/provider/powershell_spec.rb +53 -11
- data/spec/unit/provider/remote_directory_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +25 -6
- data/spec/unit/provider/service/freebsd_service_spec.rb +0 -12
- data/spec/unit/provider/user_spec.rb +3 -3
- data/spec/unit/provider_resolver_spec.rb +463 -327
- data/spec/unit/recipe_spec.rb +42 -15
- data/spec/unit/resource/breakpoint_spec.rb +1 -1
- data/spec/unit/resource/erl_call_spec.rb +1 -1
- data/spec/unit/resource/file_spec.rb +1 -1
- data/spec/unit/resource/ifconfig_spec.rb +10 -6
- data/spec/unit/resource/remote_file_spec.rb +5 -0
- data/spec/unit/resource/route_spec.rb +1 -1
- data/spec/unit/resource/ruby_block_spec.rb +2 -2
- data/spec/unit/resource/template_spec.rb +1 -1
- data/spec/unit/resource/timestamped_deploy_spec.rb +1 -2
- data/spec/unit/resource/windows_service_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +99 -13
- data/spec/unit/rest_spec.rb +5 -5
- data/spec/unit/run_context_spec.rb +41 -0
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/user_spec.rb +406 -93
- data/tasks/maintainers.rb +69 -0
- metadata +37 -4
data/spec/unit/cookbook_spec.rb
CHANGED
@@ -59,15 +59,6 @@ describe Chef::CookbookVersion do
|
|
59
59
|
expect(@cookbook.fully_qualified_recipe_names.include?("openldap::three")).to eq(true)
|
60
60
|
end
|
61
61
|
|
62
|
-
it "should find a preferred file" do
|
63
|
-
skip
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should not return an unchanged preferred file" do
|
67
|
-
pending
|
68
|
-
expect(@cookbook.preferred_filename(@node, :files, 'a-filename', 'the-checksum')).to be_nil
|
69
|
-
end
|
70
|
-
|
71
62
|
it "should raise an ArgumentException if you try to load a bad recipe name" do
|
72
63
|
expect { @cookbook.load_recipe("doesnt_exist", @node) }.to raise_error(ArgumentError)
|
73
64
|
end
|
@@ -306,26 +306,6 @@ describe Chef::CookbookVersion do
|
|
306
306
|
|
307
307
|
subject(:cbv) { Chef::CookbookVersion.new("version validation", '/tmp/blah') }
|
308
308
|
|
309
|
-
describe "HTTP Resource behaviors", pending: "will be deprected when CookbookManifest API is stablized" do
|
310
|
-
|
311
|
-
it "errors on #save_url" do
|
312
|
-
expect { cbv.save_url }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
313
|
-
end
|
314
|
-
|
315
|
-
it "errors on #force_save_url" do
|
316
|
-
expect { cbv.force_save_url }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
317
|
-
end
|
318
|
-
|
319
|
-
it "errors on #to_hash" do
|
320
|
-
expect { cbv.to_hash }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
321
|
-
end
|
322
|
-
|
323
|
-
it "errors on #to_json" do
|
324
|
-
expect { cbv.to_json }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
325
|
-
end
|
326
|
-
|
327
|
-
end
|
328
|
-
|
329
309
|
it "errors on #status and #status=" do
|
330
310
|
expect { cbv.status = :wat }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
331
311
|
expect { cbv.status }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
@@ -95,4 +95,59 @@ describe Chef::Deprecation do
|
|
95
95
|
expect { test_instance.deprecated_method(10) }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
96
96
|
end
|
97
97
|
|
98
|
+
context "When a class has deprecated_attr, _reader and _writer" do
|
99
|
+
before(:context) do
|
100
|
+
class DeprecatedAttrTest
|
101
|
+
extend Chef::Mixin::Deprecation
|
102
|
+
def initialize
|
103
|
+
@a = @r = @w = 1
|
104
|
+
end
|
105
|
+
deprecated_attr :a, "a"
|
106
|
+
deprecated_attr_reader :r, "r"
|
107
|
+
deprecated_attr_writer :w, "w"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
it "The deprecated_attr emits warnings" do
|
112
|
+
test = DeprecatedAttrTest.new
|
113
|
+
expect { test.a = 10 }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
114
|
+
expect { test.a }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "The deprecated_attr_writer emits warnings, and does not create a reader" do
|
118
|
+
test = DeprecatedAttrTest.new
|
119
|
+
expect { test.w = 10 }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
120
|
+
expect { test.w }.to raise_error(NoMethodError)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "The deprecated_attr_reader emits warnings, and does not create a writer" do
|
124
|
+
test = DeprecatedAttrTest.new
|
125
|
+
expect { test.r = 10 }.to raise_error(NoMethodError)
|
126
|
+
expect { test.r }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
|
127
|
+
end
|
128
|
+
|
129
|
+
context "With deprecation warnings not throwing exceptions" do
|
130
|
+
before do
|
131
|
+
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
132
|
+
end
|
133
|
+
|
134
|
+
it "The deprecated_attr can be written to and read from" do
|
135
|
+
test = DeprecatedAttrTest.new
|
136
|
+
test.a = 10
|
137
|
+
expect(test.a).to eq 10
|
138
|
+
end
|
139
|
+
|
140
|
+
it "The deprecated_attr_reader can be read from" do
|
141
|
+
test = DeprecatedAttrTest.new
|
142
|
+
expect(test.r).to eq 1
|
143
|
+
end
|
144
|
+
|
145
|
+
it "The deprecated_attr_writer can be written to" do
|
146
|
+
test = DeprecatedAttrTest.new
|
147
|
+
test.w = 10
|
148
|
+
expect(test.instance_eval { @w }).to eq 10
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
98
153
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Noah Kantrowitz (<noah@coderanger.net>)
|
3
|
+
# Copyright:: Copyright (c) 2015 Noah Kantrowitz
|
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/dsl/resources'
|
21
|
+
|
22
|
+
describe Chef::DSL::Resources do
|
23
|
+
let(:declared_resources) { [] }
|
24
|
+
let(:test_class) do
|
25
|
+
r = declared_resources
|
26
|
+
Class.new do
|
27
|
+
include Chef::DSL::Resources
|
28
|
+
define_method(:declare_resource) do |dsl_name, name, _created_at, &_block|
|
29
|
+
r << [dsl_name, name]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
subject { declared_resources }
|
34
|
+
after do
|
35
|
+
# Always clean up after ourselves.
|
36
|
+
described_class.remove_resource_dsl(:test_resource)
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with a resource added' do
|
40
|
+
before do
|
41
|
+
Chef::DSL::Resources.add_resource_dsl(:test_resource)
|
42
|
+
test_class.new.instance_eval do
|
43
|
+
test_resource 'test_name' do
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
it { is_expected.to eq [[:test_resource, 'test_name']]}
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with no resource added' do
|
51
|
+
subject do
|
52
|
+
test_class.new.instance_eval do
|
53
|
+
test_resource 'test_name' do
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it { expect { subject }.to raise_error NoMethodError }
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with a resource added and removed' do
|
62
|
+
before do
|
63
|
+
Chef::DSL::Resources.add_resource_dsl(:test_resource)
|
64
|
+
Chef::DSL::Resources.remove_resource_dsl(:test_resource)
|
65
|
+
end
|
66
|
+
subject do
|
67
|
+
test_class.new.instance_eval do
|
68
|
+
test_resource 'test_name' do
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it { expect { subject }.to raise_error NoMethodError }
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'with a nameless resource' do
|
77
|
+
before do
|
78
|
+
Chef::DSL::Resources.add_resource_dsl(:test_resource)
|
79
|
+
test_class.new.instance_eval do
|
80
|
+
test_resource { }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
it { is_expected.to eq [[:test_resource, nil]]}
|
84
|
+
end
|
85
|
+
end
|
@@ -113,7 +113,7 @@ describe Chef::Exceptions do
|
|
113
113
|
context "initialized with 1 error and nil" do
|
114
114
|
let(:e) { Chef::Exceptions::RunFailedWrappingError.new(RuntimeError.new("foo"), nil) }
|
115
115
|
let(:num_errors) { 1 }
|
116
|
-
let(:backtrace) { ["1) RuntimeError - foo"
|
116
|
+
let(:backtrace) { ["1) RuntimeError - foo"] }
|
117
117
|
|
118
118
|
include_examples "RunFailedWrappingError expectations"
|
119
119
|
end
|
@@ -121,7 +121,7 @@ describe Chef::Exceptions do
|
|
121
121
|
context "initialized with 2 errors" do
|
122
122
|
let(:e) { Chef::Exceptions::RunFailedWrappingError.new(RuntimeError.new("foo"), RuntimeError.new("bar")) }
|
123
123
|
let(:num_errors) { 2 }
|
124
|
-
let(:backtrace) { ["1) RuntimeError - foo", "", "2) RuntimeError - bar"
|
124
|
+
let(:backtrace) { ["1) RuntimeError - foo", "", "2) RuntimeError - bar"] }
|
125
125
|
|
126
126
|
include_examples "RunFailedWrappingError expectations"
|
127
127
|
end
|
@@ -115,6 +115,66 @@ describe Chef::FileContentManagement::Deploy::MvWindows do
|
|
115
115
|
|
116
116
|
end
|
117
117
|
|
118
|
+
context "and the target file has null dacl and sacl" do
|
119
|
+
|
120
|
+
before do
|
121
|
+
allow(target_file_security_descriptor).to receive(:dacl_present?).and_return(true)
|
122
|
+
allow(target_file_security_descriptor).to receive(:dacl).and_return(nil)
|
123
|
+
allow(target_file_security_descriptor).to receive(:dacl_inherits?).and_return(false)
|
124
|
+
|
125
|
+
allow(target_file_security_descriptor).to receive(:sacl_present?).and_return(true)
|
126
|
+
allow(target_file_security_descriptor).to receive(:sacl).and_return(nil)
|
127
|
+
allow(target_file_security_descriptor).to receive(:sacl_inherits?).and_return(false)
|
128
|
+
|
129
|
+
expect(updated_target_security_object).to receive(:set_dacl).with(nil, false)
|
130
|
+
expect(updated_target_security_object).to receive(:set_sacl).with(nil, false)
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
it "fixes up permissions and moves the file into place" do
|
135
|
+
content_deployer.deploy(staging_file_path, target_file_path)
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
context "and the target has an empty dacl and sacl" do
|
141
|
+
let(:original_target_file_dacl) { [] }
|
142
|
+
let(:original_target_file_sacl) { [] }
|
143
|
+
|
144
|
+
let(:empty_dacl) { double("Windows ACL with no dacl ACEs") }
|
145
|
+
let(:empty_sacl) { double("Windows ACL with no sacl ACEs") }
|
146
|
+
|
147
|
+
before do
|
148
|
+
allow(target_file_security_descriptor).to receive(:dacl_present?).and_return(true)
|
149
|
+
allow(target_file_security_descriptor).to receive(:dacl_inherits?).and_return(false)
|
150
|
+
|
151
|
+
allow(target_file_security_descriptor).to receive(:dacl).and_return(original_target_file_dacl)
|
152
|
+
expect(Chef::ReservedNames::Win32::Security::ACL).
|
153
|
+
to receive(:create).
|
154
|
+
with([]).
|
155
|
+
and_return(empty_dacl)
|
156
|
+
|
157
|
+
|
158
|
+
allow(target_file_security_descriptor).to receive(:sacl_present?).and_return(true)
|
159
|
+
allow(target_file_security_descriptor).to receive(:sacl_inherits?).and_return(false)
|
160
|
+
|
161
|
+
allow(target_file_security_descriptor).to receive(:sacl).and_return(original_target_file_sacl)
|
162
|
+
expect(Chef::ReservedNames::Win32::Security::ACL).
|
163
|
+
to receive(:create).
|
164
|
+
with([]).
|
165
|
+
and_return(empty_sacl)
|
166
|
+
|
167
|
+
|
168
|
+
expect(updated_target_security_object).to receive(:set_dacl).with(empty_dacl, false)
|
169
|
+
expect(updated_target_security_object).to receive(:set_sacl).with(empty_sacl, false)
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
it "fixes up permissions and moves the file into place" do
|
174
|
+
content_deployer.deploy(staging_file_path, target_file_path)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
118
178
|
context "and the target has a dacl and sacl" do
|
119
179
|
let(:inherited_dacl_ace) { double("Windows dacl ace (inherited)", :inherited? => true) }
|
120
180
|
let(:not_inherited_dacl_ace) { double("Windows dacl ace (not inherited)", :inherited? => false) }
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@chef.io>)
|
3
|
+
#
|
4
|
+
# Copyright:: Copyright (c) 2015 Chef Software, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'spec_helper'
|
21
|
+
|
22
|
+
describe Chef::Formatters::Base do
|
23
|
+
|
24
|
+
let(:out) { StringIO.new }
|
25
|
+
let(:err) { StringIO.new }
|
26
|
+
|
27
|
+
subject(:formatter) { Chef::Formatters::Doc.new(out, err) }
|
28
|
+
|
29
|
+
it "prints a policyfile's name and revision ID" do
|
30
|
+
minimal_policyfile = {
|
31
|
+
"revision_id"=> "613f803bdd035d574df7fa6da525b38df45a74ca82b38b79655efed8a189e073",
|
32
|
+
"name"=> "jenkins",
|
33
|
+
"run_list"=> [
|
34
|
+
"recipe[apt::default]",
|
35
|
+
"recipe[java::default]",
|
36
|
+
"recipe[jenkins::master]",
|
37
|
+
"recipe[policyfile_demo::default]"
|
38
|
+
],
|
39
|
+
"cookbook_locks"=> { }
|
40
|
+
}
|
41
|
+
|
42
|
+
formatter.policyfile_loaded(minimal_policyfile)
|
43
|
+
expect(out.string).to include("Using policy 'jenkins' at revision '613f803bdd035d574df7fa6da525b38df45a74ca82b38b79655efed8a189e073'")
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -29,19 +29,21 @@ describe Chef::Formatters::APIErrorFormatting do
|
|
29
29
|
|
30
30
|
|
31
31
|
context "when describe_406_error is called" do
|
32
|
-
context "when response
|
32
|
+
context "when response['x-ops-server-api-version'] exists" do
|
33
33
|
let(:min_version) { "2" }
|
34
34
|
let(:max_version) { "5" }
|
35
|
+
let(:request_version) { "30" }
|
35
36
|
let(:return_hash) {
|
36
37
|
{
|
37
|
-
"error" => "invalid-x-ops-server-api-version",
|
38
38
|
"min_version" => min_version,
|
39
|
-
"max_version" => max_version
|
39
|
+
"max_version" => max_version,
|
40
|
+
"request_version" => request_version
|
40
41
|
}
|
41
42
|
}
|
42
43
|
|
43
44
|
before do
|
44
|
-
|
45
|
+
# mock out the header
|
46
|
+
allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(Chef::JSONCompat.to_json(return_hash))
|
45
47
|
end
|
46
48
|
|
47
49
|
it "prints an error about client and server API version incompatibility with a min API version" do
|
@@ -53,17 +55,17 @@ describe Chef::Formatters::APIErrorFormatting do
|
|
53
55
|
expect(error_description).to receive(:section).with("Incompatible server API version:",/a max API version of #{max_version}/)
|
54
56
|
class_instance.describe_406_error(error_description, response)
|
55
57
|
end
|
58
|
+
|
59
|
+
it "prints an error describing the request API version" do
|
60
|
+
expect(error_description).to receive(:section).with("Incompatible server API version:",/a request with an API version of #{request_version}/)
|
61
|
+
class_instance.describe_406_error(error_description, response)
|
62
|
+
end
|
56
63
|
end
|
57
64
|
|
58
65
|
context "when response.body['error'] != 'invalid-x-ops-server-api-version'" do
|
59
|
-
let(:return_hash) {
|
60
|
-
{
|
61
|
-
"error" => "some-other-error"
|
62
|
-
}
|
63
|
-
}
|
64
66
|
|
65
67
|
before do
|
66
|
-
allow(
|
68
|
+
allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(nil)
|
67
69
|
end
|
68
70
|
|
69
71
|
it "forwards the error_description to describe_http_error" do
|
@@ -84,6 +84,14 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do
|
|
84
84
|
expect(guard_interpreter.evaluate).to eq(true)
|
85
85
|
end
|
86
86
|
|
87
|
+
it "does not corrupt the run_context of the node" do
|
88
|
+
node_run_context_before_guard_execution = parent_resource.run_context
|
89
|
+
expect(node_run_context_before_guard_execution.object_id).to eq(parent_resource.node.run_context.object_id)
|
90
|
+
guard_interpreter.evaluate
|
91
|
+
node_run_context_after_guard_execution = parent_resource.run_context
|
92
|
+
expect(node_run_context_after_guard_execution.object_id).to eq(parent_resource.node.run_context.object_id)
|
93
|
+
end
|
94
|
+
|
87
95
|
describe "script command opts switch" do
|
88
96
|
let(:command_opts) { {} }
|
89
97
|
let(:guard_interpreter) { Chef::GuardInterpreter::ResourceGuardInterpreter.new(parent_resource, "exit 0", command_opts) }
|
@@ -32,10 +32,19 @@ describe Chef::HTTP::Authenticator do
|
|
32
32
|
|
33
33
|
context "when handle_request is called" do
|
34
34
|
shared_examples_for "merging the server API version into the headers" do
|
35
|
-
it "merges X-Ops-Server-API-Version into the headers" do
|
35
|
+
it "merges the default version of X-Ops-Server-API-Version into the headers" do
|
36
36
|
# headers returned
|
37
37
|
expect(class_instance.handle_request(method, url, headers, data)[2]).
|
38
|
-
to include({'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::
|
38
|
+
to include({'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION})
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when api_version is set to something other than the default" do
|
42
|
+
let(:class_instance) { Chef::HTTP::Authenticator.new({:api_version => '-10'}) }
|
43
|
+
|
44
|
+
it "merges the requested version of X-Ops-Server-API-Version into the headers" do
|
45
|
+
expect(class_instance.handle_request(method, url, headers, data)[2]).
|
46
|
+
to include({'X-Ops-Server-API-Version' => '-10'})
|
47
|
+
end
|
39
48
|
end
|
40
49
|
end
|
41
50
|
|
@@ -22,6 +22,8 @@ Chef::Knife::ClientCreate.load_deps
|
|
22
22
|
|
23
23
|
describe Chef::Knife::ClientCreate do
|
24
24
|
let(:stderr) { StringIO.new }
|
25
|
+
let(:stdout) { StringIO.new }
|
26
|
+
|
25
27
|
|
26
28
|
let(:default_client_hash) do
|
27
29
|
{
|
@@ -32,84 +34,153 @@ describe Chef::Knife::ClientCreate do
|
|
32
34
|
end
|
33
35
|
|
34
36
|
let(:client) do
|
35
|
-
|
36
|
-
allow(c).to receive(:save).and_return({"private_key" => ""})
|
37
|
-
allow(c).to receive(:to_s).and_return("client[adam]")
|
38
|
-
c
|
37
|
+
Chef::ApiClient.new
|
39
38
|
end
|
40
39
|
|
41
40
|
let(:knife) do
|
42
41
|
k = Chef::Knife::ClientCreate.new
|
43
|
-
k.name_args = [
|
44
|
-
k.
|
42
|
+
k.name_args = []
|
43
|
+
allow(k).to receive(:client).and_return(client)
|
44
|
+
allow(k).to receive(:edit_data).with(client).and_return(client)
|
45
45
|
allow(k.ui).to receive(:stderr).and_return(stderr)
|
46
|
-
allow(k.ui).to receive(:stdout).and_return(
|
46
|
+
allow(k.ui).to receive(:stdout).and_return(stdout)
|
47
47
|
k
|
48
48
|
end
|
49
49
|
|
50
|
+
before do
|
51
|
+
allow(client).to receive(:to_s).and_return("client[adam]")
|
52
|
+
allow(knife).to receive(:create_client).and_return(client)
|
53
|
+
end
|
54
|
+
|
50
55
|
before(:each) do
|
51
56
|
Chef::Config[:node_name] = "webmonkey.example.com"
|
52
57
|
end
|
53
58
|
|
54
59
|
describe "run" do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
context "when nothing is passed" do
|
61
|
+
# from spec/support/shared/unit/knife_shared.rb
|
62
|
+
it_should_behave_like "mandatory field missing" do
|
63
|
+
let(:name_args) { [] }
|
64
|
+
let(:fieldname) { 'client name' }
|
65
|
+
end
|
59
66
|
end
|
60
67
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
expect(stderr.string).to match /Created client.*adam/i
|
66
|
-
end
|
68
|
+
context "when clientname is passed" do
|
69
|
+
before do
|
70
|
+
knife.name_args = ['adam']
|
71
|
+
end
|
67
72
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
73
|
+
context "when public_key and prevent_keygen are passed" do
|
74
|
+
before do
|
75
|
+
knife.config[:public_key] = "some_key"
|
76
|
+
knife.config[:prevent_keygen] = true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "prints the usage" do
|
80
|
+
expect(knife).to receive(:show_usage)
|
81
|
+
expect { knife.run }.to raise_error(SystemExit)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "prints a relevant error message" do
|
85
|
+
expect { knife.run }.to raise_error(SystemExit)
|
86
|
+
expect(stderr.string).to match /You cannot pass --public-key and --prevent-keygen/
|
87
|
+
end
|
88
|
+
end
|
72
89
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
90
|
+
it "should create the ApiClient" do
|
91
|
+
expect(knife).to receive(:create_client)
|
92
|
+
knife.run
|
93
|
+
end
|
77
94
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
95
|
+
it "should print a message upon creation" do
|
96
|
+
expect(knife).to receive(:create_client)
|
97
|
+
knife.run
|
98
|
+
expect(stderr.string).to match /Created client.*adam/i
|
99
|
+
end
|
82
100
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
101
|
+
it "should set the Client name" do
|
102
|
+
knife.run
|
103
|
+
expect(client.name).to eq("adam")
|
104
|
+
end
|
88
105
|
|
89
|
-
|
90
|
-
it "should write the private key to a file" do
|
91
|
-
knife.config[:file] = "/tmp/monkeypants"
|
92
|
-
allow_any_instance_of(Chef::ApiClient).to receive(:save).and_return({ 'private_key' => "woot" })
|
93
|
-
filehandle = double("Filehandle")
|
94
|
-
expect(filehandle).to receive(:print).with('woot')
|
95
|
-
expect(File).to receive(:open).with("/tmp/monkeypants", "w").and_yield(filehandle)
|
106
|
+
it "by default it is not an admin" do
|
96
107
|
knife.run
|
108
|
+
expect(client.admin).to be_falsey
|
97
109
|
end
|
98
|
-
end
|
99
110
|
|
100
|
-
|
101
|
-
it "should create an admin client" do
|
102
|
-
knife.config[:admin] = true
|
103
|
-
expect(Chef::ApiClient).to receive(:from_hash).with(hash_including("admin" => true)).and_return(client)
|
111
|
+
it "by default it is not a validator" do
|
104
112
|
knife.run
|
113
|
+
expect(client.admin).to be_falsey
|
105
114
|
end
|
106
|
-
end
|
107
115
|
|
108
|
-
|
109
|
-
it "should create an validator client" do
|
110
|
-
knife.config[:validator] = true
|
111
|
-
expect(Chef::ApiClient).to receive(:from_hash).with(hash_including("validator" => true)).and_return(client)
|
116
|
+
it "by default it should set create_key to true" do
|
112
117
|
knife.run
|
118
|
+
expect(client.create_key).to be_truthy
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should allow you to edit the data" do
|
122
|
+
expect(knife).to receive(:edit_data).with(client).and_return(client)
|
123
|
+
knife.run
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "with -f or --file" do
|
127
|
+
before do
|
128
|
+
client.private_key "woot"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should write the private key to a file" do
|
132
|
+
knife.config[:file] = "/tmp/monkeypants"
|
133
|
+
filehandle = double("Filehandle")
|
134
|
+
expect(filehandle).to receive(:print).with('woot')
|
135
|
+
expect(File).to receive(:open).with("/tmp/monkeypants", "w").and_yield(filehandle)
|
136
|
+
knife.run
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "with -a or --admin" do
|
141
|
+
before do
|
142
|
+
knife.config[:admin] = true
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should create an admin client" do
|
146
|
+
knife.run
|
147
|
+
expect(client.admin).to be_truthy
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "with -p or --public-key" do
|
152
|
+
before do
|
153
|
+
knife.config[:public_key] = 'some_key'
|
154
|
+
allow(File).to receive(:read).and_return('some_key')
|
155
|
+
allow(File).to receive(:expand_path)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "sets the public key" do
|
159
|
+
knife.run
|
160
|
+
expect(client.public_key).to eq('some_key')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "with -k or --prevent-keygen" do
|
165
|
+
before do
|
166
|
+
knife.config[:prevent_keygen] = true
|
167
|
+
end
|
168
|
+
|
169
|
+
it "does not set create_key" do
|
170
|
+
knife.run
|
171
|
+
expect(client.create_key).to be_falsey
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe "with --validator" do
|
176
|
+
before do
|
177
|
+
knife.config[:validator] = true
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should create an validator client" do
|
181
|
+
knife.run
|
182
|
+
expect(client.validator).to be_truthy
|
183
|
+
end
|
113
184
|
end
|
114
185
|
end
|
115
186
|
end
|