summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-01-04 13:51:58 -0800
committerdanielsdeleo <dan@opscode.com>2013-01-04 13:51:58 -0800
commit45740c8c72ddf643455b017257d4d6c3ab03d95c (patch)
treece5629e8df354ee94eeb39d14558412326df1630
parent2e2c317c9e0438ca645b97b4e3aa893f6cd33721 (diff)
downloadchef-45740c8c72ddf643455b017257d4d6c3ab03d95c.tar.gz
[CHEF-3557] report file modes with leading 0 for clarity
-rw-r--r--lib/chef/scan_access_control.rb2
-rw-r--r--spec/support/shared/functional/securable_resource_with_reporting.rb12
-rw-r--r--spec/unit/provider/directory_spec.rb2
-rw-r--r--spec/unit/provider/file_spec.rb4
-rw-r--r--spec/unit/scan_access_control_spec.rb6
5 files changed, 13 insertions, 13 deletions
diff --git a/lib/chef/scan_access_control.rb b/lib/chef/scan_access_control.rb
index dba3574e44..1384656a8b 100644
--- a/lib/chef/scan_access_control.rb
+++ b/lib/chef/scan_access_control.rb
@@ -119,7 +119,7 @@ class Chef
def current_mode
case new_resource.mode
when String, Integer, nil
- (stat.mode & 07777).to_s(8)
+ "0#{(stat.mode & 07777).to_s(8)}"
else
Chef::Log.error("The `mode` parameter of the #@new_resource resource is set to an invalid value (#{new_resource.mode.inspect})")
raise ArgumentError, "Invalid value #{new_resource.mode.inspect} for `mode` on resource #@new_resource"
diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb
index 81569a1382..60ab1e77db 100644
--- a/spec/support/shared/functional/securable_resource_with_reporting.rb
+++ b/spec/support/shared/functional/securable_resource_with_reporting.rb
@@ -30,7 +30,7 @@ shared_examples_for "a securable resource with reporting" do
# TODO: most stable way to specify?
resource.owner.should == Etc.getpwuid(Process.uid).name
resource.group.should == Etc.getgrgid(Process.gid).name
- resource.mode.should == default_mode
+ resource.mode.should == "0#{default_mode}"
end
end
@@ -101,7 +101,7 @@ shared_examples_for "a securable resource with reporting" do
# Need full permission for owner here or else remote directory gets
# into trouble trying to manage nested directories
let(:set_mode) { "0740" }
- let(:expected_mode) { "740" }
+ let(:expected_mode) { "0740" }
before do
resource.mode(set_mode)
@@ -116,7 +116,7 @@ shared_examples_for "a securable resource with reporting" do
context "and mode is specified as an Integer" do
let(:set_mode) { 00740 }
- let(:expected_mode) { "740" }
+ let(:expected_mode) { "0740" }
before do
resource.mode(set_mode)
resource.run_action(:create)
@@ -139,7 +139,7 @@ shared_examples_for "a securable resource with reporting" do
# TODO: most stable way to specify?
current_resource.owner.should == Etc.getpwuid(Process.uid).name
current_resource.group.should == Etc.getgrgid(Process.gid).name
- current_resource.mode.should == ((0100666 - File.umask) & 07777).to_s(8)
+ current_resource.mode.should == "0#{((0100666 - File.umask) & 07777).to_s(8)}"
end
end
@@ -199,7 +199,7 @@ shared_examples_for "a securable resource with reporting" do
context "and mode is specified as a String" do
let(:default_create_mode) { (0100666 - File.umask) }
- let(:expected_mode) { (default_create_mode & 07777).to_s(8) }
+ let(:expected_mode) { "0#{(default_create_mode & 07777).to_s(8)}" }
before do
resource.mode(expected_mode)
@@ -212,7 +212,7 @@ shared_examples_for "a securable resource with reporting" do
context "and mode is specified as an Integer" do
let(:set_mode) { (0100666 - File.umask) & 07777 }
- let(:expected_mode) { set_mode.to_s(8) }
+ let(:expected_mode) { "0#{set_mode.to_s(8)}" }
before do
resource.mode(set_mode)
diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb
index 26e1d9d562..722a451a7b 100644
--- a/spec/unit/provider/directory_spec.rb
+++ b/spec/unit/provider/directory_spec.rb
@@ -59,7 +59,7 @@ describe Chef::Provider::Directory do
File.stub!(:exist?).and_return(true)
File.should_receive(:stat).and_return(mock_stat)
@directory.load_current_resource
- @directory.current_resource.mode.should == "755"
+ @directory.current_resource.mode.should == "0755"
end
context "when user and group are specified with UID/GID" do
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb
index f9d9d163d6..9dc3908bad 100644
--- a/spec/unit/provider/file_spec.rb
+++ b/spec/unit/provider/file_spec.rb
@@ -68,7 +68,7 @@ describe Chef::Provider::File do
@provider.load_current_resource
# post-condition checks
- @provider.current_resource.mode.should == "600"
+ @provider.current_resource.mode.should == "0600"
@provider.current_resource.owner.should == "root"
@provider.current_resource.group.should == "wheel"
end
@@ -112,7 +112,7 @@ describe Chef::Provider::File do
# post-condition checks
@provider.new_resource.group.should == "wheel"
@provider.new_resource.owner.should == "root"
- @provider.new_resource.mode.should == "600"
+ @provider.new_resource.mode.should == "0600"
end
end
end
diff --git a/spec/unit/scan_access_control_spec.rb b/spec/unit/scan_access_control_spec.rb
index bc0457dec2..8fcda0edb1 100644
--- a/spec/unit/scan_access_control_spec.rb
+++ b/spec/unit/scan_access_control_spec.rb
@@ -60,7 +60,7 @@ describe Chef::ScanAccessControl do
end
it "sets the mode of the current resource to the current mode as a String" do
- @current_resource.mode.should == "644"
+ @current_resource.mode.should == "0644"
end
context "on unix", :unix_only do
@@ -91,7 +91,7 @@ describe Chef::ScanAccessControl do
end
it "sets the mode of the current resource to the file's current mode as a string" do
- @current_resource.mode.should == "644"
+ @current_resource.mode.should == "0644"
end
end
@@ -102,7 +102,7 @@ describe Chef::ScanAccessControl do
end
it "sets the mode of the current resource to the current mode as a String" do
- @current_resource.mode.should == "644"
+ @current_resource.mode.should == "0644"
end
end