chef 13.6.4-universal-mingw32 → 13.7.16-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- 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 +7 -19
- data/acceptance/.DS_Store +0 -0
- data/acceptance/.bundle/config +0 -2
- data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
- data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
- data/distro/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/chef/.DS_Store +0 -0
- data/lib/chef/knife/.DS_Store +0 -0
- data/lib/chef/mixin/.DS_Store +0 -0
- data/spec/.DS_Store +0 -0
- data/spec/functional/.DS_Store +0 -0
- data/spec/support/.DS_Store +0 -0
- data/spec/unit/.DS_Store +0 -0
- data/tasks/.DS_Store +0 -0
@@ -19,76 +19,73 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Chef::Resource::Template do
|
22
|
-
|
23
|
-
before(:each) do
|
24
|
-
@resource = Chef::Resource::Template.new("fakey_fakerton")
|
25
|
-
end
|
22
|
+
let(:resource) { Chef::Resource::Template.new("fakey_fakerton") }
|
26
23
|
|
27
24
|
describe "initialize" do
|
28
|
-
it "
|
29
|
-
expect(
|
30
|
-
expect(
|
31
|
-
expect(
|
25
|
+
it "creates a new Chef::Resource::Template" do
|
26
|
+
expect(resource).to be_a_kind_of(Chef::Resource)
|
27
|
+
expect(resource).to be_a_kind_of(Chef::Resource::File)
|
28
|
+
expect(resource).to be_a_kind_of(Chef::Resource::Template)
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
35
32
|
describe "source" do
|
36
|
-
it "
|
37
|
-
|
38
|
-
expect(
|
33
|
+
it "accepts a string for the template source" do
|
34
|
+
resource.source "something"
|
35
|
+
expect(resource.source).to eql("something")
|
39
36
|
end
|
40
37
|
|
41
|
-
it "
|
42
|
-
expect(
|
38
|
+
it "has a default based on the param name with .erb appended" do
|
39
|
+
expect(resource.source).to eql("fakey_fakerton.erb")
|
43
40
|
end
|
44
41
|
|
45
|
-
it "
|
42
|
+
it "uses only the basename of the file as the default" do
|
46
43
|
r = Chef::Resource::Template.new("/tmp/obit/fakey_fakerton")
|
47
44
|
expect(r.source).to eql("fakey_fakerton.erb")
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
51
48
|
describe "variables" do
|
52
|
-
it "
|
53
|
-
|
54
|
-
expect(
|
49
|
+
it "accepts a hash for the variable list" do
|
50
|
+
resource.variables({ :reluctance => :awkward })
|
51
|
+
expect(resource.variables).to eq({ :reluctance => :awkward })
|
55
52
|
end
|
56
53
|
end
|
57
54
|
|
58
55
|
describe "cookbook" do
|
59
|
-
it "
|
60
|
-
|
61
|
-
expect(
|
56
|
+
it "accepts a string for the cookbook name" do
|
57
|
+
resource.cookbook("foo")
|
58
|
+
expect(resource.cookbook).to eq("foo")
|
62
59
|
end
|
63
60
|
|
64
|
-
it "
|
65
|
-
expect(
|
61
|
+
it "defaults to nil" do
|
62
|
+
expect(resource.cookbook).to eq(nil)
|
66
63
|
end
|
67
64
|
end
|
68
65
|
|
69
66
|
describe "local" do
|
70
|
-
it "
|
71
|
-
|
72
|
-
expect(
|
67
|
+
it "accepts a boolean for whether a template is local or remote" do
|
68
|
+
resource.local(true)
|
69
|
+
expect(resource.local).to eq(true)
|
73
70
|
end
|
74
71
|
|
75
|
-
it "
|
76
|
-
expect(
|
72
|
+
it "defaults to false" do
|
73
|
+
expect(resource.local).to eq(false)
|
77
74
|
end
|
78
75
|
end
|
79
76
|
|
80
77
|
describe "when it has a path, owner, group, mode, and checksum" do
|
81
78
|
before do
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
79
|
+
resource.path("/tmp/foo.txt")
|
80
|
+
resource.owner("root")
|
81
|
+
resource.group("wheel")
|
82
|
+
resource.mode("0644")
|
83
|
+
resource.checksum("1" * 64)
|
87
84
|
end
|
88
85
|
|
89
86
|
context "on unix", :unix_only do
|
90
87
|
it "describes its state" do
|
91
|
-
state =
|
88
|
+
state = resource.state_for_resource_reporter
|
92
89
|
expect(state[:owner]).to eq("root")
|
93
90
|
expect(state[:group]).to eq("wheel")
|
94
91
|
expect(state[:mode]).to eq("0644")
|
@@ -102,7 +99,7 @@ describe Chef::Resource::Template do
|
|
102
99
|
end
|
103
100
|
|
104
101
|
it "returns the file path as its identity" do
|
105
|
-
expect(
|
102
|
+
expect(resource.identity).to eq("/tmp/foo.txt")
|
106
103
|
end
|
107
104
|
end
|
108
105
|
|
@@ -115,16 +112,16 @@ describe Chef::Resource::Template do
|
|
115
112
|
end
|
116
113
|
|
117
114
|
it "collects helper method bodies as blocks" do
|
118
|
-
|
119
|
-
|
120
|
-
expect(
|
121
|
-
expect(
|
115
|
+
resource.helper(:example_1) { "example_1" }
|
116
|
+
resource.helper(:example_2) { "example_2" }
|
117
|
+
expect(resource.inline_helper_blocks[:example_1].call).to eq("example_1")
|
118
|
+
expect(resource.inline_helper_blocks[:example_2].call).to eq("example_2")
|
122
119
|
end
|
123
120
|
|
124
121
|
it "compiles helper methods into a module" do
|
125
|
-
|
126
|
-
|
127
|
-
modules =
|
122
|
+
resource.helper(:example_1) { "example_1" }
|
123
|
+
resource.helper(:example_2) { "example_2" }
|
124
|
+
modules = resource.helper_modules
|
128
125
|
expect(modules.size).to eq(1)
|
129
126
|
o = Object.new
|
130
127
|
modules.each { |m| o.extend(m) }
|
@@ -133,38 +130,38 @@ describe Chef::Resource::Template do
|
|
133
130
|
end
|
134
131
|
|
135
132
|
it "compiles helper methods with arguments into a module" do
|
136
|
-
|
137
|
-
modules =
|
133
|
+
resource.helper(:shout) { |quiet| quiet.upcase }
|
134
|
+
modules = resource.helper_modules
|
138
135
|
o = Object.new
|
139
136
|
modules.each { |m| o.extend(m) }
|
140
137
|
expect(o.shout("shout")).to eq("SHOUT")
|
141
138
|
end
|
142
139
|
|
143
140
|
it "raises an error when attempting to define a helper method without a method body" do
|
144
|
-
expect {
|
141
|
+
expect { resource.helper(:example) }.to raise_error(Chef::Exceptions::ValidationFailed)
|
145
142
|
end
|
146
143
|
|
147
144
|
it "raises an error when attempting to define a helper method with a non-Symbod method name" do
|
148
|
-
expect {
|
145
|
+
expect { resource.helper("example") { "fail" } }.to raise_error(Chef::Exceptions::ValidationFailed)
|
149
146
|
end
|
150
147
|
|
151
148
|
it "collects helper module bodies as blocks" do
|
152
|
-
|
149
|
+
resource.helpers do
|
153
150
|
def example_1
|
154
151
|
"example_1"
|
155
152
|
end
|
156
153
|
end
|
157
|
-
module_body =
|
154
|
+
module_body = resource.inline_helper_modules.first
|
158
155
|
expect(module_body).to be_a(Proc)
|
159
156
|
end
|
160
157
|
|
161
158
|
it "compiles helper module bodies into modules" do
|
162
|
-
|
159
|
+
resource.helpers do
|
163
160
|
def example_1
|
164
161
|
"example_1"
|
165
162
|
end
|
166
163
|
end
|
167
|
-
modules =
|
164
|
+
modules = resource.helper_modules
|
168
165
|
expect(modules.size).to eq(1)
|
169
166
|
o = Object.new
|
170
167
|
modules.each { |m| o.extend(m) }
|
@@ -172,39 +169,37 @@ describe Chef::Resource::Template do
|
|
172
169
|
end
|
173
170
|
|
174
171
|
it "raises an error when no block or module name is given for helpers definition" do
|
175
|
-
expect {
|
172
|
+
expect { resource.helpers() }.to raise_error(Chef::Exceptions::ValidationFailed)
|
176
173
|
end
|
177
174
|
|
178
175
|
it "raises an error when a non-module is given for helpers definition" do
|
179
|
-
expect {
|
176
|
+
expect { resource.helpers("NotAModule") }.to raise_error(Chef::Exceptions::ValidationFailed)
|
180
177
|
end
|
181
178
|
|
182
179
|
it "raises an error when a module name and block are both given for helpers definition" do
|
183
|
-
expect {
|
180
|
+
expect { resource.helpers(ExampleHelpers) { module_code } }.to raise_error(Chef::Exceptions::ValidationFailed)
|
184
181
|
end
|
185
182
|
|
186
183
|
it "collects helper modules" do
|
187
|
-
|
188
|
-
expect(
|
184
|
+
resource.helpers(ExampleHelpers)
|
185
|
+
expect(resource.helper_modules).to include(ExampleHelpers)
|
189
186
|
end
|
190
187
|
|
191
188
|
it "combines all helpers into a set of compiled modules" do
|
192
|
-
|
193
|
-
|
189
|
+
resource.helpers(ExampleHelpers)
|
190
|
+
resource.helpers do
|
194
191
|
def inline_module
|
195
192
|
"inline_module"
|
196
193
|
end
|
197
194
|
end
|
198
|
-
|
199
|
-
expect(
|
195
|
+
resource.helper(:inline_method) { "inline_method" }
|
196
|
+
expect(resource.helper_modules.size).to eq(3)
|
200
197
|
|
201
198
|
o = Object.new
|
202
|
-
|
199
|
+
resource.helper_modules.each { |m| o.extend(m) }
|
203
200
|
expect(o.static_example).to eq("static_example")
|
204
201
|
expect(o.inline_module).to eq("inline_module")
|
205
202
|
expect(o.inline_method).to eq("inline_method")
|
206
203
|
end
|
207
|
-
|
208
204
|
end
|
209
|
-
|
210
205
|
end
|
@@ -19,115 +19,109 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Chef::Resource::User, "initialize" do
|
22
|
-
|
23
|
-
@resource = Chef::Resource::User.new("adam")
|
24
|
-
end
|
22
|
+
let(:resource) { Chef::Resource::User.new("adam") }
|
25
23
|
|
26
|
-
it "
|
27
|
-
expect(
|
28
|
-
expect(
|
24
|
+
it "creates a new Chef::Resource::User" do
|
25
|
+
expect(resource).to be_a_kind_of(Chef::Resource)
|
26
|
+
expect(resource).to be_a_kind_of(Chef::Resource::User)
|
29
27
|
end
|
30
28
|
|
31
|
-
it "
|
32
|
-
expect(
|
29
|
+
it "sets the resource_name to :user" do
|
30
|
+
expect(resource.resource_name).to eql(:user_resource_abstract_base_class)
|
33
31
|
end
|
34
32
|
|
35
|
-
it "
|
36
|
-
expect(
|
33
|
+
it "sets the username equal to the argument to initialize" do
|
34
|
+
expect(resource.username).to eql("adam")
|
37
35
|
end
|
38
36
|
|
39
37
|
%w{comment uid gid home shell password}.each do |attrib|
|
40
|
-
it "
|
41
|
-
expect(
|
38
|
+
it "sets #{attrib} to nil" do
|
39
|
+
expect(resource.send(attrib)).to eql(nil)
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
45
|
-
it "
|
46
|
-
expect(
|
43
|
+
it "sets action to :create" do
|
44
|
+
expect(resource.action).to eql([:create])
|
47
45
|
end
|
48
46
|
|
49
|
-
it "
|
50
|
-
expect(
|
47
|
+
it "sets manage_home to false" do
|
48
|
+
expect(resource.manage_home).to eql(false)
|
51
49
|
end
|
52
50
|
|
53
|
-
it "
|
54
|
-
expect(
|
51
|
+
it "sets non_unique to false" do
|
52
|
+
expect(resource.non_unique).to eql(false)
|
55
53
|
end
|
56
54
|
|
57
|
-
it "
|
58
|
-
expect(
|
55
|
+
it "sets force to false" do
|
56
|
+
expect(resource.force).to eql(false)
|
59
57
|
end
|
60
58
|
|
61
59
|
%w{create remove modify manage lock unlock}.each do |action|
|
62
|
-
it "
|
63
|
-
expect(
|
60
|
+
it "allows action #{action}" do
|
61
|
+
expect(resource.allowed_actions.detect { |a| a == action.to_sym }).to eql(action.to_sym)
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
67
|
-
it "
|
68
|
-
expect {
|
69
|
-
expect(
|
70
|
-
expect {
|
71
|
-
expect(
|
65
|
+
it "accepts domain users (@ or \ separator) on non-windows" do
|
66
|
+
expect { resource.username "domain\@user" }.not_to raise_error
|
67
|
+
expect(resource.username).to eq("domain\@user")
|
68
|
+
expect { resource.username "domain\\user" }.not_to raise_error
|
69
|
+
expect(resource.username).to eq("domain\\user")
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
75
73
|
%w{username comment home shell password}.each do |attrib|
|
76
74
|
describe Chef::Resource::User, attrib do
|
77
|
-
|
78
|
-
@resource = Chef::Resource::User.new("adam")
|
79
|
-
end
|
75
|
+
let(:resource) { Chef::Resource::User.new("adam") }
|
80
76
|
|
81
|
-
it "
|
82
|
-
|
83
|
-
expect(
|
77
|
+
it "allows a string" do
|
78
|
+
resource.send(attrib, "adam")
|
79
|
+
expect(resource.send(attrib)).to eql("adam")
|
84
80
|
end
|
85
81
|
|
86
|
-
it "
|
87
|
-
expect {
|
82
|
+
it "does not allow a hash" do
|
83
|
+
expect { resource.send(attrib, { :woot => "i found it" }) }.to raise_error(ArgumentError)
|
88
84
|
end
|
89
85
|
end
|
90
86
|
end
|
91
87
|
|
92
88
|
%w{uid gid}.each do |attrib|
|
93
89
|
describe Chef::Resource::User, attrib do
|
94
|
-
|
95
|
-
@resource = Chef::Resource::User.new("adam")
|
96
|
-
end
|
90
|
+
let(:resource) { Chef::Resource::User.new("adam") }
|
97
91
|
|
98
|
-
it "
|
99
|
-
|
100
|
-
expect(
|
92
|
+
it "allows a string" do
|
93
|
+
resource.send(attrib, "100")
|
94
|
+
expect(resource.send(attrib)).to eql("100")
|
101
95
|
end
|
102
96
|
|
103
|
-
it "
|
104
|
-
|
105
|
-
expect(
|
97
|
+
it "allows an integer" do
|
98
|
+
resource.send(attrib, 100)
|
99
|
+
expect(resource.send(attrib)).to eql(100)
|
106
100
|
end
|
107
101
|
|
108
|
-
it "
|
109
|
-
expect {
|
102
|
+
it "does not allow a hash" do
|
103
|
+
expect { resource.send(attrib, { :woot => "i found it" }) }.to raise_error(ArgumentError)
|
110
104
|
end
|
111
105
|
end
|
112
106
|
|
113
107
|
describe "when it has uid, gid, and home" do
|
108
|
+
let(:resource) { Chef::Resource::User.new("root") }
|
109
|
+
|
114
110
|
before do
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
@resource.home("/usr/local/root/")
|
111
|
+
resource.uid(123)
|
112
|
+
resource.gid(456)
|
113
|
+
resource.home("/usr/local/root/")
|
119
114
|
end
|
120
115
|
|
121
116
|
it "describes its state" do
|
122
|
-
state =
|
117
|
+
state = resource.state_for_resource_reporter
|
123
118
|
expect(state[:uid]).to eq(123)
|
124
119
|
expect(state[:gid]).to eq(456)
|
125
120
|
expect(state[:home]).to eq("/usr/local/root/")
|
126
121
|
end
|
127
122
|
|
128
123
|
it "returns the username as its identity" do
|
129
|
-
expect(
|
124
|
+
expect(resource.identity).to eq("root")
|
130
125
|
end
|
131
126
|
end
|
132
|
-
|
133
127
|
end
|
@@ -88,7 +88,7 @@ describe Chef::Resource::WindowsPackage, "initialize" do
|
|
88
88
|
let(:resource_source) { "https://foo.bar/solitare.msi" }
|
89
89
|
let(:resource) { Chef::Resource::WindowsPackage.new(resource_source) }
|
90
90
|
|
91
|
-
it "
|
91
|
+
it "returns the source unmodified" do
|
92
92
|
expect(resource.source).to eq(resource_source)
|
93
93
|
end
|
94
94
|
end
|
@@ -19,20 +19,23 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Chef::Resource::WindowsPath do
|
22
|
-
|
23
|
-
|
24
|
-
it { is_expected.to be_a_kind_of(Chef::Resource) }
|
25
|
-
it { is_expected.to be_a_instance_of(Chef::Resource::WindowsPath) }
|
22
|
+
let(:resource) { Chef::Resource::WindowsPath.new("some_path") }
|
26
23
|
|
27
24
|
it "sets resource name as :windows_path" do
|
28
|
-
expect(
|
25
|
+
expect(resource.resource_name).to eql(:windows_path)
|
29
26
|
end
|
30
27
|
|
31
|
-
it "sets the path as
|
32
|
-
expect(
|
28
|
+
it "sets the path as its name" do
|
29
|
+
expect(resource.path).to eql("some_path")
|
33
30
|
end
|
34
31
|
|
35
32
|
it "sets the default action as :add" do
|
36
|
-
expect(
|
33
|
+
expect(resource.action).to eql([:add])
|
34
|
+
end
|
35
|
+
|
36
|
+
it "supports :add and :remove actions" do
|
37
|
+
expect { resource.action :add }.not_to raise_error
|
38
|
+
expect { resource.action :remove }.not_to raise_error
|
39
|
+
expect { resource.action :delete }.to raise_error(ArgumentError)
|
37
40
|
end
|
38
41
|
end
|
@@ -30,12 +30,12 @@ describe Chef::Resource::WindowsTask do
|
|
30
30
|
expect(resource.resource_name).to eql(:windows_task)
|
31
31
|
end
|
32
32
|
|
33
|
-
it "sets the task_name as
|
33
|
+
it "sets the task_name as its name" do
|
34
34
|
expect(resource.task_name).to eql("sample_task")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "sets the default action as :create" do
|
38
|
-
expect(resource.action).to eql(:create)
|
38
|
+
expect(resource.action).to eql([:create])
|
39
39
|
end
|
40
40
|
|
41
41
|
it "sets the default user as System" do
|
@@ -62,39 +62,86 @@ describe Chef::Resource::WindowsTask do
|
|
62
62
|
expect(resource.frequency).to eql(:hourly)
|
63
63
|
end
|
64
64
|
|
65
|
+
context "when user is set but password is not" do
|
66
|
+
it "raises an error if the user is a non-system user" do
|
67
|
+
resource.user "bob"
|
68
|
+
expect { resource.after_created }.to raise_error(ArgumentError, %q{Cannot specify a user other than the system users without specifying a password!. Valid passwordless users: 'NT AUTHORITY\SYSTEM', 'SYSTEM', 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE', 'BUILTIN\USERS', 'USERS'})
|
69
|
+
end
|
70
|
+
|
71
|
+
it "does not raise an error if the user is a system user" do
|
72
|
+
resource.user 'NT AUTHORITY\SYSTEM'
|
73
|
+
expect { resource.after_created }.to_not raise_error
|
74
|
+
end
|
75
|
+
|
76
|
+
it "does not raise an error if the user is a system user even if lowercase" do
|
77
|
+
resource.user 'nt authority\system'
|
78
|
+
expect { resource.after_created }.to_not raise_error
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
65
82
|
context "when random_delay is passed" do
|
66
83
|
it "raises error if frequency is `:once`" do
|
67
84
|
resource.frequency :once
|
68
85
|
resource.random_delay "20"
|
69
|
-
expect { resource.after_created }.to raise_error(
|
86
|
+
expect { resource.after_created }.to raise_error(ArgumentError, "`random_delay` property is supported only for frequency :minute, :hourly, :daily, :weekly and :monthly")
|
70
87
|
end
|
71
88
|
|
72
89
|
it "raises error for invalid random_delay" do
|
73
90
|
resource.frequency :monthly
|
74
91
|
resource.random_delay "xyz"
|
75
|
-
expect { resource.after_created }.to raise_error(
|
92
|
+
expect { resource.after_created }.to raise_error(ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
|
76
93
|
end
|
77
94
|
|
78
|
-
it "
|
95
|
+
it "raises error for invalid random_delay which looks like an Integer" do
|
96
|
+
resource.frequency :monthly
|
97
|
+
resource.random_delay "5,000"
|
98
|
+
expect { resource.after_created }.to raise_error(ArgumentError, "Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "converts seconds String into iso8601 duration format" do
|
79
102
|
resource.frequency :monthly
|
80
103
|
resource.random_delay "60"
|
81
104
|
resource.after_created
|
82
105
|
expect(resource.random_delay).to eq("PT60S")
|
83
106
|
end
|
107
|
+
|
108
|
+
it "converts seconds Integer into iso8601 duration format" do
|
109
|
+
resource.frequency :monthly
|
110
|
+
resource.random_delay 60
|
111
|
+
resource.after_created
|
112
|
+
expect(resource.random_delay).to eq("PT60S")
|
113
|
+
end
|
114
|
+
|
115
|
+
it "raises error that random_delay is not supported" do
|
116
|
+
expect { resource.send(:validate_random_delay, 60, :on_idle) }.to raise_error(ArgumentError, "`random_delay` property is supported only for frequency :minute, :hourly, :daily, :weekly and :monthly")
|
117
|
+
end
|
84
118
|
end
|
85
119
|
|
86
|
-
context "when execution_time_limit
|
87
|
-
it "sets the
|
120
|
+
context "when execution_time_limit isn't specified" do
|
121
|
+
it "sets the default value to PT72H" do
|
88
122
|
resource.after_created
|
89
123
|
expect(resource.execution_time_limit).to eq("PT72H")
|
90
124
|
end
|
125
|
+
end
|
91
126
|
|
127
|
+
context "when execution_time_limit is passed" do
|
92
128
|
it "raises error for invalid execution_time_limit" do
|
93
129
|
resource.execution_time_limit "abc"
|
94
|
-
expect { resource.after_created }.to raise_error(
|
130
|
+
expect { resource.after_created }.to raise_error(ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
|
95
131
|
end
|
96
132
|
|
97
|
-
it "
|
133
|
+
it "raises error for invalid execution_time_limit that looks like an Integer" do
|
134
|
+
resource.execution_time_limit "5,000"
|
135
|
+
expect { resource.after_created }.to raise_error(ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
|
136
|
+
end
|
137
|
+
|
138
|
+
it "converts seconds Integer into iso8601 format" do
|
139
|
+
resource.execution_time_limit 60
|
140
|
+
resource.after_created
|
141
|
+
expect(resource.execution_time_limit).to eq("PT60S")
|
142
|
+
end
|
143
|
+
|
144
|
+
it "converts seconds String into iso8601 format" do
|
98
145
|
resource.execution_time_limit "60"
|
99
146
|
resource.after_created
|
100
147
|
expect(resource.execution_time_limit).to eq("PT60S")
|
@@ -104,28 +151,48 @@ describe Chef::Resource::WindowsTask do
|
|
104
151
|
context "#validate_start_time" do
|
105
152
|
it "raises error if start_time is nil when frequency `:once`" do
|
106
153
|
resource.frequency :once
|
107
|
-
expect { resource.send(:validate_start_time, nil, :once) }.to raise_error(
|
154
|
+
expect { resource.send(:validate_start_time, nil, :once) }.to raise_error(ArgumentError, "`start_time` needs to be provided with `frequency :once`")
|
108
155
|
end
|
109
156
|
|
110
157
|
it "raises error if start_time is given when frequency `:none`" do
|
111
158
|
resource.frequency :none
|
112
|
-
expect { resource.send(:validate_start_time, "12.00", :none) }.to raise_error(
|
159
|
+
expect { resource.send(:validate_start_time, "12.00", :none) }.to raise_error(ArgumentError, "`start_time` property is not supported with `frequency :none`")
|
160
|
+
end
|
161
|
+
|
162
|
+
it "raises error if start_time is not HH:mm format" do
|
163
|
+
resource.frequency :once
|
164
|
+
expect { resource.send(:validate_start_time, "2:30", :once) }.to raise_error(ArgumentError, "`start_time` property must be in the HH:mm format (e.g. 6:20pm -> 18:20).")
|
165
|
+
end
|
166
|
+
|
167
|
+
it "does not raise error if start_time is in HH:mm format" do
|
168
|
+
resource.frequency :once
|
169
|
+
expect { resource.send(:validate_start_time, "12:30", :once) }.not_to raise_error
|
113
170
|
end
|
114
171
|
end
|
115
172
|
|
116
173
|
context "#validate_start_day" do
|
117
|
-
it "raise error if start_day is passed with frequency :on_logon" do
|
118
|
-
resource.
|
119
|
-
expect { resource.send(:validate_start_day, "Wed", :on_logon) }.to raise_error(Chef::Exceptions::ArgumentError, "`start_day` property is not supported with frequency: on_logon")
|
174
|
+
it "raise error if start_day is passed with invalid frequency (:on_logon)" do
|
175
|
+
expect { resource.send(:validate_start_day, "02/07/1984", :on_logon) }.to raise_error(ArgumentError, "`start_day` property is not supported with frequency: on_logon")
|
120
176
|
end
|
121
|
-
end
|
122
177
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
178
|
+
it "does not raise error if start_day is passed with valid frequency (:weekly)" do
|
179
|
+
expect { resource.send(:validate_start_day, "02/07/1984", :weekly) }.not_to raise_error
|
180
|
+
end
|
181
|
+
|
182
|
+
it "raise error if start_day is passed with invalid date format (DD/MM/YYYY)" do
|
183
|
+
expect { resource.send(:validate_start_day, "28/12/2009", :weekly) }.to raise_error(ArgumentError, "`start_day` property must be in the MM/DD/YYYY format.")
|
184
|
+
end
|
185
|
+
|
186
|
+
it "raise error if start_day is passed with invalid date format (M/DD/YYYY)" do
|
187
|
+
expect { resource.send(:validate_start_day, "2/07/1984", :weekly) }.to raise_error(ArgumentError, "`start_day` property must be in the MM/DD/YYYY format.")
|
188
|
+
end
|
189
|
+
|
190
|
+
it "raise error if start_day is passed with invalid date format (MM/D/YYYY)" do
|
191
|
+
expect { resource.send(:validate_start_day, "02/7/1984", :weekly) }.to raise_error(ArgumentError, "`start_day` property must be in the MM/DD/YYYY format.")
|
192
|
+
end
|
193
|
+
|
194
|
+
it "raise error if start_day is passed with invalid date format (MM/DD/YY)" do
|
195
|
+
expect { resource.send(:validate_start_day, "02/07/84", :weekly) }.to raise_error(ArgumentError, "`start_day` property must be in the MM/DD/YYYY format.")
|
129
196
|
end
|
130
197
|
end
|
131
198
|
|
@@ -138,42 +205,42 @@ describe Chef::Resource::WindowsTask do
|
|
138
205
|
context "#validate_create_frequency_modifier" do
|
139
206
|
context "when frequency is :minute" do
|
140
207
|
it "raises error if frequency_modifier > 1439" do
|
141
|
-
expect { resource.send(:validate_create_frequency_modifier, :minute, 1500) }.to raise_error("frequency_modifier value 1500 is invalid.
|
208
|
+
expect { resource.send(:validate_create_frequency_modifier, :minute, 1500) }.to raise_error("frequency_modifier value 1500 is invalid. Valid values for :minute frequency are 1 - 1439.")
|
142
209
|
end
|
143
210
|
end
|
144
211
|
|
145
212
|
context "when frequency is :hourly" do
|
146
213
|
it "raises error if frequency_modifier > 23" do
|
147
|
-
expect { resource.send(:validate_create_frequency_modifier, :hourly, 24) }.to raise_error("frequency_modifier value 24 is invalid.
|
214
|
+
expect { resource.send(:validate_create_frequency_modifier, :hourly, 24) }.to raise_error("frequency_modifier value 24 is invalid. Valid values for :hourly frequency are 1 - 23.")
|
148
215
|
end
|
149
216
|
end
|
150
217
|
|
151
218
|
context "when frequency is :daily" do
|
152
219
|
it "raises error if frequency_modifier > 365" do
|
153
|
-
expect { resource.send(:validate_create_frequency_modifier, :daily, 366) }.to raise_error("frequency_modifier value 366 is invalid.
|
220
|
+
expect { resource.send(:validate_create_frequency_modifier, :daily, 366) }.to raise_error("frequency_modifier value 366 is invalid. Valid values for :daily frequency are 1 - 365.")
|
154
221
|
end
|
155
222
|
end
|
156
223
|
|
157
224
|
context "when frequency is :weekly" do
|
158
225
|
it "raises error if frequency_modifier > 52" do
|
159
|
-
expect { resource.send(:validate_create_frequency_modifier, :weekly, 53) }.to raise_error("frequency_modifier value 53 is invalid.
|
226
|
+
expect { resource.send(:validate_create_frequency_modifier, :weekly, 53) }.to raise_error("frequency_modifier value 53 is invalid. Valid values for :weekly frequency are 1 - 52.")
|
160
227
|
end
|
161
228
|
end
|
162
229
|
|
163
230
|
context "when frequency is :monthly" do
|
164
231
|
it "raises error if frequency_modifier > 12" do
|
165
|
-
expect { resource.send(:validate_create_frequency_modifier, :monthly, 14) }.to raise_error("frequency_modifier value 14 is invalid.
|
232
|
+
expect { resource.send(:validate_create_frequency_modifier, :monthly, 14) }.to raise_error("frequency_modifier value 14 is invalid. Valid values for :monthly frequency are 1 - 12, 'FIRST', 'SECOND', 'THIRD', 'FOURTH', 'LAST', 'LASTDAY'.")
|
166
233
|
end
|
167
234
|
|
168
235
|
it "raises error if frequency_modifier is invalid" do
|
169
|
-
expect { resource.send(:validate_create_frequency_modifier, :monthly, "abc") }.to raise_error("frequency_modifier value abc is invalid.
|
236
|
+
expect { resource.send(:validate_create_frequency_modifier, :monthly, "abc") }.to raise_error("frequency_modifier value abc is invalid. Valid values for :monthly frequency are 1 - 12, 'FIRST', 'SECOND', 'THIRD', 'FOURTH', 'LAST', 'LASTDAY'.")
|
170
237
|
end
|
171
238
|
end
|
172
239
|
end
|
173
240
|
|
174
241
|
context "#validate_create_day" do
|
175
242
|
it "raises error if frequency is not :weekly or :monthly" do
|
176
|
-
expect { resource.send(:validate_create_day, "Mon", :once) }.to raise_error("day
|
243
|
+
expect { resource.send(:validate_create_day, "Mon", :once) }.to raise_error("day property is only valid for tasks that run monthly or weekly")
|
177
244
|
end
|
178
245
|
|
179
246
|
it "accepts a valid single day" do
|
@@ -185,13 +252,13 @@ describe Chef::Resource::WindowsTask do
|
|
185
252
|
end
|
186
253
|
|
187
254
|
it "raises error for invalid day value" do
|
188
|
-
expect { resource.send(:validate_create_day, "xyz", :weekly) }.to raise_error("day
|
255
|
+
expect { resource.send(:validate_create_day, "xyz", :weekly) }.to raise_error(ArgumentError, "day property invalid. Only valid values are: MON, TUE, WED, THU, FRI, SAT, SUN and *. Multiple values must be separated by a comma.")
|
189
256
|
end
|
190
257
|
end
|
191
258
|
|
192
259
|
context "#validate_create_months" do
|
193
260
|
it "raises error if frequency is not :monthly" do
|
194
|
-
expect { resource.send(:validate_create_months, "Jan", :once) }.to raise_error("months
|
261
|
+
expect { resource.send(:validate_create_months, "Jan", :once) }.to raise_error(ArgumentError, "months property is only valid for tasks that run monthly")
|
195
262
|
end
|
196
263
|
|
197
264
|
it "accepts a valid single month" do
|
@@ -203,17 +270,46 @@ describe Chef::Resource::WindowsTask do
|
|
203
270
|
end
|
204
271
|
|
205
272
|
it "raises error for invalid month value" do
|
206
|
-
expect { resource.send(:validate_create_months, "xyz", :monthly) }.to raise_error("months
|
273
|
+
expect { resource.send(:validate_create_months, "xyz", :monthly) }.to raise_error(ArgumentError, "months property invalid. Only valid values are: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC and *. Multiple values must be separated by a comma.")
|
207
274
|
end
|
208
275
|
end
|
209
276
|
|
210
277
|
context "#validate_idle_time" do
|
211
278
|
it "raises error if frequency is not :on_idle" do
|
212
|
-
expect { resource.send(:validate_idle_time, 5, :hourly) }.to raise_error("idle_time
|
279
|
+
expect { resource.send(:validate_idle_time, 5, :hourly) }.to raise_error(ArgumentError, "idle_time property is only valid for tasks that run on_idle")
|
213
280
|
end
|
214
281
|
|
215
282
|
it "raises error if idle_time > 999" do
|
216
|
-
expect { resource.send(:validate_idle_time, 1000, :on_idle) }.to raise_error("idle_time value 1000 is invalid.
|
283
|
+
expect { resource.send(:validate_idle_time, 1000, :on_idle) }.to raise_error(ArgumentError, "idle_time value 1000 is invalid. Valid values for :on_idle frequency are 1 - 999.")
|
284
|
+
end
|
285
|
+
|
286
|
+
it "raises error if idle_time < 0" do
|
287
|
+
expect { resource.send(:validate_idle_time, -5, :on_idle) }.to raise_error(ArgumentError, "idle_time value -5 is invalid. Valid values for :on_idle frequency are 1 - 999.")
|
288
|
+
end
|
289
|
+
|
290
|
+
it "raises error if idle_time is not set" do
|
291
|
+
expect { resource.send(:validate_idle_time, nil, :on_idle) }.to raise_error(ArgumentError, "idle_time value should be set for :on_idle frequency.")
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
context "#sec_to_dur" do
|
296
|
+
it "return nil when passed 0" do
|
297
|
+
expect(resource.send(:sec_to_dur, 0)).to eql("PT0S")
|
298
|
+
end
|
299
|
+
it "return PT1S when passed 1" do
|
300
|
+
expect(resource.send(:sec_to_dur, 1)).to eql("PT1S")
|
301
|
+
end
|
302
|
+
it "return PT86400S when passed 86400" do
|
303
|
+
expect(resource.send(:sec_to_dur, 86400)).to eql("PT86400S")
|
304
|
+
end
|
305
|
+
it "return PT86401S when passed 86401" do
|
306
|
+
expect(resource.send(:sec_to_dur, 86401)).to eql("PT86401S")
|
307
|
+
end
|
308
|
+
it "return PT86500S when passed 86500" do
|
309
|
+
expect(resource.send(:sec_to_dur, 86500)).to eql("PT86500S")
|
310
|
+
end
|
311
|
+
it "return PT604801S when passed 604801" do
|
312
|
+
expect(resource.send(:sec_to_dur, 604801)).to eql("PT604801S")
|
217
313
|
end
|
218
314
|
end
|
219
315
|
end
|