chef 11.18.12 → 12.0.0.alpha.0
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,46 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2014 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 'chef/knife'
|
19
|
-
require 'chef/json_compat'
|
20
|
-
|
21
|
-
class Chef
|
22
|
-
class Resource
|
23
|
-
class ZenFollower < Chef::Resource
|
24
|
-
attr_accessor :created_as_type
|
25
|
-
|
26
|
-
provides :follower, :on_platforms => ["zen"]
|
27
|
-
|
28
|
-
def initialize(name, run_context=nil)
|
29
|
-
@resource_name = :zen_follower
|
30
|
-
@created_as_type = "zen_follower"
|
31
|
-
super
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_s
|
35
|
-
"#{created_as_type}[#{name}]"
|
36
|
-
end
|
37
|
-
|
38
|
-
def master(arg=nil)
|
39
|
-
if !arg.nil?
|
40
|
-
@master = arg
|
41
|
-
end
|
42
|
-
@master
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# For storing any examples shared between multiple tests
|
2
|
-
|
3
|
-
# Any object which defines a .to_json should import this test
|
4
|
-
shared_examples "to_json equalivent to Chef::JSONCompat.to_json" do
|
5
|
-
|
6
|
-
it "should allow consumers to call #to_json or Chef::JSONCompat.to_json" do
|
7
|
-
expect(subject.to_json).to eq(Chef::JSONCompat.to_json(subject))
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Ryan Cragun (<ryan@getchef.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
|
-
require 'lib/chef/chef_fs/data_handler/group_data_handler'
|
21
|
-
|
22
|
-
class TestEntry < Mash
|
23
|
-
attr_accessor :name, :org
|
24
|
-
|
25
|
-
def initialize(name, org)
|
26
|
-
@name = name
|
27
|
-
@org = org
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe Chef::ChefFS::DataHandler::GroupDataHandler do
|
32
|
-
describe '#normalize_for_post' do
|
33
|
-
let(:entry) do
|
34
|
-
TestEntry.new('workers.json', 'hive')
|
35
|
-
end
|
36
|
-
|
37
|
-
let(:group) do
|
38
|
-
{ 'name' => 'worker_bees',
|
39
|
-
'clients' => %w(honey sting),
|
40
|
-
'users' => %w(fizz buzz),
|
41
|
-
'actors' => %w(honey)
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
let(:normalized) do
|
46
|
-
{ 'actors' =>
|
47
|
-
{ 'users' => %w(fizz buzz),
|
48
|
-
'clients'=> %w(honey sting),
|
49
|
-
'groups'=> []
|
50
|
-
},
|
51
|
-
'groupname' => 'workers',
|
52
|
-
'name' => 'worker_bees',
|
53
|
-
'orgname' => 'hive'
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
let(:handler) { described_class.new }
|
58
|
-
|
59
|
-
it 'normalizes the users, clients and groups into actors' do
|
60
|
-
expect(handler.normalize_for_post(group, entry)).to eq(normalized)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Lamont Granquist (<lamont@getchef.com>)
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright (c) 2012 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
|
-
let(:out) { double("out") }
|
24
|
-
let(:err) { double("err") }
|
25
|
-
let(:formatter) { Chef::Formatters::Base.new(out, err) }
|
26
|
-
|
27
|
-
it "starts with an indentation of zero" do
|
28
|
-
expect(formatter.output.indent).to eql(0)
|
29
|
-
end
|
30
|
-
|
31
|
-
it "increments it to two correctly" do
|
32
|
-
formatter.indent_by(2)
|
33
|
-
expect(formatter.output.indent).to eql(2)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "increments it and then decrements it corectly" do
|
37
|
-
formatter.indent_by(2)
|
38
|
-
formatter.indent_by(-2)
|
39
|
-
expect(formatter.output.indent).to eql(0)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "does not allow negative indentation" do
|
43
|
-
formatter.indent_by(-2)
|
44
|
-
expect(formatter.output.indent).to eql(0)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
@@ -1,174 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Jay Mundrawala (<jdm@getchef.com>)
|
3
|
-
#
|
4
|
-
# Copyright:: Copyright (c) 2014 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 'chef'
|
21
|
-
require 'chef/util/dsc/resource_info'
|
22
|
-
require 'spec_helper'
|
23
|
-
|
24
|
-
describe Chef::Provider::DscScript do
|
25
|
-
context 'when DSC is available' do
|
26
|
-
let (:node) {
|
27
|
-
node = Chef::Node.new
|
28
|
-
node.automatic[:languages][:powershell][:version] = '4.0'
|
29
|
-
node
|
30
|
-
}
|
31
|
-
let (:events) { Chef::EventDispatch::Dispatcher.new }
|
32
|
-
let (:run_context) { Chef::RunContext.new(node, {}, events) }
|
33
|
-
let (:resource) { Chef::Resource::DscScript.new("script", run_context) }
|
34
|
-
let (:provider) do
|
35
|
-
Chef::Provider::DscScript.new(resource, run_context)
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#load_current_resource' do
|
39
|
-
it "describes the resource as converged if there were 0 DSC resources" do
|
40
|
-
allow(provider).to receive(:run_configuration).with(:test).and_return([])
|
41
|
-
provider.load_current_resource
|
42
|
-
provider.instance_variable_get('@resource_converged').should be_true
|
43
|
-
end
|
44
|
-
|
45
|
-
it "describes the resource as not converged if there is 1 DSC resources that is converged" do
|
46
|
-
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something'])
|
47
|
-
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
|
48
|
-
provider.load_current_resource
|
49
|
-
provider.instance_variable_get('@resource_converged').should be_true
|
50
|
-
end
|
51
|
-
|
52
|
-
it "describes the resource as not converged if there is 1 DSC resources that is not converged" do
|
53
|
-
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something'])
|
54
|
-
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
|
55
|
-
provider.load_current_resource
|
56
|
-
provider.instance_variable_get('@resource_converged').should be_false
|
57
|
-
end
|
58
|
-
|
59
|
-
it "describes the resource as not converged if there are any DSC resources that are not converged" do
|
60
|
-
dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something'])
|
61
|
-
dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something'])
|
62
|
-
|
63
|
-
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2])
|
64
|
-
provider.load_current_resource
|
65
|
-
provider.instance_variable_get('@resource_converged').should be_false
|
66
|
-
end
|
67
|
-
|
68
|
-
it "describes the resource as converged if all DSC resources that are converged" do
|
69
|
-
dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something'])
|
70
|
-
dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something'])
|
71
|
-
|
72
|
-
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2])
|
73
|
-
provider.load_current_resource
|
74
|
-
provider.instance_variable_get('@resource_converged').should be_true
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#generate_configuration_document' do
|
79
|
-
# I think integration tests should cover these cases
|
80
|
-
|
81
|
-
it 'uses configuration_document_from_script_path when a dsc script file is given' do
|
82
|
-
allow(provider).to receive(:load_current_resource)
|
83
|
-
resource.command("path_to_script")
|
84
|
-
generator = double('Chef::Util::DSC::ConfigurationGenerator')
|
85
|
-
generator.should_receive(:configuration_document_from_script_path)
|
86
|
-
allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator)
|
87
|
-
provider.send(:generate_configuration_document, 'tmp', nil)
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'uses configuration_document_from_script_code when a the dsc resource is given' do
|
91
|
-
allow(provider).to receive(:load_current_resource)
|
92
|
-
resource.code("ImADSCResource{}")
|
93
|
-
generator = double('Chef::Util::DSC::ConfigurationGenerator')
|
94
|
-
generator.should_receive(:configuration_document_from_script_code)
|
95
|
-
allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator)
|
96
|
-
provider.send(:generate_configuration_document, 'tmp', nil)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should noop if neither code or command are provided' do
|
100
|
-
allow(provider).to receive(:load_current_resource)
|
101
|
-
generator = double('Chef::Util::DSC::ConfigurationGenerator')
|
102
|
-
generator.should_receive(:configuration_document_from_script_code).with('', anything(), anything())
|
103
|
-
allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator)
|
104
|
-
provider.send(:generate_configuration_document, 'tmp', nil)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe 'action_run' do
|
109
|
-
it 'should converge the script if it is not converged' do
|
110
|
-
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something'])
|
111
|
-
allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info])
|
112
|
-
allow(provider).to receive(:run_configuration).with(:set)
|
113
|
-
|
114
|
-
provider.run_action(:run)
|
115
|
-
resource.should be_updated
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should not converge if the script is already converged' do
|
119
|
-
allow(provider).to receive(:run_configuration).with(:test).and_return([])
|
120
|
-
|
121
|
-
provider.run_action(:run)
|
122
|
-
resource.should_not be_updated
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe '#generate_description' do
|
127
|
-
it 'removes the resource name from the beginning of any log line from the LCM' do
|
128
|
-
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', true, ['resourcename doing something', 'lastline'])
|
129
|
-
provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info])
|
130
|
-
provider.send(:generate_description)[1].should match(/converge DSC resource resourcename by doing something/)
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'ignores the last line' do
|
134
|
-
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', true, ['resourcename doing something', 'lastline'])
|
135
|
-
provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info])
|
136
|
-
provider.send(:generate_description)[1].should_not match(/lastline/)
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'reports a dsc resource has not been changed if the LCM reported no change was required' do
|
140
|
-
dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', false, ['resourcename does nothing', 'lastline'])
|
141
|
-
provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info])
|
142
|
-
provider.send(:generate_description)[1].should match(/converge DSC resource resourcename by doing nothing/)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'when Dsc is not available' do
|
148
|
-
let (:node) { Chef::Node.new }
|
149
|
-
let (:events) { Chef::EventDispatch::Dispatcher.new }
|
150
|
-
let (:run_context) { Chef::RunContext.new(node, {}, events) }
|
151
|
-
let (:resource) { Chef::Resource::DscScript.new('script', run_context) }
|
152
|
-
let (:provider) { Chef::Provider::DscScript.new(resource, run_context) }
|
153
|
-
|
154
|
-
describe 'action_run' do
|
155
|
-
['1.0', '2.0', '3.0'].each do |version|
|
156
|
-
it "raises an exception for powershell version '#{version}'" do
|
157
|
-
node.automatic[:languages][:powershell][:version] = version
|
158
|
-
|
159
|
-
expect {
|
160
|
-
provider.run_action(:run)
|
161
|
-
}.to raise_error(Chef::Exceptions::NoProviderAvailable)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'raises an exception if Powershell is not present' do
|
166
|
-
expect {
|
167
|
-
provider.run_action(:run)
|
168
|
-
}.to raise_error(Chef::Exceptions::NoProviderAvailable)
|
169
|
-
end
|
170
|
-
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
@@ -1,98 +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
|
-
|
21
|
-
describe Chef::Resource::DscScript do
|
22
|
-
let(:dsc_test_resource_name) { 'DSCTest' }
|
23
|
-
|
24
|
-
context 'when Powershell supports Dsc' do
|
25
|
-
let(:dsc_test_run_context) {
|
26
|
-
node = Chef::Node.new
|
27
|
-
node.automatic[:languages][:powershell][:version] = '4.0'
|
28
|
-
empty_events = Chef::EventDispatch::Dispatcher.new
|
29
|
-
Chef::RunContext.new(node, {}, empty_events)
|
30
|
-
}
|
31
|
-
let(:dsc_test_resource) {
|
32
|
-
Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context)
|
33
|
-
}
|
34
|
-
let(:configuration_code) {'echo "This is supposed to create a configuration document."'}
|
35
|
-
let(:configuration_path) {'c:/myconfigs/formatc.ps1'}
|
36
|
-
let(:configuration_name) { 'formatme' }
|
37
|
-
let(:configuration_data) { '@{AllNodes = @( @{ NodeName = "localhost"; PSDscAllowPlainTextPassword = $true })}' }
|
38
|
-
let(:configuration_data_script) { 'c:/myconfigs/data/safedata.psd1' }
|
39
|
-
|
40
|
-
it "has a default action of `:run`" do
|
41
|
-
expect(dsc_test_resource.action).to eq(:run)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "has an allowed_actions attribute with only the `:run` and `:nothing` attributes" do
|
45
|
-
expect(dsc_test_resource.allowed_actions.to_set).to eq([:run,:nothing].to_set)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "allows the code attribute to be set" do
|
49
|
-
dsc_test_resource.code(configuration_code)
|
50
|
-
expect(dsc_test_resource.code).to eq(configuration_code)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "allows the command attribute to be set" do
|
54
|
-
dsc_test_resource.command(configuration_path)
|
55
|
-
expect(dsc_test_resource.command).to eq(configuration_path)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "allows the configuration_name attribute to be set" do
|
59
|
-
dsc_test_resource.configuration_name(configuration_name)
|
60
|
-
expect(dsc_test_resource.configuration_name).to eq(configuration_name)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "allows the configuration_data attribute to be set" do
|
64
|
-
dsc_test_resource.configuration_data(configuration_data)
|
65
|
-
expect(dsc_test_resource.configuration_data).to eq(configuration_data)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "allows the configuration_data_script attribute to be set" do
|
69
|
-
dsc_test_resource.configuration_data_script(configuration_data_script)
|
70
|
-
expect(dsc_test_resource.configuration_data_script).to eq(configuration_data_script)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "raises an ArgumentError exception if an attempt is made to set the code attribute when the command attribute is already set" do
|
74
|
-
dsc_test_resource.command(configuration_path)
|
75
|
-
expect { dsc_test_resource.code(configuration_code) }.to raise_error(ArgumentError)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "raises an ArgumentError exception if an attempt is made to set the command attribute when the code attribute is already set" do
|
79
|
-
dsc_test_resource.code(configuration_code)
|
80
|
-
expect { dsc_test_resource.command(configuration_path) }.to raise_error(ArgumentError)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "raises an ArgumentError exception if an attempt is made to set the configuration_name attribute when the code attribute is already set" do
|
84
|
-
dsc_test_resource.code(configuration_code)
|
85
|
-
expect { dsc_test_resource.configuration_name(configuration_name) }.to raise_error(ArgumentError)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "raises an ArgumentError exception if an attempt is made to set the configuration_data attribute when the configuration_data_script attribute is already set" do
|
89
|
-
dsc_test_resource.configuration_data_script(configuration_data_script)
|
90
|
-
expect { dsc_test_resource.configuration_data(configuration_data) }.to raise_error(ArgumentError)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "raises an ArgumentError exception if an attempt is made to set the configuration_data_script attribute when the configuration_data attribute is already set" do
|
94
|
-
dsc_test_resource.configuration_data(configuration_data)
|
95
|
-
expect { dsc_test_resource.configuration_data_script(configuration_data_script) }.to raise_error(ArgumentError)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,171 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Jay Mundrawala <jmundrawala@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 'chef'
|
20
|
-
require 'chef/util/dsc/configuration_generator'
|
21
|
-
|
22
|
-
describe Chef::Util::DSC::ConfigurationGenerator do
|
23
|
-
let(:conf_man) do
|
24
|
-
node = Chef::Node.new
|
25
|
-
Chef::Util::DSC::ConfigurationGenerator.new(node, 'tmp')
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#validate_configuration_name!' do
|
29
|
-
it 'should not raise an error if a name contains all upper case letters' do
|
30
|
-
conf_man.send(:validate_configuration_name!, "HELLO")
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should not raise an error if the name contains all lower case letters' do
|
34
|
-
conf_man.send(:validate_configuration_name!, "hello")
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should not raise an error if no special characters are used except _' do
|
38
|
-
conf_man.send(:validate_configuration_name!, "hello_world")
|
39
|
-
end
|
40
|
-
|
41
|
-
%w{! @ # $ % ^ & * & * ( ) - = + \{ \} . ? < > \\ /}.each do |sym|
|
42
|
-
it "raises an Argument error if it configuration name contains #{sym}" do
|
43
|
-
expect {
|
44
|
-
conf_man.send(:validate_configuration_name!, "Hello#{sym}")
|
45
|
-
}.to raise_error(ArgumentError)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#get_merged_configuration_flags" do
|
51
|
-
context 'when strings are used as switches' do
|
52
|
-
it 'should merge the hash if there are no restricted switches' do
|
53
|
-
merged = conf_man.send(:get_merged_configuration_flags!, {'flag' => 'a'}, 'hello')
|
54
|
-
merged.should include(:flag)
|
55
|
-
merged[:flag].should eql('a')
|
56
|
-
merged.should include(:outputpath)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should raise an ArgumentError if you try to override outputpath' do
|
60
|
-
expect {
|
61
|
-
conf_man.send(:get_merged_configuration_flags!, {'outputpath' => 'a'}, 'hello')
|
62
|
-
}.to raise_error(ArgumentError)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should be case insensitive for switches that are not allowed' do
|
66
|
-
expect {
|
67
|
-
conf_man.send(:get_merged_configuration_flags!, {'OutputPath' => 'a'}, 'hello')
|
68
|
-
}.to raise_error(ArgumentError)
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should be case insensitive to switches that are allowed' do
|
72
|
-
merged = conf_man.send(:get_merged_configuration_flags!, {'FLAG' => 'a'}, 'hello')
|
73
|
-
merged.should include(:flag)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when symbols are used as switches' do
|
78
|
-
it 'should merge the hash if there are no restricted switches' do
|
79
|
-
merged = conf_man.send(:get_merged_configuration_flags!, {:flag => 'a'}, 'hello')
|
80
|
-
merged.should include(:flag)
|
81
|
-
merged[:flag].should eql('a')
|
82
|
-
merged.should include(:outputpath)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should raise an ArgumentError if you try to override outputpath' do
|
86
|
-
expect {
|
87
|
-
conf_man.send(:get_merged_configuration_flags!, {:outputpath => 'a'}, 'hello')
|
88
|
-
}.to raise_error(ArgumentError)
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'should be case insensitive for switches that are not allowed' do
|
92
|
-
expect {
|
93
|
-
conf_man.send(:get_merged_configuration_flags!, {:OutputPath => 'a'}, 'hello')
|
94
|
-
}.to raise_error(ArgumentError)
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should be case insensitive to switches that are allowed' do
|
98
|
-
merged = conf_man.send(:get_merged_configuration_flags!, {:FLAG => 'a'}, 'hello')
|
99
|
-
merged.should include(:flag)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context 'when there are no flags' do
|
104
|
-
it 'should supply an output path if configuration_flags is an empty hash' do
|
105
|
-
merged = conf_man.send(:get_merged_configuration_flags!, {}, 'hello')
|
106
|
-
merged.should include(:outputpath)
|
107
|
-
merged.length.should eql(1)
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should supply an output path if configuration_flags is an empty hash' do
|
111
|
-
merged = conf_man.send(:get_merged_configuration_flags!, nil, 'hello')
|
112
|
-
merged.should include(:outputpath)
|
113
|
-
merged.length.should eql(1)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# What should happen if configuration flags contains duplicates?
|
118
|
-
# flagA => 'a', flaga => 'a'
|
119
|
-
# or
|
120
|
-
# flagA => 'a', flaga => 'b'
|
121
|
-
#
|
122
|
-
end
|
123
|
-
|
124
|
-
describe '#write_document_generation_script' do
|
125
|
-
let(:file_like_object) { double("file like object") }
|
126
|
-
|
127
|
-
it "should write the input to a file" do
|
128
|
-
allow(File).to receive(:open).and_yield(file_like_object)
|
129
|
-
allow(File).to receive(:join) do |a, b|
|
130
|
-
[a,b].join("++")
|
131
|
-
end
|
132
|
-
allow(file_like_object).to receive(:write)
|
133
|
-
conf_man.send(:write_document_generation_script, 'file', 'hello')
|
134
|
-
expect(file_like_object).to have_received(:write)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "#find_configuration_document" do
|
139
|
-
it "should find the mof file" do
|
140
|
-
# These tests seem way too implementation specific. Unfortunatly, File and Dir
|
141
|
-
# need to be mocked because they are OS specific
|
142
|
-
allow(File).to receive(:join) do |a, b|
|
143
|
-
[a,b].join("++")
|
144
|
-
end
|
145
|
-
|
146
|
-
allow(Dir).to receive(:entries).with("tmp++hello") {['f1', 'f2', 'hello.mof', 'f3']}
|
147
|
-
expect(conf_man.send(:find_configuration_document, 'hello')).to eql('tmp++hello++hello.mof')
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should return nil if the mof file is not found" do
|
151
|
-
allow(File).to receive(:join) do |a, b|
|
152
|
-
[a,b].join("++")
|
153
|
-
end
|
154
|
-
allow(Dir).to receive(:entries).with("tmp++hello") {['f1', 'f2', 'f3']}
|
155
|
-
expect(conf_man.send(:find_configuration_document, 'hello')).to be_nil
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe "#configuration_code" do
|
160
|
-
it "should build dsc" do
|
161
|
-
dsc = conf_man.send(:configuration_code, 'archive{}', 'hello')
|
162
|
-
found_configuration = false
|
163
|
-
dsc.split(';').each do |command|
|
164
|
-
if command.downcase =~ /\s*configuration\s+'hello'\s*\{\s*node\s+'localhost'\s*\{\s*archive\s*\{\s*\}\s*\}\s*\}\s*/
|
165
|
-
found_configuration = true
|
166
|
-
end
|
167
|
-
end
|
168
|
-
expect(found_configuration).to be_true
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|