summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2009-01-09 09:50:09 -0800
committerAdam Jacob <adam@hjksolutions.com>2009-01-09 09:50:09 -0800
commit60b65e35d7088799216605defb0ee2a6a09e4699 (patch)
tree5ee471a6656bd403573661c3b13f059cd6e01789
parentb525f326aa30bcf5a93655a3f238ae422562c1d9 (diff)
downloadchef-60b65e35d7088799216605defb0ee2a6a09e4699.tar.gz
Fixing up the daemon tests - Process.initgroups needed a stub
-rw-r--r--chef/spec/unit/daemon_spec.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/chef/spec/unit/daemon_spec.rb b/chef/spec/unit/daemon_spec.rb
index 5bf7f67282..f11372eb2f 100644
--- a/chef/spec/unit/daemon_spec.rb
+++ b/chef/spec/unit/daemon_spec.rb
@@ -203,6 +203,8 @@ describe Chef::Daemon do
@pw_user = mock("Struct::Passwd", :null_object => true, :uid => 501)
@pw_group = mock("Struct::Group", :null_object => true, :gid => 20)
+ Process.stub!(:initgroups).and_return(true)
+
Etc.stub!(:getpwnam).and_return(@pw_user)
Etc.stub!(:getgrnam).and_return(@pw_group)
end
@@ -218,11 +220,6 @@ describe Chef::Daemon do
Chef::Daemon._change_privilege("aj")
end
- it "should attempt to change the process GID"
- it "should attempt to change the process UID"
-
-# I'm not sure how we can test these - requires root privileges?..
-=begin
it "should attempt to change the process GID" do
Process::GID.should_receive(:change_privilege).with(20).and_return(20)
Chef::Daemon._change_privilege("aj")
@@ -232,7 +229,6 @@ describe Chef::Daemon do
Process::UID.should_receive(:change_privilege).with(501).and_return(501)
Chef::Daemon._change_privilege("aj")
end
-=end
end
describe "with insufficient privileges" do
@@ -242,6 +238,7 @@ describe Chef::Daemon do
end
it "should log an appropriate error message and fail miserably" do
+ Process.stub!(:initgroups).and_raise(Errno::EPERM)
Chef.should_receive(:fatal!).with("Permission denied when trying to change 999:999 to 501:20. Operation not permitted")
Chef::Daemon._change_privilege("aj")
end