diff options
author | skippy <jonathan.yates.jones@gmail.com> | 2019-11-19 04:03:22 +0000 |
---|---|---|
committer | skippy <jonathan.yates.jones@gmail.com> | 2019-11-19 04:04:27 +0000 |
commit | 5767cbb81367a73f5ea5a44db7a08c250b49b1c1 (patch) | |
tree | 4915336890cfc1bd18104c79fe4b8ca009893576 /spec/support | |
parent | 5d67a3dca1c4f601ac65de0a75867afd1e0af2c4 (diff) | |
download | chef-5767cbb81367a73f5ea5a44db7a08c250b49b1c1.tar.gz |
Removed method for defining return codes, changed to evaluate stderr on exit code 12
Signed-off-by: Jonathan Jones <gitmaster@thespooky.house>
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared/unit/provider/useradd_based_user_provider.rb | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb index e54d192372..99933991a9 100644 --- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb +++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb @@ -160,7 +160,6 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option "-d", "/Users/mud", "-m", "adam"]) - command.concat([ { returns: [0] } ]) expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true) provider.create_user end @@ -182,7 +181,6 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option "-u", "1000", "-r", "-m", "adam"]) - command.concat([ { returns: [0] } ]) expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true) provider.create_user end @@ -192,7 +190,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option end describe "when managing a user" do - let(:passwd_s_status) do + let(:manage_u_status) do double("Mixlib::ShellOut command", exitstatus: 0, stdout: @stdout, stderr: @stderr, error!: nil) end @@ -200,6 +198,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option provider.new_resource.manage_home true provider.new_resource.home "/Users/mud" provider.new_resource.gid "23" + @stderr = "" end # CHEF-3423, -m must come before the username @@ -210,8 +209,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option "-d", "/Users/mud", "-m", "adam"] - command.concat([ { returns: [0] } ]) - expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true) + command.concat([ { returns: [0, 12] } ]) + expect(provider).to receive(:shell_out_compacted).with(*command).and_return(manage_u_status) provider.manage_user end @@ -222,8 +221,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option "-d", "/Users/mud", "-m", "adam"] - command.concat([ { returns: [0] } ]) - expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true) + command.concat([ { returns: [0, 12] } ]) + expect(provider).to receive(:shell_out_compacted).with(*command).and_return(manage_u_status) provider.manage_user end @@ -232,8 +231,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option command = ["usermod", "-g", "23", "adam"] - command.concat([ { returns: [0] } ]) - expect(provider).to receive(:shell_out_compacted!).with(*command).and_return(true) + command.concat([ { returns: [0, 12] } ]) + expect(provider).to receive(:shell_out_compacted).with(*command).and_return(manage_u_status) provider.manage_user end end @@ -241,24 +240,24 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option describe "when removing a user" do it "should run userdel with the new resources user name" do - expect(provider).to receive(:shell_out_compacted!).with("userdel", @new_resource.username, { returns: [0] }).and_return(true) + expect(provider).to receive(:shell_out_compacted!).with("userdel", @new_resource.username).and_return(true) provider.remove_user end it "should run userdel with the new resources user name and -r if manage_home is true" do @new_resource.manage_home true - expect(provider).to receive(:shell_out_compacted!).with("userdel", "-r", @new_resource.username, { returns: [0] }).and_return(true) + expect(provider).to receive(:shell_out_compacted!).with("userdel", "-r", @new_resource.username).and_return(true) provider.remove_user end it "should run userdel with the new resources user name if non_unique is true" do - expect(provider).to receive(:shell_out_compacted!).with("userdel", @new_resource.username, { returns: [0] }).and_return(true) + expect(provider).to receive(:shell_out_compacted!).with("userdel", @new_resource.username).and_return(true) provider.remove_user end it "should run userdel with the new resources user name and -f if force is true" do @new_resource.force(true) - expect(provider).to receive(:shell_out_compacted!).with("userdel", "-f", @new_resource.username, { returns: [0] }).and_return(true) + expect(provider).to receive(:shell_out_compacted!).with("userdel", "-f", @new_resource.username).and_return(true) provider.remove_user end end @@ -344,14 +343,14 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option describe "when locking the user" do it "should run usermod -L with the new resources username" do - expect(provider).to receive(:shell_out_compacted!).with("usermod", "-L", @new_resource.username, { returns: [0] }) + expect(provider).to receive(:shell_out_compacted!).with("usermod", "-L", @new_resource.username) provider.lock_user end end describe "when unlocking the user" do it "should run usermod -L with the new resources username" do - expect(provider).to receive(:shell_out_compacted!).with("usermod", "-U", @new_resource.username, { returns: [0] }) + expect(provider).to receive(:shell_out_compacted!).with("usermod", "-U", @new_resource.username) provider.unlock_user end end |