spec/solaris/commands_spec.rb in serverspec-0.2.18 vs spec/solaris/commands_spec.rb in serverspec-0.2.19
- old
+ new
@@ -112,25 +112,42 @@
it { should eq "id -Gn root | grep wheel" }
end
describe 'have_gid', :os => :solaris do
subject { commands.check_gid('root', 0) }
- it { should eq "getent group | grep -w ^root | cut -f 3 -d ':' | grep -w 0" }
+ it { should eq "getent group | grep ^root: | cut -f 3 -d ':' | grep -w 0" }
end
describe 'have_uid', :os => :solaris do
subject { commands.check_uid('root', 0) }
it { should eq "id root | grep '^uid=0('" }
end
describe 'have_login_shell', :os => :solaris do
subject { commands.check_login_shell('root', '/bin/bash') }
- it { should eq "grep -w ^root /etc/passwd | cut -f 7 -d ':' | grep -w /bin/bash" }
+ it { should eq "getent passwd root | cut -f 7 -d ':' | grep -w /bin/bash" }
end
describe 'have_home_directory', :os => :solaris do
subject { commands.check_home_directory('root', '/root') }
- it { should eq "grep -w ^root /etc/passwd | cut -f 6 -d ':' | grep -w /root" }
+ it { should eq "getent passwd root | cut -f 6 -d ':' | grep -w /root" }
+end
+
+describe 'have_authorized_key', :os => :solaris do
+ key = "ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH"
+
+ context 'with commented publickey' do
+ commented_key = key + " foo@bar.local"
+ subject { commands.check_authorized_key('root', commented_key) }
+ describe 'when command insert publickey is removed comment' do
+ it { should eq "grep -w '#{key}' ~root/.ssh/authorized_keys" }
+ end
+ end
+
+ context 'with uncomented publickey' do
+ subject { commands.check_authorized_key('root', key) }
+ it { should eq "grep -w '#{key}' ~root/.ssh/authorized_keys" }
+ end
end
describe 'check_zfs', :os => :solaris do
context 'check without properties' do
subject { commands.check_zfs('rpool') }