microwave 1.0.4 → 11.400.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -60,7 +60,6 @@ describe Chef::Provider::ErlCall do
|
|
60
60
|
Process.should_receive(:wait).with(@pid)
|
61
61
|
|
62
62
|
@provider.action_run
|
63
|
-
@provider.converge
|
64
63
|
|
65
64
|
@stdin.string.should == "#{@new_resource.code}\n"
|
66
65
|
end
|
@@ -78,7 +77,6 @@ describe Chef::Provider::ErlCall do
|
|
78
77
|
Process.should_receive(:wait).with(@pid)
|
79
78
|
|
80
79
|
@provider.action_run
|
81
|
-
@provider.converge
|
82
80
|
|
83
81
|
@stdin.string.should == "#{@new_resource.code}\n"
|
84
82
|
end
|
@@ -53,80 +53,86 @@ describe Chef::Provider::File do
|
|
53
53
|
@provider.current_resource.content.should eql(nil)
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
describe "examining file security metadata on Unix" do
|
57
|
+
before do
|
58
|
+
Chef::Platform.stub!(:windows?).and_return(false)
|
59
|
+
end
|
57
60
|
it "should collect the current state of the file on the filesystem and populate current_resource" do
|
58
61
|
# test setup
|
59
|
-
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
60
|
-
::File.should_receive(:stat).exactly(
|
61
|
-
|
62
|
+
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
63
|
+
::File.should_receive(:stat).exactly(1).times.with(@resource.path).and_return(stat_struct)
|
64
|
+
|
65
|
+
# test execution
|
66
|
+
|
67
|
+
Etc.should_receive(:getgrgid).with(0).and_return(mock("Group Ent", :name => "wheel"))
|
68
|
+
Etc.should_receive(:getpwuid).with(0).and_return(mock("User Ent", :name => "root"))
|
69
|
+
|
62
70
|
# test execution
|
63
71
|
@provider.load_current_resource
|
64
|
-
|
72
|
+
|
65
73
|
# post-condition checks
|
66
|
-
@provider.current_resource.mode.should == 0600
|
67
|
-
@provider.current_resource.owner.should ==
|
68
|
-
@provider.current_resource.group.should ==
|
74
|
+
@provider.current_resource.mode.should == "0600"
|
75
|
+
@provider.current_resource.owner.should == "root"
|
76
|
+
@provider.current_resource.group.should == "wheel"
|
69
77
|
end
|
70
|
-
|
78
|
+
|
71
79
|
it "should NOT update the new_resource state with the current_resourse state if new_resource state is already specified" do
|
72
80
|
# test setup
|
73
|
-
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
74
|
-
::File.should_receive(:stat).exactly(
|
75
|
-
|
81
|
+
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
82
|
+
::File.should_receive(:stat).exactly(1).times.with(@resource.path).and_return(stat_struct)
|
83
|
+
|
76
84
|
@provider.new_resource.group(1)
|
77
85
|
@provider.new_resource.owner(1)
|
78
86
|
@provider.new_resource.mode(0644)
|
79
|
-
|
80
|
-
# test execution
|
87
|
+
|
88
|
+
# test execution
|
81
89
|
@provider.load_current_resource
|
82
|
-
|
90
|
+
|
83
91
|
# post-condition checks
|
84
92
|
@provider.new_resource.group.should == 1
|
85
93
|
@provider.new_resource.owner.should == 1
|
86
94
|
@provider.new_resource.mode.should == 0644
|
87
95
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
::File.should_receive(:directory?).once.with(@provider.new_resource.path).and_return(false)
|
113
|
-
|
114
|
-
@provider.new_resource.group(nil)
|
115
|
-
@provider.new_resource.owner(nil)
|
116
|
-
@provider.new_resource.mode(nil)
|
117
|
-
|
118
|
-
# test exectution
|
119
|
-
@provider.update_new_file_state
|
120
|
-
|
121
|
-
# post-condition checks
|
122
|
-
@provider.new_resource.group.should == 0
|
123
|
-
@provider.new_resource.owner.should == 0
|
124
|
-
@provider.new_resource.mode.should == 0600
|
96
|
+
|
97
|
+
context "when the new_resource does not specify the desired access control" do
|
98
|
+
it "records access control information in the new resource after modifying the file" do
|
99
|
+
# test setup
|
100
|
+
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
|
101
|
+
# called once in update_new_file_state and once in checksum
|
102
|
+
::File.should_receive(:stat).once.with(@provider.new_resource.path).and_return(stat_struct)
|
103
|
+
::File.should_receive(:directory?).once.with(@provider.new_resource.path).and_return(false)
|
104
|
+
|
105
|
+
Etc.should_receive(:getpwuid).with(0).and_return(mock("User Ent", :name => "root"))
|
106
|
+
Etc.should_receive(:getgrgid).with(0).and_return(mock("Group Ent", :name => "wheel"))
|
107
|
+
|
108
|
+
@provider.new_resource.group(nil)
|
109
|
+
@provider.new_resource.owner(nil)
|
110
|
+
@provider.new_resource.mode(nil)
|
111
|
+
|
112
|
+
# test exectution
|
113
|
+
@provider.update_new_file_state
|
114
|
+
|
115
|
+
# post-condition checks
|
116
|
+
@provider.new_resource.group.should == "wheel"
|
117
|
+
@provider.new_resource.owner.should == "root"
|
118
|
+
@provider.new_resource.mode.should == "0600"
|
119
|
+
end
|
125
120
|
end
|
126
121
|
end
|
127
122
|
|
128
|
-
|
129
|
-
|
123
|
+
describe "when reporting security metadata on windows" do
|
124
|
+
|
125
|
+
it "records the file owner" do
|
126
|
+
pending
|
127
|
+
end
|
128
|
+
|
129
|
+
it "records rights for each user in the ACL" do
|
130
|
+
pending
|
131
|
+
end
|
132
|
+
|
133
|
+
it "records deny_rights for each user in the ACL" do
|
134
|
+
pending
|
135
|
+
end
|
130
136
|
end
|
131
137
|
|
132
138
|
it "should load a mostly blank current resource if the file specified in new_resource doesn't exist/isn't readable" do
|
@@ -174,16 +180,18 @@ describe Chef::Provider::File do
|
|
174
180
|
@provider.new_resource.content "foobar"
|
175
181
|
@provider.should_receive(:diff_current_from_content).and_return("")
|
176
182
|
@provider.should_receive(:backup)
|
183
|
+
# checksum check
|
184
|
+
File.should_receive(:open).with(@provider.new_resource.path, "rb").and_yield(io)
|
177
185
|
File.should_receive(:open).with(@provider.new_resource.path, "w").and_yield(io)
|
178
186
|
@provider.set_content
|
179
|
-
lambda { @provider.send(:converge_actions).converge! }.should_not raise_error
|
180
187
|
io.string.should == "foobar"
|
181
188
|
end
|
182
189
|
|
183
190
|
it "should not set the content of the file if it already matches the requested content" do
|
184
191
|
@provider.load_current_resource
|
185
192
|
@provider.new_resource.content IO.read(@resource.path)
|
186
|
-
|
193
|
+
# Checksum check:
|
194
|
+
File.should_receive(:open).with(@resource.path, "rb").and_yield(StringIO.new(@resource.content))
|
187
195
|
File.should_not_receive(:open).with(@provider.new_resource.path, "w")
|
188
196
|
lambda { @provider.set_content }.should_not raise_error
|
189
197
|
@resource.should_not be_updated_by_last_action
|
@@ -343,10 +351,12 @@ describe Chef::Provider::File do
|
|
343
351
|
end
|
344
352
|
|
345
353
|
it "should call action create if the does not file exist" do
|
346
|
-
@resource.path("/tmp/non_existant_file")
|
354
|
+
@resource.path("/tmp/example-dir/non_existant_file")
|
347
355
|
@provider = Chef::Provider::File.new(@resource, @run_context)
|
348
356
|
@provider.should_receive(:diff_current_from_content).and_return("")
|
349
357
|
::File.stub!(:exists?).with(@resource.path).and_return(false)
|
358
|
+
::File.stub!(:directory?).with("/tmp/example-dir/non_existant_file").and_return(false)
|
359
|
+
::File.stub!(:directory?).with("/tmp/example-dir").and_return(true)
|
350
360
|
@provider.stub!(:update_new_file_state)
|
351
361
|
io = StringIO.new
|
352
362
|
File.should_receive(:open).with(@provider.new_resource.path, "w+").and_yield(io)
|
@@ -356,7 +366,7 @@ describe Chef::Provider::File do
|
|
356
366
|
end
|
357
367
|
end
|
358
368
|
|
359
|
-
describe "when a diff is requested" do
|
369
|
+
describe "when a diff is requested", :uses_diff => true do
|
360
370
|
|
361
371
|
before(:each) do
|
362
372
|
@original_config = Chef::Config.hash_dup
|
@@ -486,7 +496,7 @@ describe Chef::Provider::File do
|
|
486
496
|
it "should return valid diff output when content does not match the string content provided" do
|
487
497
|
Tempfile.open("some-temp") do |file|
|
488
498
|
@resource.path file.path
|
489
|
-
@provider = Chef::Provider::File.new(@resource, @run_context)
|
499
|
+
@provider = Chef::Provider::File.new(@resource, @run_context)
|
490
500
|
@provider.load_current_resource
|
491
501
|
result = @provider.diff_current_from_content "foo baz"
|
492
502
|
# remove the file name info which varies.
|
@@ -163,7 +163,6 @@ SHAS
|
|
163
163
|
:environment =>{"GIT_SSH"=>"do_it_this_way.sh"}, :log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT)
|
164
164
|
|
165
165
|
@provider.clone
|
166
|
-
@provider.converge
|
167
166
|
end
|
168
167
|
|
169
168
|
it "runs a clone command with escaped destination" do
|
@@ -174,7 +173,6 @@ SHAS
|
|
174
173
|
@provider.should_receive(:shell_out!).with(expected_cmd, :user => "deployNinja",
|
175
174
|
:environment =>{"GIT_SSH"=>"do_it_this_way.sh"}, :log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT)
|
176
175
|
@provider.clone
|
177
|
-
@provider.converge
|
178
176
|
end
|
179
177
|
|
180
178
|
it "compiles a clone command using --depth for shallow cloning" do
|
@@ -182,7 +180,6 @@ SHAS
|
|
182
180
|
expected_cmd = 'git clone --depth 5 git://github.com/opscode/chef.git /my/deploy/dir'
|
183
181
|
@provider.should_receive(:shell_out!).with(expected_cmd, {:log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT})
|
184
182
|
@provider.clone
|
185
|
-
@provider.converge
|
186
183
|
end
|
187
184
|
|
188
185
|
it "compiles a clone command with a remote other than ``origin''" do
|
@@ -190,14 +187,12 @@ SHAS
|
|
190
187
|
expected_cmd = 'git clone -o opscode git://github.com/opscode/chef.git /my/deploy/dir'
|
191
188
|
@provider.should_receive(:shell_out!).with(expected_cmd, {:log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT})
|
192
189
|
@provider.clone
|
193
|
-
@provider.converge
|
194
190
|
end
|
195
191
|
|
196
192
|
it "runs a checkout command with default options" do
|
197
193
|
expected_cmd = 'git checkout -b deploy d35af14d41ae22b19da05d7d03a0bafc321b244c'
|
198
194
|
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]")
|
199
195
|
@provider.checkout
|
200
|
-
@provider.converge
|
201
196
|
end
|
202
197
|
|
203
198
|
it "runs an enable_submodule command" do
|
@@ -205,20 +200,17 @@ SHAS
|
|
205
200
|
expected_cmd = "git submodule update --init --recursive"
|
206
201
|
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_level => :info, :log_tag => "git[web2.0 app]", :live_stream => STDOUT)
|
207
202
|
@provider.enable_submodules
|
208
|
-
@provider.converge
|
209
203
|
end
|
210
204
|
|
211
205
|
it "does nothing for enable_submodules if resource.enable_submodules #=> false" do
|
212
206
|
@provider.should_not_receive(:shell_out!)
|
213
207
|
@provider.enable_submodules
|
214
|
-
@provider.converge
|
215
208
|
end
|
216
209
|
|
217
210
|
it "runs a sync command with default options" do
|
218
211
|
expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
|
219
212
|
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd=> "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]")
|
220
213
|
@provider.fetch_updates
|
221
|
-
@provider.converge
|
222
214
|
end
|
223
215
|
|
224
216
|
it "runs a sync command with the user and group specified in the resource" do
|
@@ -228,7 +220,6 @@ SHAS
|
|
228
220
|
@provider.should_receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir",
|
229
221
|
:user => "whois", :group => "thisis", :log_level => :debug, :log_tag => "git[web2.0 app]")
|
230
222
|
@provider.fetch_updates
|
231
|
-
@provider.converge
|
232
223
|
end
|
233
224
|
|
234
225
|
it "configures remote tracking branches when remote is not ``origin''" do
|
@@ -239,7 +230,6 @@ SHAS
|
|
239
230
|
fetch_command = "git fetch opscode && git fetch opscode --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c"
|
240
231
|
@provider.should_receive(:shell_out!).with(fetch_command, :cwd => "/my/deploy/dir", :log_level => :debug, :log_tag => "git[web2.0 app]")
|
241
232
|
@provider.fetch_updates
|
242
|
-
@provider.converge
|
243
233
|
end
|
244
234
|
|
245
235
|
it "raises an error if the git clone command would fail because the enclosing directory doesn't exist" do
|
@@ -132,7 +132,7 @@ describe Chef::Provider::Group::Groupadd do
|
|
132
132
|
describe "modify_group_members" do
|
133
133
|
|
134
134
|
it "should raise an error when calling modify_group_members" do
|
135
|
-
lambda { @provider.modify_group_members
|
135
|
+
lambda { @provider.modify_group_members }.should raise_error(Chef::Exceptions::Group, "you must override modify_group_members in #{@provider.to_s}")
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -64,7 +64,7 @@ describe Chef::Provider::Group::Usermod do
|
|
64
64
|
|
65
65
|
platforms.each do |platform, flags|
|
66
66
|
it "should usermod each user when the append option is set on #{platform}" do
|
67
|
-
@node[:platform] = platform
|
67
|
+
@node.automatic_attrs[:platform] = platform
|
68
68
|
@new_resource.stub!(:append).and_return(true)
|
69
69
|
@provider.should_receive(:run_command).with({:command => "usermod #{flags} wheel all"})
|
70
70
|
@provider.should_receive(:run_command).with({:command => "usermod #{flags} wheel your"})
|
@@ -76,7 +76,7 @@ describe Chef::Provider::Group::Usermod do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "when loading the current resource" do
|
79
|
-
before
|
79
|
+
before(:each) do
|
80
80
|
File.stub!(:exists?).and_return(false)
|
81
81
|
@provider.define_resource_requirements
|
82
82
|
end
|
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -26,13 +26,13 @@ describe Chef::Provider::HttpRequest do
|
|
26
26
|
|
27
27
|
@new_resource = Chef::Resource::HttpRequest.new('adam')
|
28
28
|
@new_resource.name "adam"
|
29
|
-
@new_resource.url "http://www.opscode.com"
|
29
|
+
@new_resource.url "http://www.opscode.com/"
|
30
30
|
@new_resource.message "is cool"
|
31
31
|
|
32
32
|
@provider = Chef::Provider::HttpRequest.new(@new_resource, @run_context)
|
33
33
|
end
|
34
34
|
|
35
|
-
describe "load_current_resource" do
|
35
|
+
describe "load_current_resource" do
|
36
36
|
|
37
37
|
it "should set up a Chef::REST client, with no authentication" do
|
38
38
|
Chef::REST.should_receive(:new).with(@new_resource.url, nil, nil)
|
@@ -45,91 +45,59 @@ describe Chef::Provider::HttpRequest do
|
|
45
45
|
# run_action(x) forces load_current_resource to run;
|
46
46
|
# that would overwrite our supplied mock Chef::Rest # object
|
47
47
|
@provider.stub!(:load_current_resource).and_return(true)
|
48
|
-
@rest = mock("Chef::REST"
|
48
|
+
@rest = mock("Chef::REST")
|
49
49
|
@provider.rest = @rest
|
50
50
|
end
|
51
51
|
|
52
|
-
describe "action_get" do
|
53
|
-
it "should create the url with a message argument" do
|
54
|
-
@rest.should_receive(:create_url).with("#{@new_resource.url}?message=#{@new_resource.message}")
|
55
|
-
@provider.run_action(:get)
|
56
|
-
end
|
52
|
+
describe "action_get" do
|
57
53
|
|
58
54
|
it "should inflate a message block at runtime" do
|
59
|
-
@new_resource.
|
60
|
-
@rest.should_receive(:
|
55
|
+
@new_resource.message { "return" }
|
56
|
+
@rest.should_receive(:get).with("http://www.opscode.com/?message=return", false, {})
|
61
57
|
@provider.run_action(:get)
|
58
|
+
@new_resource.should be_updated
|
62
59
|
end
|
63
60
|
|
64
61
|
it "should run a GET request" do
|
65
|
-
@rest.should_receive(:
|
66
|
-
@provider.run_action(:get)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should update the resource" do
|
62
|
+
@rest.should_receive(:get).with("http://www.opscode.com/?message=is cool", false, {})
|
70
63
|
@provider.run_action(:get)
|
71
64
|
@new_resource.should be_updated
|
72
65
|
end
|
73
66
|
end
|
74
67
|
|
75
|
-
describe "action_put" do
|
76
|
-
it "should create the url" do
|
77
|
-
@rest.should_receive(:create_url).with("#{@new_resource.url}")
|
78
|
-
@provider.run_action(:put)
|
79
|
-
end
|
80
|
-
|
68
|
+
describe "action_put" do
|
81
69
|
it "should run a PUT request with the message as the payload" do
|
82
|
-
@rest.should_receive(:
|
70
|
+
@rest.should_receive(:put).with("http://www.opscode.com/", @new_resource.message, {})
|
83
71
|
@provider.run_action(:put)
|
72
|
+
@new_resource.should be_updated
|
84
73
|
end
|
85
74
|
|
86
75
|
it "should inflate a message block at runtime" do
|
87
76
|
@new_resource.stub!(:message).and_return(lambda { "return" })
|
88
|
-
@rest.should_receive(:
|
89
|
-
@provider.run_action(:put)
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should update the resource" do
|
77
|
+
@rest.should_receive(:put).with("http://www.opscode.com/", "return", {})
|
93
78
|
@provider.run_action(:put)
|
94
79
|
@new_resource.should be_updated
|
95
80
|
end
|
96
81
|
end
|
97
82
|
|
98
|
-
describe "action_post" do
|
99
|
-
it "should create the url" do
|
100
|
-
@rest.should_receive(:create_url).with("#{@new_resource.url}")
|
101
|
-
@provider.run_action(:post)
|
102
|
-
end
|
103
|
-
|
83
|
+
describe "action_post" do
|
104
84
|
it "should run a PUT request with the message as the payload" do
|
105
|
-
@rest.should_receive(:
|
85
|
+
@rest.should_receive(:post).with("http://www.opscode.com/", @new_resource.message, {})
|
106
86
|
@provider.run_action(:post)
|
87
|
+
@new_resource.should be_updated
|
107
88
|
end
|
108
|
-
|
89
|
+
|
109
90
|
it "should inflate a message block at runtime" do
|
110
|
-
@new_resource.
|
111
|
-
@rest.should_receive(:
|
112
|
-
@provider.run_action(:post)
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should update the resource" do
|
91
|
+
@new_resource.message { "return" }
|
92
|
+
@rest.should_receive(:post).with("http://www.opscode.com/", "return", {})
|
116
93
|
@provider.run_action(:post)
|
117
94
|
@new_resource.should be_updated
|
118
95
|
end
|
119
96
|
end
|
120
97
|
|
121
|
-
describe "action_delete" do
|
122
|
-
it "should create the url" do
|
123
|
-
@rest.should_receive(:create_url).with("#{@new_resource.url}")
|
124
|
-
@provider.run_action(:delete)
|
125
|
-
end
|
126
|
-
|
98
|
+
describe "action_delete" do
|
127
99
|
it "should run a DELETE request" do
|
128
|
-
@rest.should_receive(:
|
129
|
-
@provider.run_action(:delete)
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should update the resource" do
|
100
|
+
@rest.should_receive(:delete).with("http://www.opscode.com/", {})
|
133
101
|
@provider.run_action(:delete)
|
134
102
|
@new_resource.should be_updated
|
135
103
|
end
|
@@ -137,39 +105,30 @@ describe Chef::Provider::HttpRequest do
|
|
137
105
|
|
138
106
|
describe "action_head" do
|
139
107
|
before do
|
140
|
-
@rest = mock("Chef::REST", :create_url => "http://www.opscode.com", :run_request => true)
|
141
108
|
@provider.rest = @rest
|
142
109
|
end
|
143
110
|
|
144
|
-
it "should create the url with a message argument" do
|
145
|
-
@rest.should_receive(:create_url).with("#{@new_resource.url}?message=#{@new_resource.message}")
|
146
|
-
@provider.run_action(:head)
|
147
|
-
end
|
148
|
-
|
149
111
|
it "should inflate a message block at runtime" do
|
150
|
-
@new_resource.
|
151
|
-
@rest.should_receive(:
|
112
|
+
@new_resource.message { "return" }
|
113
|
+
@rest.should_receive(:head).with("http://www.opscode.com/?message=return", {}).and_return("")
|
152
114
|
@provider.run_action(:head)
|
115
|
+
@new_resource.should be_updated
|
153
116
|
end
|
154
117
|
|
155
118
|
it "should run a HEAD request" do
|
156
|
-
@rest.should_receive(:
|
157
|
-
@provider.run_action(:head)
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should update the resource" do
|
119
|
+
@rest.should_receive(:head).with("http://www.opscode.com/?message=is cool", {}).and_return("")
|
161
120
|
@provider.run_action(:head)
|
162
121
|
@new_resource.should be_updated
|
163
122
|
end
|
164
123
|
|
165
124
|
it "should run a HEAD request with If-Modified-Since header" do
|
166
125
|
@new_resource.headers "If-Modified-Since" => File.mtime(__FILE__).httpdate
|
167
|
-
@rest.should_receive(:
|
126
|
+
@rest.should_receive(:head).with("http://www.opscode.com/?message=is cool", @new_resource.headers)
|
168
127
|
@provider.run_action(:head)
|
169
128
|
end
|
170
129
|
|
171
130
|
it "doesn't call converge_by if HEAD does not return modified" do
|
172
|
-
@rest.should_receive(:
|
131
|
+
@rest.should_receive(:head).and_return(false)
|
173
132
|
@provider.should_not_receive(:converge_by)
|
174
133
|
@provider.run_action(:head)
|
175
134
|
end
|