summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-09-11 11:26:35 -0700
committerTim Smith <tsmith84@gmail.com>2020-09-11 17:15:46 -0700
commit405778e51c3ffde480b6d2e94ec56b7dde9232c5 (patch)
treec3df03226b73115db5e30920e2bc343f297d447f /spec
parentc0c510a465cb22cace9e37595945e50b6e79fba3 (diff)
downloadchef-405778e51c3ffde480b6d2e94ec56b7dde9232c5.tar.gz
Simplify validation and add some unit tests
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/resource/windows_user_privilege_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/resource/windows_user_privilege_spec.rb b/spec/unit/resource/windows_user_privilege_spec.rb
index 7e1d2e5304..96f9eb93fe 100644
--- a/spec/unit/resource/windows_user_privilege_spec.rb
+++ b/spec/unit/resource/windows_user_privilege_spec.rb
@@ -24,7 +24,27 @@ describe Chef::Resource::WindowsUserPrivilege do
expect(resource.resource_name).to eql(:windows_user_privilege)
end
+ it "the principal property is the name_property" do
+ expect(resource.principal).to eql("fakey_fakerton")
+ end
+
+ it "the principal privilege property coerces to an array" do
+ resource.privilege "SeDenyRemoteInteractiveLogonRight"
+ expect(resource.privilege).to eql(["SeDenyRemoteInteractiveLogonRight"])
+ end
+
+ it "the principal privilege validates inputs against the allowed list of privs" do
+ expect { resource.privilege "invalidPriv" }.to raise_error(Chef::Exceptions::ValidationFailed)
+ end
+
it "sets the default action as :add" do
expect(resource.action).to eql([:add])
end
+
+ it "supports :add, :set, :clear, :remove actions" do
+ expect { resource.action :add }.not_to raise_error
+ expect { resource.action :set }.not_to raise_error
+ expect { resource.action :clear }.not_to raise_error
+ expect { resource.action :remove }.not_to raise_error
+ end
end