chef 13.6.4 → 13.7.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/acceptance/Gemfile +2 -2
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
- data/distro/powershell/chef/chef.psm1 +1 -5
- data/lib/chef/api_client.rb +5 -5
- data/lib/chef/api_client_v1.rb +6 -6
- data/lib/chef/application.rb +3 -2
- data/lib/chef/application/knife.rb +4 -0
- data/lib/chef/chef_class.rb +2 -2
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
- data/lib/chef/client.rb +3 -3
- data/lib/chef/cookbook/chefignore.rb +4 -0
- data/lib/chef/cookbook/cookbook_collection.rb +2 -2
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/deprecated.rb +10 -0
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/http.rb +10 -10
- data/lib/chef/knife.rb +16 -15
- data/lib/chef/knife/configure.rb +12 -36
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +6 -2
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/edit.rb +1 -1
- data/lib/chef/knife/ssh.rb +47 -35
- data/lib/chef/knife/user_create.rb +2 -0
- data/lib/chef/knife/user_delete.rb +2 -0
- data/lib/chef/knife/user_edit.rb +2 -0
- data/lib/chef/knife/user_reregister.rb +2 -0
- data/lib/chef/knife/user_show.rb +2 -0
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +46 -70
- data/lib/chef/node/attribute_collections.rb +5 -5
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/immutable_collections.rb +180 -23
- data/lib/chef/node/mixin/state_tracking.rb +6 -6
- data/lib/chef/node_map.rb +63 -45
- data/lib/chef/property.rb +8 -8
- data/lib/chef/provider.rb +9 -3
- data/lib/chef/provider/apt_preference.rb +1 -1
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/apt_update.rb +1 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +6 -2
- data/lib/chef/provider/ifconfig.rb +96 -34
- data/lib/chef/provider/launchd.rb +0 -1
- data/lib/chef/provider/log.rb +3 -13
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/reboot.rb +12 -0
- data/lib/chef/provider/remote_directory.rb +1 -1
- data/lib/chef/provider/remote_file/http.rb +3 -2
- data/lib/chef/provider/service/solaris.rb +6 -2
- data/lib/chef/provider/systemd_unit.rb +34 -33
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/windows_path.rb +6 -7
- data/lib/chef/provider/windows_task.rb +89 -33
- data/lib/chef/provider/yum_repository.rb +24 -9
- data/lib/chef/resource/apt_package.rb +1 -0
- data/lib/chef/resource/apt_preference.rb +4 -0
- data/lib/chef/resource/apt_repository.rb +4 -0
- data/lib/chef/resource/apt_update.rb +3 -0
- data/lib/chef/resource/bash.rb +4 -0
- data/lib/chef/resource/batch.rb +5 -0
- data/lib/chef/resource/bff_package.rb +4 -0
- data/lib/chef/resource/breakpoint.rb +6 -0
- data/lib/chef/resource/cab_package.rb +6 -6
- data/lib/chef/resource/chef_gem.rb +13 -0
- data/lib/chef/resource/chocolatey_package.rb +4 -6
- data/lib/chef/resource/cookbook_file.rb +13 -15
- data/lib/chef/resource/cron.rb +2 -0
- data/lib/chef/resource/csh.rb +4 -0
- data/lib/chef/resource/directory.rb +8 -26
- data/lib/chef/resource/dnf_package.rb +5 -0
- data/lib/chef/resource/dpkg_package.rb +2 -0
- data/lib/chef/resource/dsc_resource.rb +5 -0
- data/lib/chef/resource/dsc_script.rb +6 -0
- data/lib/chef/resource/env.rb +3 -0
- data/lib/chef/resource/erl_call.rb +5 -0
- data/lib/chef/resource/execute.rb +5 -1
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/file/verification.rb +10 -0
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/gem_package.rb +2 -0
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -0
- data/lib/chef/resource/homebrew_package.rb +3 -0
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +23 -150
- data/lib/chef/resource/ips_package.rb +1 -0
- data/lib/chef/resource/ksh.rb +6 -0
- data/lib/chef/resource/launchd.rb +5 -4
- data/lib/chef/resource/link.rb +10 -0
- data/lib/chef/resource/log.rb +19 -46
- data/lib/chef/resource/macports_package.rb +1 -0
- data/lib/chef/resource/mdadm.rb +4 -0
- data/lib/chef/resource/mount.rb +1 -0
- data/lib/chef/resource/msu_package.rb +7 -8
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/openbsd_package.rb +3 -0
- data/lib/chef/resource/osx_profile.rb +10 -40
- data/lib/chef/resource/package.rb +6 -0
- data/lib/chef/resource/pacman_package.rb +1 -0
- data/lib/chef/resource/paludis_package.rb +3 -0
- data/lib/chef/resource/perl.rb +4 -0
- data/lib/chef/resource/portage_package.rb +1 -0
- data/lib/chef/resource/powershell_package.rb +5 -0
- data/lib/chef/resource/powershell_script.rb +8 -0
- data/lib/chef/resource/python.rb +4 -0
- data/lib/chef/resource/reboot.rb +14 -20
- data/lib/chef/resource/registry_key.rb +1 -0
- data/lib/chef/resource/remote_directory.rb +3 -0
- data/lib/chef/resource/remote_file.rb +2 -0
- data/lib/chef/resource/resource_notification.rb +17 -0
- data/lib/chef/resource/route.rb +1 -0
- data/lib/chef/resource/rpm_package.rb +1 -0
- data/lib/chef/resource/ruby.rb +4 -0
- data/lib/chef/resource/ruby_block.rb +3 -0
- data/lib/chef/resource/script.rb +4 -0
- data/lib/chef/resource/service.rb +1 -0
- data/lib/chef/resource/smartos_package.rb +1 -0
- data/lib/chef/resource/solaris_package.rb +1 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/systemd_unit.rb +6 -0
- data/lib/chef/resource/template.rb +9 -0
- data/lib/chef/resource/user.rb +1 -0
- data/lib/chef/resource/windows_package.rb +2 -0
- data/lib/chef/resource/windows_path.rb +5 -10
- data/lib/chef/resource/windows_service.rb +3 -0
- data/lib/chef/resource/windows_task.rb +66 -87
- data/lib/chef/resource/yum_repository.rb +26 -22
- data/lib/chef/resource/zypper_package.rb +2 -0
- data/lib/chef/resource/zypper_repository.rb +6 -1
- data/lib/chef/run_context.rb +8 -2
- data/lib/chef/server_api.rb +1 -0
- data/lib/chef/util/selinux.rb +5 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +18 -0
- data/lib/chef/version_constraint/platform.rb +2 -0
- data/spec/data/client.d_00/02-strings.rb +2 -0
- data/spec/functional/assets/chefinittest +6 -4
- data/spec/functional/knife/ssh_spec.rb +54 -7
- data/spec/functional/resource/bff_spec.rb +3 -3
- data/spec/functional/resource/ifconfig_spec.rb +1 -1
- data/spec/functional/resource/mount_spec.rb +7 -3
- data/spec/functional/resource/user/useradd_spec.rb +4 -4
- data/spec/functional/resource/windows_task_spec.rb +6 -6
- data/spec/functional/win32/security_spec.rb +7 -33
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
- data/spec/integration/recipes/resource_action_spec.rb +2 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
- data/spec/spec_helper.rb +19 -0
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/unit/application_dot_d.rb +2 -0
- data/spec/support/shared/unit/execute_resource.rb +8 -1
- data/spec/support/shared/unit/provider/file.rb +9 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
- data/spec/unit/client_spec.rb +1 -1
- data/spec/unit/deprecated_spec.rb +4 -4
- data/spec/unit/http_spec.rb +9 -0
- data/spec/unit/knife/bootstrap_spec.rb +5 -0
- data/spec/unit/knife/configure_spec.rb +10 -60
- data/spec/unit/knife/data_bag_create_spec.rb +40 -2
- data/spec/unit/knife/data_bag_show_spec.rb +16 -2
- data/spec/unit/knife/ssh_spec.rb +85 -39
- data/spec/unit/knife_spec.rb +2 -0
- data/spec/unit/lwrp_spec.rb +5 -3
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
- data/spec/unit/node/attribute_spec.rb +55 -24
- data/spec/unit/node/immutable_collections_spec.rb +28 -14
- data/spec/unit/node/vivid_mash_spec.rb +27 -10
- data/spec/unit/node_map_spec.rb +34 -0
- data/spec/unit/property_spec.rb +13 -13
- data/spec/unit/provider/group/dscl_spec.rb +14 -5
- data/spec/unit/provider/ifconfig_spec.rb +10 -3
- data/spec/unit/provider/remote_file/http_spec.rb +23 -19
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
- data/spec/unit/provider/user/dscl_spec.rb +26 -0
- data/spec/unit/provider/windows_task_spec.rb +148 -4
- data/spec/unit/provider_spec.rb +1 -1
- data/spec/unit/resource/apt_package_spec.rb +1 -1
- data/spec/unit/resource/bash_spec.rb +8 -10
- data/spec/unit/resource/batch_spec.rb +1 -1
- data/spec/unit/resource/cab_package_spec.rb +19 -1
- data/spec/unit/resource/chef_gem_spec.rb +3 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
- data/spec/unit/resource/conditional_spec.rb +2 -2
- data/spec/unit/resource/cookbook_file_spec.rb +24 -30
- data/spec/unit/resource/cron_spec.rb +79 -82
- data/spec/unit/resource/csh_spec.rb +8 -10
- data/spec/unit/resource/deploy_spec.rb +1 -1
- data/spec/unit/resource/directory_spec.rb +28 -31
- data/spec/unit/resource/dnf_package_spec.rb +9 -9
- data/spec/unit/resource/env_spec.rb +7 -7
- data/spec/unit/resource/erl_call_spec.rb +9 -9
- data/spec/unit/resource/execute_spec.rb +6 -6
- data/spec/unit/resource/file/verification_spec.rb +18 -4
- data/spec/unit/resource/file_spec.rb +53 -56
- data/spec/unit/resource/freebsd_package_spec.rb +7 -7
- data/spec/unit/resource/gem_package_spec.rb +1 -1
- data/spec/unit/resource/git_spec.rb +7 -9
- data/spec/unit/resource/group_spec.rb +60 -70
- data/spec/unit/resource/http_request_spec.rb +16 -19
- data/spec/unit/resource/ifconfig_spec.rb +3 -3
- data/spec/unit/resource/ips_package_spec.rb +3 -5
- data/spec/unit/resource/ksh_spec.rb +8 -10
- data/spec/unit/resource/launchd_spec.rb +17 -10
- data/spec/unit/resource/link_spec.rb +53 -53
- data/spec/unit/resource/log_spec.rb +24 -28
- data/spec/unit/resource/mdadm_spec.rb +42 -44
- data/spec/unit/resource/mount_spec.rb +97 -99
- data/spec/unit/resource/msu_package_spec.rb +14 -8
- data/spec/unit/resource/ohai_spec.rb +15 -17
- data/spec/unit/resource/openbsd_package_spec.rb +3 -3
- data/spec/unit/resource/osx_profile_spec.rb +7 -7
- data/spec/unit/resource/package_spec.rb +36 -40
- data/spec/unit/resource/perl_spec.rb +8 -11
- data/spec/unit/resource/portage_package_spec.rb +8 -10
- data/spec/unit/resource/powershell_package_spec.rb +9 -9
- data/spec/unit/resource/python_spec.rb +8 -11
- data/spec/unit/resource/reboot_spec.rb +50 -0
- data/spec/unit/resource/registry_key_spec.rb +84 -98
- data/spec/unit/resource/remote_directory_spec.rb +40 -42
- data/spec/unit/resource/remote_file_spec.rb +78 -80
- data/spec/unit/resource/route_spec.rb +42 -44
- data/spec/unit/resource/rpm_package_spec.rb +5 -7
- data/spec/unit/resource/ruby_block_spec.rb +14 -16
- data/spec/unit/resource/ruby_spec.rb +8 -12
- data/spec/unit/resource/scm_spec.rb +66 -69
- data/spec/unit/resource/script_spec.rb +1 -1
- data/spec/unit/resource/service_spec.rb +80 -83
- data/spec/unit/resource/smartos_package_spec.rb +5 -0
- data/spec/unit/resource/solaris_package_spec.rb +3 -5
- data/spec/unit/resource/subversion_spec.rb +18 -16
- data/spec/unit/resource/systemd_unit_spec.rb +50 -54
- data/spec/unit/resource/template_spec.rb +56 -61
- data/spec/unit/resource/user_spec.rb +47 -53
- data/spec/unit/resource/windows_package_spec.rb +1 -1
- data/spec/unit/resource/windows_path_spec.rb +11 -8
- data/spec/unit/resource/windows_task_spec.rb +129 -33
- data/spec/unit/resource/yum_package_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +61 -8
- data/spec/unit/resource/zypper_repository_spec.rb +17 -18
- data/spec/unit/util/selinux_spec.rb +3 -6
- data/tasks/dependencies.rb +0 -5
- data/tasks/rspec.rb +1 -1
- metadata +6 -6
- data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
- data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
@@ -24,7 +24,7 @@ describe Chef::Resource::Script do
|
|
24
24
|
let(:script_resource) { Chef::Resource::Script.new(resource_instance_name) }
|
25
25
|
let(:resource_name) { :script }
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "accepts a string for the interpreter" do
|
28
28
|
script_resource.interpreter "naaaaNaNaNaaNaaNaaNaa"
|
29
29
|
expect(script_resource.interpreter).to eql("naaaaNaNaNaaNaaNaaNaa")
|
30
30
|
end
|
@@ -20,180 +20,177 @@
|
|
20
20
|
require "spec_helper"
|
21
21
|
|
22
22
|
describe Chef::Resource::Service do
|
23
|
+
let(:resource) { Chef::Resource::Service.new("chef") }
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
it "creates a new Chef::Resource::Service" do
|
26
|
+
expect(resource).to be_a_kind_of(Chef::Resource)
|
27
|
+
expect(resource).to be_a_kind_of(Chef::Resource::Service)
|
26
28
|
end
|
27
29
|
|
28
|
-
it "
|
29
|
-
expect(
|
30
|
-
expect(@resource).to be_a_kind_of(Chef::Resource::Service)
|
30
|
+
it "does not set a provider unless node[:init_package] is defined as systemd" do
|
31
|
+
expect(resource.provider).to eq(nil)
|
31
32
|
end
|
32
33
|
|
33
|
-
it "
|
34
|
-
expect(
|
34
|
+
it "sets the service_name to the first argument to new" do
|
35
|
+
expect(resource.service_name).to eql("chef")
|
35
36
|
end
|
36
37
|
|
37
|
-
it "
|
38
|
-
expect(
|
38
|
+
it "sets the pattern to be the service name by default" do
|
39
|
+
expect(resource.pattern).to eql("chef")
|
39
40
|
end
|
40
41
|
|
41
|
-
it "
|
42
|
-
|
42
|
+
it "accepts a string for the service name" do
|
43
|
+
resource.service_name "something"
|
44
|
+
expect(resource.service_name).to eql("something")
|
43
45
|
end
|
44
46
|
|
45
|
-
it "
|
46
|
-
|
47
|
-
expect(
|
47
|
+
it "accepts a string for the service pattern" do
|
48
|
+
resource.pattern ".*"
|
49
|
+
expect(resource.pattern).to eql(".*")
|
48
50
|
end
|
49
51
|
|
50
|
-
it "
|
51
|
-
@resource.pattern ".*"
|
52
|
-
expect(@resource.pattern).to eql(".*")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should not accept a regexp for the service pattern" do
|
52
|
+
it "does not accept a regexp for the service pattern" do
|
56
53
|
expect do
|
57
|
-
|
54
|
+
resource.pattern /.*/
|
58
55
|
end.to raise_error(ArgumentError)
|
59
56
|
end
|
60
57
|
|
61
|
-
it "
|
62
|
-
|
63
|
-
expect(
|
58
|
+
it "accepts a string for the service start command" do
|
59
|
+
resource.start_command "/etc/init.d/chef start"
|
60
|
+
expect(resource.start_command).to eql("/etc/init.d/chef start")
|
64
61
|
end
|
65
62
|
|
66
|
-
it "
|
63
|
+
it "does not accept a regexp for the service start command" do
|
67
64
|
expect do
|
68
|
-
|
65
|
+
resource.start_command /.*/
|
69
66
|
end.to raise_error(ArgumentError)
|
70
67
|
end
|
71
68
|
|
72
|
-
it "
|
73
|
-
|
74
|
-
expect(
|
69
|
+
it "accepts a string for the service stop command" do
|
70
|
+
resource.stop_command "/etc/init.d/chef stop"
|
71
|
+
expect(resource.stop_command).to eql("/etc/init.d/chef stop")
|
75
72
|
end
|
76
73
|
|
77
|
-
it "
|
74
|
+
it "does not accept a regexp for the service stop command" do
|
78
75
|
expect do
|
79
|
-
|
76
|
+
resource.stop_command /.*/
|
80
77
|
end.to raise_error(ArgumentError)
|
81
78
|
end
|
82
79
|
|
83
|
-
it "
|
84
|
-
|
85
|
-
expect(
|
80
|
+
it "accepts a string for the service status command" do
|
81
|
+
resource.status_command "/etc/init.d/chef status"
|
82
|
+
expect(resource.status_command).to eql("/etc/init.d/chef status")
|
86
83
|
end
|
87
84
|
|
88
|
-
it "
|
85
|
+
it "does not accept a regexp for the service status command" do
|
89
86
|
expect do
|
90
|
-
|
87
|
+
resource.status_command /.*/
|
91
88
|
end.to raise_error(ArgumentError)
|
92
89
|
end
|
93
90
|
|
94
|
-
it "
|
95
|
-
|
96
|
-
expect(
|
91
|
+
it "accepts a string for the service restart command" do
|
92
|
+
resource.restart_command "/etc/init.d/chef restart"
|
93
|
+
expect(resource.restart_command).to eql("/etc/init.d/chef restart")
|
97
94
|
end
|
98
95
|
|
99
|
-
it "
|
96
|
+
it "does not accept a regexp for the service restart command" do
|
100
97
|
expect do
|
101
|
-
|
98
|
+
resource.restart_command /.*/
|
102
99
|
end.to raise_error(ArgumentError)
|
103
100
|
end
|
104
101
|
|
105
|
-
it "
|
106
|
-
|
107
|
-
expect(
|
102
|
+
it "accepts a string for the service reload command" do
|
103
|
+
resource.reload_command "/etc/init.d/chef reload"
|
104
|
+
expect(resource.reload_command).to eql("/etc/init.d/chef reload")
|
108
105
|
end
|
109
106
|
|
110
|
-
it "
|
107
|
+
it "does not accept a regexp for the service reload command" do
|
111
108
|
expect do
|
112
|
-
|
109
|
+
resource.reload_command /.*/
|
113
110
|
end.to raise_error(ArgumentError)
|
114
111
|
end
|
115
112
|
|
116
|
-
it "
|
117
|
-
|
118
|
-
expect(
|
113
|
+
it "accepts a string for the service init command" do
|
114
|
+
resource.init_command "/etc/init.d/chef"
|
115
|
+
expect(resource.init_command).to eql("/etc/init.d/chef")
|
119
116
|
end
|
120
117
|
|
121
|
-
it "
|
118
|
+
it "does not accept a regexp for the service init command" do
|
122
119
|
expect do
|
123
|
-
|
120
|
+
resource.init_command /.*/
|
124
121
|
end.to raise_error(ArgumentError)
|
125
122
|
end
|
126
123
|
|
127
|
-
it "
|
128
|
-
|
129
|
-
expect(
|
124
|
+
it "accepts an array for options" do
|
125
|
+
resource.options ["-r", "-s"]
|
126
|
+
expect(resource.options).to eql(["-r", "-s"])
|
130
127
|
end
|
131
128
|
|
132
|
-
it "
|
133
|
-
|
134
|
-
expect(
|
129
|
+
it "accepts a string for options" do
|
130
|
+
resource.options "-r"
|
131
|
+
expect(resource.options).to eql(["-r"])
|
135
132
|
end
|
136
133
|
|
137
|
-
it "
|
138
|
-
|
139
|
-
expect(
|
134
|
+
it "accepts a string with multiple flags for options" do
|
135
|
+
resource.options "-r -s"
|
136
|
+
expect(resource.options).to eql(["-r", "-s"])
|
140
137
|
end
|
141
138
|
|
142
|
-
it "
|
139
|
+
it "does not accept a boolean for options" do
|
143
140
|
expect do
|
144
|
-
|
141
|
+
resource.options true
|
145
142
|
end.to raise_error(ArgumentError)
|
146
143
|
end
|
147
144
|
|
148
145
|
%w{enabled running}.each do |attrib|
|
149
|
-
it "
|
150
|
-
|
151
|
-
expect(
|
146
|
+
it "accepts true for #{attrib}" do
|
147
|
+
resource.send(attrib, true)
|
148
|
+
expect(resource.send(attrib)).to eql(true)
|
152
149
|
end
|
153
150
|
|
154
|
-
it "
|
155
|
-
|
156
|
-
expect(
|
151
|
+
it "accepts false for #{attrib}" do
|
152
|
+
resource.send(attrib, false)
|
153
|
+
expect(resource.send(attrib)).to eql(false)
|
157
154
|
end
|
158
155
|
|
159
|
-
it "
|
160
|
-
expect {
|
156
|
+
it "does not accept a string for #{attrib}" do
|
157
|
+
expect { resource.send(attrib, "poop") }.to raise_error(ArgumentError)
|
161
158
|
end
|
162
159
|
|
163
|
-
it "
|
160
|
+
it "defaults all the feature support to nil" do
|
164
161
|
support_hash = { :status => nil, :restart => nil, :reload => nil }
|
165
|
-
expect(
|
162
|
+
expect(resource.supports).to eq(support_hash)
|
166
163
|
end
|
167
164
|
|
168
|
-
it "
|
165
|
+
it "allows you to set what features this resource supports as a array" do
|
169
166
|
support_array = [ :status, :restart ]
|
170
167
|
support_hash = { :status => true, :restart => true }
|
171
|
-
|
172
|
-
expect(
|
168
|
+
resource.supports(support_array)
|
169
|
+
expect(resource.supports).to eq(support_hash)
|
173
170
|
end
|
174
171
|
|
175
|
-
it "
|
172
|
+
it "allows you to set what features this resource supports as a hash" do
|
176
173
|
support_hash = { :status => true, :restart => true }
|
177
|
-
|
178
|
-
expect(
|
174
|
+
resource.supports(support_hash)
|
175
|
+
expect(resource.supports).to eq(support_hash)
|
179
176
|
end
|
180
177
|
end
|
181
178
|
|
182
179
|
describe "when it has pattern and supports" do
|
183
180
|
before do
|
184
|
-
|
185
|
-
|
186
|
-
|
181
|
+
resource.service_name("superfriend")
|
182
|
+
resource.enabled(true)
|
183
|
+
resource.running(false)
|
187
184
|
end
|
188
185
|
|
189
186
|
it "describes its state" do
|
190
|
-
state =
|
187
|
+
state = resource.state_for_resource_reporter
|
191
188
|
expect(state[:enabled]).to eql(true)
|
192
189
|
expect(state[:running]).to eql(false)
|
193
190
|
end
|
194
191
|
|
195
192
|
it "returns the service name as its identity" do
|
196
|
-
expect(
|
193
|
+
expect(resource.identity).to eq("superfriend")
|
197
194
|
end
|
198
195
|
end
|
199
196
|
end
|
@@ -30,4 +30,9 @@ describe Chef::Resource::SmartosPackage, "initialize" do
|
|
30
30
|
platform_family: "smartos"
|
31
31
|
)
|
32
32
|
|
33
|
+
let(:resource) { Chef::Resource::SmartosPackage.new("foo") }
|
34
|
+
|
35
|
+
it "sets the package_name to the name provided" do
|
36
|
+
expect(resource.package_name).to eql("foo")
|
37
|
+
end
|
33
38
|
end
|
@@ -32,11 +32,9 @@ describe Chef::Resource::SolarisPackage, "initialize" do
|
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
@resource = Chef::Resource::SolarisPackage.new("foo")
|
37
|
-
end
|
35
|
+
let(:resource) { Chef::Resource::SolarisPackage.new("foo") }
|
38
36
|
|
39
|
-
it "
|
40
|
-
expect(
|
37
|
+
it "sets the package_name to the name provided" do
|
38
|
+
expect(resource.package_name).to eql("foo")
|
41
39
|
end
|
42
40
|
end
|
@@ -28,44 +28,46 @@ describe Chef::Resource::Subversion do
|
|
28
28
|
action: :install
|
29
29
|
)
|
30
30
|
|
31
|
-
|
32
|
-
@svn = Chef::Resource::Subversion.new("ohai, svn project!")
|
33
|
-
end
|
31
|
+
let(:resource) { Chef::Resource::Subversion.new("ohai, svn project!") }
|
34
32
|
|
35
33
|
it "is a subclass of Resource::Scm" do
|
36
|
-
expect(
|
37
|
-
expect(
|
34
|
+
expect(resource).to be_an_instance_of(Chef::Resource::Subversion)
|
35
|
+
expect(resource).to be_a_kind_of(Chef::Resource::Scm)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "set destination property to the name_property" do
|
39
|
+
expect(resource.destination).to eq("ohai, svn project!")
|
38
40
|
end
|
39
41
|
|
40
42
|
it "allows the force_export action" do
|
41
|
-
expect(
|
43
|
+
expect(resource.allowed_actions).to include(:force_export)
|
42
44
|
end
|
43
45
|
|
44
46
|
it "sets svn info arguments to --no-auth-cache by default" do
|
45
|
-
expect(
|
47
|
+
expect(resource.svn_info_args).to eq("--no-auth-cache")
|
46
48
|
end
|
47
49
|
|
48
50
|
it "resets svn info arguments to nil when given false in the setter" do
|
49
|
-
|
50
|
-
expect(
|
51
|
+
resource.svn_info_args(false)
|
52
|
+
expect(resource.svn_info_args).to be_nil
|
51
53
|
end
|
52
54
|
|
53
55
|
it "sets svn arguments to --no-auth-cache by default" do
|
54
|
-
expect(
|
56
|
+
expect(resource.svn_arguments).to eq("--no-auth-cache")
|
55
57
|
end
|
56
58
|
|
57
59
|
it "sets svn binary to nil by default" do
|
58
|
-
expect(
|
60
|
+
expect(resource.svn_binary).to be_nil
|
59
61
|
end
|
60
62
|
|
61
63
|
it "resets svn arguments to nil when given false in the setter" do
|
62
|
-
|
63
|
-
expect(
|
64
|
+
resource.svn_arguments(false)
|
65
|
+
expect(resource.svn_arguments).to be_nil
|
64
66
|
end
|
65
67
|
|
66
68
|
it "hides password from custom exception message" do
|
67
|
-
|
68
|
-
e =
|
69
|
-
expect(e.message.include?(
|
69
|
+
resource.svn_password "l33th4x0rpa$$w0rd"
|
70
|
+
e = resource.customize_exception(Chef::Exceptions::Exec.new "Exception with password #{resource.svn_password}")
|
71
|
+
expect(e.message.include?(resource.svn_password)).to be_falsey
|
70
72
|
end
|
71
73
|
end
|
@@ -19,12 +19,8 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Chef::Resource::SystemdUnit do
|
22
|
-
|
23
|
-
@resource = Chef::Resource::SystemdUnit.new("sysstat-collect.timer")
|
24
|
-
end
|
25
|
-
|
22
|
+
let(:resource) { Chef::Resource::SystemdUnit.new("sysstat-collect.timer") }
|
26
23
|
let(:unit_content_string) { "[Unit]\nDescription = Run system activity accounting tool every 10 minutes\n\n[Timer]\nOnCalendar = *:00/10\n\n[Install]\nWantedBy = sysstat.service\n" }
|
27
|
-
|
28
24
|
let(:unit_content_hash) do
|
29
25
|
{
|
30
26
|
"Unit" => {
|
@@ -40,76 +36,76 @@ describe Chef::Resource::SystemdUnit do
|
|
40
36
|
end
|
41
37
|
|
42
38
|
it "creates a new Chef::Resource::SystemdUnit" do
|
43
|
-
expect(
|
44
|
-
expect(
|
39
|
+
expect(resource).to be_a_kind_of(Chef::Resource)
|
40
|
+
expect(resource).to be_a_kind_of(Chef::Resource::SystemdUnit)
|
45
41
|
end
|
46
42
|
|
47
|
-
it "
|
48
|
-
expect(
|
43
|
+
it "has a name" do
|
44
|
+
expect(resource.name).to eql("sysstat-collect.timer")
|
49
45
|
end
|
50
46
|
|
51
47
|
it "has a default action of nothing" do
|
52
|
-
expect(
|
48
|
+
expect(resource.action).to eql([:nothing])
|
53
49
|
end
|
54
50
|
|
55
51
|
it "supports appropriate unit actions" do
|
56
|
-
expect {
|
57
|
-
expect {
|
58
|
-
expect {
|
59
|
-
expect {
|
60
|
-
expect {
|
61
|
-
expect {
|
62
|
-
expect {
|
63
|
-
expect {
|
64
|
-
expect {
|
65
|
-
expect {
|
66
|
-
expect {
|
52
|
+
expect { resource.action :create }.not_to raise_error
|
53
|
+
expect { resource.action :delete }.not_to raise_error
|
54
|
+
expect { resource.action :enable }.not_to raise_error
|
55
|
+
expect { resource.action :disable }.not_to raise_error
|
56
|
+
expect { resource.action :mask }.not_to raise_error
|
57
|
+
expect { resource.action :unmask }.not_to raise_error
|
58
|
+
expect { resource.action :start }.not_to raise_error
|
59
|
+
expect { resource.action :stop }.not_to raise_error
|
60
|
+
expect { resource.action :restart }.not_to raise_error
|
61
|
+
expect { resource.action :reload }.not_to raise_error
|
62
|
+
expect { resource.action :wrong }.to raise_error(ArgumentError)
|
67
63
|
end
|
68
64
|
|
69
65
|
it "accepts boolean state properties" do
|
70
|
-
expect {
|
71
|
-
expect {
|
72
|
-
expect {
|
66
|
+
expect { resource.active false }.not_to raise_error
|
67
|
+
expect { resource.active true }.not_to raise_error
|
68
|
+
expect { resource.active "yes" }.to raise_error(ArgumentError)
|
73
69
|
|
74
|
-
expect {
|
75
|
-
expect {
|
76
|
-
expect {
|
70
|
+
expect { resource.enabled true }.not_to raise_error
|
71
|
+
expect { resource.enabled false }.not_to raise_error
|
72
|
+
expect { resource.enabled "no" }.to raise_error(ArgumentError)
|
77
73
|
|
78
|
-
expect {
|
79
|
-
expect {
|
80
|
-
expect {
|
74
|
+
expect { resource.masked true }.not_to raise_error
|
75
|
+
expect { resource.masked false }.not_to raise_error
|
76
|
+
expect { resource.masked :nope }.to raise_error(ArgumentError)
|
81
77
|
|
82
|
-
expect {
|
83
|
-
expect {
|
84
|
-
expect {
|
78
|
+
expect { resource.static true }.not_to raise_error
|
79
|
+
expect { resource.static false }.not_to raise_error
|
80
|
+
expect { resource.static "yep" }.to raise_error(ArgumentError)
|
85
81
|
end
|
86
82
|
|
87
83
|
it "accepts the content property" do
|
88
|
-
expect {
|
89
|
-
expect {
|
90
|
-
expect {
|
91
|
-
expect {
|
84
|
+
expect { resource.content nil }.not_to raise_error
|
85
|
+
expect { resource.content "test" }.not_to raise_error
|
86
|
+
expect { resource.content({}) }.not_to raise_error
|
87
|
+
expect { resource.content 5 }.to raise_error(ArgumentError)
|
92
88
|
end
|
93
89
|
|
94
90
|
it "accepts the user property" do
|
95
|
-
expect {
|
96
|
-
expect {
|
97
|
-
expect {
|
91
|
+
expect { resource.user nil }.not_to raise_error
|
92
|
+
expect { resource.user "deploy" }.not_to raise_error
|
93
|
+
expect { resource.user 5 }.to raise_error(ArgumentError)
|
98
94
|
end
|
99
95
|
|
100
96
|
it "accepts the triggers_reload property" do
|
101
|
-
expect {
|
102
|
-
expect {
|
103
|
-
expect {
|
97
|
+
expect { resource.triggers_reload true }.not_to raise_error
|
98
|
+
expect { resource.triggers_reload false }.not_to raise_error
|
99
|
+
expect { resource.triggers_reload "no" }.to raise_error(ArgumentError)
|
104
100
|
end
|
105
101
|
|
106
102
|
it "reports its state" do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
state =
|
103
|
+
resource.active true
|
104
|
+
resource.enabled true
|
105
|
+
resource.masked false
|
106
|
+
resource.static false
|
107
|
+
resource.content "test"
|
108
|
+
state = resource.state_for_resource_reporter
|
113
109
|
expect(state[:active]).to eq(true)
|
114
110
|
expect(state[:enabled]).to eq(true)
|
115
111
|
expect(state[:masked]).to eq(false)
|
@@ -118,16 +114,16 @@ describe Chef::Resource::SystemdUnit do
|
|
118
114
|
end
|
119
115
|
|
120
116
|
it "returns the unit name as its identity" do
|
121
|
-
expect(
|
117
|
+
expect(resource.identity).to eq("sysstat-collect.timer")
|
122
118
|
end
|
123
119
|
|
124
120
|
it "serializes to ini with a string-formatted content property" do
|
125
|
-
|
126
|
-
expect(
|
121
|
+
resource.content(unit_content_string)
|
122
|
+
expect(resource.to_ini).to eq unit_content_string
|
127
123
|
end
|
128
124
|
|
129
125
|
it "serializes to ini with a hash-formatted content property" do
|
130
|
-
|
131
|
-
expect(
|
126
|
+
resource.content(unit_content_hash)
|
127
|
+
expect(resource.to_ini).to eq unit_content_string
|
132
128
|
end
|
133
129
|
end
|