summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorkaustubh-d <kaustubh@clogeny.com>2014-08-19 15:45:46 +0530
committerJulian C. Dunn <jdunn@getchef.com>2014-08-27 13:13:14 -0400
commit3b389790688adb1007b33476ec2e2b6111e26d76 (patch)
tree230f505bfdc3daa704966db8ef2c342111d994fb /spec
parent7070c0b3807a68cf56b0f38b21f7e0600d972dfb (diff)
downloadmixlib-shellout-3b389790688adb1007b33476ec2e2b6111e26d76.tar.gz
aix does not allow resetting real uid once the euid is changed to non-root.
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout_spec.rb21
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/support/platform_helpers.rb5
3 files changed, 27 insertions, 0 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index dca66ae..e009dd8 100644
--- a/spec/mixlib/shellout_spec.rb
+++ b/spec/mixlib/shellout_spec.rb
@@ -1319,4 +1319,25 @@ describe Mixlib::ShellOut do
end
end
end
+
+ context "when running under *nix", :requires_root, :unix_only do
+ let(:cmd) { 'whoami' }
+ let(:running_user) { shell_cmd.run_command.stdout.chomp }
+
+ context "when no user is set" do
+ it "should run as current user" do
+ running_user.should eql(ENV["USER"])
+ end
+ end
+
+ context "when user is specified" do
+ let(:user) { 'nobody' }
+
+ let(:options) { { :user => user } }
+
+ it "should run as specified user" do
+ running_user.should eql("#{user}")
+ end
+ end
+ end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9d51c5e..b435176 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -19,6 +19,7 @@ RSpec.configure do |config|
# Add jruby filters here
config.filter_run_excluding :windows_only => true unless windows?
config.filter_run_excluding :unix_only => true unless unix?
+ config.filter_run_excluding :requires_root => true unless root?
config.run_all_when_everything_filtered = true
config.treat_symbols_as_metadata_keys_with_true_values = true
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 69bdbf7..c730b4d 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -24,3 +24,8 @@ else
LINE_ENDING = "\n"
ECHO_LC_ALL = "echo $LC_ALL"
end
+
+def root?
+ return false if windows?
+ Process.euid == 0
+end