From 7de549577c283f7350886c26b71669736eab229d Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Thu, 18 Jul 2019 01:43:08 -0700 Subject: [PATCH] Return keys are really nice. They make code more readable by visually separating different sections of text. Signed-off-by: Ryan Davis --- test/unit/resources/file_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/unit/resources/file_test.rb b/test/unit/resources/file_test.rb index 81720f973..000e21948 100644 --- a/test/unit/resources/file_test.rb +++ b/test/unit/resources/file_test.rb @@ -4,6 +4,7 @@ require "inspec/resources/file" describe Inspec::Resources::FileResource do let(:file) { stub(unix_mode_mask: 000, mode: 000) } + it "responds on Ubuntu" do resource = MockLoader.new(:ubuntu1404).load_resource("file", "/fakepath/fakefile") resource.stubs(:exist?).returns(true) @@ -18,6 +19,7 @@ describe Inspec::Resources::FileResource do resource.stubs(:file_permission_granted?).with("read", "by_usergroup", "by_specific_user").returns("test_result") resource.stubs(:file_permission_granted?).with("write", "by_usergroup", "by_specific_user").returns("test_result") resource.stubs(:file_permission_granted?).with("execute", "by_usergroup", "by_specific_user").returns("test_result") + _(resource.content).must_equal "content" _(resource.more_permissive_than?("000")).must_equal false _(resource.exist?).must_equal true @@ -35,6 +37,7 @@ describe Inspec::Resources::FileResource do proc { resource.send(:more_permissive_than?, nil) }.must_raise(ArgumentError) proc { resource.send(:more_permissive_than?, 0700) }.must_raise(ArgumentError) end + it "responds on Windows" do resource = MockLoader.new(:windows).load_resource("file", "C:/fakepath/fakefile") resource.stubs(:exist?).returns(true) @@ -55,12 +58,14 @@ describe Inspec::Resources::FileResource do _(resource.allowed?("execute", by: "by_usergroup", by_user: "by_specific_user")).must_equal "test_result" _(resource.allowed?("full-control", by: "by_usergroup", by_user: "by_specific_user")).must_equal "test_result" end + it "does not support Windows-style ACL on Ubuntu" do resource = MockLoader.new(:ubuntu1404).load_resource("file", "/fakepath/fakefile") resource.stubs(:exist?).returns(true) proc { resource.send("allowed?", "full-control", { by: "by_usergroup", by_user: "by_specific_user" }) }.must_raise(RuntimeError) proc { resource.send("allowed?", "modify", { by: "by_usergroup", by_user: "by_specific_user" }) }.must_raise(RuntimeError) end + it "does not support check by mask on Windows" do resource = MockLoader.new(:windows).load_resource("file", "C:/fakepath/fakefile") resource.stubs(:exist?).returns(true) @@ -68,6 +73,7 @@ describe Inspec::Resources::FileResource do proc { resource.send("writable?", "by_usergroup", nil) }.must_raise(RuntimeError) proc { resource.send("executable?", "by_usergroup", nil) }.must_raise(RuntimeError) end + it "responds with errors on unsupported OS" do resource = MockLoader.new(:undefined).load_resource("file", "C:/fakepath/fakefile") resource.stubs(:exist?).returns(true)