microwave 1.0.4 → 11.400.2
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.
- data/CONTRIBUTING.md +155 -0
- data/README.md +89 -0
- data/Rakefile +2 -2
- data/bin/chef-apply +25 -0
- data/bin/chef-shell +34 -0
- data/bin/chef-solo +0 -2
- data/bin/shef +6 -5
- data/lib/chef.rb +2 -4
- data/spec/data/big_json.json +2 -1
- data/spec/data/big_json_plus_one.json +2 -1
- data/spec/data/cookbooks/chefignore +2 -0
- data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
- data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
- data/spec/data/git_bundles/sinatra-test-app-with-callback-files.gitbundle +0 -0
- data/spec/data/git_bundles/sinatra-test-app-with-symlinks.gitbundle +0 -0
- data/spec/data/git_bundles/sinatra-test-app.gitbundle +0 -0
- data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
- data/spec/data/nodes/default.rb +3 -3
- data/spec/data/nodes/test.example.com.rb +3 -3
- data/spec/data/nodes/test.rb +3 -3
- data/spec/data/partial_one.erb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
- data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
- data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
- data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
- data/spec/data/shef-config.rb +10 -0
- data/spec/functional/dsl/registry_helper_spec.rb +63 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +0 -2
- data/spec/functional/knife/exec_spec.rb +4 -6
- data/spec/functional/knife/smoke_test.rb +34 -0
- data/spec/functional/knife/ssh_spec.rb +64 -3
- data/spec/functional/resource/cookbook_file_spec.rb +33 -2
- data/spec/functional/resource/deploy_revision_spec.rb +515 -0
- data/spec/functional/resource/directory_spec.rb +4 -0
- data/spec/functional/resource/file_spec.rb +56 -22
- data/spec/functional/resource/link_spec.rb +12 -10
- data/spec/functional/resource/registry_spec.rb +572 -0
- data/spec/functional/resource/remote_directory_spec.rb +142 -36
- data/spec/functional/resource/remote_file_spec.rb +28 -3
- data/spec/functional/resource/template_spec.rb +23 -2
- data/spec/functional/run_lock_spec.rb +238 -0
- data/spec/functional/shell_spec.rb +101 -0
- data/spec/functional/tiny_server_spec.rb +5 -4
- data/spec/functional/win32/registry_helper_spec.rb +632 -0
- data/spec/functional/win32/security_spec.rb +37 -0
- data/spec/spec_helper.rb +15 -3
- data/spec/stress/win32/security_spec.rb +5 -5
- data/spec/support/chef_helpers.rb +14 -3
- data/spec/support/lib/chef/resource/cat.rb +3 -5
- data/spec/support/lib/chef/resource/one_two_three_four.rb +8 -10
- data/spec/support/lib/chef/resource/zen_master.rb +8 -10
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/platform_helpers.rb +18 -0
- data/spec/support/shared/functional/directory_resource.rb +85 -23
- data/spec/support/shared/functional/file_resource.rb +198 -53
- data/spec/support/shared/functional/securable_resource.rb +140 -105
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +375 -0
- data/spec/support/shared/unit/file_system_support.rb +110 -0
- data/spec/support/shared/unit/platform_introspector.rb +162 -0
- data/spec/tiny_server.rb +29 -10
- data/spec/unit/api_client/registration_spec.rb +172 -0
- data/spec/unit/api_client_spec.rb +156 -103
- data/spec/unit/application/apply.rb +84 -0
- data/spec/unit/application/knife_spec.rb +5 -0
- data/spec/unit/application_spec.rb +57 -2
- data/spec/unit/chef_fs/diff_spec.rb +329 -0
- data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
- data/spec/unit/chef_fs/file_system/chef_server_root_dir_spec.rb +237 -0
- data/spec/unit/chef_fs/file_system/cookbooks_dir_spec.rb +568 -0
- data/spec/unit/chef_fs/file_system/data_bags_dir_spec.rb +220 -0
- data/spec/unit/chef_fs/file_system_spec.rb +136 -0
- data/spec/unit/client_spec.rb +188 -16
- data/spec/unit/config_spec.rb +54 -4
- data/spec/unit/cookbook/chefignore_spec.rb +2 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +48 -109
- data/spec/unit/cookbook_loader_spec.rb +153 -91
- data/spec/unit/cookbook_manifest_spec.rb +81 -81
- data/spec/unit/cookbook_spec.rb +3 -20
- data/spec/unit/cookbook_version_spec.rb +23 -122
- data/spec/unit/digester_spec.rb +50 -0
- data/spec/unit/dsl/data_query_spec.rb +66 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
- data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +126 -10
- data/spec/unit/environment_spec.rb +0 -130
- data/spec/unit/exceptions_spec.rb +2 -3
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +23 -3
- data/spec/unit/json_compat_spec.rb +69 -0
- data/spec/unit/knife/bootstrap_spec.rb +81 -28
- data/spec/unit/knife/client_reregister_spec.rb +23 -22
- data/spec/unit/knife/configure_spec.rb +29 -26
- data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
- data/spec/unit/knife/cookbook_site_install_spec.rb +12 -2
- data/spec/unit/knife/cookbook_test_spec.rb +1 -0
- data/spec/unit/knife/cookbook_upload_spec.rb +41 -2
- data/spec/unit/knife/core/bootstrap_context_spec.rb +8 -1
- data/spec/unit/knife/core/ui_spec.rb +156 -7
- data/spec/unit/knife/data_bag_create_spec.rb +14 -0
- data/spec/unit/knife/data_bag_edit_spec.rb +14 -4
- data/spec/unit/knife/data_bag_from_file_spec.rb +17 -5
- data/spec/unit/knife/data_bag_show_spec.rb +11 -4
- data/spec/unit/knife/index_rebuild_spec.rb +96 -33
- data/spec/unit/knife/knife_help.rb +7 -7
- data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
- data/spec/unit/knife/ssh_spec.rb +121 -15
- data/spec/unit/knife/status_spec.rb +2 -2
- data/spec/unit/knife/user_create_spec.rb +86 -0
- data/spec/unit/knife/user_delete_spec.rb +39 -0
- data/spec/unit/knife/user_edit_spec.rb +42 -0
- data/spec/unit/knife/user_list_spec.rb +32 -0
- data/spec/unit/knife/user_reregister_spec.rb +53 -0
- data/spec/unit/knife/user_show_spec.rb +41 -0
- data/spec/unit/knife_spec.rb +53 -0
- data/spec/unit/lwrp_spec.rb +59 -17
- data/spec/unit/mixin/checksum_spec.rb +2 -2
- data/spec/unit/mixin/deep_merge_spec.rb +56 -491
- data/spec/unit/mixin/deprecation_spec.rb +23 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +6 -1
- data/spec/unit/mixin/params_validate_spec.rb +4 -2
- data/spec/unit/mixin/securable_spec.rb +5 -3
- data/spec/unit/mixin/template_spec.rb +119 -0
- data/spec/unit/node/attribute_spec.rb +272 -137
- data/spec/unit/node/immutable_collections_spec.rb +139 -0
- data/spec/unit/node_spec.rb +411 -339
- data/spec/unit/platform_spec.rb +8 -8
- data/spec/unit/provider/breakpoint_spec.rb +8 -8
- data/spec/unit/provider/cookbook_file_spec.rb +4 -8
- data/spec/unit/provider/deploy/revision_spec.rb +2 -8
- data/spec/unit/provider/deploy_spec.rb +6 -40
- data/spec/unit/provider/directory_spec.rb +103 -68
- data/spec/unit/provider/erl_call_spec.rb +0 -2
- data/spec/unit/provider/file_spec.rb +69 -59
- data/spec/unit/provider/git_spec.rb +0 -10
- data/spec/unit/provider/group/groupadd_spec.rb +1 -1
- data/spec/unit/provider/group/usermod_spec.rb +2 -2
- data/spec/unit/provider/http_request_spec.rb +28 -69
- data/spec/unit/provider/ifconfig_spec.rb +2 -2
- data/spec/unit/provider/link_spec.rb +1 -1
- data/spec/unit/provider/ohai_spec.rb +4 -4
- data/spec/unit/provider/package/apt_spec.rb +0 -1
- data/spec/unit/provider/package/ips_spec.rb +0 -1
- data/spec/unit/provider/package/rubygems_spec.rb +0 -18
- data/spec/unit/provider/package/yum_spec.rb +79 -15
- data/spec/unit/provider/package_spec.rb +7 -5
- data/spec/unit/provider/registry_key_spec.rb +269 -0
- data/spec/unit/provider/remote_directory_spec.rb +24 -7
- data/spec/unit/provider/remote_file_spec.rb +36 -0
- data/spec/unit/provider/route_spec.rb +3 -6
- data/spec/unit/provider/ruby_block_spec.rb +8 -0
- data/spec/unit/provider/service/arch_service_spec.rb +4 -4
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/freebsd_service_spec.rb +4 -4
- data/spec/unit/provider/service/init_service_spec.rb +26 -3
- data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
- data/spec/unit/provider/service/invokercd_service_spec.rb +3 -3
- data/spec/unit/provider/service/redhat_spec.rb +1 -1
- data/spec/unit/provider/service/simple_service_spec.rb +3 -3
- data/spec/unit/provider/service/upstart_service_spec.rb +7 -7
- data/spec/unit/provider/service_spec.rb +2 -2
- data/spec/unit/provider/subversion_spec.rb +1 -1
- data/spec/unit/provider/template_spec.rb +35 -11
- data/spec/unit/provider/user/dscl_spec.rb +57 -31
- data/spec/unit/provider/user_spec.rb +7 -16
- data/spec/unit/provider_spec.rb +4 -3
- data/spec/unit/recipe_spec.rb +10 -8
- data/spec/unit/registry_helper_spec.rb +376 -0
- data/spec/unit/resource/log_spec.rb +9 -0
- data/spec/unit/resource/registry_key_spec.rb +171 -0
- data/spec/unit/resource/remote_file_spec.rb +21 -23
- data/spec/unit/resource/ruby_block_spec.rb +7 -3
- data/spec/unit/resource/service_spec.rb +11 -0
- data/spec/unit/resource_spec.rb +27 -4
- data/spec/unit/rest/auth_credentials_spec.rb +2 -14
- data/spec/unit/rest_spec.rb +122 -187
- data/spec/unit/run_context/cookbook_compiler_spec.rb +181 -0
- data/spec/unit/run_context_spec.rb +18 -4
- data/spec/unit/run_list_spec.rb +0 -209
- data/spec/unit/run_lock_spec.rb +37 -0
- data/spec/unit/runner_spec.rb +101 -2
- data/spec/unit/scan_access_control_spec.rb +4 -4
- data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
- data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
- data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +12 -12
- data/spec/unit/shell_out_spec.rb +18 -0
- data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
- data/spec/unit/user_spec.rb +255 -0
- metadata +162 -157
- data/README.rdoc +0 -177
- data/spec/unit/certificate_spec.rb +0 -76
- data/spec/unit/checksum_cache_spec.rb +0 -209
- data/spec/unit/checksum_spec.rb +0 -94
- data/spec/unit/couchdb_spec.rb +0 -274
- data/spec/unit/index_queue_spec.rb +0 -391
- data/spec/unit/json_compat_spect.rb +0 -53
- data/spec/unit/mixin/language_spec.rb +0 -305
- data/spec/unit/openid_registration_spec.rb +0 -153
- data/spec/unit/solr_query/query_transform_spec.rb +0 -454
- data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
- data/spec/unit/solr_query_spec.rb +0 -203
- data/spec/unit/webui_user_spec.rb +0 -238
@@ -346,11 +346,13 @@ describe Chef::Provider::Package do
|
|
346
346
|
Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, @cookbook_repo) }
|
347
347
|
|
348
348
|
@node = Chef::Node.new
|
349
|
-
|
349
|
+
cl = Chef::CookbookLoader.new(@cookbook_repo)
|
350
|
+
cl.load_cookbooks
|
351
|
+
@cookbook_collection = Chef::CookbookCollection.new(cl)
|
350
352
|
@run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
|
351
353
|
|
352
|
-
@node[:platform] = 'PLATFORM: just testing'
|
353
|
-
@node[:platform_version] = 'PLATFORM VERSION: just testing'
|
354
|
+
@node.automatic_attrs[:platform] = 'PLATFORM: just testing'
|
355
|
+
@node.automatic_attrs[:platform_version] = 'PLATFORM VERSION: just testing'
|
354
356
|
|
355
357
|
@new_resource.response_file('java.response')
|
356
358
|
@new_resource.cookbook_name = 'java'
|
@@ -386,8 +388,8 @@ describe Chef::Provider::Package do
|
|
386
388
|
|
387
389
|
describe "when installing the preseed file to the cache location" do
|
388
390
|
before do
|
389
|
-
@node[:platform] = :just_testing
|
390
|
-
@node[:platform_version] = :just_testing
|
391
|
+
@node.automatic_attrs[:platform] = :just_testing
|
392
|
+
@node.automatic_attrs[:platform_version] = :just_testing
|
391
393
|
|
392
394
|
@response_file_destination = Dir.tmpdir + '/preseed--java--java-6.seed'
|
393
395
|
|
@@ -0,0 +1,269 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Lamont Granquist (lamont@opscode.com)
|
3
|
+
# Copyright:: Copyright (c) 2012 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::Provider::RegistryKey do
|
22
|
+
|
23
|
+
let(:testval1) { { :name => "one", :type => :string, :data => "1" } }
|
24
|
+
let(:testval1_wrong_type) { { :name => "one", :type => :multi_string, :data => "1" } }
|
25
|
+
let(:testval1_wrong_data) { { :name => "one", :type => :string, :data => "2" } }
|
26
|
+
let(:testval2) { { :name => "two", :type => :string, :data => "2" } }
|
27
|
+
let(:testkey1) { 'HKLM\Software\Opscode\Testing' }
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
@node = Chef::Node.new
|
31
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
32
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
33
|
+
|
34
|
+
@new_resource = Chef::Resource::RegistryKey.new("windows is fun", @run_context)
|
35
|
+
@new_resource.key testkey1
|
36
|
+
@new_resource.values( testval1 )
|
37
|
+
@new_resource.recursive false
|
38
|
+
|
39
|
+
@provider = Chef::Provider::RegistryKey.new(@new_resource, @run_context)
|
40
|
+
|
41
|
+
@provider.stub!(:running_on_windows!).and_return(true)
|
42
|
+
@double_registry = double(Chef::Win32::Registry)
|
43
|
+
@provider.stub!(:registry).and_return(@double_registry)
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "when first created" do
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "executing load_current_resource" do
|
50
|
+
describe "when the key exists" do
|
51
|
+
before(:each) do
|
52
|
+
@double_registry.should_receive(:key_exists?).with(testkey1).and_return(true)
|
53
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
|
54
|
+
@provider.load_current_resource
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set the key of the current resource to the key of the new resource" do
|
58
|
+
@provider.current_resource.key.should == @new_resource.key
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should set the architecture of the current resource to the architecture of the new resource" do
|
62
|
+
@provider.current_resource.architecture.should == @new_resource.architecture
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should set the recursive flag of the current resource to the recursive flag of the new resource" do
|
66
|
+
@provider.current_resource.recursive.should == @new_resource.recursive
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should set the values of the current resource to the values it got from the registry" do
|
70
|
+
@provider.current_resource.values.should == [ testval2 ]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "when the key does not exist" do
|
75
|
+
before(:each) do
|
76
|
+
@double_registry.should_receive(:key_exists?).with(testkey1).and_return(false)
|
77
|
+
@provider.load_current_resource
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should set the values in the current resource to empty array" do
|
81
|
+
@provider.current_resource.values.should == []
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "action_create" do
|
87
|
+
context "when the key exists" do
|
88
|
+
before(:each) do
|
89
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
|
90
|
+
end
|
91
|
+
it "should do nothing if the key and the value both exist" do
|
92
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
|
93
|
+
@double_registry.should_not_receive(:set_value)
|
94
|
+
@provider.load_current_resource
|
95
|
+
@provider.action_create
|
96
|
+
end
|
97
|
+
it "should create the value if the key exists but the value does not" do
|
98
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
|
99
|
+
@double_registry.should_receive(:set_value).with(testkey1, testval1)
|
100
|
+
@provider.load_current_resource
|
101
|
+
@provider.action_create
|
102
|
+
end
|
103
|
+
it "should set the value if the key exists but the data does not match" do
|
104
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_data )
|
105
|
+
@double_registry.should_receive(:set_value).with(testkey1, testval1)
|
106
|
+
@provider.load_current_resource
|
107
|
+
@provider.action_create
|
108
|
+
end
|
109
|
+
it "should set the value if the key exists but the type does not match" do
|
110
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_type )
|
111
|
+
@double_registry.should_receive(:set_value).with(testkey1, testval1)
|
112
|
+
@provider.load_current_resource
|
113
|
+
@provider.action_create
|
114
|
+
end
|
115
|
+
end
|
116
|
+
context "when the key exists and the values in the new resource are empty" do
|
117
|
+
it "when a value is in the key, it should do nothing" do
|
118
|
+
@provider.new_resource.values([])
|
119
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
|
120
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
|
121
|
+
@double_registry.should_not_receive(:create_key)
|
122
|
+
@double_registry.should_not_receive(:set_value)
|
123
|
+
@provider.load_current_resource
|
124
|
+
@provider.action_create
|
125
|
+
end
|
126
|
+
it "when no value is in the key, it should do nothing" do
|
127
|
+
@provider.new_resource.values([])
|
128
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
|
129
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( nil )
|
130
|
+
@double_registry.should_not_receive(:create_key)
|
131
|
+
@double_registry.should_not_receive(:set_value)
|
132
|
+
@provider.load_current_resource
|
133
|
+
@provider.action_create
|
134
|
+
end
|
135
|
+
end
|
136
|
+
context "when the key does not exist" do
|
137
|
+
before(:each) do
|
138
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
|
139
|
+
end
|
140
|
+
it "should create the key and the value" do
|
141
|
+
@double_registry.should_receive(:create_key).with(testkey1, false)
|
142
|
+
@double_registry.should_receive(:set_value).with(testkey1, testval1)
|
143
|
+
@provider.load_current_resource
|
144
|
+
@provider.action_create
|
145
|
+
end
|
146
|
+
end
|
147
|
+
context "when the key does not exist and the values in the new resource are empty" do
|
148
|
+
it "should create the key" do
|
149
|
+
@new_resource.values([])
|
150
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
|
151
|
+
@double_registry.should_receive(:create_key).with(testkey1, false)
|
152
|
+
@double_registry.should_not_receive(:set_value)
|
153
|
+
@provider.load_current_resource
|
154
|
+
@provider.action_create
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "action_create_if_missing" do
|
160
|
+
context "when the key exists" do
|
161
|
+
before(:each) do
|
162
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
|
163
|
+
end
|
164
|
+
it "should do nothing if the key and the value both exist" do
|
165
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
|
166
|
+
@double_registry.should_not_receive(:set_value)
|
167
|
+
@provider.load_current_resource
|
168
|
+
@provider.action_create_if_missing
|
169
|
+
end
|
170
|
+
it "should create the value if the key exists but the value does not" do
|
171
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
|
172
|
+
@double_registry.should_receive(:set_value).with(testkey1, testval1)
|
173
|
+
@provider.load_current_resource
|
174
|
+
@provider.action_create_if_missing
|
175
|
+
end
|
176
|
+
it "should not set the value if the key exists but the data does not match" do
|
177
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_data )
|
178
|
+
@double_registry.should_not_receive(:set_value)
|
179
|
+
@provider.load_current_resource
|
180
|
+
@provider.action_create_if_missing
|
181
|
+
end
|
182
|
+
it "should not set the value if the key exists but the type does not match" do
|
183
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_type )
|
184
|
+
@double_registry.should_not_receive(:set_value)
|
185
|
+
@provider.load_current_resource
|
186
|
+
@provider.action_create_if_missing
|
187
|
+
end
|
188
|
+
end
|
189
|
+
context "when the key does not exist" do
|
190
|
+
before(:each) do
|
191
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
|
192
|
+
end
|
193
|
+
it "should create the key and the value" do
|
194
|
+
@double_registry.should_receive(:create_key).with(testkey1, false)
|
195
|
+
@double_registry.should_receive(:set_value).with(testkey1, testval1)
|
196
|
+
@provider.load_current_resource
|
197
|
+
@provider.action_create_if_missing
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
describe "action_delete" do
|
203
|
+
context "when the key exists" do
|
204
|
+
before(:each) do
|
205
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
|
206
|
+
end
|
207
|
+
it "deletes the value when the value exists" do
|
208
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
|
209
|
+
@double_registry.should_receive(:delete_value).with(testkey1, testval1)
|
210
|
+
@provider.load_current_resource
|
211
|
+
@provider.action_delete
|
212
|
+
end
|
213
|
+
it "deletes the value when the value exists, but the type is wrong" do
|
214
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_type )
|
215
|
+
@double_registry.should_receive(:delete_value).with(testkey1, testval1)
|
216
|
+
@provider.load_current_resource
|
217
|
+
@provider.action_delete
|
218
|
+
end
|
219
|
+
it "deletes the value when the value exists, but the data is wrong" do
|
220
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1_wrong_data )
|
221
|
+
@double_registry.should_receive(:delete_value).with(testkey1, testval1)
|
222
|
+
@provider.load_current_resource
|
223
|
+
@provider.action_delete
|
224
|
+
end
|
225
|
+
it "does not delete the value when the value does not exist" do
|
226
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
|
227
|
+
@double_registry.should_not_receive(:delete_value)
|
228
|
+
@provider.load_current_resource
|
229
|
+
@provider.action_delete
|
230
|
+
end
|
231
|
+
end
|
232
|
+
context "when the key does not exist" do
|
233
|
+
before(:each) do
|
234
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
|
235
|
+
end
|
236
|
+
it "does nothing" do
|
237
|
+
@double_registry.should_not_receive(:delete_value)
|
238
|
+
@provider.load_current_resource
|
239
|
+
@provider.action_delete
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
describe "action_delete_key" do
|
245
|
+
context "when the key exists" do
|
246
|
+
before(:each) do
|
247
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(true)
|
248
|
+
end
|
249
|
+
it "deletes the key" do
|
250
|
+
@double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
|
251
|
+
@double_registry.should_receive(:delete_key).with(testkey1, false)
|
252
|
+
@provider.load_current_resource
|
253
|
+
@provider.action_delete_key
|
254
|
+
end
|
255
|
+
end
|
256
|
+
context "when the key does not exist" do
|
257
|
+
before(:each) do
|
258
|
+
@double_registry.should_receive(:key_exists?).twice.with(testkey1).and_return(false)
|
259
|
+
end
|
260
|
+
it "does nothing" do
|
261
|
+
@double_registry.should_not_receive(:delete_key)
|
262
|
+
@provider.load_current_resource
|
263
|
+
@provider.action_delete_key
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
269
|
+
|
@@ -32,7 +32,7 @@ describe Chef::Provider::RemoteDirectory do
|
|
32
32
|
#to not have this line. Only affects updating state fields.
|
33
33
|
Chef::Provider::CookbookFile.any_instance.stub(:update_new_file_state)
|
34
34
|
|
35
|
-
@resource = Chef::Resource::RemoteDirectory.new("
|
35
|
+
@resource = Chef::Resource::RemoteDirectory.new(File.join(Dir.tmpdir, "tafty"))
|
36
36
|
# in CHEF_SPEC_DATA/cookbooks/openldap/files/default/remotedir
|
37
37
|
@resource.source "remotedir"
|
38
38
|
@resource.cookbook('openldap')
|
@@ -41,7 +41,9 @@ describe Chef::Provider::RemoteDirectory do
|
|
41
41
|
Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, @cookbook_repo) }
|
42
42
|
|
43
43
|
@node = Chef::Node.new
|
44
|
-
|
44
|
+
cl = Chef::CookbookLoader.new(@cookbook_repo)
|
45
|
+
cl.load_cookbooks
|
46
|
+
@cookbook_collection = Chef::CookbookCollection.new(cl)
|
45
47
|
|
46
48
|
@events = Chef::EventDispatch::Dispatcher.new
|
47
49
|
@run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
|
@@ -50,6 +52,21 @@ describe Chef::Provider::RemoteDirectory do
|
|
50
52
|
@provider.current_resource = @resource.clone
|
51
53
|
end
|
52
54
|
|
55
|
+
describe "when the contents of the directory changed on the first run and not on the second run" do
|
56
|
+
before do
|
57
|
+
@resource_second_run = @resource.clone
|
58
|
+
@provider_second_run = Chef::Provider::RemoteDirectory.new(@resource_second_run, @run_context)
|
59
|
+
@provider.run_action(:create)
|
60
|
+
@provider_second_run.run_action(:create)
|
61
|
+
end
|
62
|
+
it "identifies that the state has changed the after first run" do
|
63
|
+
@provider_second_run.new_resource.updated_by_last_action? == true
|
64
|
+
end
|
65
|
+
it "identifies that the state has not changed after the second run" do
|
66
|
+
@provider_second_run.new_resource.updated_by_last_action? == false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
53
70
|
describe "when access control is configured on the resource" do
|
54
71
|
before do
|
55
72
|
@resource.mode "0750"
|
@@ -65,8 +82,8 @@ describe Chef::Provider::RemoteDirectory do
|
|
65
82
|
end
|
66
83
|
|
67
84
|
it "configures access control on intermediate directorys" do
|
68
|
-
directory_resource = @provider.send(:resource_for_directory, "
|
69
|
-
directory_resource.path.should == "
|
85
|
+
directory_resource = @provider.send(:resource_for_directory, File.join(Dir.tmpdir, "intermediate_dir"))
|
86
|
+
directory_resource.path.should == File.join(Dir.tmpdir, "intermediate_dir")
|
70
87
|
directory_resource.mode.should == "0750"
|
71
88
|
directory_resource.group.should == "wheel"
|
72
89
|
directory_resource.owner.should == "root"
|
@@ -89,8 +106,8 @@ describe Chef::Provider::RemoteDirectory do
|
|
89
106
|
|
90
107
|
describe "when creating the remote directory" do
|
91
108
|
before do
|
92
|
-
@node[:platform] = :just_testing
|
93
|
-
@node[:platform_version] = :just_testing
|
109
|
+
@node.automatic_attrs[:platform] = :just_testing
|
110
|
+
@node.automatic_attrs[:platform_version] = :just_testing
|
94
111
|
|
95
112
|
@destination_dir = Dir.mktmpdir << "/remote_directory_test"
|
96
113
|
@resource.path(@destination_dir)
|
@@ -164,7 +181,7 @@ describe Chef::Provider::RemoteDirectory do
|
|
164
181
|
::File.exist?(@destination_dir + '/a/multiply/nested/directory/qux.txt').should be_false
|
165
182
|
end
|
166
183
|
|
167
|
-
it "removes directory symlinks properly" do
|
184
|
+
it "removes directory symlinks properly", :not_supported_on_win2k3 do
|
168
185
|
symlinked_dir_path = @destination_dir + '/symlinked_dir'
|
169
186
|
@provider.action = :create
|
170
187
|
@provider.run_action
|
@@ -79,6 +79,42 @@ describe Chef::Provider::RemoteFile, "action_create" do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
shared_examples_for "source specified with multiple URIs" do
|
83
|
+
it "should try to download the next URI when the first one fails" do
|
84
|
+
@rest.should_receive(:streaming_request).with("http://foo", {}).once.and_raise(SocketError)
|
85
|
+
@rest.should_receive(:streaming_request).with("http://bar", {}).once.and_return(@tempfile)
|
86
|
+
@provider.run_action(:create)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should raise an exception when all the URIs fail" do
|
90
|
+
@rest.should_receive(:streaming_request).with("http://foo", {}).once.and_raise(SocketError)
|
91
|
+
@rest.should_receive(:streaming_request).with("http://bar", {}).once.and_raise(SocketError)
|
92
|
+
lambda { @provider.run_action(:create) }.should raise_error(SocketError)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should download from only one URI when the first one works" do
|
96
|
+
@rest.should_receive(:streaming_request).once.and_return(@tempfile)
|
97
|
+
@provider.run_action(:create)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "and the source specifies multiple URIs using multiple arguments" do
|
103
|
+
it_should_behave_like "source specified with multiple URIs"
|
104
|
+
|
105
|
+
before(:each) do
|
106
|
+
@resource.source("http://foo", "http://bar")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "and the source specifies multiple URIs using an array" do
|
111
|
+
it_should_behave_like "source specified with multiple URIs"
|
112
|
+
|
113
|
+
before(:each) do
|
114
|
+
@resource.source([ "http://foo", "http://bar" ])
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
82
118
|
describe "and the resource specifies a checksum" do
|
83
119
|
|
84
120
|
describe "and the existing file matches the checksum exactly" do
|
@@ -51,7 +51,7 @@ describe Chef::Provider::Route do
|
|
51
51
|
describe Chef::Provider::Route, "load_current_resource" do
|
52
52
|
context "on linux" do
|
53
53
|
before do
|
54
|
-
@node[:os] = 'linux'
|
54
|
+
@node.automatic_attrs[:os] = 'linux'
|
55
55
|
routing_table = "Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n" +
|
56
56
|
"eth0 0064A8C0 0984A8C0 0003 0 0 0 00FFFFFF 0 0 0\n"
|
57
57
|
route_file = StringIO.new(routing_table)
|
@@ -198,20 +198,18 @@ describe Chef::Provider::Route do
|
|
198
198
|
describe Chef::Provider::Route, "generate_config method" do
|
199
199
|
%w[ centos redhat fedora ].each do |platform|
|
200
200
|
it "should write a route file on #{platform} platform" do
|
201
|
-
@node[:platform] = platform
|
201
|
+
@node.automatic_attrs[:platform] = platform
|
202
202
|
|
203
203
|
route_file = StringIO.new
|
204
204
|
File.should_receive(:new).with("/etc/sysconfig/network-scripts/route-eth0", "w").and_return(route_file)
|
205
205
|
#Chef::Log.should_receive(:debug).with("route[10.0.0.10] writing route.eth0\n10.0.0.10 via 10.0.0.9\n")
|
206
206
|
@run_context.resource_collection << @new_resource
|
207
|
-
|
208
207
|
@provider.generate_config
|
209
|
-
@provider.converge
|
210
208
|
end
|
211
209
|
end
|
212
210
|
|
213
211
|
it "should put all routes for a device in a route config file" do
|
214
|
-
@node[:platform] = 'centos'
|
212
|
+
@node.automatic_attrs[:platform] = 'centos'
|
215
213
|
|
216
214
|
route_file = StringIO.new
|
217
215
|
File.should_receive(:new).and_return(route_file)
|
@@ -220,7 +218,6 @@ describe Chef::Provider::Route do
|
|
220
218
|
@run_context.resource_collection << Chef::Resource::Route.new('192.168.3.0/24 via 192.168.0.1')
|
221
219
|
|
222
220
|
@provider.generate_config
|
223
|
-
@provider.converge
|
224
221
|
route_file.string.split("\n").should have(3).items
|
225
222
|
route_file.string.should match(/^192.168.1.0\/24 via 192.168.0.1$/)
|
226
223
|
route_file.string.should match(/^192.168.2.0\/24 via 192.168.0.1$/)
|