summaryrefslogtreecommitdiff
path: root/spec/unit/provider/group
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider/group')
-rw-r--r--spec/unit/provider/group/dscl_spec.rb24
-rw-r--r--spec/unit/provider/group/gpasswd_spec.rb4
-rw-r--r--spec/unit/provider/group/groupmod_spec.rb26
-rw-r--r--spec/unit/provider/group/pw_spec.rb32
-rw-r--r--spec/unit/provider/group/usermod_spec.rb18
5 files changed, 52 insertions, 52 deletions
diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb
index b526848dfd..28d78cbdbd 100644
--- a/spec/unit/provider/group/dscl_spec.rb
+++ b/spec/unit/provider/group/dscl_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,14 +27,14 @@ describe Chef::Provider::Group::Dscl do
@current_resource = Chef::Resource::Group.new("aj")
@provider = Chef::Provider::Group::Dscl.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
- @status = mock("Process::Status", :exitstatus => 0)
+ @status = mock("Process::Status", :exitstatus => 0)
@pid = 2342
@stdin = StringIO.new
@stdout = StringIO.new("\n")
@stderr = StringIO.new("")
@provider.stub!(:popen4).and_yield(@pid,@stdin,@stdout,@stderr).and_return(@status)
end
-
+
it "should run popen4 with the supplied array of arguments appended to the dscl command" do
@provider.should_receive(:popen4).with("dscl . -cmd /Path arg1 arg2")
@provider.dscl("cmd", "/Path", "arg1", "arg2")
@@ -52,7 +52,7 @@ describe Chef::Provider::Group::Dscl do
@provider = Chef::Provider::Group::Dscl.new(@node, @new_resource)
@provider.stub!(:dscl).and_return(["cmd", @status, "stdout", "stderr"])
end
-
+
it "should run dscl with the supplied cmd /Path args" do
@provider.should_receive(:dscl).with("cmd /Path args")
@provider.safe_dscl("cmd /Path args")
@@ -84,7 +84,7 @@ describe Chef::Provider::Group::Dscl do
lambda { @provider.safe_dscl("cmd /Path arguments") }.should raise_error(Chef::Exceptions::Group)
end
end
-
+
describe "with the dscl command returning a zero exit status" do
it "should return the third array element, the string of standard output" do
safe_dscl_retval = @provider.safe_dscl("cmd /Path args")
@@ -100,7 +100,7 @@ describe Chef::Provider::Group::Dscl do
@provider = Chef::Provider::Group::Dscl.new(@node, @new_resource)
@provider.stub!(:safe_dscl).and_return("\naj 200\njt 201\n")
end
-
+
it "should run safe_dscl with list /Groups gid" do
@provider.should_receive(:safe_dscl).with("list /Groups gid")
@provider.get_free_gid
@@ -109,7 +109,7 @@ describe Chef::Provider::Group::Dscl do
it "should return the first unused gid number on or above 200" do
@provider.get_free_gid.should equal(202)
end
-
+
it "should raise an exception when the search limit is exhausted" do
search_limit = 1
lambda { @provider.get_free_gid(search_limit) }.should raise_error(RuntimeError)
@@ -127,7 +127,7 @@ describe Chef::Provider::Group::Dscl do
@provider.should_receive(:safe_dscl).with("list /Groups gid")
@provider.gid_used?(500)
end
-
+
it "should return true for a used gid number" do
@provider.gid_used?(500).should be_true
end
@@ -151,7 +151,7 @@ describe Chef::Provider::Group::Dscl do
lambda { @provider.set_gid }.should raise_error(Chef::Exceptions::Group)
end
end
-
+
describe "with no gid number for the new resources" do
it "should run get_free_gid and return a valid, unused gid number" do
@provider.should_receive(:get_free_gid).and_return(501)
@@ -220,7 +220,7 @@ describe Chef::Provider::Group::Dscl do
@provider.set_members
end
end
-
+
describe "with no members in the new resource" do
before do
@new_resource.append(true)
@@ -276,7 +276,7 @@ describe Chef::Provider::Group::Dscl do
@provider.should_receive(:set_gid)
@provider.manage_group
end
-
+
it "should manage the members if it changed and the new resources members is not null" do
@current_resource.members(%{charlie root})
@new_resource.members(%{crab revenge})
diff --git a/spec/unit/provider/group/gpasswd_spec.rb b/spec/unit/provider/group/gpasswd_spec.rb
index 59da88e851..8889ba322e 100644
--- a/spec/unit/provider/group/gpasswd_spec.rb
+++ b/spec/unit/provider/group/gpasswd_spec.rb
@@ -36,8 +36,8 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do
@provider.define_resource_requirements
end
- # Checking for required binaries is already done in the spec
- # for Chef::Provider::Group - no need to repeat it here. We'll
+ # Checking for required binaries is already done in the spec
+ # for Chef::Provider::Group - no need to repeat it here. We'll
# include only what's specific to this provider.
it "should raise an error if the required binary /usr/bin/gpasswd doesn't exist" do
File.stub!(:exists?).and_return(true)
diff --git a/spec/unit/provider/group/groupmod_spec.rb b/spec/unit/provider/group/groupmod_spec.rb
index c9c56313b5..69b96c6edb 100644
--- a/spec/unit/provider/group/groupmod_spec.rb
+++ b/spec/unit/provider/group/groupmod_spec.rb
@@ -29,7 +29,7 @@ describe Chef::Provider::Group::Groupmod do
@new_resource.append false
@provider = Chef::Provider::Group::Groupmod.new(@new_resource, @run_context)
end
-
+
describe "manage_group" do
describe "when determining the current group state" do
it "should raise an error if the required binary /usr/sbin/group doesn't exist" do
@@ -41,25 +41,25 @@ describe Chef::Provider::Group::Groupmod do
File.should_receive(:exists?).with("/usr/sbin/user").and_return(false)
lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Group)
end
-
+
it "shouldn't raise an error if the required binaries exist" do
File.stub!(:exists?).and_return(true)
lambda { @provider.load_current_resource }.should_not raise_error(Chef::Exceptions::Group)
end
end
-
+
describe "after the group's current state is known" do
before do
@current_resource = @new_resource.dup
@provider.current_resource = @current_resource
end
-
+
describe "when no group members are specified and append is not set" do
before do
@new_resource.append(false)
@new_resource.members([])
end
-
+
it "logs a message and sets group's members to 'none', then removes existing group members" do
Chef::Log.should_receive(:debug).with("group[wheel] setting group members to: none")
Chef::Log.should_receive(:debug).with("group[wheel] removing members lobster, rage, fist")
@@ -69,26 +69,26 @@ describe Chef::Provider::Group::Groupmod do
@provider.manage_group
end
end
-
+
describe "when no group members are specified and append is set" do
before do
@new_resource.append(true)
@new_resource.members([])
end
-
+
it "logs a message and does not modify group membership" do
Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members to add")
@provider.should_not_receive(:shell_out!)
@provider.manage_group
end
end
-
+
describe "when removing some group members" do
before do
@new_resource.append(false)
@new_resource.members(%w{ lobster })
end
-
+
it "updates group membership correctly" do
Chef::Log.stub!(:debug)
@provider.should_receive(:shell_out!).with("group mod -n wheel_bak wheel")
@@ -100,14 +100,14 @@ describe Chef::Provider::Group::Groupmod do
end
end
end
-
+
describe "create_group" do
describe "when creating a new group" do
before do
@current_resource = Chef::Resource::Group.new("wheel")
@provider.current_resource = @current_resource
end
-
+
it "should run a group add command and some user mod commands" do
@provider.should_receive(:shell_out!).with("group add -g '123' wheel")
@provider.should_receive(:shell_out!).with("user mod -G wheel lobster")
@@ -117,14 +117,14 @@ describe Chef::Provider::Group::Groupmod do
end
end
end
-
+
describe "remove_group" do
describe "when removing an existing group" do
before do
@current_resource = @new_resource.dup
@provider.current_resource = @current_resource
end
-
+
it "should run a group del command" do
@provider.should_receive(:shell_out!).with("group del wheel")
@provider.remove_group
diff --git a/spec/unit/provider/group/pw_spec.rb b/spec/unit/provider/group/pw_spec.rb
index a7dbdb8615..e7c38f9555 100644
--- a/spec/unit/provider/group/pw_spec.rb
+++ b/spec/unit/provider/group/pw_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@ describe Chef::Provider::Group::Pw do
@node = Chef::Node.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, {}, @events)
-
+
@new_resource = Chef::Resource::Group.new("wheel")
@new_resource.gid 50
@new_resource.members [ "root", "aj"]
@@ -34,12 +34,12 @@ describe Chef::Provider::Group::Pw do
@provider = Chef::Provider::Group::Pw.new(@new_resource, @run_context)
@provider.current_resource = @current_resource
end
-
+
describe "when setting options for the pw command" do
it "does not set the gid option if gids match or are unmanaged" do
@provider.set_options.should == " wheel"
end
-
+
it "sets the option for gid if it is not nil" do
@new_resource.gid(42)
@provider.set_options.should eql(" wheel -g '42'")
@@ -55,7 +55,7 @@ describe Chef::Provider::Group::Pw do
end
describe "when managing the group" do
-
+
it "should run pw groupmod with the return of set_options" do
@new_resource.gid(42)
@provider.should_receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -M root,aj" }).and_return(true)
@@ -72,18 +72,18 @@ describe Chef::Provider::Group::Pw do
end
describe "when setting group membership" do
-
+
describe "with an empty members array in both the new and current resource" do
before do
@new_resource.stub!(:members).and_return([])
@current_resource.stub!(:members).and_return([])
end
-
+
it "should log an appropriate message" do
Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members")
@provider.set_members_option
end
-
+
it "should set no options" do
@provider.set_members_option.should eql("")
end
@@ -94,28 +94,28 @@ describe Chef::Provider::Group::Pw do
@new_resource.stub!(:members).and_return([])
@current_resource.stub!(:members).and_return(["all", "your", "base"])
end
-
+
it "should log an appropriate message" do
Chef::Log.should_receive(:debug).with("group[wheel] removing group members all, your, base")
@provider.set_members_option
end
-
+
it "should set the -d option with the members joined by ','" do
@provider.set_members_option.should eql(" -d all,your,base")
end
end
-
+
describe "with supplied members array in the new resource and an empty members array in the current resource" do
before do
@new_resource.stub!(:members).and_return(["all", "your", "base"])
@current_resource.stub!(:members).and_return([])
end
-
+
it "should log an appropriate debug message" do
Chef::Log.should_receive(:debug).with("group[wheel] setting group members to all, your, base")
@provider.set_members_option
end
-
+
it "should set the -M option with the members joined by ','" do
@provider.set_members_option.should eql(" -M all,your,base")
end
@@ -123,7 +123,7 @@ describe Chef::Provider::Group::Pw do
end
describe"load_current_resource" do
- before (:each) do
+ before (:each) do
@provider.load_current_resource
@provider.define_resource_requirements
end
@@ -131,7 +131,7 @@ describe Chef::Provider::Group::Pw do
File.should_receive(:exists?).with("/usr/sbin/pw").and_return(false)
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Group)
end
-
+
it "shouldn't raise an error if /usr/sbin/pw exists" do
File.stub!(:exists?).and_return(true)
lambda { @provider.process_resource_requirements }.should_not raise_error(Chef::Exceptions::Group)
diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb
index 880a3b01e4..7f2931f2e2 100644
--- a/spec/unit/provider/group/usermod_spec.rb
+++ b/spec/unit/provider/group/usermod_spec.rb
@@ -6,9 +6,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,20 +28,20 @@ describe Chef::Provider::Group::Usermod do
@provider = Chef::Provider::Group::Usermod.new(@new_resource, @run_context)
@provider.stub!(:run_command)
end
-
+
describe "modify_group_members" do
-
+
describe "with an empty members array" do
before do
@new_resource.stub!(:members).and_return([])
end
-
+
it "should log an appropriate message" do
Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members")
@provider.modify_group_members
end
end
-
+
describe "with supplied members" do
platforms = {
"openbsd" => "-G",
@@ -61,10 +61,10 @@ describe Chef::Provider::Group::Usermod do
@provider.define_resource_requirements
@provider.load_current_resource
@provider.instance_variable_set("@group_exists", true)
- @provider.action = :modify
+ @provider.action = :modify
lambda { @provider.run_action(@provider.process_resource_requirements) }.should raise_error(Chef::Exceptions::Group, "setting group members directly is not supported by #{@provider.to_s}, must set append true in group")
end
-
+
platforms.each do |platform, flags|
it "should usermod each user when the append option is set on #{platform}" do
@node.automatic_attrs[:platform] = platform
@@ -89,7 +89,7 @@ describe Chef::Provider::Group::Usermod do
File.should_receive(:exists?).with("/usr/sbin/usermod").and_return(false)
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Group)
end
-
+
it "shouldn't raise an error if the required binaries exist" do
File.stub!(:exists?).and_return(true)
lambda { @provider.process_resource_requirements }.should_not raise_error(Chef::Exceptions::Group)