spec/smartos/commands_spec.rb in serverspec-0.6.20 vs spec/smartos/commands_spec.rb in serverspec-0.6.21

- old
+ new

@@ -1,41 +1,23 @@ require 'spec_helper' include Serverspec::Helper::SmartOS describe 'Serverspec commands of Solaris family specified SmartOS' do - it_behaves_like 'support command check_file', '/etc/passwd' - it_behaves_like 'support command check_directory', '/var/log' - it_behaves_like 'support command check_socket', '/var/run/unicorn.sock' - - it_behaves_like 'support command check_mounted', '/' - it_behaves_like 'support command check_user', 'root' it_behaves_like 'support command check_user', 'wheel' - it_behaves_like 'support command check_file_md5checksum', '/etc/passewd', '96c8c50f81a29965f7af6de371ab4250' - it_behaves_like 'support command check_running_under_supervisor', 'httpd' it_behaves_like 'support command check_monitored_by_monit', 'unicorn' it_behaves_like 'support command check_process', 'httpd' - it_behaves_like 'support command check_file_contain', '/etc/passwd', 'root' - - it_behaves_like 'support command check_mode', '/etc/sudoers', 440 - it_behaves_like 'support command check_owner', '/etc/sudoers', 'root' - it_behaves_like 'support command check_grouped', '/etc/sudoers', 'wheel' - - it_behaves_like 'support command check_link', '/etc/system-release', '/etc/redhat-release' - it_behaves_like 'support command check_uid', 'root', 0 it_behaves_like 'support command check_login_shell', 'root', '/bin/bash' it_behaves_like 'support command check_home_directory', 'root', '/root' it_behaves_like 'support command check_authorized_key' - - it_behaves_like 'support command get_mode' end describe 'check_enabled' do subject { commands.check_enabled('httpd') } it { should eq "svcs -l httpd 2> /dev/null | grep -wx '^enabled.*true$'" } @@ -50,33 +32,10 @@ ## SmartOS describe 'check_installed' do subject { commands.check_installed('httpd', '2.2') } it { should eq '/opt/local/bin/pkgin list 2> /dev/null | grep -qw ^httpd-2.2' } end - -describe 'check_file_contain_within' do - context 'contain a pattern in the file' do - subject { commands.check_file_contain_within('Gemfile', 'rspec') } - it { should eq "sed -n 1,\\$p Gemfile | grep -q -- rspec /dev/stdin" } - end - - context 'contain a pattern after a line in a file' do - subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/') } - it { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec /dev/stdin" } - end - - context 'contain a pattern before a line in a file' do - subject {commands.check_file_contain_within('Gemfile', 'rspec', nil, '/^end/') } - it { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" } - end - - context 'contain a pattern from within a line and another line in a file' do - subject { commands.check_file_contain_within('Gemfile', 'rspec', '/^group :test do/', '/^end/') } - it { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin" } - end -end - describe 'check_listening' do subject { commands.check_listening(80) } it { should eq "netstat -an 2> /dev/null | egrep 'LISTEN|Idle' | grep -- .80\\ " } end @@ -133,23 +92,6 @@ 'httpd/enable_64bit' => 'false', 'httpd/server_type' => 'worker', }) } it { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep -- \\^false\\$ && svcprop -p httpd/server_type svc:/network/http:apache22 | grep -- \\^worker\\$" } -end - -describe 'check_access_by_user' do - context 'read access' do - subject {commands.check_access_by_user '/tmp/something', 'dummyuser1', 'r'} - it { should eq 'su dummyuser1 -c "test -r /tmp/something"' } - end - - context 'write access' do - subject {commands.check_access_by_user '/tmp/somethingw', 'dummyuser2', 'w'} - it { should eq 'su dummyuser2 -c "test -w /tmp/somethingw"' } - end - - context 'execute access' do - subject {commands.check_access_by_user '/tmp/somethingx', 'dummyuser3', 'x'} - it { should eq 'su dummyuser3 -c "test -x /tmp/somethingx"' } - end end