chef 11.18.12-x86-mingw32 → 12.0.0.alpha.0-x86-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 +10 -0
- data/README.md +1 -1
- data/distro/common/html/_sources/index.txt +5 -2
- data/distro/common/html/_sources/knife_serve.txt +19 -0
- data/distro/common/html/_sources/knife_ssl_check.txt +2 -2
- data/distro/common/html/_sources/knife_ssl_fetch.txt +2 -2
- data/distro/common/html/_static/basic.css +1 -1
- data/distro/common/html/_static/doctools.js +1 -1
- data/distro/common/html/_static/searchtools.js +1 -1
- data/distro/common/html/_static/websupport.js +1 -1
- data/distro/common/html/ctl_chef_client.html +19 -9
- data/distro/common/html/ctl_chef_server.html +7 -1
- data/distro/common/html/ctl_chef_shell.html +3 -4
- data/distro/common/html/ctl_chef_solo.html +12 -7
- data/distro/common/html/index.html +19 -12
- data/distro/common/html/knife.html +1 -2
- data/distro/common/html/knife_bootstrap.html +16 -5
- data/distro/common/html/knife_client.html +8 -5
- data/distro/common/html/knife_common_options.html +11 -12
- data/distro/common/html/knife_configure.html +2 -3
- data/distro/common/html/knife_cookbook.html +16 -17
- data/distro/common/html/knife_cookbook_site.html +19 -18
- data/distro/common/html/knife_data_bag.html +6 -7
- data/distro/common/html/knife_delete.html +2 -3
- data/distro/common/html/knife_deps.html +2 -3
- data/distro/common/html/knife_diff.html +3 -4
- data/distro/common/html/knife_download.html +6 -7
- data/distro/common/html/knife_edit.html +0 -1
- data/distro/common/html/knife_environment.html +3 -4
- data/distro/common/html/knife_exec.html +0 -1
- data/distro/common/html/knife_index_rebuild.html +0 -1
- data/distro/common/html/knife_list.html +5 -6
- data/distro/common/html/knife_node.html +13 -6
- data/distro/common/html/knife_raw.html +0 -1
- data/distro/common/html/knife_recipe_list.html +0 -1
- data/distro/common/html/knife_role.html +1 -2
- data/distro/common/html/knife_search.html +2 -3
- data/distro/common/html/knife_serve.html +79 -0
- data/distro/common/html/knife_show.html +1 -2
- data/distro/common/html/knife_ssh.html +2 -3
- data/distro/common/html/knife_ssl_check.html +12 -9
- data/distro/common/html/knife_ssl_fetch.html +9 -10
- data/distro/common/html/knife_status.html +2 -3
- data/distro/common/html/knife_tag.html +0 -1
- data/distro/common/html/knife_upload.html +3 -4
- data/distro/common/html/knife_user.html +2 -3
- data/distro/common/html/knife_using.html +0 -1
- data/distro/common/html/knife_xargs.html +3 -4
- data/distro/common/html/search.html +0 -1
- data/distro/common/html/searchindex.js +1 -1
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +24 -67
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -3
- data/lib/chef/chef_fs/command_line.rb +2 -3
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -5
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -2
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -5
- data/lib/chef/config.rb +26 -2
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/synchronizer.rb +50 -8
- data/lib/chef/cookbook_uploader.rb +9 -23
- data/lib/chef/cookbook_version.rb +3 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/dsl/recipe.rb +1 -14
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +2 -24
- data/lib/chef/file_content_management/tempfile.rb +8 -1
- data/lib/chef/formatters/base.rb +0 -7
- data/lib/chef/http.rb +12 -19
- data/lib/chef/http/json_input.rb +12 -1
- data/lib/chef/json_compat.rb +45 -64
- data/lib/chef/knife.rb +2 -5
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +10 -34
- data/lib/chef/knife/cookbook_site_list.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +3 -3
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +0 -24
- data/lib/chef/knife/core/ui.rb +8 -7
- data/lib/chef/knife/deps.rb +2 -3
- data/lib/chef/knife/serve.rb +2 -1
- data/lib/chef/local_mode.rb +105 -0
- data/lib/chef/mixin/file_class.rb +1 -4
- data/lib/chef/mixin/shell_out.rb +15 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +0 -16
- data/lib/chef/node.rb +1 -1
- data/lib/chef/platform/query_helpers.rb +1 -5
- data/lib/chef/policy_builder/expand_node_object.rb +3 -0
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/cookbook_file.rb +0 -1
- data/lib/chef/provider/deploy.rb +0 -1
- data/lib/chef/provider/deploy/revision.rb +1 -1
- data/lib/chef/provider/env.rb +10 -25
- data/lib/chef/provider/env/windows.rb +23 -10
- data/lib/chef/provider/execute.rb +0 -3
- data/lib/chef/provider/file.rb +0 -3
- data/lib/chef/provider/git.rb +0 -6
- data/lib/chef/provider/group/dscl.rb +9 -27
- data/lib/chef/provider/group/gpasswd.rb +0 -3
- data/lib/chef/provider/group/groupmod.rb +0 -4
- data/lib/chef/provider/group/suse.rb +0 -3
- data/lib/chef/provider/group/usermod.rb +0 -3
- data/lib/chef/provider/link.rb +22 -5
- data/lib/chef/provider/log.rb +15 -4
- data/lib/chef/provider/mdadm.rb +0 -3
- data/lib/chef/provider/mount/mount.rb +0 -2
- data/lib/chef/provider/mount/solaris.rb +0 -2
- data/lib/chef/provider/package.rb +0 -1
- data/lib/chef/provider/package/apt.rb +0 -3
- data/lib/chef/provider/package/dpkg.rb +0 -1
- data/lib/chef/provider/package/easy_install.rb +0 -4
- data/lib/chef/provider/package/freebsd/base.rb +0 -3
- data/lib/chef/provider/package/freebsd/pkgng.rb +0 -2
- data/lib/chef/provider/package/freebsd/port.rb +0 -2
- data/lib/chef/provider/package/ips.rb +0 -3
- data/lib/chef/provider/package/paludis.rb +0 -5
- data/lib/chef/provider/package/portage.rb +0 -2
- data/lib/chef/provider/package/rpm.rb +2 -4
- data/lib/chef/provider/package/rubygems.rb +0 -4
- data/lib/chef/provider/package/smartos.rb +0 -3
- data/lib/chef/provider/package/windows/msi.rb +0 -2
- data/lib/chef/provider/package/yum.rb +0 -4
- data/lib/chef/provider/package/zypper.rb +0 -3
- data/lib/chef/provider/registry_key.rb +0 -2
- data/lib/chef/provider/remote_directory.rb +0 -1
- data/lib/chef/provider/remote_file.rb +0 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -3
- data/lib/chef/provider/remote_file/content.rb +0 -1
- data/lib/chef/provider/remote_file/fetcher.rb +0 -2
- data/lib/chef/provider/remote_file/ftp.rb +0 -1
- data/lib/chef/provider/resource_update.rb +0 -3
- data/lib/chef/provider/service/freebsd.rb +0 -3
- data/lib/chef/provider/service/init.rb +0 -3
- data/lib/chef/provider/service/macosx.rb +0 -1
- data/lib/chef/provider/service/redhat.rb +0 -2
- data/lib/chef/provider/service/simple.rb +0 -3
- data/lib/chef/provider/service/solaris.rb +0 -3
- data/lib/chef/provider/service/systemd.rb +15 -14
- data/lib/chef/provider/service/windows.rb +0 -3
- data/lib/chef/provider/subversion.rb +0 -2
- data/lib/chef/provider/template.rb +0 -2
- data/lib/chef/provider/template/content.rb +0 -1
- data/lib/chef/provider/user/dscl.rb +156 -549
- data/lib/chef/provider/user/solaris.rb +0 -1
- data/lib/chef/provider/user/useradd.rb +0 -3
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/resource.rb +1 -4
- data/lib/chef/resource/freebsd_package.rb +2 -10
- data/lib/chef/resource/lwrp_base.rb +1 -12
- data/lib/chef/resource/user.rb +0 -18
- data/lib/chef/resource_collection.rb +1 -1
- data/lib/chef/resource_reporter.rb +10 -10
- data/lib/chef/resources.rb +0 -1
- data/lib/chef/role.rb +3 -3
- data/lib/chef/run_list.rb +1 -1
- data/lib/chef/tasks/chef_repo.rake +131 -264
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/path_helper.rb +2 -2
- data/lib/chef/version.rb +9 -1
- data/lib/chef/win32/api/system.rb +0 -9
- data/spec/data/bootstrap/test-hints.erb +1 -1
- data/spec/data/bootstrap/test.erb +1 -1
- data/spec/functional/dsl/reboot_pending_spec.rb +53 -58
- data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
- data/spec/functional/knife/exec_spec.rb +1 -1
- data/spec/functional/mixin/shell_out_spec.rb +48 -0
- data/spec/functional/resource/base.rb +0 -10
- data/spec/functional/resource/group_spec.rb +1 -5
- data/spec/functional/resource/link_spec.rb +8 -0
- data/spec/functional/resource/{user/useradd_spec.rb → user_spec.rb} +1 -1
- data/spec/integration/knife/chef_fs_data_store_spec.rb +3 -3
- data/spec/integration/knife/chef_repo_path_spec.rb +1 -6
- data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
- data/spec/integration/knife/chefignore_spec.rb +1 -1
- data/spec/integration/knife/common_options_spec.rb +50 -3
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
- data/spec/integration/knife/delete_spec.rb +1 -1
- data/spec/integration/knife/deps_spec.rb +1 -1
- data/spec/integration/knife/diff_spec.rb +3 -3
- data/spec/integration/knife/download_spec.rb +3 -3
- data/spec/integration/knife/list_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +1 -11
- data/spec/integration/knife/redirection_spec.rb +1 -1
- data/spec/integration/knife/serve_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +1 -1
- data/spec/integration/knife/upload_spec.rb +9 -9
- data/spec/spec_helper.rb +0 -9
- data/spec/support/pedant/pedant_config.rb +2 -1
- data/spec/support/pedant/run_pedant.rb +2 -1
- data/spec/support/platform_helpers.rb +5 -24
- data/spec/support/shared/integration/integration_helper.rb +2 -1
- data/spec/support/shared/matchers.rb +17 -0
- data/spec/tiny_server.rb +1 -2
- data/spec/unit/api_client_spec.rb +3 -3
- data/spec/unit/application_spec.rb +9 -32
- data/spec/unit/config_fetcher_spec.rb +1 -1
- data/spec/unit/cookbook/metadata_spec.rb +3 -7
- data/spec/unit/cookbook/synchronizer_spec.rb +441 -226
- data/spec/unit/cookbook_loader_spec.rb +1 -1
- data/spec/unit/cookbook_uploader_spec.rb +160 -0
- data/spec/unit/cookbook_version_spec.rb +0 -4
- data/spec/unit/data_bag_item_spec.rb +1 -5
- data/spec/unit/data_bag_spec.rb +1 -5
- data/spec/unit/deprecation_spec.rb +1 -1
- data/spec/unit/dsl/recipe_spec.rb +12 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +7 -14
- data/spec/unit/environment_spec.rb +3 -7
- data/spec/unit/exceptions_spec.rb +0 -6
- data/spec/unit/http/json_input_spec.rb +128 -0
- data/spec/unit/json_compat_spec.rb +17 -58
- data/spec/unit/knife/client_create_spec.rb +3 -3
- data/spec/unit/knife/configure_client_spec.rb +6 -5
- data/spec/unit/knife/cookbook_delete_spec.rb +1 -1
- data/spec/unit/knife/cookbook_download_spec.rb +5 -5
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -0
- data/spec/unit/knife/cookbook_metadata_spec.rb +1 -1
- data/spec/unit/knife/cookbook_site_download_spec.rb +10 -11
- data/spec/unit/knife/cookbook_site_install_spec.rb +116 -161
- data/spec/unit/knife/cookbook_site_share_spec.rb +8 -8
- data/spec/unit/knife/cookbook_upload_spec.rb +3 -2
- data/spec/unit/knife/core/bootstrap_context_spec.rb +3 -3
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -66
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -1
- data/spec/unit/knife/tag_create_spec.rb +3 -3
- data/spec/unit/knife/tag_delete_spec.rb +3 -3
- data/spec/unit/knife/user_create_spec.rb +1 -1
- data/spec/unit/knife_spec.rb +14 -14
- data/spec/unit/lwrp_spec.rb +1 -21
- data/spec/unit/mixin/shell_out_spec.rb +92 -0
- data/spec/unit/node_spec.rb +0 -4
- data/spec/unit/platform/query_helpers_spec.rb +0 -23
- data/spec/unit/provider/env/windows_spec.rb +34 -70
- data/spec/unit/provider/env_spec.rb +11 -76
- data/spec/unit/provider/group/dscl_spec.rb +1 -38
- data/spec/unit/provider/log_spec.rb +18 -0
- data/spec/unit/provider/package/rpm_spec.rb +0 -12
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
- data/spec/unit/provider/service/systemd_service_spec.rb +44 -27
- data/spec/unit/provider/user/dscl_spec.rb +264 -660
- data/spec/unit/provider/user/useradd_spec.rb +0 -1
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/unit/provider_spec.rb +12 -0
- data/spec/unit/recipe_spec.rb +0 -41
- data/spec/unit/resource_collection_spec.rb +1 -5
- data/spec/unit/resource_reporter_spec.rb +3 -51
- data/spec/unit/resource_spec.rb +3 -14
- data/spec/unit/rest_spec.rb +1 -4
- data/spec/unit/role_spec.rb +0 -10
- data/spec/unit/run_list_spec.rb +1 -5
- data/spec/unit/user_spec.rb +1 -5
- metadata +20 -100
- data/lib/chef/mixin/windows_env_helper.rb +0 -56
- data/lib/chef/provider/dsc_script.rb +0 -175
- data/lib/chef/resource/dsc_script.rb +0 -126
- data/lib/chef/streaming_cookbook_uploader.rb +0 -205
- data/lib/chef/util/dsc/configuration_generator.rb +0 -115
- data/lib/chef/util/dsc/lcm_output_parser.rb +0 -133
- data/lib/chef/util/dsc/local_configuration_manager.rb +0 -141
- data/lib/chef/util/dsc/resource_info.rb +0 -26
- data/lib/chef/util/powershell/cmdlet.rb +0 -136
- data/lib/chef/util/powershell/cmdlet_result.rb +0 -46
- data/spec/data/mac_users/10.7-8.plist.xml +0 -559
- data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
- data/spec/data/mac_users/10.7.plist.xml +0 -559
- data/spec/data/mac_users/10.7.shadow.xml +0 -11
- data/spec/data/mac_users/10.8.plist.xml +0 -559
- data/spec/data/mac_users/10.8.shadow.xml +0 -21
- data/spec/data/mac_users/10.9.plist.xml +0 -560
- data/spec/data/mac_users/10.9.shadow.xml +0 -21
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +0 -51
- data/spec/functional/resource/dsc_script_spec.rb +0 -382
- data/spec/functional/resource/env_spec.rb +0 -182
- data/spec/functional/resource/user/dscl_spec.rb +0 -199
- data/spec/functional/util/powershell/cmdlet_spec.rb +0 -113
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -46
- data/spec/support/shared/shared_examples.rb +0 -10
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +0 -63
- data/spec/unit/formatters/base_spec.rb +0 -48
- data/spec/unit/provider/dsc_script_spec.rb +0 -174
- data/spec/unit/resource/dsc_script_spec.rb +0 -98
- data/spec/unit/util/dsc/configuration_generator_spec.rb +0 -171
- data/spec/unit/util/dsc/lcm_output_parser_spec.rb +0 -169
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +0 -139
- data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -1,21 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>SALTED-SHA512-PBKDF2</key>
|
6
|
-
<dict>
|
7
|
-
<key>entropy</key>
|
8
|
-
<data>
|
9
|
-
EmAakNsXy/i6SAjmOC+w07nYpsGhkEd79oCrIa+2BlRnE25VzCCKb3QVbj2v
|
10
|
-
IPsTNp70t7r6BH2ANZ+0akikrczVSOuzOFGwk0fMqENBp/k6JxRzQ/ifuEP7
|
11
|
-
RsABfSZK+kl2uqz5QbkVvR7ByiTDCz51ngJAPgL1n+f/WTinY2w=
|
12
|
-
</data>
|
13
|
-
<key>iterations</key>
|
14
|
-
<integer>34482</integer>
|
15
|
-
<key>salt</key>
|
16
|
-
<data>
|
17
|
-
7pVL5HL9xg3fiUhHgUM5k2JfAGr27IEMCPSafkE5RqE=
|
18
|
-
</data>
|
19
|
-
</dict>
|
20
|
-
</dict>
|
21
|
-
</plist>
|
@@ -1,51 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Serdar Sutay (<serdar@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2014 Opscode, 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
|
-
|
21
|
-
describe Chef::Resource::WhyrunSafeRubyBlock do
|
22
|
-
let(:node) { Chef::Node.new }
|
23
|
-
|
24
|
-
let(:run_context) {
|
25
|
-
events = Chef::EventDispatch::Dispatcher.new
|
26
|
-
Chef::RunContext.new(node, {}, events)
|
27
|
-
}
|
28
|
-
|
29
|
-
before do
|
30
|
-
$evil_global_evil_laugh = :wahwah
|
31
|
-
Chef::Config[:why_run] = true
|
32
|
-
end
|
33
|
-
|
34
|
-
after do
|
35
|
-
Chef::Config[:why_run] = false
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "when testing the resource" do
|
39
|
-
let(:new_resource) do
|
40
|
-
r = Chef::Resource::WhyrunSafeRubyBlock.new("reload all", run_context)
|
41
|
-
r.block { $evil_global_evil_laugh = :mwahahaha }
|
42
|
-
r
|
43
|
-
end
|
44
|
-
|
45
|
-
it "updates the evil laugh, even in why-run mode" do
|
46
|
-
new_resource.run_action(new_resource.action)
|
47
|
-
$evil_global_evil_laugh.should == :mwahahaha
|
48
|
-
new_resource.should be_updated
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,382 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Edwards (<adamed@getchef.com>)
|
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/shell_out'
|
21
|
-
require 'chef/mixin/windows_architecture_helper'
|
22
|
-
|
23
|
-
describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
|
24
|
-
include Chef::Mixin::WindowsArchitectureHelper
|
25
|
-
before(:all) do
|
26
|
-
@temp_dir = ::Dir.mktmpdir("dsc-functional-test")
|
27
|
-
end
|
28
|
-
|
29
|
-
after(:all) do
|
30
|
-
::FileUtils.rm_rf(@temp_dir) if ::Dir.exist?(@temp_dir)
|
31
|
-
end
|
32
|
-
|
33
|
-
include Chef::Mixin::ShellOut
|
34
|
-
|
35
|
-
def create_config_script_from_code(code, configuration_name, data = false)
|
36
|
-
script_code = data ? code : "Configuration '#{configuration_name}'\n{\n\t#{code}\n}\n"
|
37
|
-
data_suffix = data ? '_config_data' : ''
|
38
|
-
extension = data ? 'psd1' : 'ps1'
|
39
|
-
script_path = "#{@temp_dir}/dsc_functional_test#{data_suffix}.#{extension}"
|
40
|
-
::File.open(script_path, 'wt') do | script |
|
41
|
-
script.write(script_code)
|
42
|
-
end
|
43
|
-
script_path
|
44
|
-
end
|
45
|
-
|
46
|
-
def user_exists?(target_user)
|
47
|
-
result = false
|
48
|
-
begin
|
49
|
-
shell_out!("net user #{target_user}")
|
50
|
-
result = true
|
51
|
-
rescue Mixlib::ShellOut::ShellCommandFailed
|
52
|
-
end
|
53
|
-
result
|
54
|
-
end
|
55
|
-
|
56
|
-
def delete_user(target_user)
|
57
|
-
begin
|
58
|
-
shell_out!("net user #{target_user} /delete")
|
59
|
-
rescue Mixlib::ShellOut::ShellCommandFailed
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
let(:dsc_env_variable) { 'chefenvtest' }
|
64
|
-
let(:dsc_env_value1) { 'value1' }
|
65
|
-
let(:env_value2) { 'value2' }
|
66
|
-
let(:dsc_test_run_context) {
|
67
|
-
node = Chef::Node.new
|
68
|
-
node.automatic['platform'] = 'windows'
|
69
|
-
node.automatic['platform_version'] = '6.1'
|
70
|
-
node.automatic['kernel'][:machine] =
|
71
|
-
is_i386_process_on_x86_64_windows? ? :x86_64 : :i386
|
72
|
-
node.automatic[:languages][:powershell][:version] = '4.0'
|
73
|
-
empty_events = Chef::EventDispatch::Dispatcher.new
|
74
|
-
Chef::RunContext.new(node, {}, empty_events)
|
75
|
-
}
|
76
|
-
let(:dsc_test_resource_name) { 'DSCTest' }
|
77
|
-
let(:dsc_test_resource_base) {
|
78
|
-
Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context)
|
79
|
-
}
|
80
|
-
let(:test_registry_key) { 'HKEY_LOCAL_MACHINE\Software\Chef\Spec\Functional\Resource\dsc_script_spec' }
|
81
|
-
let(:test_registry_value) { 'Registration' }
|
82
|
-
let(:test_registry_data1) { 'LL927' }
|
83
|
-
let(:test_registry_data2) { 'LL928' }
|
84
|
-
let(:reg_key_name_param_name) { 'testregkeyname' }
|
85
|
-
let(:reg_key_value_param_name) { 'testregvaluename' }
|
86
|
-
let(:registry_embedded_parameters) { "$#{reg_key_name_param_name} = '#{test_registry_key}';$#{reg_key_value_param_name} = '#{test_registry_value}'"}
|
87
|
-
let(:dsc_reg_code) { <<-EOH
|
88
|
-
#{registry_embedded_parameters}
|
89
|
-
Registry "ChefRegKey"
|
90
|
-
{
|
91
|
-
Key = $#{reg_key_name_param_name}
|
92
|
-
ValueName = $#{reg_key_value_param_name}
|
93
|
-
ValueData = '#{test_registry_data}'
|
94
|
-
Ensure = 'Present'
|
95
|
-
}
|
96
|
-
EOH
|
97
|
-
}
|
98
|
-
|
99
|
-
let(:dsc_code) { dsc_reg_code }
|
100
|
-
let(:dsc_reg_script) { <<-EOH
|
101
|
-
param($testregkeyname, $testregvaluename)
|
102
|
-
#{dsc_reg_code}
|
103
|
-
EOH
|
104
|
-
}
|
105
|
-
|
106
|
-
let(:dsc_user_prefix) { 'dsc' }
|
107
|
-
let(:dsc_user_suffix) { 'chefx' }
|
108
|
-
let(:dsc_user) {"#{dsc_user_prefix}_usr_#{dsc_user_suffix}" }
|
109
|
-
let(:dsc_user_prefix_env_var_name) { 'dsc_user_env_prefix' }
|
110
|
-
let(:dsc_user_suffix_env_var_name) { 'dsc_user_env_suffix' }
|
111
|
-
let(:dsc_user_prefix_env_code) { "$env:#{dsc_user_prefix_env_var_name}"}
|
112
|
-
let(:dsc_user_suffix_env_code) { "$env:#{dsc_user_suffix_env_var_name}"}
|
113
|
-
let(:dsc_user_prefix_param_name) { 'dsc_user_prefix_param' }
|
114
|
-
let(:dsc_user_suffix_param_name) { 'dsc_user_suffix_param' }
|
115
|
-
let(:dsc_user_prefix_param_code) { "$#{dsc_user_prefix_param_name}"}
|
116
|
-
let(:dsc_user_suffix_param_code) { "$#{dsc_user_suffix_param_name}"}
|
117
|
-
let(:dsc_user_env_code) { "\"$(#{dsc_user_prefix_env_code})_usr_$(#{dsc_user_suffix_env_code})\""}
|
118
|
-
let(:dsc_user_param_code) { "\"$(#{dsc_user_prefix_param_code})_usr_$(#{dsc_user_suffix_param_code})\""}
|
119
|
-
|
120
|
-
let(:config_flags) { nil }
|
121
|
-
let(:config_params) { <<-EOH
|
122
|
-
|
123
|
-
[CmdletBinding()]
|
124
|
-
param
|
125
|
-
(
|
126
|
-
$#{dsc_user_prefix_param_name},
|
127
|
-
$#{dsc_user_suffix_param_name}
|
128
|
-
)
|
129
|
-
EOH
|
130
|
-
}
|
131
|
-
|
132
|
-
let(:config_param_section) { '' }
|
133
|
-
let(:dsc_user_code) { "'#{dsc_user}'" }
|
134
|
-
let(:dsc_user_prefix_code) { dsc_user_prefix }
|
135
|
-
let(:dsc_user_suffix_code) { dsc_user_suffix }
|
136
|
-
let(:dsc_script_environment_attribute) { nil }
|
137
|
-
let(:dsc_user_resources_code) { <<-EOH
|
138
|
-
#{config_param_section}
|
139
|
-
node localhost
|
140
|
-
{
|
141
|
-
$testuser = #{dsc_user_code}
|
142
|
-
$testpassword = ConvertTo-SecureString -String "jf9a8m49jrajf4#" -AsPlainText -Force
|
143
|
-
$testcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $testuser, $testpassword
|
144
|
-
|
145
|
-
User dsctestusercreate
|
146
|
-
{
|
147
|
-
UserName = $testuser
|
148
|
-
Password = $testcred
|
149
|
-
Description = "DSC test user"
|
150
|
-
Ensure = "Present"
|
151
|
-
Disabled = $false
|
152
|
-
PasswordNeverExpires = $true
|
153
|
-
PasswordChangeRequired = $false
|
154
|
-
}
|
155
|
-
}
|
156
|
-
EOH
|
157
|
-
}
|
158
|
-
|
159
|
-
let(:dsc_user_config_data) {
|
160
|
-
<<-EOH
|
161
|
-
@{
|
162
|
-
AllNodes = @(
|
163
|
-
@{
|
164
|
-
NodeName = "localhost";
|
165
|
-
PSDscAllowPlainTextPassword = $true
|
166
|
-
}
|
167
|
-
)
|
168
|
-
}
|
169
|
-
|
170
|
-
EOH
|
171
|
-
}
|
172
|
-
|
173
|
-
let(:dsc_environment_env_var_name) { 'dsc_test_cwd' }
|
174
|
-
let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV['systemroot']}\\system32" }
|
175
|
-
let(:dsc_environment_fail_etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" }
|
176
|
-
let(:exception_message_signature) { 'LL927-LL928' }
|
177
|
-
let(:dsc_environment_config) {<<-EOH
|
178
|
-
if (($pwd.path -eq '#{dsc_environment_fail_etc_directory}') -and (test-path('#{dsc_environment_fail_etc_directory}')))
|
179
|
-
{
|
180
|
-
throw 'Signature #{exception_message_signature}: Purposefully failing because cwd == #{dsc_environment_fail_etc_directory}'
|
181
|
-
}
|
182
|
-
environment "whatsmydir"
|
183
|
-
{
|
184
|
-
Name = '#{dsc_environment_env_var_name}'
|
185
|
-
Value = $pwd.path
|
186
|
-
Ensure = 'Present'
|
187
|
-
}
|
188
|
-
EOH
|
189
|
-
}
|
190
|
-
|
191
|
-
let(:dsc_config_name) {
|
192
|
-
dsc_test_resource_base.name
|
193
|
-
}
|
194
|
-
let(:dsc_resource_from_code) {
|
195
|
-
dsc_test_resource_base.code(dsc_code)
|
196
|
-
dsc_test_resource_base
|
197
|
-
}
|
198
|
-
let(:config_name_value) { dsc_test_resource_base.name }
|
199
|
-
|
200
|
-
let(:dsc_resource_from_path) {
|
201
|
-
dsc_test_resource_base.command(create_config_script_from_code(dsc_code, config_name_value))
|
202
|
-
dsc_test_resource_base
|
203
|
-
}
|
204
|
-
|
205
|
-
before(:each) do
|
206
|
-
test_key_resource = Chef::Resource::RegistryKey.new(test_registry_key, dsc_test_run_context)
|
207
|
-
test_key_resource.recursive(true)
|
208
|
-
test_key_resource.run_action(:delete_key)
|
209
|
-
end
|
210
|
-
|
211
|
-
after(:each) do
|
212
|
-
test_key_resource = Chef::Resource::RegistryKey.new(test_registry_key, dsc_test_run_context)
|
213
|
-
test_key_resource.recursive(true)
|
214
|
-
test_key_resource.run_action(:delete_key)
|
215
|
-
end
|
216
|
-
|
217
|
-
shared_examples_for 'a dsc_script resource with specified PowerShell configuration code' do
|
218
|
-
let(:test_registry_data) { test_registry_data1 }
|
219
|
-
it 'should create a registry key with a specific registry value and data' do
|
220
|
-
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false)
|
221
|
-
dsc_test_resource.run_action(:run)
|
222
|
-
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true)
|
223
|
-
expect(dsc_test_resource.registry_value_exists?(test_registry_key, {:name => test_registry_value, :type => :string, :data => test_registry_data})).to eq(true)
|
224
|
-
end
|
225
|
-
|
226
|
-
it_should_behave_like 'a dsc_script resource with configuration affected by cwd'
|
227
|
-
end
|
228
|
-
|
229
|
-
shared_examples_for 'a dsc_script resource with configuration affected by cwd' do
|
230
|
-
after(:each) do
|
231
|
-
removal_resource = Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context)
|
232
|
-
removal_resource.code <<-EOH
|
233
|
-
environment 'removethis'
|
234
|
-
{
|
235
|
-
Name = '#{dsc_environment_env_var_name}'
|
236
|
-
Ensure = 'Absent'
|
237
|
-
}
|
238
|
-
EOH
|
239
|
-
removal_resource.run_action(:run)
|
240
|
-
end
|
241
|
-
|
242
|
-
describe 'when the DSC configuration contains code that raises an exception if cwd has a specific value' do
|
243
|
-
let(:dsc_code) { dsc_environment_config }
|
244
|
-
it 'should not raise an exception if the cwd is not etc' do
|
245
|
-
dsc_test_resource.cwd(dsc_environment_no_fail_not_etc_directory)
|
246
|
-
expect {dsc_test_resource.run_action(:run)}.not_to raise_error
|
247
|
-
end
|
248
|
-
|
249
|
-
it 'should raise an exception if the cwd is etc' do
|
250
|
-
dsc_test_resource.cwd(dsc_environment_fail_etc_directory)
|
251
|
-
expect {dsc_test_resource.run_action(:run)}.to raise_error(Chef::Exceptions::PowershellCmdletException)
|
252
|
-
begin
|
253
|
-
dsc_test_resource.run_action(:run)
|
254
|
-
rescue Chef::Exceptions::PowershellCmdletException => e
|
255
|
-
expect(e.message).to match(exception_message_signature)
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
shared_examples_for 'a parameterized DSC configuration script' do
|
262
|
-
let(:dsc_user_prefix_code) { dsc_user_prefix_env_code }
|
263
|
-
let(:dsc_user_suffix_code) { dsc_user_suffix_env_code }
|
264
|
-
it_behaves_like 'a dsc_script with configuration that uses environment variables'
|
265
|
-
end
|
266
|
-
|
267
|
-
shared_examples_for 'a dsc_script without configuration data that takes parameters' do
|
268
|
-
context 'when configuration data is not specified' do
|
269
|
-
|
270
|
-
before(:each) do
|
271
|
-
test_key_resource = Chef::Resource::RegistryKey.new(test_registry_key, dsc_test_run_context)
|
272
|
-
test_key_resource.recursive(true)
|
273
|
-
test_key_resource.run_action(:delete_key)
|
274
|
-
end
|
275
|
-
|
276
|
-
after(:each) do
|
277
|
-
test_key_resource = Chef::Resource::RegistryKey.new(test_registry_key, dsc_test_run_context)
|
278
|
-
test_key_resource.recursive(true)
|
279
|
-
test_key_resource.run_action(:delete_key)
|
280
|
-
end
|
281
|
-
|
282
|
-
let(:test_registry_data) { test_registry_data1 }
|
283
|
-
let(:dsc_parameterized_env_param_value) { "val" + Random::rand.to_s }
|
284
|
-
|
285
|
-
it 'should have a default value of nil for the configuration_data attribute' do
|
286
|
-
expect(dsc_test_resource.configuration_data).to eql(nil)
|
287
|
-
end
|
288
|
-
|
289
|
-
it 'should have a default value of nil for the configuration_data_path attribute' do
|
290
|
-
expect(dsc_test_resource.configuration_data_script).to eql(nil)
|
291
|
-
end
|
292
|
-
|
293
|
-
let(:dsc_test_resource) { dsc_resource_from_path }
|
294
|
-
let(:registry_embedded_parameters) { '' }
|
295
|
-
let(:dsc_code) { dsc_reg_script }
|
296
|
-
|
297
|
-
it 'should set a registry key according to parameters passed to the configuration' do
|
298
|
-
dsc_test_resource.configuration_name(config_name_value)
|
299
|
-
dsc_test_resource.flags({:"#{reg_key_name_param_name}" => test_registry_key, :"#{reg_key_value_param_name}" => test_registry_value})
|
300
|
-
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false)
|
301
|
-
dsc_test_resource.run_action(:run)
|
302
|
-
expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true)
|
303
|
-
expect(dsc_test_resource.registry_value_exists?(test_registry_key, {:name => test_registry_value, :type => :string, :data => test_registry_data})).to eq(true)
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
|
-
shared_examples_for 'a dsc_script with configuration data' do
|
309
|
-
let(:configuration_data_attribute) { 'configuration_data' }
|
310
|
-
it_behaves_like 'a dsc_script with configuration data set via an attribute'
|
311
|
-
|
312
|
-
let(:configuration_data_attribute) { 'configuration_data_script' }
|
313
|
-
it_behaves_like 'a dsc_script with configuration data set via an attribute'
|
314
|
-
end
|
315
|
-
|
316
|
-
shared_examples_for 'a dsc_script with configuration data set via an attribute' do
|
317
|
-
it 'should run a configuration script that creates a user' do
|
318
|
-
config_data_value = dsc_user_config_data
|
319
|
-
dsc_test_resource.configuration_name(config_name_value)
|
320
|
-
if configuration_data_attribute == 'configuration_data_script'
|
321
|
-
config_data_value = create_config_script_from_code(dsc_user_config_data, '', true)
|
322
|
-
end
|
323
|
-
dsc_test_resource.environment({dsc_user_prefix_env_var_name => dsc_user_prefix,
|
324
|
-
dsc_user_suffix_env_var_name => dsc_user_suffix})
|
325
|
-
dsc_test_resource.send(configuration_data_attribute, config_data_value)
|
326
|
-
dsc_test_resource.flags(config_flags)
|
327
|
-
expect(user_exists?(dsc_user)).to eq(false)
|
328
|
-
expect {dsc_test_resource.run_action(:run)}.not_to raise_error
|
329
|
-
expect(user_exists?(dsc_user)).to eq(true)
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
shared_examples_for 'a dsc_script with configuration data that takes parameters' do
|
334
|
-
let(:dsc_user_code) { dsc_user_param_code }
|
335
|
-
let(:config_param_section) { config_params }
|
336
|
-
let(:config_flags) {{:"#{dsc_user_prefix_param_name}" => "#{dsc_user_prefix}", :"#{dsc_user_suffix_param_name}" => "#{dsc_user_suffix}"}}
|
337
|
-
it 'does not directly contain the user name' do
|
338
|
-
configuration_script_content = ::File.open(dsc_test_resource.command) do | file |
|
339
|
-
file.read
|
340
|
-
end
|
341
|
-
expect(configuration_script_content.include?(dsc_user)).to be(false)
|
342
|
-
end
|
343
|
-
it_behaves_like 'a dsc_script with configuration data'
|
344
|
-
end
|
345
|
-
|
346
|
-
shared_examples_for 'a dsc_script with configuration data that uses environment variables' do
|
347
|
-
let(:dsc_user_code) { dsc_user_env_code }
|
348
|
-
|
349
|
-
it 'does not directly contain the user name' do
|
350
|
-
configuration_script_content = ::File.open(dsc_test_resource.command) do | file |
|
351
|
-
file.read
|
352
|
-
end
|
353
|
-
expect(configuration_script_content.include?(dsc_user)).to be(false)
|
354
|
-
end
|
355
|
-
it_behaves_like 'a dsc_script with configuration data'
|
356
|
-
end
|
357
|
-
|
358
|
-
context 'when supplying configuration through the configuration attribute' do
|
359
|
-
let(:dsc_test_resource) { dsc_resource_from_code }
|
360
|
-
it_behaves_like 'a dsc_script resource with specified PowerShell configuration code'
|
361
|
-
end
|
362
|
-
|
363
|
-
context 'when supplying configuration using the path attribute' do
|
364
|
-
let(:dsc_test_resource) { dsc_resource_from_path }
|
365
|
-
it_behaves_like 'a dsc_script resource with specified PowerShell configuration code'
|
366
|
-
end
|
367
|
-
|
368
|
-
context 'when running a configuration that manages users' do
|
369
|
-
before(:each) do
|
370
|
-
delete_user(dsc_user)
|
371
|
-
end
|
372
|
-
|
373
|
-
let(:dsc_code) { dsc_user_resources_code }
|
374
|
-
let(:config_name_value) { 'DSCTestConfig' }
|
375
|
-
let(:dsc_test_resource) { dsc_resource_from_path }
|
376
|
-
|
377
|
-
it_behaves_like 'a dsc_script with configuration data'
|
378
|
-
it_behaves_like 'a dsc_script with configuration data that uses environment variables'
|
379
|
-
it_behaves_like 'a dsc_script with configuration data that takes parameters'
|
380
|
-
it_behaves_like 'a dsc_script without configuration data that takes parameters'
|
381
|
-
end
|
382
|
-
end
|