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
@@ -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,158 +26,211 @@ describe Chef::ApiClient do
|
|
26
26
|
@client = Chef::ApiClient.new
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
it "has a name attribute" do
|
30
|
+
@client.name("ops_master")
|
31
|
+
@client.name.should == "ops_master"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "does not allow spaces in the name" do
|
35
|
+
lambda { @client.name "ops master" }.should raise_error(ArgumentError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "only allows string values for the name" do
|
39
|
+
lambda { @client.name Hash.new }.should raise_error(ArgumentError)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "has an admin flag attribute" do
|
43
|
+
@client.admin(true)
|
44
|
+
@client.admin.should be_true
|
45
|
+
end
|
46
|
+
|
47
|
+
it "defaults to non-admin" do
|
48
|
+
@client.admin.should be_false
|
49
|
+
end
|
50
|
+
|
51
|
+
it "allows only boolean values for the admin flag" do
|
52
|
+
lambda { @client.admin(false) }.should_not raise_error
|
53
|
+
lambda { @client.admin(Hash.new) }.should raise_error(ArgumentError)
|
33
54
|
end
|
34
55
|
|
35
|
-
describe "name" do
|
36
|
-
it "should let you set the name to a string" do
|
37
|
-
@client.name("ops_master").should == "ops_master"
|
38
|
-
end
|
39
56
|
|
40
|
-
|
41
|
-
|
42
|
-
|
57
|
+
it "has a public key attribute" do
|
58
|
+
@client.public_key("super public")
|
59
|
+
@client.public_key.should == "super public"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "accepts only String values for the public key" do
|
63
|
+
lambda { @client.public_key "" }.should_not raise_error
|
64
|
+
lambda { @client.public_key Hash.new }.should raise_error(ArgumentError)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
it "has a private key attribute" do
|
69
|
+
@client.private_key("super private")
|
70
|
+
@client.private_key.should == "super private"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "accepts only String values for the private key" do
|
74
|
+
lambda { @client.private_key "" }.should_not raise_error
|
75
|
+
lambda { @client.private_key Hash.new }.should raise_error(ArgumentError)
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "when serializing to JSON" do
|
79
|
+
before(:each) do
|
80
|
+
@client.name("black")
|
81
|
+
@client.public_key("crowes")
|
82
|
+
@json = @client.to_json
|
43
83
|
end
|
44
84
|
|
45
|
-
it "
|
46
|
-
|
85
|
+
it "serializes as a JSON object" do
|
86
|
+
@json.should match(/^\{.+\}$/)
|
47
87
|
end
|
48
88
|
|
49
|
-
it "
|
50
|
-
|
89
|
+
it "includes the name value" do
|
90
|
+
@json.should include(%q{"name":"black"})
|
51
91
|
end
|
52
|
-
end
|
53
92
|
|
54
|
-
|
55
|
-
|
56
|
-
@client.admin(true).should == true
|
93
|
+
it "includes the public key value" do
|
94
|
+
@json.should include(%{"public_key":"crowes"})
|
57
95
|
end
|
58
96
|
|
59
|
-
it "
|
60
|
-
@
|
61
|
-
@client.admin.should == true
|
97
|
+
it "includes the 'admin' flag" do
|
98
|
+
@json.should include(%q{"admin":false})
|
62
99
|
end
|
63
100
|
|
64
|
-
it "
|
65
|
-
@client.
|
101
|
+
it "includes the private key when present" do
|
102
|
+
@client.private_key("monkeypants")
|
103
|
+
@client.to_json.should include(%q{"private_key":"monkeypants"})
|
66
104
|
end
|
67
105
|
|
68
|
-
it "
|
69
|
-
|
106
|
+
it "does not include the private key if not present" do
|
107
|
+
@json.should_not include("private_key")
|
70
108
|
end
|
71
109
|
end
|
72
110
|
|
73
|
-
describe "
|
74
|
-
|
75
|
-
|
111
|
+
describe "when deserializing from JSON" do
|
112
|
+
before(:each) do
|
113
|
+
client = {
|
114
|
+
"name" => "black",
|
115
|
+
"public_key" => "crowes",
|
116
|
+
"private_key" => "monkeypants",
|
117
|
+
"admin" => true,
|
118
|
+
"json_class" => "Chef::ApiClient"
|
119
|
+
}
|
120
|
+
@client = Chef::JSONCompat.from_json(client.to_json)
|
76
121
|
end
|
77
122
|
|
78
|
-
it "should
|
79
|
-
@client.
|
80
|
-
@client.public_key.should == "super public"
|
123
|
+
it "should deserialize to a Chef::ApiClient object" do
|
124
|
+
@client.should be_a_kind_of(Chef::ApiClient)
|
81
125
|
end
|
82
126
|
|
83
|
-
it "
|
84
|
-
|
85
|
-
end
|
86
|
-
|
127
|
+
it "preserves the name" do
|
128
|
+
@client.name.should == "black"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "preserves the public key" do
|
132
|
+
@client.public_key.should == "crowes"
|
133
|
+
end
|
87
134
|
|
88
|
-
|
89
|
-
|
90
|
-
@client.private_key("super private").should == "super private"
|
135
|
+
it "preserves the admin status" do
|
136
|
+
@client.admin.should be_true
|
91
137
|
end
|
92
138
|
|
93
|
-
it "
|
94
|
-
@client.private_key
|
95
|
-
@client.private_key.should == "super private"
|
139
|
+
it "includes the private key if present" do
|
140
|
+
@client.private_key.should == "monkeypants"
|
96
141
|
end
|
97
142
|
|
98
|
-
it "should throw an ArgumentError if you feed it something lame" do
|
99
|
-
lambda { @client.private_key Hash.new }.should raise_error(ArgumentError)
|
100
|
-
end
|
101
143
|
end
|
102
144
|
|
103
|
-
describe "
|
104
|
-
before
|
105
|
-
Chef::
|
145
|
+
describe "with correctly configured API credentials" do
|
146
|
+
before do
|
147
|
+
Chef::Config[:node_name] = "silent-bob"
|
148
|
+
Chef::Config[:client_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA)
|
106
149
|
end
|
107
150
|
|
108
|
-
|
109
|
-
Chef::
|
110
|
-
|
151
|
+
after do
|
152
|
+
Chef::Config[:node_name] = nil
|
153
|
+
Chef::Config[:client_key] = nil
|
111
154
|
end
|
112
155
|
|
113
|
-
|
114
|
-
|
115
|
-
@client.private_key.should == "key"
|
156
|
+
let :private_key_data do
|
157
|
+
File.open(Chef::Config[:client_key], "r") {|f| f.read.chomp }
|
116
158
|
end
|
117
159
|
|
118
|
-
it "
|
119
|
-
@client.
|
120
|
-
@client.
|
160
|
+
it "has an HTTP client configured with default credentials" do
|
161
|
+
@client.http_api.should be_a_kind_of(Chef::REST)
|
162
|
+
@client.http_api.client_name.should == "silent-bob"
|
163
|
+
@client.http_api.signing_key.to_s.should == private_key_data
|
121
164
|
end
|
122
165
|
end
|
123
166
|
|
124
|
-
describe "serialize" do
|
125
|
-
before(:each) do
|
126
|
-
@client.name("black")
|
127
|
-
@client.public_key("crowes")
|
128
|
-
@client.private_key("monkeypants")
|
129
|
-
@serial = @client.to_json
|
130
|
-
end
|
131
167
|
|
132
|
-
|
133
|
-
|
168
|
+
describe "when requesting a new key" do
|
169
|
+
before do
|
170
|
+
@http_client = mock("Chef::REST mock")
|
171
|
+
Chef::REST.stub!(:new).and_return(@http_client)
|
134
172
|
end
|
135
173
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
@
|
174
|
+
context "and the client does not exist on the server" do
|
175
|
+
before do
|
176
|
+
@a_404_response = Net::HTTPNotFound.new("404 not found and such", nil, nil)
|
177
|
+
@a_404_exception = Net::HTTPServerException.new("404 not found exception", @a_404_response)
|
178
|
+
|
179
|
+
@http_client.should_receive(:get).with("clients/lost-my-key").and_raise(@a_404_exception)
|
142
180
|
end
|
143
|
-
end
|
144
181
|
|
145
|
-
|
146
|
-
|
182
|
+
it "raises a 404 error" do
|
183
|
+
lambda { Chef::ApiClient.reregister("lost-my-key") }.should raise_error(Net::HTTPServerException)
|
184
|
+
end
|
147
185
|
end
|
148
186
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
187
|
+
context "and the client exists" do
|
188
|
+
before do
|
189
|
+
@api_client_without_key = Chef::ApiClient.new
|
190
|
+
@api_client_without_key.name("lost-my-key")
|
191
|
+
@http_client.should_receive(:get).with("clients/lost-my-key").and_return(@api_client_without_key)
|
192
|
+
end
|
153
193
|
|
154
|
-
describe "deserialize" do
|
155
|
-
before(:each) do
|
156
|
-
@client.name("black")
|
157
|
-
@client.public_key("crowes")
|
158
|
-
@client.private_key("monkeypants")
|
159
|
-
@client.admin(true)
|
160
|
-
@deserial = Chef::JSONCompat.from_json(@client.to_json)
|
161
|
-
end
|
162
194
|
|
163
|
-
|
164
|
-
|
165
|
-
|
195
|
+
context "and the client exists on a Chef 11-like server" do
|
196
|
+
before do
|
197
|
+
@api_client_with_key = Chef::ApiClient.new
|
198
|
+
@api_client_with_key.name("lost-my-key")
|
199
|
+
@api_client_with_key.private_key("the new private key")
|
200
|
+
@http_client.should_receive(:put).
|
201
|
+
with("clients/lost-my-key", :name => "lost-my-key", :admin => false, :private_key => true).
|
202
|
+
and_return(@api_client_with_key)
|
203
|
+
end
|
204
|
+
|
205
|
+
it "returns an ApiClient with a private key" do
|
206
|
+
response = Chef::ApiClient.reregister("lost-my-key")
|
207
|
+
# no sane == method for ApiClient :'(
|
208
|
+
response.should == @api_client_without_key
|
209
|
+
response.private_key.should == "the new private key"
|
210
|
+
response.name.should == "lost-my-key"
|
211
|
+
response.admin.should be_false
|
212
|
+
end
|
213
|
+
end
|
166
214
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
215
|
+
context "and the client exists on a Chef 10-like server" do
|
216
|
+
before do
|
217
|
+
@api_client_with_key = {"name" => "lost-my-key", "private_key" => "the new private key"}
|
218
|
+
@http_client.should_receive(:put).
|
219
|
+
with("clients/lost-my-key", :name => "lost-my-key", :admin => false, :private_key => true).
|
220
|
+
and_return(@api_client_with_key)
|
221
|
+
end
|
222
|
+
|
223
|
+
it "returns an ApiClient with a private key" do
|
224
|
+
response = Chef::ApiClient.reregister("lost-my-key")
|
225
|
+
# no sane == method for ApiClient :'(
|
226
|
+
response.should == @api_client_without_key
|
227
|
+
response.private_key.should == "the new private key"
|
228
|
+
response.name.should == "lost-my-key"
|
229
|
+
response.admin.should be_false
|
230
|
+
end
|
174
231
|
end
|
175
|
-
end
|
176
232
|
|
177
|
-
it "should not include the private key" do
|
178
|
-
@deserial.private_key.should == nil
|
179
233
|
end
|
180
|
-
|
181
234
|
end
|
182
235
|
end
|
183
236
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan W. Berry (<bryan.berry@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Bryan W. Berry
|
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
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
describe Chef::Application::Apply do
|
21
|
+
|
22
|
+
before do
|
23
|
+
@original_config = Chef::Config.configuration
|
24
|
+
@app = Chef::Application::Recipe.new
|
25
|
+
@app.stub!(:configure_logging).and_return(true)
|
26
|
+
@recipe_text = "package 'nyancat'"
|
27
|
+
Chef::Config[:solo] = true
|
28
|
+
end
|
29
|
+
|
30
|
+
after do
|
31
|
+
Chef::Config[:solo] = nil
|
32
|
+
Chef::Config.configuration.replace(@original_config)
|
33
|
+
Chef::Config[:solo] = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
describe "configuring the application" do
|
38
|
+
it "should set solo mode to true" do
|
39
|
+
@app.reconfigure
|
40
|
+
Chef::Config[:solo].should be_true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
describe "read_recipe_file" do
|
44
|
+
before do
|
45
|
+
@recipe_file_name = "foo.rb"
|
46
|
+
@recipe_path = File.expand_path("foo.rb")
|
47
|
+
@recipe_file = mock("Tempfile (mock)", :read => @recipe_text)
|
48
|
+
@app.stub!(:open).with(@recipe_path).and_return(@recipe_file)
|
49
|
+
File.stub!(:exist?).with("foo.rb").and_return(true)
|
50
|
+
Chef::Application.stub!(:fatal!).and_return(true)
|
51
|
+
end
|
52
|
+
it "should read text properly" do
|
53
|
+
@app.read_recipe_file(@recipe_file_name)[0].should == @recipe_text
|
54
|
+
end
|
55
|
+
it "should return a file_handle" do
|
56
|
+
@app.read_recipe_file(@recipe_file_name)[1].should be_instance_of(RSpec::Mocks::Mock)
|
57
|
+
end
|
58
|
+
describe "when recipe doesn't exist" do
|
59
|
+
before do
|
60
|
+
File.stub!(:exist?).with(@recipe_file_name).and_return(false)
|
61
|
+
end
|
62
|
+
it "should raise a fatal" do
|
63
|
+
Chef::Application.should_receive(:fatal!)
|
64
|
+
@app.read_recipe_file(@recipe_file_name)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
describe "temp_recipe_file" do
|
69
|
+
before do
|
70
|
+
@app.instance_variable_set(:@recipe_text, @recipe_text)
|
71
|
+
@app.temp_recipe_file
|
72
|
+
@recipe_fh = @app.instance_variable_get(:@recipe_fh)
|
73
|
+
end
|
74
|
+
it "should open a tempfile" do
|
75
|
+
@recipe_fh.path.should match(/.*recipe-temporary-file.*/)
|
76
|
+
end
|
77
|
+
it "should write recipe text to the tempfile" do
|
78
|
+
@recipe_fh.read.should == @recipe_text
|
79
|
+
end
|
80
|
+
it "should save the filename for later use" do
|
81
|
+
@recipe_fh.path.should == @app.instance_variable_get(:@recipe_filename)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -20,12 +20,17 @@ require 'spec_helper'
|
|
20
20
|
|
21
21
|
describe Chef::Application do
|
22
22
|
before do
|
23
|
+
@original_conf = Chef::Config.configuration
|
23
24
|
Chef::Log.logger = Logger.new(StringIO.new)
|
24
25
|
@app = Chef::Application.new
|
25
26
|
Dir.stub!(:chdir).and_return(0)
|
26
27
|
@app.stub!(:reconfigure)
|
27
28
|
end
|
28
29
|
|
30
|
+
after do
|
31
|
+
Chef::Config.configuration.replace(@original_conf)
|
32
|
+
end
|
33
|
+
|
29
34
|
describe "reconfigure" do
|
30
35
|
before do
|
31
36
|
@app = Chef::Application.new
|
@@ -170,14 +175,14 @@ describe Chef::Application do
|
|
170
175
|
end
|
171
176
|
end
|
172
177
|
|
173
|
-
describe "
|
178
|
+
describe "when configuring the logger" do
|
174
179
|
before do
|
175
180
|
@app = Chef::Application.new
|
176
181
|
Chef::Log.stub!(:init)
|
177
|
-
Chef::Log.stub!(:level=)
|
178
182
|
end
|
179
183
|
|
180
184
|
it "should initialise the chef logger" do
|
185
|
+
Chef::Log.stub!(:level=)
|
181
186
|
Chef::Log.should_receive(:init).with(Chef::Config[:log_location]).and_return(true)
|
182
187
|
@app.configure_logging
|
183
188
|
end
|
@@ -187,6 +192,56 @@ describe Chef::Application do
|
|
187
192
|
@app.configure_logging
|
188
193
|
end
|
189
194
|
|
195
|
+
context "and log_level is :auto" do
|
196
|
+
before do
|
197
|
+
Chef::Config[:log_level] = :auto
|
198
|
+
end
|
199
|
+
|
200
|
+
context "and STDOUT is to a tty" do
|
201
|
+
before do
|
202
|
+
STDOUT.stub!(:tty?).and_return(true)
|
203
|
+
end
|
204
|
+
|
205
|
+
it "configures the log level to :warn" do
|
206
|
+
@app.configure_logging
|
207
|
+
Chef::Log.level.should == :warn
|
208
|
+
end
|
209
|
+
|
210
|
+
context "and force_logger is configured" do
|
211
|
+
before do
|
212
|
+
Chef::Config[:force_logger] = true
|
213
|
+
end
|
214
|
+
|
215
|
+
it "configures the log level to info" do
|
216
|
+
@app.configure_logging
|
217
|
+
Chef::Log.level.should == :info
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
context "and STDOUT is not to a tty" do
|
223
|
+
before do
|
224
|
+
STDOUT.stub!(:tty?).and_return(false)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "configures the log level to :info" do
|
228
|
+
@app.configure_logging
|
229
|
+
Chef::Log.level.should == :info
|
230
|
+
end
|
231
|
+
|
232
|
+
context "and force_formatter is configured" do
|
233
|
+
before do
|
234
|
+
Chef::Config[:force_formatter] = true
|
235
|
+
end
|
236
|
+
it "sets the log level to :warn" do
|
237
|
+
@app.configure_logging
|
238
|
+
Chef::Log.level.should == :warn
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
end
|
190
245
|
end
|
191
246
|
|
192
247
|
describe "class method: fatal!" do
|