diff --git a/lib/serverspec/version.rb b/lib/serverspec/version.rb index da96ac19..774e9491 100644 --- a/lib/serverspec/version.rb +++ b/lib/serverspec/version.rb @@ -1,3 +1,3 @@ module Serverspec - VERSION = "1.4.1" + VERSION = "2.0.0.beta1" end diff --git a/serverspec.gemspec b/serverspec.gemspec index 01f373f8..f34a069f 100644 --- a/serverspec.gemspec +++ b/serverspec.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "net-ssh" spec.add_runtime_dependency "rspec", "~> 2.13" spec.add_runtime_dependency "highline" - spec.add_runtime_dependency "specinfra", ">= 1.5.0" + spec.add_runtime_dependency "specinfra", "~> 2.0.0.beta" spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake", "~> 10.1.1" spec.add_development_dependency "octokit", "~> 2.7.2" diff --git a/spec/aix/command_spec.rb b/spec/aix/command_spec.rb deleted file mode 100644 index 68df7181..00000000 --- a/spec/aix/command_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::AIX - -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe command('ls -al /') do - let(:stdout) { < ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "su -s sh -c \"test -r /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "su -s sh -c \"test -w /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "su -s sh -c \"test -x /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -w 1 -c 2 -n 127.0.0.1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end diff --git a/spec/aix/package_spec.rb b/spec/aix/package_spec.rb deleted file mode 100644 index 196e2f4e..00000000 --- a/spec/aix/package_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::AIX - -describe package('httpd') do - it { should be_installed } - its(:command) { should eq "lslpp -L httpd" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('httpd') do - it { should be_installed.with_version('2.2.15-28.el6') } - its(:command) { should eq "lslpp -L httpd | awk '{print $2}' | grep -w -- 2.2.15-28.el6" } -end - -describe package('httpd') do - it { should_not be_installed.with_version('invalid-version') } -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end diff --git a/spec/aix/php_config_spec.rb b/spec/aix/php_config_spec.rb deleted file mode 100644 index 356fb796..00000000 --- a/spec/aix/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::AIX - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/aix/port_spec.rb b/spec/aix/port_spec.rb deleted file mode 100644 index 26fcb269..00000000 --- a/spec/aix/port_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::AIX - -describe port(80) do - it { should be_listening } - its(:command) { should eq "netstat -an -f inet | awk '{print $4}' | grep -- *.80 " } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/aix/process_spec.rb b/spec/aix/process_spec.rb deleted file mode 100644 index 3baf5d41..00000000 --- a/spec/aix/process_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::AIX - -describe process("memcached") do - let(:stdout) { " 1407\n" } - its(:pid) { should eq 1407 } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" } - its(:args) { should match /-c 30000\b/ } - its(:command) { should eq "ps -C memcached -o args= | head -1" } -end - -describe process("memcached") do - context "when running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end - - context "when not running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end -end diff --git a/spec/aix/routing_table_spec.rb b/spec/aix/routing_table_spec.rb deleted file mode 100644 index 12dc8e12..00000000 --- a/spec/aix/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::AIX - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/aix/service_spec.rb b/spec/aix/service_spec.rb deleted file mode 100644 index b9ac35db..00000000 --- a/spec/aix/service_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::AIX - -describe service('sshd') do - it { should be_enabled } - its(:command) { should eq "lssrc -s sshd | grep active" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('sshd') do - it { should be_enabled.with_level(4) } - its(:command) { should eq "lssrc -s sshd | grep active" } -end - -describe service('invalid-service') do - it { should_not be_enabled.with_level(4) } -end - -describe service('sshd') do - it { should be_running } - its(:command) { should eq "ps -ef | grep -v grep | grep sshd" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/aix/user_spec.rb b/spec/aix/user_spec.rb deleted file mode 100644 index 258d2945..00000000 --- a/spec/aix/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::AIX - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "lsuser -a groups root | awk -F'=' '{print $2}'| sed -e 's/,/ /g' |grep -w -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "lsuser -a shell root |awk -F'=' '{print $2}' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "lsuser -a home root | awk -F'=' '{print $2}' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/arch/file_spec.rb b/spec/arch/file_spec.rb deleted file mode 100644 index f0f1c754..00000000 --- a/spec/arch/file_spec.rb +++ /dev/null @@ -1,413 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Arch - -describe file('/etc/ssh/sshd_config') do - it { should be_file } - its(:command) { should eq "test -f /etc/ssh/sshd_config" } -end - -describe file('/etc/invalid_file') do - it { should_not be_file } -end - -describe file('/etc/ssh') do - it { should be_directory } - its(:command) { should eq "test -d /etc/ssh" } -end - -describe file('/etc/invalid_directory') do - it { should_not be_directory } -end - -describe file('/var/run/unicorn.sock') do - it { should be_socket } - its(:command) { should eq "test -S /var/run/unicorn.sock" } -end - -describe file('/etc/invalid_socket') do - it { should_not be_socket } -end - -describe file('/etc/ssh/sshd_config') do - it { should contain 'This is the sshd server system-wide configuration file' } - its(:command) { should eq "grep -q -- This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config || grep -qF -- This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config" } -end - -describe file('/etc/ssh/sshd_config') do - it { should contain /^This is the sshd server system-wide configuration file/ } - its(:command) { should eq "grep -q -- \\^This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config || grep -qF -- \\^This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config" } -end - -describe file('/etc/ssh/sshd_config') do - it { should_not contain 'This is invalid text!!' } -end - -describe file('Gemfile') do - it { should contain('rspec').from(/^group :test do/).to(/^end/) } - its(:command) { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec - || sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -qF -- rspec -" } -end - -describe file('/etc/ssh/sshd_config') do - it { should_not contain('This is invalid text!!').from(/^group :test do/).to(/^end/) } -end - -describe file('Gemfile') do - it { should contain('rspec').after(/^group :test do/) } - its(:command) { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec - || sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -qF -- rspec -" } -end - -describe file('/etc/ssh/sshd_config') do - it { should_not contain('This is invalid text!!').after(/^group :test do/) } -end - -describe file('Gemfile') do - it { should contain('rspec').before(/^end/) } - its(:command) { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec - || sed -n 1,/\\^end/p Gemfile | grep -qF -- rspec -" } -end - -describe file('/etc/ssh/sshd_config') do - it { should_not contain('This is invalid text!!').before(/^end/) } -end - -describe file('/etc/passwd') do - it { should be_mode 644 } - its(:command) { should eq "stat -c %a /etc/passwd | grep -- \\^644\\$" } -end - -describe file('/etc/passwd') do - it { should_not be_mode 'invalid' } -end - -describe file('/etc/passwd') do - it { should be_owned_by 'root' } - its(:command) { should eq "stat -c %U /etc/passwd | grep -- \\^root\\$" } -end - -describe file('/etc/passwd') do - it { should_not be_owned_by 'invalid-owner' } -end - -describe file('/etc/passwd') do - it { should be_grouped_into 'root' } - its(:command) { should eq "stat -c %G /etc/passwd | grep -- \\^root\\$" } -end - -describe file('/etc/passwd') do - it { should_not be_grouped_into 'invalid-group' } -end - -describe file('/etc/pam.d/system-auth') do - it { should be_linked_to '/etc/pam.d/system-auth-ac' } - its(:command) { should eq "stat -c %N /etc/pam.d/system-auth | egrep -e \"-> ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "runuser -s /bin/sh -c \"test -r /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "runuser -s /bin/sh -c \"test -w /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "runuser -s /bin/sh -c \"test -x /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< 'root' } } - c.ssh = ssh - end - end - - context file('/etc/passwd') do - it { should be_file } - its(:command) { should eq 'test -f /etc/passwd' } - end -end - -describe 'path is set' do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'root' } } - c.ssh = ssh - end - end - - let(:path) { '/sbin:/usr/sbin' } - context file('/etc/passwd') do - it { should be_file } - its(:command) { should eq 'env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' } - end -end - -describe 'pre_command is set and user is root' do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'root' } } - c.ssh = ssh - end - end - - let(:pre_command) { 'source ~/.zshrc' } - context file('/etc/passwd') do - it { should be_file } - its(:command) { should eq 'source ~/.zshrc && test -f /etc/passwd' } - end -end - -describe 'pre_command is set and user is non-root' do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - - let(:pre_command) { 'source ~/.zshrc' } - context file('/etc/passwd') do - it { should be_file } - its(:command) { should eq 'sudo source ~/.zshrc && sudo test -f /etc/passwd' } - end -end - -describe 'pre_command is not set and user is non-root' do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - - context file('/etc/passwd') do - it { should be_file } - its(:command) { should eq 'sudo test -f /etc/passwd' } - end -end - - -describe 'path pre_command and set and user is non-root' do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - - let(:path) { '/sbin:/usr/sbin' } - let(:pre_command) { 'source ~/.zshrc' } - context file('/etc/passwd') do - it { should be_file } - its(:command) { should eq 'sudo env PATH=/sbin:/usr/sbin:$PATH source ~/.zshrc && sudo env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' } - end -end - -describe 'path pre_command and set and user is non-root' do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'root' } } - c.ssh = ssh - end - end - - let(:path) { '/sbin:/usr/sbin' } - let(:pre_command) { 'source ~/.zshrc' } - context file('/etc/passwd') do - it { should be_file } - its(:command) { should eq 'env PATH=/sbin:/usr/sbin:$PATH source ~/.zshrc && env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' } - end -end - -describe 'user is non-root for check_selinux' do - context selinux do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - it { should be_disabled } - its(:command) { should eq "sudo test ! -f /etc/selinux/config || (sudo getenforce | grep -i -- disabled && sudo grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" } - end - - context selinux do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - it { should be_enforcing } - its(:command) { should eq "sudo getenforce | grep -i -- enforcing && sudo grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" } - end - - context selinux do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - it { should be_permissive } - its(:command) { should eq "sudo getenforce | grep -i -- permissive && sudo grep -i -- ^SELINUX=permissive$ /etc/selinux/config" } - end -end - -describe 'path is set and user is non-root for check_selinux' do - let(:path) { "/sbin:/usr/sbin" } - - context selinux do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - it { should be_disabled } - its(:command) { should eq "sudo env PATH=/sbin:/usr/sbin:$PATH test ! -f /etc/selinux/config || (sudo env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- disabled && sudo env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" } - end - - context selinux do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - it { should be_enforcing } - its(:command) { should eq "sudo env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- enforcing && sudo env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" } - end - - context selinux do - before :all do - RSpec.configure do |c| - ssh.stub(:options) { { :user => 'foo' } } - c.ssh = ssh - end - end - it { should be_permissive } - its(:command) { should eq "sudo env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- permissive && sudo env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=permissive$ /etc/selinux/config" } - end -end diff --git a/spec/backend/winrm/configuration_spec.rb b/spec/backend/winrm/configuration_spec.rb deleted file mode 100644 index 4e8a797f..00000000 --- a/spec/backend/winrm/configuration_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'spec_helper' -require 'support/powershell_command_runner' - -include SpecInfra::Helper::WinRM -include SpecInfra::Helper::Windows - -describe "WinRM" do - it_behaves_like "a powershell command runner" -end diff --git a/spec/darwin/command_spec.rb b/spec/darwin/command_spec.rb deleted file mode 100644 index 9959782e..00000000 --- a/spec/darwin/command_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe command('ls -al /') do - let(:stdout) { < 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "openssl md5 /etc/services | cut -d'=' -f2 | cut -c 2- | grep -E ^35435ea447c19f0ea5ef971837ab9ced$" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "openssl sha256 /etc/services | cut -d'=' -f2 | cut -c 2- | grep -E ^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a$" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -w 1 -c 2 -n 127.0.0.1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end diff --git a/spec/darwin/mail_alias_spec.rb b/spec/darwin/mail_alias_spec.rb deleted file mode 100644 index 5f4ef4ad..00000000 --- a/spec/darwin/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/darwin/package_spec.rb b/spec/darwin/package_spec.rb deleted file mode 100644 index ef0aa460..00000000 --- a/spec/darwin/package_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end diff --git a/spec/darwin/php_config_spec.rb b/spec/darwin/php_config_spec.rb deleted file mode 100644 index ed6ac286..00000000 --- a/spec/darwin/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/darwin/port_spec.rb b/spec/darwin/port_spec.rb deleted file mode 100644 index 5e7fe825..00000000 --- a/spec/darwin/port_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -describe port(80) do - it { should be_listening } - its(:command) { should eq 'netstat -tunl | grep -- :80\\ ' } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/darwin/process_spec.rb b/spec/darwin/process_spec.rb deleted file mode 100644 index cd1205a5..00000000 --- a/spec/darwin/process_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -describe process("memcached") do - let(:stdout) { " 1407\n" } - its(:pid) { should eq 1407 } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" } - its(:args) { should match /-c 30000\b/ } - its(:command) { should eq "ps -C memcached -o args= | head -1" } -end - -describe process("memcached") do - context "when running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end - - context "when not running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end -end diff --git a/spec/darwin/routing_table_spec.rb b/spec/darwin/routing_table_spec.rb deleted file mode 100644 index cad3fd95..00000000 --- a/spec/darwin/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/darwin/service_spec.rb b/spec/darwin/service_spec.rb deleted file mode 100644 index bd3d618f..00000000 --- a/spec/darwin/service_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -#describe service('sshd') do -# it { should be_enabled } -#end - -#describe service('invalid-service') do -# it { should_not be_enabled } -#end - -#describe service('sshd') do -# it { should be_enabled.with_level(3) } -#end - -#describe service('invalid-service') do -# it { should_not be_enabled.with_level(3) } -#end - -describe service('sshd') do - it { should be_running } - its(:command) { should eq "service sshd status" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/darwin/user_spec.rb b/spec/darwin/user_spec.rb deleted file mode 100644 index da10b7d1..00000000 --- a/spec/darwin/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Darwin - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id root | awk '{print $3}' | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/debian/cgroup_spec.rb b/spec/debian/cgroup_spec.rb deleted file mode 100644 index 1823882d..00000000 --- a/spec/debian/cgroup_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe cgroup('group1') do - let(:stdout) { "1\r\n" } - its('cpuset.cpus') { should eq 1 } - its(:command) { should eq "cgget -n -r cpuset.cpus group1 | awk '{print $2}'" } -end - -describe cgroup('group1') do - let(:stdout) { "1\r\n" } - its('cpuset.cpus') { should_not eq 0 } -end diff --git a/spec/debian/command_spec.rb b/spec/debian/command_spec.rb deleted file mode 100644 index ea993dcf..00000000 --- a/spec/debian/command_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe command('ls -al /') do - let(:stdout) { < ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -r /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -w /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -x /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -w 1 -c 2 -n 127.0.0.1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end diff --git a/spec/debian/interface_spec.rb b/spec/debian/interface_spec.rb deleted file mode 100644 index fa222d1e..00000000 --- a/spec/debian/interface_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe interface('eth0') do - let(:stdout) { '1000' } - its(:speed) { should eq 1000 } - its(:command) { should eq "ethtool eth0 | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\/s/,\"\\\\1\",\"\")}'" } -end - -describe interface('eth0') do - it { should have_ipv4_address("192.168.10.10") } - its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/'" } -end - -describe interface('eth0') do - it { should have_ipv4_address("192.168.10.10/24") } - its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/24 '" } -end - -describe interface('invalid-interface') do - let(:stdout) { '1000' } - its(:speed) { should_not eq 100 } -end diff --git a/spec/debian/iptables_spec.rb b/spec/debian/iptables_spec.rb deleted file mode 100644 index 343a9063..00000000 --- a/spec/debian/iptables_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe iptables do - it { should have_rule '-P INPUT ACCEPT' } - its(:command) { should eq "iptables -S | grep -- -P\\ INPUT\\ ACCEPT || iptables-save | grep -- -P\\ INPUT\\ ACCEPT" } -end - -describe iptables do - it { should_not have_rule 'invalid-rule' } -end - -describe iptables do - it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') } - its(:command) { should eq "iptables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || iptables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" } -end - -describe iptables do - it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') } -end diff --git a/spec/debian/kernel_module_spec.rb b/spec/debian/kernel_module_spec.rb deleted file mode 100644 index 10dd72d2..00000000 --- a/spec/debian/kernel_module_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe kernel_module('lp') do - it { should be_loaded } - its(:command) { should eq "lsmod | grep ^lp" } -end - -describe kernel_module('invalid-module') do - it { should_not be_loaded } -end diff --git a/spec/debian/linux_kernel_parameter_spec.rb b/spec/debian/linux_kernel_parameter_spec.rb deleted file mode 100644 index b9effdfa..00000000 --- a/spec/debian/linux_kernel_parameter_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do - let(:stdout) { "1\n" } - its(:value) { should eq 1 } - its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_syncookies" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do - let(:stdout) { "1\n" } - its(:value) { should_not eq 2 } -end - -describe linux_kernel_parameter('kernel.osrelease') do - let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" } - its(:value) { should eq "2.6.32-131.0.15.el6.x86_64" } - its(:command) { should eq "/sbin/sysctl -q -n kernel.osrelease" } -end - -describe linux_kernel_parameter('kernel.osrelease') do - let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" } - its(:value) { should_not eq "2.6.32-131.0.15.el6.i386" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_wmem') do - let(:stdout) { "4096 16384 4194304\n" } - its(:value) { should match /16384/ } - its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_wmem" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_wmem') do - let(:stdout) { "4096 16384 4194304\n" } - its(:value) { should_not match /123456/ } -end diff --git a/spec/debian/lxc_spec.rb b/spec/debian/lxc_spec.rb deleted file mode 100644 index f060c012..00000000 --- a/spec/debian/lxc_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe lxc('ct01') do - it { should exist } - its(:command) { should eq "lxc-ls -1 | grep -w ct01" } -end - -describe lxc('invalid-ct') do - it { should_not exist } -end - -describe lxc('ct01') do - it { should be_running } - its(:command) { should eq "lxc-info -n ct01 -t RUNNING"} -end - -describe lxc('invalid-ct') do - it { should_not be_running } -end - diff --git a/spec/debian/mail_alias_spec.rb b/spec/debian/mail_alias_spec.rb deleted file mode 100644 index 929a9307..00000000 --- a/spec/debian/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/debian/package_spec.rb b/spec/debian/package_spec.rb deleted file mode 100644 index abd16f50..00000000 --- a/spec/debian/package_spec.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe package('apache2') do - it { should be_installed } - its(:command) { should eq "dpkg-query -f '${Status}' -W apache2 | grep -E '^(install|hold) ok installed$'" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('apache2') do - it { should be_installed.with_version('1.1.1') } - its(:command) { should eq "dpkg-query -f '${Status} ${Version}' -W apache2 | grep -E '^(install|hold) ok installed 1.1.1$'" } -end - -describe package('invalid-package') do - it { should_not be_installed.with_version('invalid-version') } -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end - -describe package('httpd') do - let(:stdout) { "2.2.15\n" } - its(:version) { should eq '2.2.15' } - its(:version) { should > '2.2.14' } - its(:version) { should < '2.2.16' } - its(:command) { should eq "dpkg-query -f '${Status} ${Version}' -W httpd | sed -n 's/^install ok installed //p'" } -end - -# Debian-style versions -describe package('httpd') do - let(:stdout) { "2.2.15-3\n" } - its(:version) { should eq '2.2.15-3' } - its(:version) { should > '2.2.15' } - its(:version) { should < '2.2.16' } - its(:version) { should < '2.2.15-4' } - its(:version) { should > '2.2.15-3~bpo70+1' } -end - -# With some epoch -describe package('httpd') do - let(:stdout) { "3:2.2.15-3~git20120918+ae4569bc\n" } - its(:version) { should eq '3:2.2.15-3~git20120918+ae4569bc' } - its(:version) { should > '3:2.2.15-3~git20120912+ae4569bc' } - its(:version) { should < '3:2.2.15-3' } - its(:version) { should < '3:2.2.15-3+feature1' } - its(:version) { should < '4:1.2.15' } - its(:version) { should > '2:4.2.15' } - its(:version) { should > '14.2.15' } -end diff --git a/spec/debian/php_config_spec.rb b/spec/debian/php_config_spec.rb deleted file mode 100644 index c94387b9..00000000 --- a/spec/debian/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/debian/port_spec.rb b/spec/debian/port_spec.rb deleted file mode 100644 index 5a5abdb6..00000000 --- a/spec/debian/port_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe port(80) do - it { should be_listening } - its(:command) { should eq 'netstat -tunl | grep -- :80\\ ' } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' } -end - -describe port(81) do - it { should be_listening.with("tcp6") } - its(:command) { should eq 'netstat -tunl | grep -- \\^tcp6\\ .\\*:81\\ ' } -end - -describe port(1234) do - it { should be_listening.with("udp6") } - its(:command) { should eq 'netstat -tunl | grep -- \\^udp6\\ .\\*:1234\\ ' } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/debian/process_spec.rb b/spec/debian/process_spec.rb deleted file mode 100644 index 319aec2f..00000000 --- a/spec/debian/process_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe process("memcached") do - let(:stdout) { " 1407\n" } - its(:pid) { should eq 1407 } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" } - its(:args) { should match /-c 30000\b/ } - its(:command) { should eq "ps -C memcached -o args= | head -1" } -end - -describe process("memcached") do - context "when running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end - - context "when not running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end -end diff --git a/spec/debian/routing_table_spec.rb b/spec/debian/routing_table_spec.rb deleted file mode 100644 index c37de69f..00000000 --- a/spec/debian/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/debian/selinux_spec.rb b/spec/debian/selinux_spec.rb deleted file mode 100644 index 98387b36..00000000 --- a/spec/debian/selinux_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe selinux do - it { should be_enforcing } - its(:command) { should eq "getenforce | grep -i -- enforcing && grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" } -end - -describe selinux do - it { should be_permissive } - its(:command) { should eq "getenforce | grep -i -- permissive && grep -i -- ^SELINUX=permissive$ /etc/selinux/config" } -end - -describe selinux do - it { should be_disabled } - its(:command) { should eq "test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" } -end diff --git a/spec/debian/service_spec.rb b/spec/debian/service_spec.rb deleted file mode 100644 index c1b9cce5..00000000 --- a/spec/debian/service_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe service('sshd') do - it { should be_enabled } - its(:command) { should eq "ls /etc/rc3.d/ | grep -- '^S..sshd' || grep 'start on' /etc/init/sshd.conf" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('sshd') do - it { should be_enabled.with_level(4) } - its(:command) { should eq "ls /etc/rc4.d/ | grep -- '^S..sshd' || grep 'start on' /etc/init/sshd.conf" } -end - -describe service('invalid-service') do - it { should_not be_enabled.with_level(4) } -end - -describe service('sshd') do - it { should be_running } - its(:command) { should eq "service sshd status" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/debian/user_spec.rb b/spec/debian/user_spec.rb deleted file mode 100644 index 02e1c0f1..00000000 --- a/spec/debian/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id root | awk '{print $3}' | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/debian/zfs_spec.rb b/spec/debian/zfs_spec.rb deleted file mode 100644 index 3afb2ae6..00000000 --- a/spec/debian/zfs_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Debian - -describe zfs('rpool') do - it { should exist } - its(:command) { should eq "zfs list -H rpool" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool' } - its(:command) { should eq "zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' } - its(:command) { should eq "zfs list -H -o compression rpool | grep -- \\^off\\$ && zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end diff --git a/spec/freebsd/command_spec.rb b/spec/freebsd/command_spec.rb deleted file mode 100644 index dd0a5737..00000000 --- a/spec/freebsd/command_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD - -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe command('ls -al /') do - let(:stdout) { < ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -f%Lp /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -f%Lp /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -w 1 -c 2 -n 127.0.0.1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end diff --git a/spec/freebsd/package_spec.rb b/spec/freebsd/package_spec.rb deleted file mode 100644 index 28f213c6..00000000 --- a/spec/freebsd/package_spec.rb +++ /dev/null @@ -1,96 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD - -describe package('httpd') do - it { should be_installed } - its(:command) { should eq "pkg_info -Ix httpd" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('httpd') do - it { should be_installed.with_version('2.2.15-28.el6') } - its(:command) { should eq "pkg_info -I httpd-2.2.15-28.el6"} -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end diff --git a/spec/freebsd/php_config_spec.rb b/spec/freebsd/php_config_spec.rb deleted file mode 100644 index b09934e6..00000000 --- a/spec/freebsd/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/freebsd/port_spec.rb b/spec/freebsd/port_spec.rb deleted file mode 100644 index bfed4e23..00000000 --- a/spec/freebsd/port_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD - -describe port(80) do - it { should be_listening } - its(:command) { should eq 'sockstat -46l -p 80 | grep -- :80\\ ' } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/freebsd/process_spec.rb b/spec/freebsd/process_spec.rb deleted file mode 100644 index 6246924f..00000000 --- a/spec/freebsd/process_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD - -describe process("memcached") do - let(:stdout) { " 1407\n" } - its(:pid) { should eq 1407 } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" } - its(:args) { should match /-c 30000\b/ } - its(:command) { should eq "ps -C memcached -o args= | head -1" } -end - -describe process("memcached") do - context "when running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end - - context "when not running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end -end diff --git a/spec/freebsd/routing_table_spec.rb b/spec/freebsd/routing_table_spec.rb deleted file mode 100644 index bd7e50c3..00000000 --- a/spec/freebsd/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/freebsd/service_spec.rb b/spec/freebsd/service_spec.rb deleted file mode 100644 index 22a13850..00000000 --- a/spec/freebsd/service_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD - -describe service('sshd') do - it { should be_enabled } - its(:command) { should eq "service -e | grep -- sshd" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('sshd') do - it { should be_enabled.with_level(4) } - its(:command) { should eq "service -e | grep -- sshd" } -end - -describe service('invalid-service') do - it { should_not be_enabled.with_level(4) } -end - -describe service('sshd') do - it { should be_running } - its(:command) { should eq "service sshd status" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/freebsd/user_spec.rb b/spec/freebsd/user_spec.rb deleted file mode 100644 index 4ffafc2e..00000000 --- a/spec/freebsd/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id root | awk '{print $3}' | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/freebsd10/package_spec.rb b/spec/freebsd10/package_spec.rb deleted file mode 100644 index da0247f1..00000000 --- a/spec/freebsd10/package_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::FreeBSD10 - -describe package('httpd') do - it { should be_installed } - its(:command) { should eq "pkg info httpd" } -end - -describe package('httpd') do - it { should be_installed.with_version('2.2.15-28.el6') } - its(:command) { should eq "pkg query %v httpd | grep -- 2.2.15-28.el6"} -end diff --git a/spec/gentoo/cgroup_spec.rb b/spec/gentoo/cgroup_spec.rb deleted file mode 100644 index a26a43d4..00000000 --- a/spec/gentoo/cgroup_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe cgroup('group1') do - let(:stdout) { "1\r\n" } - its('cpuset.cpus') { should eq 1 } - its(:command) { should eq "cgget -n -r cpuset.cpus group1 | awk '{print $2}'" } -end - -describe cgroup('group1') do - let(:stdout) { "1\r\n" } - its('cpuset.cpus') { should_not eq 0 } -end diff --git a/spec/gentoo/command_spec.rb b/spec/gentoo/command_spec.rb deleted file mode 100644 index 9a9e65e5..00000000 --- a/spec/gentoo/command_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe command('ls -al /') do - let(:stdout) { < ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -r /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -w /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -x /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -w 1 -c 2 -n 127.0.0.1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end diff --git a/spec/gentoo/interface_spec.rb b/spec/gentoo/interface_spec.rb deleted file mode 100644 index 5340d6fd..00000000 --- a/spec/gentoo/interface_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe interface('eth0') do - let(:stdout) { '1000' } - its(:speed) { should eq 1000 } - its(:command) { should eq "ethtool eth0 | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\/s/,\"\\\\1\",\"\")}'" } -end - -describe interface('eth0') do - it { should have_ipv4_address("192.168.10.10") } - its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/'" } -end - -describe interface('eth0') do - it { should have_ipv4_address("192.168.10.10/24") } - its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/24 '" } -end - -describe interface('invalid-interface') do - let(:stdout) { '1000' } - its(:speed) { should_not eq 100 } -end diff --git a/spec/gentoo/iptables_spec.rb b/spec/gentoo/iptables_spec.rb deleted file mode 100644 index fc52db85..00000000 --- a/spec/gentoo/iptables_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe iptables do - it { should have_rule '-P INPUT ACCEPT' } - its(:command) { should eq "iptables -S | grep -- -P\\ INPUT\\ ACCEPT || iptables-save | grep -- -P\\ INPUT\\ ACCEPT" } -end - -describe iptables do - it { should_not have_rule 'invalid-rule' } -end - -describe iptables do - it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') } - its(:command) { should eq "iptables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || iptables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" } -end - -describe iptables do - it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') } -end diff --git a/spec/gentoo/kernel_module_spec.rb b/spec/gentoo/kernel_module_spec.rb deleted file mode 100644 index 286029cf..00000000 --- a/spec/gentoo/kernel_module_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe kernel_module('lp') do - it { should be_loaded } - its(:command) { should eq "lsmod | grep ^lp" } -end - -describe kernel_module('invalid-module') do - it { should_not be_loaded } -end diff --git a/spec/gentoo/linux_kernel_parameter_spec.rb b/spec/gentoo/linux_kernel_parameter_spec.rb deleted file mode 100644 index 72002499..00000000 --- a/spec/gentoo/linux_kernel_parameter_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do - let(:stdout) { "1\n" } - its(:value) { should eq 1 } - its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_syncookies" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do - let(:stdout) { "1\n" } - its(:value) { should_not eq 2 } -end - -describe linux_kernel_parameter('kernel.osrelease') do - let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" } - its(:value) { should eq "2.6.32-131.0.15.el6.x86_64" } - its(:command) { should eq "/sbin/sysctl -q -n kernel.osrelease" } -end - -describe linux_kernel_parameter('kernel.osrelease') do - let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" } - its(:value) { should_not eq "2.6.32-131.0.15.el6.i386" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_wmem') do - let(:stdout) { "4096 16384 4194304\n" } - its(:value) { should match /16384/ } - its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_wmem" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_wmem') do - let(:stdout) { "4096 16384 4194304\n" } - its(:value) { should_not match /123456/ } -end diff --git a/spec/gentoo/lxc_spec.rb b/spec/gentoo/lxc_spec.rb deleted file mode 100644 index 6c154f24..00000000 --- a/spec/gentoo/lxc_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe lxc('ct01') do - it { should exist } - its(:command) { should eq "lxc-ls -1 | grep -w ct01" } -end - -describe lxc('invalid-ct') do - it { should_not exist } -end - -describe lxc('ct01') do - it { should be_running } - its(:command) { should eq "lxc-info -n ct01 -t RUNNING"} -end - -describe lxc('invalid-ct') do - it { should_not be_running } -end - diff --git a/spec/gentoo/mail_alias_spec.rb b/spec/gentoo/mail_alias_spec.rb deleted file mode 100644 index 36ed3227..00000000 --- a/spec/gentoo/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/gentoo/package_spec.rb b/spec/gentoo/package_spec.rb deleted file mode 100644 index b29a4d87..00000000 --- a/spec/gentoo/package_spec.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe package('apache') do - it { should be_installed } - its(:command) { should eq "eix apache --installed" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end diff --git a/spec/gentoo/php_config_spec.rb b/spec/gentoo/php_config_spec.rb deleted file mode 100644 index b78c9316..00000000 --- a/spec/gentoo/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/gentoo/port_spec.rb b/spec/gentoo/port_spec.rb deleted file mode 100644 index caa507ff..00000000 --- a/spec/gentoo/port_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe port(80) do - it { should be_listening } - its(:command) { should eq 'netstat -tunl | grep -- :80\\ ' } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/gentoo/process_spec.rb b/spec/gentoo/process_spec.rb deleted file mode 100644 index 9d04ef52..00000000 --- a/spec/gentoo/process_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe process("memcached") do - let(:stdout) { " 1407\n" } - its(:pid) { should eq 1407 } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" } - its(:args) { should match /-c 30000\b/ } - its(:command) { should eq "ps -C memcached -o args= | head -1" } -end - -describe process("memcached") do - context "when running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end - - context "when not running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end -end diff --git a/spec/gentoo/routing_table_spec.rb b/spec/gentoo/routing_table_spec.rb deleted file mode 100644 index ba9ab2fa..00000000 --- a/spec/gentoo/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/gentoo/selinux_spec.rb b/spec/gentoo/selinux_spec.rb deleted file mode 100644 index a71e2654..00000000 --- a/spec/gentoo/selinux_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe selinux do - it { should be_enforcing } - its(:command) { should eq "getenforce | grep -i -- enforcing && grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" } -end - -describe selinux do - it { should be_permissive } - its(:command) { should eq "getenforce | grep -i -- permissive && grep -i -- ^SELINUX=permissive$ /etc/selinux/config" } -end - -describe selinux do - it { should be_disabled } - its(:command) { should eq "test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" } -end diff --git a/spec/gentoo/service_spec.rb b/spec/gentoo/service_spec.rb deleted file mode 100644 index 6d0d6503..00000000 --- a/spec/gentoo/service_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe service('sshd') do - it { should be_enabled } - its(:command) { should eq "rc-update show | grep -- \\^\\\\s\\*sshd\\\\s\\*\\|\\\\s\\*\\\\\\(boot\\\\\\|default\\\\\\)" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('sshd') do - it { should be_enabled.with_level(4) } - its(:command) { should eq "rc-update show | grep -- \\^\\\\s\\*sshd\\\\s\\*\\|\\\\s\\*\\\\\\(boot\\\\\\|default\\\\\\)" } -end - -describe service('invalid-service') do - it { should_not be_enabled.with_level(4) } -end - -describe service('sshd') do - it { should be_running } - its(:command) { should eq "/etc/init.d/sshd status" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/gentoo/user_spec.rb b/spec/gentoo/user_spec.rb deleted file mode 100644 index 187fc0a1..00000000 --- a/spec/gentoo/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id root | awk '{print $3}' | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/gentoo/zfs_spec.rb b/spec/gentoo/zfs_spec.rb deleted file mode 100644 index a32eb1a7..00000000 --- a/spec/gentoo/zfs_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Gentoo - -describe zfs('rpool') do - it { should exist } - its(:command) { should eq "zfs list -H rpool" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool' } - its(:command) { should eq "zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' } - its(:command) { should eq "zfs list -H -o compression rpool | grep -- \\^off\\$ && zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end diff --git a/spec/plamo/cgroup_spec.rb b/spec/plamo/cgroup_spec.rb deleted file mode 100644 index 506e2cac..00000000 --- a/spec/plamo/cgroup_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe cgroup('group1') do - let(:stdout) { "1\r\n" } - its('cpuset.cpus') { should eq 1 } - its(:command) { should eq "cgget -n -r cpuset.cpus group1 | awk '{print $2}'" } -end - -describe cgroup('group1') do - let(:stdout) { "1\r\n" } - its('cpuset.cpus') { should_not eq 0 } -end diff --git a/spec/plamo/command_spec.rb b/spec/plamo/command_spec.rb deleted file mode 100644 index 6749bdc1..00000000 --- a/spec/plamo/command_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe command('ls -al /') do - let(:stdout) { < ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -r /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -w /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "su -s /bin/sh -c \"test -x /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -w 1 -c 2 -n 127.0.0.1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end diff --git a/spec/plamo/interface_spec.rb b/spec/plamo/interface_spec.rb deleted file mode 100644 index 9f13af5a..00000000 --- a/spec/plamo/interface_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe interface('eth0') do - let(:stdout) { '1000' } - its(:speed) { should eq 1000 } - its(:command) { should eq "ethtool eth0 | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\/s/,\"\\\\1\",\"\")}'" } -end - -describe interface('eth0') do - it { should have_ipv4_address("192.168.10.10") } - its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/'" } -end - -describe interface('eth0') do - it { should have_ipv4_address("192.168.10.10/24") } - its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/24 '" } -end - -describe interface('invalid-interface') do - let(:stdout) { '1000' } - its(:speed) { should_not eq 100 } -end diff --git a/spec/plamo/iptables_spec.rb b/spec/plamo/iptables_spec.rb deleted file mode 100644 index 3b5ab7e6..00000000 --- a/spec/plamo/iptables_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe iptables do - it { should have_rule '-P INPUT ACCEPT' } - its(:command) { should eq "iptables -S | grep -- -P\\ INPUT\\ ACCEPT || iptables-save | grep -- -P\\ INPUT\\ ACCEPT" } -end - -describe iptables do - it { should_not have_rule 'invalid-rule' } -end - -describe iptables do - it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') } - its(:command) { should eq "iptables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || iptables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" } -end - -describe iptables do - it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') } -end diff --git a/spec/plamo/kernel_module_spec.rb b/spec/plamo/kernel_module_spec.rb deleted file mode 100644 index 39c6854f..00000000 --- a/spec/plamo/kernel_module_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe kernel_module('lp') do - it { should be_loaded } - its(:command) { should eq "lsmod | grep ^lp" } -end - -describe kernel_module('invalid-module') do - it { should_not be_loaded } -end diff --git a/spec/plamo/linux_kernel_parameter_spec.rb b/spec/plamo/linux_kernel_parameter_spec.rb deleted file mode 100644 index 1b5ad9e6..00000000 --- a/spec/plamo/linux_kernel_parameter_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do - let(:stdout) { "1\n" } - its(:value) { should eq 1 } - its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_syncookies" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do - let(:stdout) { "1\n" } - its(:value) { should_not eq 2 } -end - -describe linux_kernel_parameter('kernel.osrelease') do - let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" } - its(:value) { should eq "2.6.32-131.0.15.el6.x86_64" } - its(:command) { should eq "/sbin/sysctl -q -n kernel.osrelease" } -end - -describe linux_kernel_parameter('kernel.osrelease') do - let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" } - its(:value) { should_not eq "2.6.32-131.0.15.el6.i386" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_wmem') do - let(:stdout) { "4096 16384 4194304\n" } - its(:value) { should match /16384/ } - its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_wmem" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_wmem') do - let(:stdout) { "4096 16384 4194304\n" } - its(:value) { should_not match /123456/ } -end diff --git a/spec/plamo/lxc_spec.rb b/spec/plamo/lxc_spec.rb deleted file mode 100644 index 8491c494..00000000 --- a/spec/plamo/lxc_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe lxc('ct01') do - it { should exist } - its(:command) { should eq "lxc-ls -1 | grep -w ct01" } -end - -describe lxc('invalid-ct') do - it { should_not exist } -end - -describe lxc('ct01') do - it { should be_running } - its(:command) { should eq "lxc-info -n ct01 -t RUNNING"} -end - -describe lxc('invalid-ct') do - it { should_not be_running } -end - diff --git a/spec/plamo/mail_alias_spec.rb b/spec/plamo/mail_alias_spec.rb deleted file mode 100644 index 09051935..00000000 --- a/spec/plamo/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/plamo/package_spec.rb b/spec/plamo/package_spec.rb deleted file mode 100644 index df144e29..00000000 --- a/spec/plamo/package_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe package('httpd') do - it { should be_installed } - its(:command) { should eq "ls /var/log/packages/httpd" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('httpd') do - it { should be_installed.with_version('1.1.1') } - its(:command) { should eq "ls /var/log/packages/httpd && grep -E \"PACKAGE NAME:.+httpd-1.1.1\" /var/log/packages/httpd" } -end - -describe package('invalid-package') do - it { should_not be_installed.with_version('invalid-version') } -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end diff --git a/spec/plamo/php_config_spec.rb b/spec/plamo/php_config_spec.rb deleted file mode 100644 index 9b49bf39..00000000 --- a/spec/plamo/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/plamo/port_spec.rb b/spec/plamo/port_spec.rb deleted file mode 100644 index 64de8a8e..00000000 --- a/spec/plamo/port_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe port(80) do - it { should be_listening } - its(:command) { should eq 'netstat -tunl | grep -- :80\\ ' } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/plamo/routing_table_spec.rb b/spec/plamo/routing_table_spec.rb deleted file mode 100644 index 0257b8e5..00000000 --- a/spec/plamo/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/plamo/selinux_spec.rb b/spec/plamo/selinux_spec.rb deleted file mode 100644 index 533e4bc1..00000000 --- a/spec/plamo/selinux_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe selinux do - it { should be_enforcing } - its(:command) { should eq "getenforce | grep -i -- enforcing && grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" } -end - -describe selinux do - it { should be_permissive } - its(:command) { should eq "getenforce | grep -i -- permissive && grep -i -- ^SELINUX=permissive$ /etc/selinux/config" } -end - -describe selinux do - it { should be_disabled } - its(:command) { should eq "test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" } -end diff --git a/spec/plamo/service_spec.rb b/spec/plamo/service_spec.rb deleted file mode 100644 index 761c464f..00000000 --- a/spec/plamo/service_spec.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe service('sshd') do - it { should be_enabled } - its(:command) { should eq "test -x /etc/rc.d/init.d/sshd" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('sshd') do - it { should be_enabled.with_level(4) } - its(:command) { should eq "test -x /etc/rc.d/init.d/sshd" } -end - -describe service('invalid-service') do - it { should_not be_enabled.with_level(4) } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/plamo/user_spec.rb b/spec/plamo/user_spec.rb deleted file mode 100644 index a93de129..00000000 --- a/spec/plamo/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id root | awk '{print $3}' | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/plamo/zfs_spec.rb b/spec/plamo/zfs_spec.rb deleted file mode 100644 index 97ddbb0c..00000000 --- a/spec/plamo/zfs_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Plamo - -describe zfs('rpool') do - it { should exist } - its(:command) { should eq "zfs list -H rpool" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool' } - its(:command) { should eq "zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' } - its(:command) { should eq "zfs list -H -o compression rpool | grep -- \\^off\\$ && zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end diff --git a/spec/redhat/cgroup_spec.rb b/spec/redhat/cgroup_spec.rb deleted file mode 100644 index 67681673..00000000 --- a/spec/redhat/cgroup_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe cgroup('group1') do - let(:stdout) { "1\r\n" } - its('cpuset.cpus') { should eq 1 } - its(:command) { should eq "cgget -n -r cpuset.cpus group1 | awk '{print $2}'" } -end - -describe cgroup('group1') do - let(:stdout) { "1\r\n" } - its('cpuset.cpus') { should_not eq 0 } -end diff --git a/spec/redhat/command_spec.rb b/spec/redhat/command_spec.rb deleted file mode 100644 index fd55374b..00000000 --- a/spec/redhat/command_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -=begin -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end -=end - -describe command('ls -al /') do - let(:stdout) { < ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "runuser -s /bin/sh -c \"test -r /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "runuser -s /bin/sh -c \"test -w /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "runuser -s /bin/sh -c \"test -x /tmp\" mail" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -w 1 -c 2 -n 127.0.0.1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt 127.0.0.1 22 -w 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu 127.0.0.1 53 -w 1" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end - -describe host('example.jp') do - let(:stdout) { "1.2.3.4\r\n" } - its(:ipaddress) { should eq '1.2.3.4' } - its(:command) { should eq "getent hosts example.jp | awk '{print $1}'" } -end diff --git a/spec/redhat/interface_spec.rb b/spec/redhat/interface_spec.rb deleted file mode 100644 index 6f91e518..00000000 --- a/spec/redhat/interface_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe interface('eth0') do - let(:stdout) { '1000' } - its(:speed) { should eq 1000 } - its(:command) { should eq "ethtool eth0 | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\/s/,\"\\\\1\",\"\")}'" } -end - -describe interface('eth0') do - it { should have_ipv4_address("192.168.10.10") } - its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/'" } -end - -describe interface('eth0') do - it { should have_ipv4_address("192.168.10.10/24") } - its(:command) { should eq "ip addr show eth0 | grep 'inet 192\\.168\\.10\\.10/24 '" } -end - -describe interface('invalid-interface') do - let(:stdout) { '1000' } - its(:speed) { should_not eq 100 } -end diff --git a/spec/redhat/iptables_spec.rb b/spec/redhat/iptables_spec.rb deleted file mode 100644 index 27753e2a..00000000 --- a/spec/redhat/iptables_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe iptables do - it { should have_rule '-P INPUT ACCEPT' } - its(:command) { should eq "iptables -S | grep -- -P\\ INPUT\\ ACCEPT || iptables-save | grep -- -P\\ INPUT\\ ACCEPT" } -end - -describe iptables do - it { should_not have_rule 'invalid-rule' } -end - -describe iptables do - it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') } - its(:command) { should eq "iptables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || iptables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" } -end - -describe iptables do - it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') } -end diff --git a/spec/redhat/kernel_module_spec.rb b/spec/redhat/kernel_module_spec.rb deleted file mode 100644 index 1cac3711..00000000 --- a/spec/redhat/kernel_module_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe kernel_module('lp') do - it { should be_loaded } - its(:command) { should eq "lsmod | grep ^lp" } -end - -describe kernel_module('invalid-module') do - it { should_not be_loaded } -end diff --git a/spec/redhat/linux_kernel_parameter_spec.rb b/spec/redhat/linux_kernel_parameter_spec.rb deleted file mode 100644 index b4b3da14..00000000 --- a/spec/redhat/linux_kernel_parameter_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do - let(:stdout) { "1\n" } - its(:value) { should eq 1 } - its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_syncookies" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do - let(:stdout) { "1\n" } - its(:value) { should_not eq 2 } -end - -describe linux_kernel_parameter('kernel.osrelease') do - let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" } - its(:value) { should eq "2.6.32-131.0.15.el6.x86_64" } - its(:command) { should eq "/sbin/sysctl -q -n kernel.osrelease" } -end - -describe linux_kernel_parameter('kernel.osrelease') do - let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" } - its(:value) { should_not eq "2.6.32-131.0.15.el6.i386" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_wmem') do - let(:stdout) { "4096 16384 4194304\n" } - its(:value) { should match /16384/ } - its(:command) { should eq "/sbin/sysctl -q -n net.ipv4.tcp_wmem" } -end - -describe linux_kernel_parameter('net.ipv4.tcp_wmem') do - let(:stdout) { "4096 16384 4194304\n" } - its(:value) { should_not match /123456/ } -end diff --git a/spec/redhat/lxc_spec.rb b/spec/redhat/lxc_spec.rb deleted file mode 100644 index f3b82822..00000000 --- a/spec/redhat/lxc_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe lxc('ct01') do - it { should exist } - its(:command) { should eq "lxc-ls -1 | grep -w ct01" } -end - -describe lxc('invalid-ct') do - it { should_not exist } -end - -describe lxc('ct01') do - it { should be_running } - its(:command) { should eq "lxc-info -n ct01 -t RUNNING"} -end - -describe lxc('invalid-ct') do - it { should_not be_running } -end - diff --git a/spec/redhat/mail_alias_spec.rb b/spec/redhat/mail_alias_spec.rb deleted file mode 100644 index dd08cbec..00000000 --- a/spec/redhat/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/redhat/package_spec.rb b/spec/redhat/package_spec.rb deleted file mode 100644 index 6392b7b0..00000000 --- a/spec/redhat/package_spec.rb +++ /dev/null @@ -1,118 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe package('httpd') do - it { should be_installed } - its(:command) { should eq "rpm -q httpd" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('invalid-package') do - it { should_not be_installed.by('rpm') } -end - -describe package('httpd') do - it { should be_installed.with_version('2.2.15-28.el6') } - its(:command) { should eq "rpm -q httpd | grep -w -- 2.2.15-28.el6" } -end - -describe package('httpd') do - it { should be_installed.by('rpm').with_version('2.2.15-28.el6') } - its(:command) { should eq "rpm -q httpd | grep -w -- 2.2.15-28.el6" } -end - -describe package('httpd') do - it { should_not be_installed.with_version('invalid-version') } -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end - -describe package('httpd') do - let(:stdout) { "2.2.15\n" } - its(:version) { should eq '2.2.15' } - its(:version) { should > '2.2.14' } - its(:version) { should < '2.2.16' } - its(:version) { should > '2.2.9' } - its(:command) { should eq "rpm -qi httpd | grep Version | awk '{print $3}'" } -end diff --git a/spec/redhat/php_config_spec.rb b/spec/redhat/php_config_spec.rb deleted file mode 100644 index 2faa9f7d..00000000 --- a/spec/redhat/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/redhat/port_spec.rb b/spec/redhat/port_spec.rb deleted file mode 100644 index 446b264e..00000000 --- a/spec/redhat/port_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe port(80) do - it { should be_listening } - its(:command) { should eq 'netstat -tunl | grep -- :80\\ ' } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^tcp\\ .\\*:80\\ ' } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq 'netstat -tunl | grep -- \\^udp\\ .\\*:123\\ ' } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/redhat/process_spec.rb b/spec/redhat/process_spec.rb deleted file mode 100644 index 2c020c40..00000000 --- a/spec/redhat/process_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe process("memcached") do - let(:stdout) { " 1407\n" } - its(:pid) { should eq 1407 } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" } - its(:args) { should match /-c 30000\b/ } - its(:command) { should eq "ps -C memcached -o args= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "nobody\n" } - its(:user) { should eq "nobody" } - its(:command) { should eq "ps -C memcached -o user= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "nobody\n" } - its(:group) { should eq "nobody" } - its(:command) { should eq "ps -C memcached -o group= | head -1" } -end - -describe process("memcached") do - context "when running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end - - context "when not running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end -end diff --git a/spec/redhat/routing_table_spec.rb b/spec/redhat/routing_table_spec.rb deleted file mode 100644 index 68dd01f4..00000000 --- a/spec/redhat/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/redhat/selinux_spec.rb b/spec/redhat/selinux_spec.rb deleted file mode 100644 index 8f6570e2..00000000 --- a/spec/redhat/selinux_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe selinux do - it { should be_enforcing } - its(:command) { should eq "getenforce | grep -i -- enforcing && grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" } -end - -describe selinux do - it { should be_permissive } - its(:command) { should eq "getenforce | grep -i -- permissive && grep -i -- ^SELINUX=permissive$ /etc/selinux/config" } -end - -describe selinux do - it { should be_disabled } - its(:command) { should eq "test ! -f /etc/selinux/config || (getenforce | grep -i -- disabled && grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" } -end diff --git a/spec/redhat/service_spec.rb b/spec/redhat/service_spec.rb deleted file mode 100644 index 540607c7..00000000 --- a/spec/redhat/service_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe service('sshd') do - it { should be_enabled } - its(:command) { should eq "chkconfig --list sshd | grep 3:on" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('sshd') do - it { should be_enabled.with_level(4) } - its(:command) { should eq "chkconfig --list sshd | grep 4:on" } -end - -describe service('invalid-service') do - it { should_not be_enabled.with_level(4) } -end - -describe service('sshd') do - it { should be_running } - its(:command) { should eq "service sshd status" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/redhat/user_spec.rb b/spec/redhat/user_spec.rb deleted file mode 100644 index d39df466..00000000 --- a/spec/redhat/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id root | awk '{print $3}' | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/redhat/yumrepo_spec.rb b/spec/redhat/yumrepo_spec.rb deleted file mode 100644 index a18cf95e..00000000 --- a/spec/redhat/yumrepo_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe 'Serverspec yumrepo matchers of Red Hat family' do - describe 'exist' do - describe yumrepo('epel') do - it { should exist } - end - - describe yumrepo('invalid-repository') do - it { should_not exist } - end - end - - describe 'be_enabled' do - describe yumrepo('epel') do - it { should be_enabled } - end - - describe yumrepo('invalid-repository') do - it { should_not be_enabled } - end - end -end diff --git a/spec/redhat/zfs_spec.rb b/spec/redhat/zfs_spec.rb deleted file mode 100644 index 28020ba2..00000000 --- a/spec/redhat/zfs_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::RedHat - -describe zfs('rpool') do - it { should exist } - its(:command) { should eq "zfs list -H rpool" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool' } - its(:command) { should eq "zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' } - its(:command) { should eq "zfs list -H -o compression rpool | grep -- \\^off\\$ && zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end diff --git a/spec/smartos/mail_alias_spec.rb b/spec/smartos/mail_alias_spec.rb deleted file mode 100644 index 7ab1a559..00000000 --- a/spec/smartos/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::SmartOS - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/smartos/process_spec.rb b/spec/smartos/process_spec.rb deleted file mode 100644 index 8721bbd4..00000000 --- a/spec/smartos/process_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::SmartOS - -describe process("memcached") do - let(:stdout) { " 1407\n" } - its(:pid) { should eq 1407 } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" } - its(:args) { should match /-c 30000\b/ } - its(:command) { should eq "ps -C memcached -o args= | head -1" } -end - -describe process("memcached") do - context "when running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end - - context "when not running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end -end diff --git a/spec/solaris/command_spec.rb b/spec/solaris/command_spec.rb deleted file mode 100644 index 199238fe..00000000 --- a/spec/solaris/command_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe command('ls -al /') do - let(:stdout) { < ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -r /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -w /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -x /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -n 127.0.0.1 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt -w 1 127.0.0.1 22" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu -w 1 127.0.0.1 53" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end diff --git a/spec/solaris/ipfilter_spec.rb b/spec/solaris/ipfilter_spec.rb deleted file mode 100644 index 14147fd8..00000000 --- a/spec/solaris/ipfilter_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe ipfilter do - it { should have_rule 'pass in quick on lo0 all' } - its(:command) { should eq "ipfstat -io 2> /dev/null | grep -- pass\\ in\\ quick\\ on\\ lo0\\ all" } -end diff --git a/spec/solaris/ipnat_spec.rb b/spec/solaris/ipnat_spec.rb deleted file mode 100644 index 01ce6ae0..00000000 --- a/spec/solaris/ipnat_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe ipnat do - it { should have_rule 'map net1 192.168.0.0/24 -> 0.0.0.0/32' } - its(:command) { should eq "ipnat -l 2> /dev/null | grep -- \\^map\\ net1\\ 192.168.0.0/24\\ -\\>\\ 0.0.0.0/32\\$" } -end diff --git a/spec/solaris/mail_alias_spec.rb b/spec/solaris/mail_alias_spec.rb deleted file mode 100644 index c918be9b..00000000 --- a/spec/solaris/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/solaris/package_spec.rb b/spec/solaris/package_spec.rb deleted file mode 100644 index 63ccf229..00000000 --- a/spec/solaris/package_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe package('httpd') do - it { should be_installed } - its(:command) { should eq "pkg list -H httpd 2> /dev/null" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('httpd') do - it { should be_installed.with_version('2.2') } - its(:command) { should eq "pkg list -H httpd 2> /dev/null | grep -qw -- 2.2" } -end - -describe package('httpd') do - it { should_not be_installed.with_version('invalid-version') } -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end diff --git a/spec/solaris/php_config_spec.rb b/spec/solaris/php_config_spec.rb deleted file mode 100644 index abaab6a5..00000000 --- a/spec/solaris/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/solaris/port_spec.rb b/spec/solaris/port_spec.rb deleted file mode 100644 index c388f4dd..00000000 --- a/spec/solaris/port_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe port(80) do - it { should be_listening } - its(:command) { should eq %q!netstat -an 2> /dev/null | grep -- LISTEN | grep -- \\\\.80\\ ! } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq %q!netstat -an -P tcp 2> /dev/null | grep -- LISTEN | grep -- .\\*\\\\.80\\ ! } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq %q!netstat -an -P udp 2> /dev/null | grep -- LISTEN | grep -- .\\*\\\\.123\\ ! } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/solaris/process_spec.rb b/spec/solaris/process_spec.rb deleted file mode 100644 index 09c6db16..00000000 --- a/spec/solaris/process_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe process("memcached") do - let(:stdout) { " 1407\n" } - its(:pid) { should eq 1407 } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } -end - -describe process("memcached") do - let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" } - its(:args) { should match /-c 30000\b/ } - its(:command) { should eq "ps -C memcached -o args= | head -1" } -end - -describe process("memcached") do - context "when running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end - - context "when not running" do - let(:stdout) { " 1407\n" } - it { should be_running } - its(:command) { should eq "ps -C memcached -o pid= | head -1" } - end -end diff --git a/spec/solaris/routing_table_spec.rb b/spec/solaris/routing_table_spec.rb deleted file mode 100644 index 6aa433e0..00000000 --- a/spec/solaris/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/solaris/service_spec.rb b/spec/solaris/service_spec.rb deleted file mode 100644 index 67c11de9..00000000 --- a/spec/solaris/service_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe service('sshd') do - it { should be_enabled } - its(:command) { should eq "svcs -l sshd 2> /dev/null | egrep '^enabled *true$'" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('sshd') do - it { should be_enabled.with_level(4) } - its(:command) { should eq "svcs -l sshd 2> /dev/null | egrep '^enabled *true$'" } -end - -describe service('invalid-service') do - it { should_not be_enabled.with_level(4) } -end - -describe service('sshd') do - it { should be_running } - its(:command) { should eq "svcs -l sshd status 2> /dev/null | egrep '^state *online$'" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/solaris/svcprop_spec.rb b/spec/solaris/svcprop_spec.rb deleted file mode 100644 index 3f3c59ab..00000000 --- a/spec/solaris/svcprop_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe service('svc:/network/http:apache22') do - it { should have_property 'httpd/enable_64bit' => false } - its(:command) { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep -- \\^false\\$" } -end - -describe service('svc:/network/http:apache22') do - it { should have_property 'httpd/enable_64bit' => false, 'httpd/server_type' => 'worker' } - its(:command) { 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 diff --git a/spec/solaris/user_spec.rb b/spec/solaris/user_spec.rb deleted file mode 100644 index 995a138e..00000000 --- a/spec/solaris/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id -Gn root | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/solaris/zfs_spec.rb b/spec/solaris/zfs_spec.rb deleted file mode 100644 index 450b5238..00000000 --- a/spec/solaris/zfs_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris - -describe zfs('rpool') do - it { should exist } - its(:command) { should eq "zfs list -H rpool" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool' } - its(:command) { should eq "zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' } - its(:command) { should eq "zfs list -H -o compression rpool | grep -- \\^off\\$ && zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end diff --git a/spec/solaris10/file_spec.rb b/spec/solaris10/file_spec.rb deleted file mode 100755 index ab272439..00000000 --- a/spec/solaris10/file_spec.rb +++ /dev/null @@ -1,395 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris10 - -describe file('/etc/ssh/sshd_config') do - it { should be_file } - its(:command) { should eq "test -f /etc/ssh/sshd_config" } -end - -describe file('/etc/invalid_file') do - it { should_not be_file } -end - -describe file('/etc/ssh') do - it { should be_directory } - its(:command) { should eq "test -d /etc/ssh" } -end - -describe file('/etc/invalid_directory') do - it { should_not be_directory } -end - -describe file('/var/run/unicorn.sock') do - it { should be_socket } - its(:command) { should eq "test -S /var/run/unicorn.sock" } -end - -describe file('/etc/invalid_socket') do - it { should_not be_socket } -end - -describe file('/etc/ssh/sshd_config') do - it { should contain 'This is the sshd server system-wide configuration file' } - its(:command) { should eq "grep -- This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config" } -end - -describe file('/etc/ssh/sshd_config') do - it { should contain /^This is the sshd server system-wide configuration file/ } - its(:command) { should eq "grep -- \\^This\\ is\\ the\\ sshd\\ server\\ system-wide\\ configuration\\ file /etc/ssh/sshd_config" } -end - -describe file('/etc/ssh/sshd_config') do - it { should_not contain 'This is invalid text!!' } -end - -describe file('Gemfile') do - it { should contain('rspec').from(/^group :test do/).to(/^end/) } - its(:command) { should eq "sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin || sed -n /\\^group\\ :test\\ do/,/\\^end/p Gemfile | grep -qF -- rspec /dev/stdin" } -end - -describe file('/etc/ssh/sshd_config') do - it { should_not contain('This is invalid text!!').from(/^group :test do/).to(/^end/) } -end - -describe file('Gemfile') do - it { should contain('rspec').after(/^group :test do/) } - its(:command) { should eq "sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -q -- rspec /dev/stdin || sed -n /\\^group\\ :test\\ do/,\\$p Gemfile | grep -qF -- rspec /dev/stdin" } -end - -describe file('/etc/ssh/sshd_config') do - it { should_not contain('This is invalid text!!').after(/^group :test do/) } -end - -describe file('Gemfile') do - it { should contain('rspec').before(/^end/) } - its(:command) { should eq "sed -n 1,/\\^end/p Gemfile | grep -q -- rspec /dev/stdin || sed -n 1,/\\^end/p Gemfile | grep -qF -- rspec /dev/stdin" } -end - -describe file('/etc/ssh/sshd_config') do - it { should_not contain('This is invalid text!!').before(/^end/) } -end - -describe file('/etc/passwd') do - it { should be_mode 644 } - its(:command) { should eq "perl -e 'printf \"%o\", (stat shift)[2]&07777' /etc/passwd | grep -- \\^644\\$" } -end - -describe file('/etc/passwd') do - it { should_not be_mode 'invalid' } -end - -describe file('/etc/passwd') do - it { should be_owned_by 'root' } - its(:command) { should eq "perl -e 'printf \"%s\", getpwuid((stat(\"/etc/passwd\"))[4])' | grep -- \\^root\\$" } -end - -describe file('/etc/passwd') do - it { should_not be_owned_by 'invalid-owner' } -end - -describe file('/etc/passwd') do - it { should be_grouped_into 'root' } - its(:command) { should eq "perl -e 'printf \"%s\", getgrgid((stat(\"/etc/passwd\"))[5])' | grep -- \\^root\\$" } -end - -describe file('/etc/passwd') do - it { should_not be_grouped_into 'invalid-group' } -end - -describe file('/etc/pam.d/system-auth') do - it { should be_linked_to '/etc/pam.d/system-auth-ac' } - its(:command) { should eq "perl -e 'printf \"%s\", readlink(\"/etc/pam.d/system-auth\")' | grep -- \\^/etc/pam.d/system-auth-ac\\$" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "perl -e 'printf \"%o\", (stat shift)[2]&07777' /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -r /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "perl -e 'printf \"%o\", (stat shift)[2]&07777' /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -w /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "perl -e 'printf \"%o\", (stat shift)[2]&07777' /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -x /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "digest -a md5 -v /etc/services | grep -iw -- 35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end diff --git a/spec/solaris10/group_spec.rb b/spec/solaris10/group_spec.rb deleted file mode 100755 index fff21207..00000000 --- a/spec/solaris10/group_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris10 - -describe group('root') do - it { should exist } - its(:command) { should eq "getent group | grep -w -- root" } -end - -describe group('invalid-group') do - it { should_not exist } -end - -describe group('root') do - it { should have_gid 0 } - its(:command) { should eq "getent group | grep -- \\^root: | cut -f 3 -d ':' | grep -w -- 0" } -end - -describe group('root') do - it { should_not have_gid 'invalid-gid' } -end diff --git a/spec/solaris10/mail_alias_spec.rb b/spec/solaris10/mail_alias_spec.rb deleted file mode 100644 index 8177bf6a..00000000 --- a/spec/solaris10/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris10 - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/solaris10/package_spec.rb b/spec/solaris10/package_spec.rb deleted file mode 100755 index 340faeb9..00000000 --- a/spec/solaris10/package_spec.rb +++ /dev/null @@ -1,85 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris10 - -describe package('httpd') do - it { should be_installed } - its(:command) { should eq "pkginfo -q httpd" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('httpd') do - it { should be_installed.with_version('2.2') } - its(:command) { should eq "pkginfo -q httpd | grep -- 2.2" } -end - -describe package('httpd') do - it { should_not be_installed.with_version('invalid-version') } -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end diff --git a/spec/solaris10/php_config_spec.rb b/spec/solaris10/php_config_spec.rb deleted file mode 100644 index a90cad47..00000000 --- a/spec/solaris10/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris10 - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/solaris10/user_spec.rb b/spec/solaris10/user_spec.rb deleted file mode 100755 index 08139969..00000000 --- a/spec/solaris10/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris10 - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id -ap root | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/solaris11/command_spec.rb b/spec/solaris11/command_spec.rb deleted file mode 100644 index 66d49b82..00000000 --- a/spec/solaris11/command_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout("nameserver 127.0.0.1") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('cat /etc/resolv.conf') do - let(:stdout) { "nameserver 127.0.0.1\r\n" } - it { should return_stdout(/127\.0\.0\.1/) } - end -end - -describe command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe 'complete matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('cat /etc/resolv.conf') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('cat /etc/resolv.conf') do - it { should return_exit_status 0 } - its(:command) { should eq 'cat /etc/resolv.conf' } -end - -describe command('ls -al /') do - let(:stdout) { < ./etc/pam.d/system-auth-ac.\"" } -end - -describe file('dummy-link') do - it { should_not be_linked_to '/invalid/target' } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_readable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "333\r\n" } - it { should_not be_readable } -end - -describe file('/dev') do - let(:stdout) { "400\r\n" } - it { should be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should_not be_readable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "040\r\n" } - it { should be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "404\r\n" } - it { should_not be_readable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "044\r\n" } - it { should be_readable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "443\r\n" } - it { should_not be_readable.by('others') } -end - -describe file('/tmp') do - it { should be_readable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -r /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_readable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_writable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable } -end - -describe file('/dev') do - let(:stdout) { "200\r\n" } - it { should be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "030\r\n" } - it { should be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should be_writable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "555\r\n" } - it { should_not be_writable.by('others') } -end - -describe file('/tmp') do - it { should be_writable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -w /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_writable.by_user('invalid-user') } -end - -describe file('/dev') do - let(:stdout) { "755\r\n" } - it { should be_executable } - its(:command) { should eq "stat -c %a /dev" } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable } -end - -describe file('/dev') do - let(:stdout) { "100\r\n" } - it { should be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('owner') } -end - -describe file('/dev') do - let(:stdout) { "070\r\n" } - it { should be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('group') } -end - -describe file('/dev') do - let(:stdout) { "001\r\n" } - it { should be_executable.by('others') } -end - -describe file('/dev') do - let(:stdout) { "666\r\n" } - it { should_not be_executable.by('others') } -end - -describe file('/tmp') do - it { should be_executable.by_user('mail') } - its(:command) { should eq "su mail -c \"test -x /tmp\"" } -end - -describe file('/tmp') do - it { should_not be_executable.by_user('invalid-user') } -end - -describe file('/') do - it { should be_mounted } - its(:command) { should eq "mount | grep -w -- on\\ /" } -end - -describe file('/etc/invalid-mount') do - it { should_not be_mounted } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) } -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.with( :type => 'ext4' ) } -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - :bind => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_root', - :type => 'ext4', - :options => { - :rw => true, - } - ) - end -end - -describe file('/') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it do - should_not be_mounted.only_with( - :device => '/dev/mapper/VolGroup-lv_roooooooooot', - :type => 'ext4', - :options => { - :rw => true, - :mode => 620, - } - ) - end -end - -describe file('/etc/invalid-mount') do - let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" } - it { should_not be_mounted.only_with( :type => 'ext4' ) } -end - -describe file('/etc/services') do - it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' } - its(:command) { should eq "md5sum /etc/services | grep -iw -- \\^35435ea447c19f0ea5ef971837ab9ced" } -end - -describe file('invalid-file') do - it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' } -end - -describe file('/etc/services') do - it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } - its(:command) { should eq "sha256sum /etc/services | grep -iw -- \\^0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } -end - -describe file('invalid-file') do - it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' } -end - -describe file('/etc/passwd') do - let(:stdout) {< "icmp", :timeout=> 1) } - its(:command) { should eq "ping -n 127.0.0.1 1" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzt -w 1 127.0.0.1 22" } -end - -describe host('127.0.0.1') do - it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } - its(:command) { should eq "nc -vvvvzu -w 1 127.0.0.1 53" } -end - -describe host('invalid-host') do - it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } -end diff --git a/spec/solaris11/ipfilter_spec.rb b/spec/solaris11/ipfilter_spec.rb deleted file mode 100644 index 5584da56..00000000 --- a/spec/solaris11/ipfilter_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe ipfilter do - it { should have_rule 'pass in quick on lo0 all' } - its(:command) { should eq "ipfstat -io 2> /dev/null | grep -- pass\\ in\\ quick\\ on\\ lo0\\ all" } -end diff --git a/spec/solaris11/ipnat_spec.rb b/spec/solaris11/ipnat_spec.rb deleted file mode 100644 index e0d56d3e..00000000 --- a/spec/solaris11/ipnat_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe ipnat do - it { should have_rule 'map net1 192.168.0.0/24 -> 0.0.0.0/32' } - its(:command) { should eq "ipnat -l 2> /dev/null | grep -- \\^map\\ net1\\ 192.168.0.0/24\\ -\\>\\ 0.0.0.0/32\\$" } -end diff --git a/spec/solaris11/mail_alias_spec.rb b/spec/solaris11/mail_alias_spec.rb deleted file mode 100644 index 7a9d8b2b..00000000 --- a/spec/solaris11/mail_alias_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe mail_alias('daemon') do - it { should be_aliased_to "root" } - its(:command) { should eq "getent aliases daemon | grep -- \\[\\[:space:\\]\\]root$" } -end - -describe mail_alias('invalid-recipient') do - it { should_not be_aliased_to "foo" } -end diff --git a/spec/solaris11/package_spec.rb b/spec/solaris11/package_spec.rb deleted file mode 100644 index 86d5f514..00000000 --- a/spec/solaris11/package_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe package('httpd') do - it { should be_installed } - its(:command) { should eq "pkg list -H httpd 2> /dev/null" } -end - -describe package('invalid-package') do - it { should_not be_installed } -end - -describe package('httpd') do - it { should be_installed.with_version('2.2') } - its(:command) { should eq "pkg list -H httpd 2> /dev/null | grep -qw -- 2.2" } -end - -describe package('httpd') do - it { should_not be_installed.with_version('invalid-version') } -end - -describe package('jekyll') do - it { should be_installed.by('gem') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" } -end - -describe package('invalid-gem') do - it { should_not be_installed.by('gem') } -end - -describe package('jekyll') do - it { should be_installed.by('gem').with_version('1.1.1') } - its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" } -end - -describe package('jekyll') do - it { should_not be_installed.by('gem').with_version('invalid-version') } -end - -describe package('bower') do - it { should be_installed.by('npm') } - its(:command) { should eq "npm ls bower -g" } -end - -describe package('invalid-npm-package') do - it { should_not be_installed.by('npm') } -end - -describe package('bower') do - it { should be_installed.by('npm').with_version('0.9.2') } - its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" } -end - -describe package('bower') do - it { should_not be_installed.by('npm').with_version('invalid-version') } -end - - -describe package('mongo') do - it { should be_installed.by('pecl') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo" } -end - -describe package('invalid-pecl') do - it { should_not be_installed.by('pecl') } -end - -describe package('mongo') do - it { should be_installed.by('pecl').with_version('1.4.1') } - its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" } -end - -describe package('mongo') do - it { should_not be_installed.by('pecl').with_version('invalid-version') } -end - -describe package('XML_Util') do - it { should be_installed.by('pear').with_version('1.2.1') } - its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" } -end - -describe package('supervisor') do - it { should be_installed.by('pip').with_version('3.0') } - its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" } -end - -describe package('invalid-pip') do - it { should_not be_installed.by('pip').with_version('invalid-version') } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" } -end - -describe package('App::Ack') do - it { should be_installed.by('cpan').with_version('2.04') } - its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" } -end diff --git a/spec/solaris11/php_config_spec.rb b/spec/solaris11/php_config_spec.rb deleted file mode 100644 index 64ae9a12..00000000 --- a/spec/solaris11/php_config_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should eq 'text/html' } - its(:command) { should eq "php -r 'echo get_cfg_var( \"default_mimetype\" );'" } -end - -describe php_config('default_mimetype') do - let(:stdout) { 'text/html' } - its(:value) { should_not eq 'text/plain' } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should eq 180 } - its(:command) { should eq "php -r 'echo get_cfg_var( \"session.cache_expire\" );'" } -end - -describe php_config('session.cache_expire') do - let(:stdout) { '180' } - its(:value) { should_not eq 360 } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should match /application/ } - its(:command) { should eq "php -r 'echo get_cfg_var( \"mbstring.http_output_conv_mimetypes\" );'" } -end - -describe php_config('mbstring.http_output_conv_mimetypes') do - let(:stdout) { 'application' } - its(:value) { should_not match /html/ } -end diff --git a/spec/solaris11/port_spec.rb b/spec/solaris11/port_spec.rb deleted file mode 100644 index b1368f44..00000000 --- a/spec/solaris11/port_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe port(80) do - it { should be_listening } - its(:command) { should eq %q!netstat -an 2> /dev/null | grep -- LISTEN | grep -- \\\\.80\\ ! } -end - -describe port('invalid') do - it { should_not be_listening } -end diff --git a/spec/solaris11/routing_table_spec.rb b/spec/solaris11/routing_table_spec.rb deleted file mode 100644 index 0fbeffae..00000000 --- a/spec/solaris11/routing_table_spec.rb +++ /dev/null @@ -1,120 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.100.0/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.0/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should_not have_entry( :destination => '192.168.100.100/24' ) } - its(:command) { should eq "ip route | grep -E '^192.168.100.100/24 |^default '" } -end - -describe routing_table do - let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1' - ) - end - - it do - should have_entry( - :destination => '192.168.100.0/24', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end - - it do - should_not have_entry( - :destination => '192.168.100.0/32', - :gateway => '192.168.100.1', - :interface => 'eth1' - ) - end -end - -describe routing_table do - let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" } - it { should have_entry( :destination => '192.168.200.0/24' ) } - it { should_not have_entry( :destination => '192.168.200.200/24' ) } - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1' - ) - end - - it do - should have_entry( - :destination => '192.168.200.0/24', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => '192.168.200.0/32', - :gateway => '192.168.200.1', - :interface => 'eth0' - ) - end -end - -describe routing_table do - let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } - it { should have_entry( :destination => 'default' ) } - it { should_not have_entry( :destination => 'defaulth' ) } - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2' - ) - end - - it do - should have_entry( - :destination => 'default', - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :gateway => '10.0.2.2', - :interface => 'eth0' - ) - end - - it do - should_not have_entry( - :destination => 'default', - :gateway => '10.0.2.1', - :interface => 'eth0' - ) - end -end diff --git a/spec/solaris11/service_spec.rb b/spec/solaris11/service_spec.rb deleted file mode 100644 index 54c0b0c7..00000000 --- a/spec/solaris11/service_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe service('sshd') do - it { should be_enabled } - its(:command) { should eq "svcs -l sshd 2> /dev/null | egrep '^enabled *true$'" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('sshd') do - it { should be_enabled.with_level(4) } - its(:command) { should eq "svcs -l sshd 2> /dev/null | egrep '^enabled *true$'" } -end - -describe service('invalid-service') do - it { should_not be_enabled.with_level(4) } -end - -describe service('sshd') do - it { should be_running } - its(:command) { should eq "svcs -l sshd status 2> /dev/null | egrep '^state *online$'" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('sshd') do - let(:stdout) { "sshd is stopped\r\n" } - it { should be_running } -end - -describe service('sshd') do - it { should be_running.under('supervisor') } - its(:command) { should eq "supervisorctl status sshd | grep RUNNING" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('supervisor') } -end - -describe service('sshd') do - it { should be_running.under('upstart') } - its(:command) { should eq "initctl status sshd | grep running" } -end - -describe service('invalid-daemon') do - it { should_not be_running.under('upstart') } -end - -describe service('sshd') do - it { - expect { - should be_running.under('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/) - } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } - it { should be_monitored_by('monit') } - its(:command) { should eq "monit status" } -end - -describe service('sshd') do - let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" } - it { should_not be_monitored_by('monit') } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('monit') } -end - -describe service('unicorn') do - it { should be_monitored_by('god') } - its(:command) { should eq "god status unicorn" } -end - -describe service('invalid-daemon') do - it { should_not be_monitored_by('god') } -end - -describe service('sshd') do - it { - expect { - should be_monitored_by('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/) - } -end diff --git a/spec/solaris11/svcprop_spec.rb b/spec/solaris11/svcprop_spec.rb deleted file mode 100644 index ceda6221..00000000 --- a/spec/solaris11/svcprop_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe service('svc:/network/http:apache22') do - it { should have_property 'httpd/enable_64bit' => false } - its(:command) { should eq "svcprop -p httpd/enable_64bit svc:/network/http:apache22 | grep -- \\^false\\$" } -end - -describe service('svc:/network/http:apache22') do - it { should have_property 'httpd/enable_64bit' => false, 'httpd/server_type' => 'worker' } - its(:command) { 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 diff --git a/spec/solaris11/user_spec.rb b/spec/solaris11/user_spec.rb deleted file mode 100644 index 3896858a..00000000 --- a/spec/solaris11/user_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe user('root') do - it { should exist } - its(:command) { should eq "id root" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('root') do - it { should belong_to_group 'root' } - its(:command) { should eq "id -Gn root | grep -- root" } -end - -describe user('root') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('root') do - it { should have_uid 0 } - its(:command) { should eq "id root | grep -- \\^uid\\=0\\(" } -end - -describe user('root') do - it { should_not have_uid 'invalid-uid' } -end - -describe user('root') do - it { should have_login_shell '/bin/bash' } - its(:command) { should eq "getent passwd root | cut -f 7 -d ':' | grep -w -- /bin/bash" } -end - -describe user('root') do - it { should_not have_login_shell 'invalid-login-shell' } -end - -describe user('root') do - it { should have_home_directory '/root' } - its(:command) { should eq "getent passwd root | cut -f 6 -d ':' | grep -w -- /root" } -end - -describe user('root') do - it { should_not have_home_directory 'invalid-home-directory' } -end - -describe user('root') do - it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } - its(:command) { should eq "grep -w -- ssh-rsa\\ ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH ~root/.ssh/authorized_keys" } -end - -describe user('root') do - it { should_not have_authorized_key 'invalid-key' } -end diff --git a/spec/solaris11/zfs_spec.rb b/spec/solaris11/zfs_spec.rb deleted file mode 100644 index 398435e3..00000000 --- a/spec/solaris11/zfs_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Solaris11 - -describe zfs('rpool') do - it { should exist } - its(:command) { should eq "zfs list -H rpool" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool' } - its(:command) { should eq "zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end - -describe zfs('rpool') do - it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' } - its(:command) { should eq "zfs list -H -o compression rpool | grep -- \\^off\\$ && zfs list -H -o mountpoint rpool | grep -- \\^/rpool\\$" } -end diff --git a/spec/support/powershell_command_runner.rb b/spec/support/powershell_command_runner.rb deleted file mode 100644 index 165b0813..00000000 --- a/spec/support/powershell_command_runner.rb +++ /dev/null @@ -1,52 +0,0 @@ -shared_examples "a powershell command runner" do - describe 'configurations are not set' do - context file('/some/file') do - it { should be_file } - its(:command) { should == "((Get-Item -Path '/some/file' -Force).attributes.ToString() -Split ', ') -contains 'Archive'" } - end - end - - describe 'path is set' do - let(:path) { 'c:/path/bin' } - context file('/some/file') do - it { should be_file } - its(:command) { - should == <<-eof -$env:path = "c:/path/bin;$env:path" -((Get-Item -Path '/some/file' -Force).attributes.ToString() -Split ', ') -contains 'Archive' -eof - } - end - end - - describe 'pre_command is set' do - let(:pre_command) { 'some_other_command' } - context file('/some/file') do - it { should be_file } - its(:command) { should == <<-eof -if (some_other_command) -{ -((Get-Item -Path '/some/file' -Force).attributes.ToString() -Split ', ') -contains 'Archive' -} -eof - } - end - end - - describe 'path and pre_command are set' do - let(:path) { 'c:/path/bin' } - let(:pre_command) { 'some_other_command' } - context file('/some/file') do - it { should be_file } - its(:command) { should == <<-eof -$env:path = "c:/path/bin;$env:path" -if (some_other_command) -{ -$env:path = "c:/path/bin;$env:path" -((Get-Item -Path '/some/file' -Force).attributes.ToString() -Split ', ') -contains 'Archive' -} -eof - } - end - end -end \ No newline at end of file diff --git a/spec/windows/command_spec.rb b/spec/windows/command_spec.rb deleted file mode 100644 index fb481378..00000000 --- a/spec/windows/command_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Cmd -include SpecInfra::Helper::Windows - -describe command('test_cmd /test/path/file') do - let(:stdout) { "test output 1.2.3\r\n" } - it { should return_stdout("test output 1.2.3") } - its(:command) { should eq 'test_cmd /test/path/file' } -end - -describe 'complete matching of stdout' do - context command('test_cmd /test/path/file') do - let(:stdout) { "foocontent-should-be-includedbar\r\n" } - it { should_not return_stdout('content-should-be-included') } - end -end - -describe 'regexp matching of stdout' do - context command('test_cmd /test/path/file') do - let(:stdout) { "test output 1.2.3\r\n" } - it { should return_stdout(/1\.2\.3/) } - end -end - -describe command('test_cmd /test/path/file') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr("No such file or directory") } - its(:command) { should eq 'test_cmd /test/path/file' } -end - -describe 'complete matching of stderr' do - context command('test_cmd /test/path/file') do - let(:stderr) { "No such file or directory\r\n" } - it { should_not return_stderr('file') } - end -end - -describe 'regexp matching of stderr' do - context command('test_cmd /test/path/file') do - let(:stderr) { "No such file or directory\r\n" } - it { should return_stderr(/file/) } - end -end - -describe command('test_cmd /test/path/file') do - it { should return_exit_status 0 } - its(:command) { should eq 'test_cmd /test/path/file' } -end - -describe command('dir "c:\"') do - let(:stdout) { < [], - :be_mode => 644, - :be_owned_by => 'root', - :be_grouped_into => 'root', - :be_linked_to => '/some/other/file', - :be_mounted => [], - :match_md5checksum => '35435ea447c19f0ea5ef971837ab9ced', - :match_sha256checksum => '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' - }.each do |method, args| - expect { should self.send(method, *args) }.to raise_error SpecInfra::Command::Windows::NotSupportedError - end - end -end diff --git a/spec/windows/group_spec.rb b/spec/windows/group_spec.rb deleted file mode 100644 index 3947bbbd..00000000 --- a/spec/windows/group_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Cmd -include SpecInfra::Helper::Windows - -describe group('test.group') do - it { should exist } - its(:command) { should eq "(FindGroup -groupName 'test.group') -ne $null" } -end - -describe group('test.domain\test.group') do - it { should exist } - its(:command) { should eq "(FindGroup -groupName 'test.group' -domain 'test.domain') -ne $null" } -end - -describe group('invalid-group') do - it { should_not exist } -end - -describe group('test.group') do - it "should raise error if command is not supported" do - { - :have_gid => [nil], - }.each do |method, args| - expect { should self.send(method, *args) }.to raise_error SpecInfra::Command::Windows::NotSupportedError - end - end -end diff --git a/spec/windows/port_spec.rb b/spec/windows/port_spec.rb deleted file mode 100644 index 294d3789..00000000 --- a/spec/windows/port_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Cmd -include SpecInfra::Helper::Windows - -describe port(80) do - it { should be_listening } - its(:command) { should eq 'IsPortListening -portNumber 80' } -end - -describe port('invalid') do - it { should_not be_listening } -end - -describe port(80) do - it { should be_listening.with("tcp") } - its(:command) { should eq "IsPortListening -portNumber 80 -protocol 'tcp'" } -end - -describe port(123) do - it { should be_listening.with("udp") } - its(:command) { should eq "IsPortListening -portNumber 123 -protocol 'udp'" } -end - -describe port(80) do - it { - expect { - should be_listening.with('not implemented') - }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) - } -end diff --git a/spec/windows/service_spec.rb b/spec/windows/service_spec.rb deleted file mode 100644 index 86fe7d4d..00000000 --- a/spec/windows/service_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Cmd -include SpecInfra::Helper::Windows - -describe service('Test Service') do - it { should be_enabled } - its(:command) { should eq "(FindService -name 'Test Service').StartMode -eq 'Auto'" } -end - -describe service('invalid-service') do - it { should_not be_enabled } -end - -describe service('Test Service') do - it { should be_running } - its(:command) { should eq "(FindService -name 'Test Service').State -eq 'Running'" } -end - -describe service('invalid-daemon') do - it { should_not be_running } -end - -describe service('Test service') do - it "should raise error if trying to check service process controller" do - expect { should be_running.under('supervisor') }.to raise_error - end - it "should raise error if trying to check service monitoring" do - expect { should_not be_monitored_by('monit') }.to raise_error - end -end diff --git a/spec/windows/user_spec.rb b/spec/windows/user_spec.rb deleted file mode 100644 index bb4d76a5..00000000 --- a/spec/windows/user_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Cmd -include SpecInfra::Helper::Windows - -describe user('test.user') do - it { should exist } - its(:command) { should eq "(FindUser -userName 'test.user') -ne $null" } -end - -describe user('test.domain\test.user') do - it { should exist } - its(:command) { should eq "(FindUser -userName 'test.user' -domain 'test.domain') -ne $null" } -end - -describe user('invalid-user') do - it { should_not exist } -end - -describe user('test.user') do - it { should belong_to_group 'test.group' } - its(:command) { should eq "(FindUserGroup -userName 'test.user' -groupName 'test.group') -ne $null" } -end - -describe user('test.user.domain\test.user') do - it { should belong_to_group 'test.group.domain\test.group' } - its(:command) { should eq "(FindUserGroup -userName 'test.user' -userDomain 'test.user.domain' -groupName 'test.group' -groupDomain 'test.group.domain') -ne $null" } -end - -describe user('test.user') do - it { should_not belong_to_group 'invalid-group' } -end - -describe user('test.user') do - it "should raise error if command is not supported" do - { - :have_uid => [nil], - :have_login_shell => [nil], - :have_authorized_key => [nil], - }.each do |method, args| - expect { should self.send(method, *args) }.to raise_error SpecInfra::Command::Windows::NotSupportedError - end - end -end diff --git a/spec/windows/windows_hot_fix_spec.rb b/spec/windows/windows_hot_fix_spec.rb deleted file mode 100644 index fba9fc26..00000000 --- a/spec/windows/windows_hot_fix_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Cmd -include SpecInfra::Helper::Windows - -describe windows_hot_fix('DESCRIPTION-OR-KB-ID') do - it { should be_installed } - its(:command) { should == "(FindInstalledHotFix -description 'DESCRIPTION-OR-KB-ID' -hotFixId 'DESCRIPTION-OR-KB-ID') -eq $true" } -end - -describe windows_hot_fix('DESCRIPTION') do - it { should be_installed.with_version('KB-ID') } - its(:command) { should == "(FindInstalledHotFix -description 'DESCRIPTION' -hotFixId 'KB-ID') -eq $true" } -end - -describe windows_hot_fix('DESCRIPTION_WITH_KB123456789_INLINED') do - it { should be_installed } - its(:command) { should == "(FindInstalledHotFix -description 'DESCRIPTION_WITH_KB123456789_INLINED' -hotFixId 'KB123456789') -eq $true" } -end - -describe windows_hot_fix('DESCRIPTION_WITH_SUFFIX_KB123456789') do - it { should be_installed } - its(:command) { should == "(FindInstalledHotFix -description 'DESCRIPTION_WITH_SUFFIX_KB123456789' -hotFixId 'KB123456789') -eq $true" } -end - diff --git a/spec/windows/windows_registry_key_spec.rb b/spec/windows/windows_registry_key_spec.rb deleted file mode 100644 index 426d30b8..00000000 --- a/spec/windows/windows_registry_key_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'spec_helper' - -include SpecInfra::Helper::Cmd -include SpecInfra::Helper::Windows - -describe windows_registry_key('PATH/TO/THE_KEY') do - it { should exist } - its(:command) { should == "(Get-Item 'Registry::PATH/TO/THE_KEY') -ne $null" } -end - -describe windows_registry_key('PATH/TO/THE_KEY') do - it { should have_value('Test Value') } - its(:command) { should == "(Compare-Object (Get-Item 'Registry::PATH/TO/THE_KEY').GetValue('') @('Test Value')) -eq $null" } -end - -describe 'Key value types' do - context 'default type' do - describe windows_registry_key('PATH/TO/THE_KEY') do - it { should have_property('TestProperty') } - its(:command) { should == "(Get-Item 'Registry::PATH/TO/THE_KEY').GetValueKind('TestProperty') -eq 'String'" } - end - end - - { - :type_string => 'String', - :type_binary => 'Binary', - :type_dword => 'DWord', - :type_qword => 'QWord', - :type_multistring => 'MultiString', - :type_expandstring => 'ExpandString' - }.each do |sym, type| - context "type #{type}" do - describe windows_registry_key('PATH/TO/THE_KEY') do - it { should have_property('TestProperty', sym) } - its(:command) { should == "(Get-Item 'Registry::PATH/TO/THE_KEY').GetValueKind('TestProperty') -eq '#{type}'" } - end - end - end -end - -describe windows_registry_key('PATH/TO/THE_KEY') do - it { should have_property_value('TestProperty', :type_binary, '12a07b') } - its(:command) { should == "(Compare-Object (Get-Item 'Registry::PATH/TO/THE_KEY').GetValue('TestProperty') ([byte[]] 18,160,123)) -eq $null" } -end - -describe windows_registry_key('PATH/TO/THE_KEY') do - it { should have_property_value('TestProperty', :type_dword, 'fffffd6c') } - its(:command) { should == "(Compare-Object (Get-Item 'Registry::PATH/TO/THE_KEY').GetValue('TestProperty') -660) -eq $null" } -end - -describe windows_registry_key('PATH/TO/THE_KEY') do - it { should have_property_value('TestProperty', :type_qword, '1e240') } - its(:command) { should == "(Compare-Object (Get-Item 'Registry::PATH/TO/THE_KEY').GetValue('TestProperty') 123456) -eq $null" } -end - -describe windows_registry_key('PATH/TO/THE_KEY') do - it { - value = <<-EOF -test line1 -test line2 -test line3 -EOF - should have_property_value('TestProperty', :type_multistring, value) - } - its(:command) { should == "(Compare-Object (Get-Item 'Registry::PATH/TO/THE_KEY').GetValue('TestProperty') @('test line1','test line2','test line3')) -eq $null" } -end