summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-19 15:24:10 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-08-24 11:36:21 +1000
commit06fcece75ef52168a73013eba2b8bfc50cf71c97 (patch)
tree9f15442bc06aabece202187c602c216108b16537 /spec
parent4eb325a1839e7803e50f148b999952a0c5abd959 (diff)
downloadpuppet-06fcece75ef52168a73013eba2b8bfc50cf71c97.tar.gz
puppet-06fcece75ef52168a73013eba2b8bfc50cf71c97.tar.xz
puppet-06fcece75ef52168a73013eba2b8bfc50cf71c97.zip
Switching the owner/group settings to use symbolic values
We previously allowed the owner and group to be set to arbitrary values but we never actually used it -- we always just set them to '$user' or '$group'. This commit changes the model to allow 'root' or 'service', where 'service' is converted to the actual service user/group. This has the potential to have backward compatibility concerns, because users could have changed the owner/group in puppet.conf, but the chances of that are fantastically small. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/util/settings/file_setting.rb69
1 files changed, 68 insertions, 1 deletions
diff --git a/spec/unit/util/settings/file_setting.rb b/spec/unit/util/settings/file_setting.rb
index 2cae56fb7..51b6be97c 100755
--- a/spec/unit/util/settings/file_setting.rb
+++ b/spec/unit/util/settings/file_setting.rb
@@ -6,8 +6,75 @@ require 'puppet/util/settings'
require 'puppet/util/settings/file_setting'
describe Puppet::Util::Settings::FileSetting do
+ FileSetting = Puppet::Util::Settings::FileSetting
it "should be able to be converted into a resource" do
- Puppet::Util::Settings::FileSetting.new(:settings => mock("settings"), :desc => "eh").should respond_to(:to_resource)
+ FileSetting.new(:settings => mock("settings"), :desc => "eh").should respond_to(:to_resource)
+ end
+
+ describe "when setting the owner" do
+ it "should allow the file to be owned by root" do
+ root_owner = lambda { FileSetting.new(:settings => mock("settings"), :owner => "root", :desc => "a setting") }
+ root_owner.should_not raise_error
+ end
+
+ it "should allow the file to be owned by the service user" do
+ service_owner = lambda { FileSetting.new(:settings => mock("settings"), :owner => "service", :desc => "a setting") }
+ service_owner.should_not raise_error
+ end
+
+ it "should allow the ownership of the file to be unspecified" do
+ no_owner = lambda { FileSetting.new(:settings => mock("settings"), :desc => "a setting") }
+ no_owner.should_not raise_error
+ end
+
+ it "should not allow other owners" do
+ invalid_owner = lambda { FileSetting.new(:settings => mock("settings"), :owner => "invalid", :desc => "a setting") }
+ invalid_owner.should raise_error(FileSetting::SettingError)
+ end
+ end
+
+ describe "when reading the owner" do
+ it "should be root when the setting specifies root" do
+ setting = FileSetting.new(:settings => mock("settings"), :owner => "root", :desc => "a setting")
+ setting.owner.should == "root"
+ end
+
+ it "should be the owner of the service when the setting specifies service" do
+ setting = FileSetting.new(:settings => mock("settings", :[] => "the_service"), :owner => "service", :desc => "a setting")
+ setting.owner.should == "the_service"
+ end
+
+ it "should be nil when the owner is unspecified" do
+ FileSetting.new(:settings => mock("settings"), :desc => "a setting").owner.should be_nil
+ end
+ end
+
+ describe "when setting the group" do
+ it "should allow the group to be service" do
+ service_group = lambda { FileSetting.new(:settings => mock("settings"), :group => "service", :desc => "a setting") }
+ service_group.should_not raise_error
+ end
+
+ it "should allow the group to be unspecified" do
+ no_group = lambda { FileSetting.new(:settings => mock("settings"), :desc => "a setting") }
+ no_group.should_not raise_error
+ end
+
+ it "should not allow invalid groups" do
+ invalid_group = lambda { FileSetting.new(:settings => mock("settings"), :group => "invalid", :desc => "a setting") }
+ invalid_group.should raise_error(FileSetting::SettingError)
+ end
+ end
+
+ describe "when reading the group" do
+ it "should be service when the setting specifies service" do
+ setting = FileSetting.new(:settings => mock("settings", :[] => "the_service"), :group => "service", :desc => "a setting")
+ setting.group.should == "the_service"
+ end
+
+ it "should be nil when the group is unspecified" do
+ FileSetting.new(:settings => mock("settings"), :desc => "a setting").group.should be_nil
+ end
end
describe "when being converted to a resource" do