summaryrefslogtreecommitdiff
path: root/spec/unit/provider/user
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/user')
-rw-r--r--spec/unit/provider/user/dscl_spec.rb64
-rw-r--r--spec/unit/provider/user/pw_spec.rb12
-rw-r--r--spec/unit/provider/user/solaris_spec.rb54
-rw-r--r--spec/unit/provider/user/useradd_spec.rb14
-rw-r--r--spec/unit/provider/user/windows_spec.rb8
5 files changed, 76 insertions, 76 deletions
diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb
index a9407a4d7e..8195bdfc25 100644
--- a/spec/unit/provider/user/dscl_spec.rb
+++ b/spec/unit/provider/user/dscl_spec.rb
@@ -18,9 +18,9 @@
ShellCmdResult = Struct.new(:stdout, :stderr, :exitstatus)
-require 'spec_helper'
-require 'ostruct'
-require 'mixlib/shellout'
+require "spec_helper"
+require "ostruct"
+require "mixlib/shellout"
describe Chef::Provider::User::Dscl do
before do
@@ -114,32 +114,32 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
describe "when shelling out to dscl" do
it "should run dscl with the supplied cmd /Path args" do
- shell_return = ShellCmdResult.new('stdout', 'err', 0)
+ shell_return = ShellCmdResult.new("stdout", "err", 0)
expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
- expect(provider.run_dscl("cmd /Path args")).to eq('stdout')
+ expect(provider.run_dscl("cmd /Path args")).to eq("stdout")
end
it "returns an empty string from delete commands" do
- shell_return = ShellCmdResult.new('out', 'err', 23)
+ shell_return = ShellCmdResult.new("out", "err", 23)
expect(provider).to receive(:shell_out).with("dscl . -delete /Path args").and_return(shell_return)
expect(provider.run_dscl("delete /Path args")).to eq("")
end
it "should raise an exception for any other command" do
- shell_return = ShellCmdResult.new('out', 'err', 23)
- expect(provider).to receive(:shell_out).with('dscl . -cmd /Path arguments').and_return(shell_return)
+ shell_return = ShellCmdResult.new("out", "err", 23)
+ expect(provider).to receive(:shell_out).with("dscl . -cmd /Path arguments").and_return(shell_return)
expect { provider.run_dscl("cmd /Path arguments") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
it "raises an exception when dscl reports 'no such key'" do
- shell_return = ShellCmdResult.new("No such key: ", 'err', 23)
- expect(provider).to receive(:shell_out).with('dscl . -cmd /Path args').and_return(shell_return)
+ shell_return = ShellCmdResult.new("No such key: ", "err", 23)
+ expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
expect { provider.run_dscl("cmd /Path args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
it "raises an exception when dscl reports 'eDSRecordNotFound'" do
- shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", 'err', -14136)
- expect(provider).to receive(:shell_out).with('dscl . -cmd /Path args').and_return(shell_return)
+ shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136)
+ expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
expect { provider.run_dscl("cmd /Path args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
end
end
@@ -197,7 +197,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
end
it "finds a valid, unused uid when none is specified" do
- expect(provider).to receive(:run_dscl).with("list /Users uid").and_return('')
+ expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("")
expect(provider).to receive(:run_dscl).with("create /Users/toor UniqueID 501")
expect(provider).to receive(:get_free_uid).and_return(501)
provider.dscl_set_uid
@@ -207,7 +207,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
it "sets the uid specified in the resource" do
new_resource.uid(1000)
expect(provider).to receive(:run_dscl).with("create /Users/toor UniqueID 1000").and_return(true)
- expect(provider).to receive(:run_dscl).with("list /Users uid").and_return('')
+ expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("")
provider.dscl_set_uid
end
end
@@ -219,7 +219,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
before do
new_resource.supports({ :manage_home => true })
- new_resource.home('/Users/toor')
+ new_resource.home("/Users/toor")
provider.current_resource = current_resource
end
@@ -232,25 +232,25 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
it "raises InvalidHomeDirectory when the resource's home directory doesn't look right" do
- new_resource.home('epic-fail')
+ new_resource.home("epic-fail")
expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::InvalidHomeDirectory)
end
it "moves the users home to the new location if it exists and the target location is different" do
new_resource.supports(:manage_home => true)
- current_home = CHEF_SPEC_DATA + '/old_home_dir'
- current_home_files = [current_home + '/my-dot-emacs', current_home + '/my-dot-vim']
+ current_home = CHEF_SPEC_DATA + "/old_home_dir"
+ current_home_files = [current_home + "/my-dot-emacs", current_home + "/my-dot-vim"]
current_resource.home(current_home)
new_resource.gid(23)
- allow(::File).to receive(:exists?).with('/old/home/toor').and_return(true)
- allow(::File).to receive(:exists?).with('/Users/toor').and_return(true)
+ allow(::File).to receive(:exists?).with("/old/home/toor").and_return(true)
+ allow(::File).to receive(:exists?).with("/Users/toor").and_return(true)
- expect(FileUtils).to receive(:mkdir_p).with('/Users/toor').and_return(true)
+ expect(FileUtils).to receive(:mkdir_p).with("/Users/toor").and_return(true)
expect(FileUtils).to receive(:rmdir).with(current_home)
expect(::Dir).to receive(:glob).with("#{CHEF_SPEC_DATA}/old_home_dir/*",::File::FNM_DOTMATCH).and_return(current_home_files)
expect(FileUtils).to receive(:mv).with(current_home_files, "/Users/toor", :force => true)
- expect(FileUtils).to receive(:chown_R).with('toor','23','/Users/toor')
+ expect(FileUtils).to receive(:chown_R).with("toor","23","/Users/toor")
expect(provider).to receive(:run_dscl).with("create /Users/toor NFSHomeDirectory '/Users/toor'")
provider.dscl_set_home
@@ -263,7 +263,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
it "should run ditto to copy any missing files from skel to the new home dir" do
expect(::File).to receive(:exists?).with("/System/Library/User\ Template/English.lproj").and_return(true)
- expect(FileUtils).to receive(:chown_R).with('toor', '', '/Users/toor')
+ expect(FileUtils).to receive(:chown_R).with("toor", "", "/Users/toor")
expect(provider).to receive(:shell_out!).with("ditto '/System/Library/User Template/English.lproj' '/Users/toor'")
provider.ditto_home
end
@@ -382,7 +382,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
expect(provider).to receive(:shell_out).with("dscacheutil '-flushcache'")
expect(provider).to receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do
if user_plist_file.nil?
- ShellCmdResult.new('Can not find the file', 'Sorry!!', 1)
+ ShellCmdResult.new("Can not find the file", "Sorry!!", 1)
else
ShellCmdResult.new(File.read(File.join(CHEF_SPEC_DATA, "mac_users/#{user_plist_file}.plist.xml")), "", 0)
end
@@ -656,7 +656,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
it "password_shadow_info should have salted-sha-512 format" do
shadow_info = provider.prepare_password_shadow_info
expect(shadow_info).to have_key("SALTED-SHA512")
- info = shadow_info["SALTED-SHA512"].string.unpack('H*').first
+ info = shadow_info["SALTED-SHA512"].string.unpack("H*").first
expect(provider.salted_sha512?(info)).to be_truthy
end
end
@@ -667,7 +667,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
it "password_shadow_info should have salted-sha-512 format" do
shadow_info = provider.prepare_password_shadow_info
expect(shadow_info).to have_key("SALTED-SHA512")
- info = shadow_info["SALTED-SHA512"].string.unpack('H*').first
+ info = shadow_info["SALTED-SHA512"].string.unpack("H*").first
expect(provider.salted_sha512?(info)).to be_truthy
expect(info).to eq(vagrant_sha_512)
end
@@ -689,7 +689,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("entropy")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("salt")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("iterations")
- info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack('H*').first
+ info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack("H*").first
expect(provider.salted_sha512_pbkdf2?(info)).to be_truthy
end
end
@@ -705,7 +705,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("entropy")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("salt")
expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("iterations")
- info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack('H*').first
+ info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack("H*").first
expect(provider.salted_sha512_pbkdf2?(info)).to be_truthy
expect(info).to eq(vagrant_sha_512_pbkdf2)
end
@@ -791,8 +791,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
end
it "should raise an exception when the group does not exist" do
- shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", 'err', -14136)
- expect(provider).to receive(:shell_out).with('dscl . -read /Groups/newgroup PrimaryGroupID').and_return(shell_return)
+ shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136)
+ expect(provider).to receive(:shell_out).with("dscl . -read /Groups/newgroup PrimaryGroupID").and_return(shell_return)
expect { provider.dscl_set_gid }.to raise_error(Chef::Exceptions::GroupIDNotFound)
end
end
@@ -814,8 +814,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
new_resource.username "mud"
new_resource.uid 2342
new_resource.gid 2342
- new_resource.home '/Users/death'
- new_resource.password 'goaway'
+ new_resource.home "/Users/death"
+ new_resource.password "goaway"
end
it "sets the user, comment field, uid, gid, moves the home directory, sets the shell, and sets the password" do
diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb
index 6683a75f42..4b58fdc58e 100644
--- a/spec/unit/provider/user/pw_spec.rb
+++ b/spec/unit/provider/user/pw_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
describe Chef::Provider::User::Pw do
before(:each) do
@@ -48,11 +48,11 @@ describe Chef::Provider::User::Pw do
describe "setting options to the pw command" do
field_list = {
- 'comment' => "-c",
- 'home' => "-d",
- 'gid' => "-g",
- 'uid' => "-u",
- 'shell' => "-s",
+ "comment" => "-c",
+ "home" => "-d",
+ "gid" => "-g",
+ "uid" => "-u",
+ "shell" => "-s",
}
field_list.each do |attribute, option|
it "should check for differences in #{attribute} between the new and current resources" do
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index a3c17a9a56..f3299aaf63 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -22,8 +22,8 @@
ShellCmdResult = Struct.new(:stdout, :stderr, :exitstatus)
-require 'mixlib/shellout'
-require 'spec_helper'
+require "mixlib/shellout"
+require "spec_helper"
describe Chef::Provider::User::Solaris do
@@ -73,63 +73,63 @@ describe Chef::Provider::User::Solaris do
end
end
- describe 'when managing user locked status' do
+ describe "when managing user locked status" do
before(:each) do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::User.new('dave')
+ @new_resource = Chef::Resource::User.new("dave")
@current_resource = @new_resource.dup
@provider = Chef::Provider::User::Solaris.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
end
- describe 'when determining if the user is locked' do
+ describe "when determining if the user is locked" do
# locked shadow lines
[
- 'dave:LK:::::::',
- 'dave:*LK*:::::::',
- 'dave:*LK*foobar:::::::',
- 'dave:*LK*bahamas10:::::::',
- 'dave:*LK*L....:::::::',
+ "dave:LK:::::::",
+ "dave:*LK*:::::::",
+ "dave:*LK*foobar:::::::",
+ "dave:*LK*bahamas10:::::::",
+ "dave:*LK*L....:::::::",
].each do |shadow|
it "should return true if user is locked with #{shadow}" do
- shell_return = ShellCmdResult.new(shadow + "\n", '', 0)
- expect(provider).to receive(:shell_out!).with('getent', 'shadow', @new_resource.username).and_return(shell_return)
+ shell_return = ShellCmdResult.new(shadow + "\n", "", 0)
+ expect(provider).to receive(:shell_out!).with("getent", "shadow", @new_resource.username).and_return(shell_return)
expect(provider.check_lock).to eql(true)
end
end
# unlocked shadow lines
[
- 'dave:NP:::::::',
- 'dave:*NP*:::::::',
- 'dave:foobar:::::::',
- 'dave:bahamas10:::::::',
- 'dave:L...:::::::',
+ "dave:NP:::::::",
+ "dave:*NP*:::::::",
+ "dave:foobar:::::::",
+ "dave:bahamas10:::::::",
+ "dave:L...:::::::",
].each do |shadow|
it "should return false if user is unlocked with #{shadow}" do
- shell_return = ShellCmdResult.new(shadow + "\n", '', 0)
- expect(provider).to receive(:shell_out!).with('getent', 'shadow', @new_resource.username).and_return(shell_return)
+ shell_return = ShellCmdResult.new(shadow + "\n", "", 0)
+ expect(provider).to receive(:shell_out!).with("getent", "shadow", @new_resource.username).and_return(shell_return)
expect(provider.check_lock).to eql(false)
end
end
end
- describe 'when locking the user' do
- it 'should run passwd -l with the new resources username' do
- shell_return = ShellCmdResult.new('', '', 0)
- expect(provider).to receive(:shell_out!).with('passwd', '-l', @new_resource.username).and_return(shell_return)
+ describe "when locking the user" do
+ it "should run passwd -l with the new resources username" do
+ shell_return = ShellCmdResult.new("", "", 0)
+ expect(provider).to receive(:shell_out!).with("passwd", "-l", @new_resource.username).and_return(shell_return)
provider.lock_user
end
end
- describe 'when unlocking the user' do
- it 'should run passwd -u with the new resources username' do
- shell_return = ShellCmdResult.new('', '', 0)
- expect(provider).to receive(:shell_out!).with('passwd', '-u', @new_resource.username).and_return(shell_return)
+ describe "when unlocking the user" do
+ it "should run passwd -u with the new resources username" do
+ shell_return = ShellCmdResult.new("", "", 0)
+ expect(provider).to receive(:shell_out!).with("passwd", "-u", @new_resource.username).and_return(shell_return)
provider.unlock_user
end
end
diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb
index a295dff679..f8bcb13363 100644
--- a/spec/unit/provider/user/useradd_spec.rb
+++ b/spec/unit/provider/user/useradd_spec.rb
@@ -18,8 +18,8 @@
# limitations under the License.
#
-require 'spec_helper'
-require 'chef/provider/user/useradd'
+require "spec_helper"
+require "chef/provider/user/useradd"
describe Chef::Provider::User::Useradd do
@@ -30,11 +30,11 @@ describe Chef::Provider::User::Useradd do
end
supported_useradd_options = {
- 'comment' => "-c",
- 'gid' => "-g",
- 'uid' => "-u",
- 'shell' => "-s",
- 'password' => "-p",
+ "comment" => "-c",
+ "gid" => "-g",
+ "uid" => "-u",
+ "shell" => "-s",
+ "password" => "-p",
}
include_examples "a useradd-based user provider", supported_useradd_options
diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb
index 7e08f971a9..7a8cb29963 100644
--- a/spec/unit/provider/user/windows_spec.rb
+++ b/spec/unit/provider/user/windows_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'spec_helper'
+require "spec_helper"
class Chef
class Util
@@ -104,7 +104,7 @@ describe Chef::Provider::User::Windows do
end
it "marks the home_dir attribute to be updated" do
- expect(@provider.set_options[:home_dir]).to eq('/home/adam')
+ expect(@provider.set_options[:home_dir]).to eq("/home/adam")
end
it "ignores the primary_group_id attribute" do
@@ -116,11 +116,11 @@ describe Chef::Provider::User::Windows do
end
it "marks the script_path attribute to be updated" do
- expect(@provider.set_options[:script_path]).to eq('/usr/bin/zsh')
+ expect(@provider.set_options[:script_path]).to eq("/usr/bin/zsh")
end
it "marks the password attribute to be updated" do
- expect(@provider.set_options[:password]).to eq('abracadabra')
+ expect(@provider.set_options[:password]).to eq("abracadabra")
end
end
end