serverspec-2.18.0/0000755000004100000410000000000012537110645014017 5ustar www-datawww-dataserverspec-2.18.0/Rakefile0000644000004100000410000000120212537110645015457 0ustar www-datawww-datarequire "bundler/gem_tasks" begin require "rspec/core/rake_task" require "octorelease" rescue LoadError end if defined?(RSpec) task :spec => 'spec:all' namespace :spec do task :all => [ 'spec:type:all', 'spec:helper' ] namespace :type do oses = Dir.glob('spec/type/*').map {|d| File.basename(d)} task :all => oses.map {|os| "spec:type:#{os}" } oses.each do |os| RSpec::Core::RakeTask.new(os.to_sym) do |t| t.pattern = "spec/type/#{os}/*_spec.rb" end end end RSpec::Core::RakeTask.new(:helper) do |t| t.pattern = "spec/helper/*_spec.rb" end end end serverspec-2.18.0/bin/0000755000004100000410000000000012537110645014567 5ustar www-datawww-dataserverspec-2.18.0/bin/serverspec-init0000755000004100000410000000020412537110645017633 0ustar www-datawww-data#!/usr/bin/env ruby $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) require 'serverspec' Serverspec::Setup.run serverspec-2.18.0/wercker.yml0000644000004100000410000000036612537110645016211 0ustar www-datawww-databox: mizzy/serverspec-base@0.0.6 build: steps: - script: name: Run walter code: ./$WORKING_DIR/walter -c ./$WORKING_DIR/pipeline.yml after-steps: - wantedly/pretty-slack-notify: webhook_url: $SLACK_WEBHOOK_URL serverspec-2.18.0/Gemfile0000644000004100000410000000034112537110645015310 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in serverspec.gemspec gemspec # Put Gemfile.local to use arbitrary gems for your use case. path = Pathname.new("Gemfile.local") eval(path.read) if path.exist? serverspec-2.18.0/appveyor.yml0000644000004100000410000000320112537110645016403 0ustar www-datawww-dataversion: "{build}" os: Windows Server 2012 platform: - x64 environment: bundle_gemfile: integration-test/Gemfile.winrm bundler_url: https://rubygems.org/downloads/bundler-1.9.9.gem matrix: - ruby_version: "193" - ruby_version: "200" - ruby_version: "21" - ruby_version: "22" matrix: allow_failures: - ruby_version: "22" # waiting for net-ssh update clone_depth: 5 cache: - C:\Ruby193\lib\ruby\gems\1.9.1 - C:\Ruby193\bin - C:\Ruby200\lib\ruby\gems\2.0.0 - C:\Ruby200\bin - C:\Ruby21\lib\ruby\gems\2.1.0 - C:\Ruby21\bin - C:\Ruby22\lib\ruby\gems\2.2.0 - C:\Ruby22\bin install: - git submodule update --init --recursive - ps: Enable-PSRemoting -Force - ps: Set-ExecutionPolicy RemoteSigned - winrm quickconfig -q - winrm set winrm/config/client @{TrustedHosts="*"} - winrm set winrm/config/client/auth @{Basic="true"} - winrm set winrm/config/service/auth @{Basic="true"} - winrm set winrm/config/service @{AllowUnencrypted="true"} - SET PATH=C:\Ruby%ruby_version%\bin;%PATH% - echo %PATH% - ruby --version - gem --version - appveyor DownloadFile -Url %bundler_url% -FileName bundler.gem - gem install --local bundler.gem --no-ri --no-rdoc ## appveyor often stops `gem install bundler`..? build_script: - ruby -rfileutils -e 'FileUtils.rm_r(File.join(Gem.dir, "cache", "bundler")) if Dir.exists?(File.join(Gem.dir, "cache", "bundler"))' - bundle install --jobs 3 --retry 3 - net user - net localgroup test_script: - net user appveyor %WINDOWS_PASSWORD% # set by webui - bundle exec rspec -fd --backtrace -r .\integration-test\winrm\spec_helper.rb .\integration-test\winrm serverspec-2.18.0/serverspec.gemspec0000644000004100000410000000221412537110645017544 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'serverspec/version' Gem::Specification.new do |spec| spec.name = "serverspec" spec.version = Serverspec::VERSION spec.authors = ["Gosuke Miyashita"] spec.email = ["gosukenator@gmail.com"] spec.description = %q{RSpec tests for your servers configured by Puppet, Chef, Itamae or anything else} spec.summary = %q{RSpec tests for your servers configured by Puppet, Chef, Itamae or anything else} spec.homepage = "http://serverspec.org/" spec.license = "MIT" spec.files = `git ls-files`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_runtime_dependency "rspec", "~> 3.0" spec.add_runtime_dependency "rspec-its" spec.add_runtime_dependency "multi_json" spec.add_runtime_dependency "specinfra", "~> 2.35" spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake", "~> 10.1.1" end serverspec-2.18.0/LICENSE.txt0000644000004100000410000000206112537110645015641 0ustar www-datawww-dataCopyright (c) 2013 Gosuke Miyashita MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. serverspec-2.18.0/spec/0000755000004100000410000000000012537110645014751 5ustar www-datawww-dataserverspec-2.18.0/spec/type/0000755000004100000410000000000012537110645015732 5ustar www-datawww-dataserverspec-2.18.0/spec/type/base/0000755000004100000410000000000012537110645016644 5ustar www-datawww-dataserverspec-2.18.0/spec/type/base/host_spec.rb0000644000004100000410000000140112537110645021154 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe host('127.0.0.1') do it { should be_resolvable } end describe host('127.0.0.1') do it { should be_resolvable.by('hosts') } end describe host('127.0.0.1') do it { should be_resolvable.by('dns') } end describe host('127.0.0.1') do it { should be_reachable } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => "icmp", :timeout=> 1) } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } end describe host('127.0.0.1') do it { should 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' } end serverspec-2.18.0/spec/type/base/group_spec.rb0000644000004100000410000000024112537110645021334 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe group('root') do it { should exist } end describe group('root') do it { should have_gid 0 } end serverspec-2.18.0/spec/type/base/mail_alias_spec.rb0000644000004100000410000000017512537110645022301 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe mail_alias('daemon') do it { should be_aliased_to "root" } end serverspec-2.18.0/spec/type/base/cron_spec.rb0000644000004100000410000000035712537110645021151 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe cron do it { should have_entry '* * * * * /usr/local/bin/batch.sh' } end describe cron do it { should have_entry('* * * * * /usr/local/bin/batch.sh').with_user('root') } end serverspec-2.18.0/spec/type/base/service_spec.rb0000644000004100000410000000166012537110645021646 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe service('sshd') do it { should 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) } end describe service('sshd') do it { should be_running.under(:upstart) } end describe service('sshd') do it { should be_running.under(:daemontools) } end describe service('sshd') do it { expect { should be_running.under('not implemented') }.to raise_exception } end describe service('sshd') do let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" } it { should be_monitored_by(:monit) } end describe service('unicorn') do it { should be_monitored_by(:god) } end describe service('sshd') do it { expect { should be_monitored_by('not implemented') }.to raise_exception } end serverspec-2.18.0/spec/type/base/port_spec.rb0000644000004100000410000000115012537110645021164 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe port(80) do it { should be_listening } end describe port(80) do it { should be_listening.with('tcp') } end describe port(80) do it do expect { should be_listening.with('not implemented') }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) end end describe port(80) do it { should be_listening.on('127.0.0.1') } end describe port(80) do it do expect{ should be_listening.on('') }.to raise_error(ArgumentError) end end describe port(53) do it { should be_listening.with('udp') } end serverspec-2.18.0/spec/type/base/package_spec.rb0000644000004100000410000000207412537110645021601 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe package('jekyll') do it { should be_installed.by(:gem) } end describe package('jekyll') do it { should be_installed.by(:gem).with_version('1.1.1') } end describe package('ruby') do it { should be_installed.by(:rvm) } end describe package('ruby') do it { should be_installed.by(:rvm).with_version('2.2.0') } end describe package('bower') do it { should be_installed.by(:npm) } end describe package('bower') do it { should be_installed.by(:npm).with_version('0.9.2') } end describe package('mongo') do it { should be_installed.by(:pecl) } end describe package('mongo') do it { should be_installed.by(:pecl).with_version('1.4.1') } end describe package('XML_Util') do it { should be_installed.by(:pear).with_version('1.2.1') } end describe package('supervisor') do it { should be_installed.by(:pip).with_version('3.0') } end describe package('App::Ack') do it { should be_installed.by(:cpan) } end describe package('App::Ack') do it { should be_installed.by(:cpan).with_version('2.04') } end serverspec-2.18.0/spec/type/base/user_spec.rb0000644000004100000410000000211412537110645021157 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe user('root') do it { should exist } end describe user('root') do it { should belong_to_group 'root' } end describe user('root') do it { should belong_to_primary_group 'root' } end describe user('root') do it { should have_uid 0 } end describe user('root') do it { should have_login_shell '/bin/bash' } end describe user('root') do it { should have_home_directory '/root' } end describe user('root') do it { should have_authorized_key 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local' } end describe user('root') do its(:minimum_days_between_password_change) { should == 0 } end describe user('root') do its(:maximum_days_between_password_change) { should == 0 } end serverspec-2.18.0/spec/type/base/routing_table_spec.rb0000644000004100000410000000266012537110645023045 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe routing_table do let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\n" } it { should have_entry( :destination => '192.168.100.0/24' ) } end describe routing_table do let(:exit_status) { 1 } it { should_not have_entry( :destination => '192.168.100.100/24' ) } end describe routing_table do let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\n" } it do should have_entry( :destination => '192.168.100.0/24', :interface => 'eth1' ) end end describe routing_table do let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\n" } it { should have_entry( :destination => '192.168.200.0/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 end describe routing_table do let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" } it { should have_entry( :destination => 'default' ) } 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 end serverspec-2.18.0/spec/type/base/file_spec.rb0000644000004100000410000002047112537110645021126 0ustar www-datawww-datarequire 'spec_helper' set :os, {:family => 'base'} describe file('/etc/ssh/sshd_config') do it { should be_file } end describe file('/etc/ssh') do it { should be_directory } end describe file('/var/run/unicorn.sock') do it { should be_socket } end describe file('/dev/disk0') do it { should be_block_device } end describe file('/dev/ttys0') do it { should be_character_device } end describe file('/var/run/pure-ftpd/pure-ftpd.upload.pipe') do it { should be_pipe } end describe file('/bin/sh') do it { should be_symlink } end describe file('/bin/sh') do it { should exist } end describe file('/etc/ssh/sshd_config') do it { should contain 'This is the sshd server system-wide configuration file' } end describe file('/etc/ssh/sshd_config') do it { should contain /^This is the sshd server system-wide configuration file/ } end describe file('Gemfile') do it { should contain('rspec').from(/^group :test do/).to(/^end/) } end describe file('Gemfile') do it { should contain('rspec').after(/^group :test do/) } end describe file('Gemfile') do it { should contain('rspec').before(/^end/) } end describe file('/etc/passwd') do it { should be_mode 644 } end describe file('/etc/passwd') do it { should be_owned_by 'root' } end describe file('/etc/passwd') do it { should be_grouped_into 'root' } end describe file('/etc/pam.d/system-auth') do it { should be_linked_to '/etc/pam.d/system-auth-ac' } end describe file('/dev') do let(:stdout) { "755\r\n" } it { should be_readable } 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 } 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 } 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('/') 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 let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" } its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' } end describe file('invalid-file') do its(:md5sum) { should_not eq 'INVALIDMD5CHECKSUM' } end describe file('/etc/services') do let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } its(:sha256sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } end describe file('invalid-file') do its(:sha256sum) { should_not eq 'INVALIDSHA256CHECKSUM' } end describe file('/etc/passwd') do let(:stdout) {< DateTime.now - 1 } end describe file('/etc/passwod') do let(:stdout) { 100.to_s } its(:size) { should > 0 } end describe file('/etc/passwd') do it 'be_immutable is not implemented in base class' do expect { should be_immutable }.to raise_exception end end serverspec-2.18.0/spec/type/base/command_spec.rb0000644000004100000410000000373212537110645021626 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe command('cat /etc/resolv.conf') do let(:stdout) { "nameserver 127.0.0.1\r\n" } its(:stdout) { should match /nameserver 127.0.0.1/ } end describe 'complete matching of stdout' do context command('cat /etc/resolv.conf') do let(:stdout) { "foocontent-should-be-includedbar\r\n" } its(:stdout) { should_not eq '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" } its(:stdout) { should match /127\.0\.0\.1/ } end end describe command('cat /etc/resolv.conf') do let(:stderr) { "No such file or directory\r\n" } its(:stderr) { should match /No such file or directory/ } end describe 'complete matching of stderr' do context command('cat /etc/resolv.conf') do let(:stderr) { "No such file or directory\r\n" } its(:stdout) { should_not eq '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" } its(:stderr) { should match /file/ } end end describe command('cat /etc/resolv.conf') do its(:exit_status) { should eq 0 } end describe command('ls -al /') do let(:stdout) { < 'base' describe process("memcached") do let(:stdout) { " 1407\n" } its(:pid) { should eq 1407 } 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/ } end describe process("memcached") do let(:stdout) { "nobody\n" } its(:user) { should eq "nobody" } end describe process("memcached") do let(:stdout) { "nobody\n" } its(:group) { should eq "nobody" } end describe process("memcached") do context "when running" do let(:stdout) { " 1407\n" } it { should be_running } end context "when not running" do let(:stdout) { " 1407\n" } it { should be_running } end end serverspec-2.18.0/spec/type/base/default_gateway_spec.rb0000644000004100000410000000050712537110645023352 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe default_gateway do let(:stdout) { "default via 192.168.1.1 dev eth1 \r\n" } its(:ipaddress) { should eq '192.168.1.1' } its(:interface) { should eq 'eth1' } its(:ipaddress) { should_not eq '192.168.1.2' } its(:interface) { should_not eq 'eth0' } end serverspec-2.18.0/spec/type/base/php_config_spec.rb0000644000004100000410000000144212537110645022320 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'base' describe php_config('default_mimetype') do let(:stdout) { 'text/html' } its(:value) { should eq 'text/html' } 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 } 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/ } end describe php_config('mbstring.http_output_conv_mimetypes') do let(:stdout) { 'application' } its(:value) { should_not match /html/ } end serverspec-2.18.0/spec/type/fedora/0000755000004100000410000000000012537110645017172 5ustar www-datawww-dataserverspec-2.18.0/spec/type/fedora/service_spec.rb0000644000004100000410000000036612537110645022176 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'fedora' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end describe service('sshd') do it { should be_running } end serverspec-2.18.0/spec/type/windows/0000755000004100000410000000000012537110645017424 5ustar www-datawww-dataserverspec-2.18.0/spec/type/windows/host_spec.rb0000644000004100000410000000125012537110645021736 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe host('127.0.0.1') do it { should be_resolvable } end describe host('127.0.0.1') do it { should be_resolvable.by('hosts') } end describe host('127.0.0.1') do it { should be_resolvable.by('dns') } end describe host('127.0.0.1') do it { should be_reachable } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => "icmp", :timeout=> 1) } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) } end serverspec-2.18.0/spec/type/windows/group_spec.rb0000644000004100000410000000067112537110645022123 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe group('test.group') do it { should exist } end describe group('test.domain\test.group') do it { should 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_exception end end end serverspec-2.18.0/spec/type/windows/service_spec.rb0000644000004100000410000000124212537110645022422 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe service('Test Service') do it { should be_enabled } end describe service('Test Service') do it { should be_running } end describe service('service') do it { should be_installed } end describe service('service') do it { should have_start_mode 'mode' } 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 serverspec-2.18.0/spec/type/windows/feature_spec.rb0000644000004100000410000000051312537110645022415 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe windows_feature('Minesweeper') do it{ should be_installed } end describe windows_feature('IIS-Webserver') do it{ should be_installed.by(:dism) } end describe windows_feature('Web-Webserver') do it{ should be_installed.by(:powershell) } end serverspec-2.18.0/spec/type/windows/iis_webisite_spec.rb0000644000004100000410000000111712537110645023442 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe iis_website('Default Website') do it { should exist } it { should be_enabled } it { should be_running } it { should be_in_app_pool('Default App Pool') } it { should have_physical_path('C:\\inetpub\\www') } it { should have_site_bindings('port').with_protocol('protocol').with_ipaddress('ipaddress').with_host_header('host_header') } it { should have_virtual_dir('vdir').with_path('path') } it { should have_site_application('app').with_pool('pool').with_physical_path('physical_path') } end serverspec-2.18.0/spec/type/windows/port_spec.rb0000644000004100000410000000067712537110645021761 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe port(80) do it { should be_listening } end describe port(80) do it { should be_listening.with("tcp") } end describe port(123) do it { should be_listening.with("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 serverspec-2.18.0/spec/type/windows/package_spec.rb0000644000004100000410000000020712537110645022355 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe package('foo') do it { should be_installed } end serverspec-2.18.0/spec/type/windows/user_spec.rb0000644000004100000410000000127512537110645021746 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe user('test.user') do it { should exist } end describe user('test.domain\test.user') do it { should exist } end describe user('test.user') do it { should belong_to_group 'test.group' } end describe user('test.user.domain\test.user') do it { should belong_to_group 'test.group.domain\test.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_exception end end end serverspec-2.18.0/spec/type/windows/scheduled_task_spec.rb0000644000004100000410000000021612537110645023744 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe windows_scheduled_task('foo') do it { should exist } end serverspec-2.18.0/spec/type/windows/file_spec.rb0000644000004100000410000000520412537110645021703 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe file('/some/valid/file') do it { should be_file } end describe file('/some/valid/folder') do it { should be_directory } end describe file('/some/file') do it { should contain 'search text' } end describe file('/some/file') do it { should contain /^search text/ } end describe file('Gemfile') do it { should contain('rspec').from(/^group :test do/).to(/^end/) } end describe file('Gemfile') do it { should contain('rspec').after(/^group :test do/) } end describe file('Gemfile') do it { should contain('rspec').before(/end/) } end describe file('/some/file') do it { should be_readable } end describe file('/some/file') do it "should raise error if trying to check access by 'owner' or 'group' or 'others'" do ['owner', 'group', 'others'].each do |access| expect { should be_readable.by(access) }.to raise_error end end end describe file('/some/file') do it { should be_readable.by('test.identity') } end describe file('/some/file') do it { should be_readable.by_user('test.identity') } end describe file('/some/file') do it { should be_writable } end describe file('/some/file') do it "should raise error if trying to check access by 'owner' or 'group' or 'others'" do ['owner', 'group', 'others'].each do |access| expect { should be_writable.by(access) }.to raise_error end end end describe file('/some/file') do it { should be_writable.by('test.identity') } end describe file('/some/file') do it { should be_writable.by_user('test.identity') } end describe file('/some/file') do it { should be_executable } end describe file('/some/file') do it "should raise error if trying to check access by 'owner' or 'group' or 'others'" do ['owner', 'group', 'others'].each do |access| expect { should be_executable.by(access) }.to raise_error end end end describe file('/some/file') do it { should be_executable.by('test.identity') } end describe file('/some/file') do it { should be_executable.by_user('test.identity') } end describe file('/some/file') do it { should be_version 1 } end describe file('/some/test/file') do it "should raise error if command is not supported" do { :be_socket => [], :be_mode => 644, :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_exception end end end serverspec-2.18.0/spec/type/windows/command_spec.rb0000644000004100000410000000345112537110645022404 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe command('test_cmd /test/path/file') do let(:stdout) { "test output 1.2.3\r\n" } its(:stdout) { should match /test output 1.2.3/ } end describe 'complete matching of stdout' do context command('test_cmd /test/path/file') do let(:stdout) { "foocontent-should-be-includedbar\r\n" } its(:stdout) { should_not eq '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" } its(:stdout) { should match /1\.2\.3/ } end end describe command('test_cmd /test/path/file') do let(:stderr) { "No such file or directory\r\n" } its(:stderr) { should match /No such file or directory/ } end describe 'complete matching of stderr' do context command('test_cmd /test/path/file') do let(:stderr) { "No such file or directory\r\n" } its(:stderr) { should_not eq '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" } its(:stderr) { should match /file/ } end end describe command('test_cmd /test/path/file') do its(:exit_status) { should eq 0 } end describe command('dir "c:\"') do let(:stdout) { < 'windows' describe windows_registry_key('PATH/TO/THE_KEY') do it { should exist } end describe windows_registry_key('PATH/TO/THE_KEY') do it { should have_value('Test Value') } end describe 'Key value types' do context 'default type' do describe windows_registry_key('PATH/TO/THE_KEY') do it { should have_property('TestProperty') } 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) } end end end end describe windows_registry_key('PATH/TO/THE_KEY') do it { should have_property_value('TestProperty', :type_binary, '12a07b') } end describe windows_registry_key('PATH/TO/THE_KEY') do it { should have_property_value('TestProperty', :type_dword, 'fffffd6c') } end describe windows_registry_key('PATH/TO/THE_KEY') do it { should have_property_value('TestProperty', :type_qword, '1e240') } 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) } end serverspec-2.18.0/spec/type/windows/iis_app_pool_spec.rb0000644000004100000410000000073312537110645023443 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe iis_app_pool('Default App Pool') do it { should exist } it { should have_dotnet_version('2.0') } it { should have_32bit_enabled } it { should have_idle_timeout(5) } it { should have_identity_type('foo') } it { should have_periodic_restart(60) } it { should have_user_profile_enabled } it { should have_username('user') } it { should have_managed_pipeline_mode('mode') } end serverspec-2.18.0/spec/type/windows/hot_fix_spec.rb0000644000004100000410000000071612537110645022427 0ustar www-datawww-datarequire 'spec_helper' set :backend, :cmd set :os, :family => 'windows' describe windows_hot_fix('DESCRIPTION-OR-KB-ID') do it { should be_installed } end describe windows_hot_fix('DESCRIPTION') do it { should be_installed.with_version('KB-ID') } end describe windows_hot_fix('DESCRIPTION_WITH_KB123456789_INLINED') do it { should be_installed } end describe windows_hot_fix('DESCRIPTION_WITH_SUFFIX_KB123456789') do it { should be_installed } end serverspec-2.18.0/spec/type/smartos/0000755000004100000410000000000012537110645017422 5ustar www-datawww-dataserverspec-2.18.0/spec/type/smartos/service_spec.rb0000644000004100000410000000037312537110645022424 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'smartos' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_running } end describe service('sshd') do it { should have_property :foo => 'bar' } end serverspec-2.18.0/spec/type/smartos/package_spec.rb0000644000004100000410000000065112537110645022356 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'smartos' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } 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' } end serverspec-2.18.0/spec/type/solaris10/0000755000004100000410000000000012537110645017547 5ustar www-datawww-dataserverspec-2.18.0/spec/type/solaris10/host_spec.rb0000644000004100000410000000053412537110645022065 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris', :release => 10 describe host('127.0.0.1') do it { should be_reachable } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => 'icmp', :timeout=> 1) } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => 'tcp', :port => 22, :timeout=> 1) } end serverspec-2.18.0/spec/type/solaris10/group_spec.rb0000644000004100000410000000017312537110645022243 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris', :release => 10 describe group('root') do it { should exist } end serverspec-2.18.0/spec/type/solaris10/package_spec.rb0000644000004100000410000000020512537110645022476 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris', :release => 10 describe package('httpd') do it { should be_installed } end serverspec-2.18.0/spec/type/solaris10/user_spec.rb0000644000004100000410000000023212537110645022061 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris', :release => 10 describe user('root') do it { should have_authorized_key 'XXXXXXXXXXXXXXX' } end serverspec-2.18.0/spec/type/solaris10/file_spec.rb0000644000004100000410000001664012537110645022034 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris', :release => 10 describe file('/etc/ssh/sshd_config') do it { should be_file } end describe file('/etc/ssh') do it { should be_directory } end describe file('/var/run/unicorn.sock') do it { should be_socket } end describe file('/etc/ssh/sshd_config') do it { should contain 'This is the sshd server system-wide configuration file' } end describe file('/etc/ssh/sshd_config') do it { should contain /^This is the sshd server system-wide configuration file/ } end describe file('Gemfile') do it { should contain('rspec').from(/^group :test do/).to(/^end/) } end describe file('Gemfile') do it { should contain('rspec').after(/^group :test do/) } end describe file('Gemfile') do it { should contain('rspec').before(/^end/) } end describe file('/etc/passwd') do it { should be_mode 644 } end describe file('/etc/passwd') do it { should be_owned_by 'root' } end describe file('/etc/passwd') do it { should be_grouped_into 'root' } end describe file('/etc/pam.d/system-auth') do it { should be_linked_to '/etc/pam.d/system-auth-ac' } end describe file('/dev') do let(:stdout) { "755\r\n" } it { should be_readable } 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 } 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 } 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('/') 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/services') do let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" } its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' } end describe file('/etc/services') do let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } its(:md5sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } end describe file('/etc/passwd') do let(:stdout) {< 'nixos' describe service('sshd') do it { should be_enabled } it { should be_running } end serverspec-2.18.0/spec/type/nixos/package_spec.rb0000644000004100000410000000046612537110645022032 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'nixos' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } end describe package('httpd') do it { should be_installed.by('nix').with_version('2.2.15-28.el6') } end serverspec-2.18.0/spec/type/fedora15/0000755000004100000410000000000012537110645017340 5ustar www-datawww-dataserverspec-2.18.0/spec/type/fedora15/service_spec.rb0000644000004100000410000000040612537110645022337 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'fedora', :release => 15 describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end describe service('sshd') do it { should be_running } end serverspec-2.18.0/spec/type/plamo/0000755000004100000410000000000012537110645017042 5ustar www-datawww-dataserverspec-2.18.0/spec/type/plamo/service_spec.rb0000644000004100000410000000016012537110645022036 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'plamo' describe service('sshd') do it { should be_enabled } end serverspec-2.18.0/spec/type/plamo/package_spec.rb0000644000004100000410000000016312537110645021774 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'plamo' describe package('httpd') do it { should be_installed } end serverspec-2.18.0/spec/type/freebsd/0000755000004100000410000000000012537110645017344 5ustar www-datawww-dataserverspec-2.18.0/spec/type/freebsd/service_spec.rb0000644000004100000410000000016212537110645022342 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'freebsd' describe service('sshd') do it { should be_enabled } end serverspec-2.18.0/spec/type/freebsd/port_spec.rb0000644000004100000410000000076412537110645021676 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'freebsd' describe port(80) do it { should be_listening } end describe port(80) do it { should be_listening.with('tcp') } end describe port(80) do it do expect { should be_listening.with('not implemented') }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) end end describe port(80) do it { should be_listening.on('127.0.0.1') } end describe port(53) do it { should be_listening.with('udp') } end serverspec-2.18.0/spec/type/freebsd/package_spec.rb0000644000004100000410000000065112537110645022300 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'freebsd' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } 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' } end serverspec-2.18.0/spec/type/freebsd/file_spec.rb0000644000004100000410000000106712537110645021626 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'freebsd' describe file('/etc/passwd') do it { should be_mode 644 } end describe file('/etc/passwd') do it { should be_owned_by 'root' } end describe file('/etc/passwd') do it { should be_grouped_into 'root' } end describe file('/sbin/nologin') do it { should be_linked_to '/usr/sbin/nologin' } end describe file('/etc/passwd') do let(:stdout) { Time.now.to_i.to_s } its(:mtime) { should > DateTime.now - 1 } end describe file('/etc/passwod') do let(:stdout) { 100.to_s } its(:size) { should > 0 } end serverspec-2.18.0/spec/type/suse/0000755000004100000410000000000012537110645016711 5ustar www-datawww-dataserverspec-2.18.0/spec/type/suse/service_spec.rb0000644000004100000410000000027012537110645021707 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'suse' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end serverspec-2.18.0/spec/type/suse/package_spec.rb0000644000004100000410000000101512537110645021640 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'suse' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } end describe package('httpd') do it { should be_installed.by('rpm').with_version('2.2.15-28.el6') } 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' } end serverspec-2.18.0/spec/type/fedora20/0000755000004100000410000000000012537110645017334 5ustar www-datawww-dataserverspec-2.18.0/spec/type/fedora20/service_spec.rb0000644000004100000410000000040612537110645022333 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'fedora', :release => 20 describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end describe service('sshd') do it { should be_running } end serverspec-2.18.0/spec/type/solaris/0000755000004100000410000000000012537110645017406 5ustar www-datawww-dataserverspec-2.18.0/spec/type/solaris/zfs_spec.rb0000644000004100000410000000045412537110645021552 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe zfs('rpool') do it { should exist } end describe zfs('rpool') do it { should have_property 'mountpoint' => '/rpool' } end describe zfs('rpool') do it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' } end serverspec-2.18.0/spec/type/solaris/host_spec.rb0000644000004100000410000000067412537110645021731 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe host('127.0.0.1') do it { should be_reachable } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => 'icmp', :timeout=> 1) } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => 'tcp', :port => 22, :timeout=> 1) } end describe host('127.0.0.1') do it { should be_reachable.with(:proto => 'udp', :port => 53, :timeout=> 1) } end serverspec-2.18.0/spec/type/solaris/group_spec.rb0000644000004100000410000000015712537110645022104 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe group('root') do it { should have_gid 0 } end serverspec-2.18.0/spec/type/solaris/ipfilter_spec.rb0000644000004100000410000000020412537110645022557 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe ipfilter do it { should have_rule 'pass in quick on lo0 all' } end serverspec-2.18.0/spec/type/solaris/cron_spec.rb0000644000004100000410000000036212537110645021707 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe cron do it { should have_entry '* * * * * /usr/local/bin/batch.sh' } end describe cron do it { should have_entry('* * * * * /usr/local/bin/batch.sh').with_user('root') } end serverspec-2.18.0/spec/type/solaris/service_spec.rb0000644000004100000410000000037312537110645022410 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_running } end describe service('sshd') do it { should have_property :foo => 'bar' } end serverspec-2.18.0/spec/type/solaris/port_spec.rb0000644000004100000410000000114512537110645021732 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe port(80) do it { should be_listening } end describe port(80) do it { should be_listening.with('tcp') } end describe port(80) do it do expect { should be_listening.with('not implemented') }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) end end describe port(80) do it { should be_listening.on('127.0.0.1') } end describe port(80) do it do expect{ should be_listening.on('') }.to raise_error(ArgumentError) end end describe port(123) do it { should be_listening.with('udp') } end serverspec-2.18.0/spec/type/solaris/package_spec.rb0000644000004100000410000000016412537110645022341 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe package('httpd') do it { should be_installed } end serverspec-2.18.0/spec/type/solaris/user_spec.rb0000644000004100000410000000042012537110645021717 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe user('root') do it { should belong_to_group 'root' } end describe user('root') do it { should have_login_shell '/bin/bash' } end describe user('root') do it { should have_home_directory '/root' } end serverspec-2.18.0/spec/type/solaris/file_spec.rb0000644000004100000410000000042512537110645021665 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe file('/tmp') do it { should be_readable.by_user('mail') } end describe file('/tmp') do it { should be_writable.by_user('mail') } end describe file('/tmp') do it { should be_executable.by_user('mail') } end serverspec-2.18.0/spec/type/solaris/ipnat_spec.rb0000644000004100000410000000021612537110645022057 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'solaris' describe ipnat do it { should have_rule 'map net1 192.168.0.0/24 -> 0.0.0.0/32' } end serverspec-2.18.0/spec/type/redhat5/0000755000004100000410000000000012537110645017266 5ustar www-datawww-dataserverspec-2.18.0/spec/type/redhat5/iptables_spec.rb0000644000004100000410000000037112537110645022431 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'redhat', :release => 5 describe iptables do it { should have_rule '-P INPUT ACCEPT' } end describe iptables do it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') } end serverspec-2.18.0/spec/type/opensuse/0000755000004100000410000000000012537110645017573 5ustar www-datawww-dataserverspec-2.18.0/spec/type/opensuse/service_spec.rb0000644000004100000410000000037112537110645022573 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'opensuse' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end describe service('sshd') do it { should be_running } end serverspec-2.18.0/spec/type/freebsd10/0000755000004100000410000000000012537110645017505 5ustar www-datawww-dataserverspec-2.18.0/spec/type/freebsd10/package_spec.rb0000644000004100000410000000067112537110645022443 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'freebsd', :release => 10 describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } 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' } end serverspec-2.18.0/spec/type/aix/0000755000004100000410000000000012537110645016513 5ustar www-datawww-dataserverspec-2.18.0/spec/type/aix/group_spec.rb0000644000004100000410000000015312537110645021205 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'aix' describe group('root') do it { should have_gid 0 } end serverspec-2.18.0/spec/type/aix/service_spec.rb0000644000004100000410000000027012537110645021511 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'aix' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end serverspec-2.18.0/spec/type/aix/port_spec.rb0000644000004100000410000000046612537110645021044 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'aix' describe port(80) do it { should be_listening } end describe port(80) do it { should be_listening.with('tcp') } end describe port(80) do it { should be_listening.on('127.0.0.1') } end describe port(53) do it { should be_listening.with('udp') } end serverspec-2.18.0/spec/type/aix/package_spec.rb0000644000004100000410000000016012537110645021442 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'aix' describe package('httpd') do it { should be_installed } end serverspec-2.18.0/spec/type/aix/user_spec.rb0000644000004100000410000000041412537110645021027 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'aix' describe user('root') do it { should belong_to_group 'root' } end describe user('root') do it { should have_login_shell '/bin/bash' } end describe user('root') do it { should have_home_directory '/root' } end serverspec-2.18.0/spec/type/aix/file_spec.rb0000644000004100000410000000106612537110645020774 0ustar www-datawww-datarequire 'spec_helper' set :os, {:family => 'aix'} describe file('/tmp') do it { should be_readable.by_user('mail') } end describe file('/tmp') do it { should be_writable.by_user('mail') } end describe file('/tmp') do it { should be_executable.by_user('mail') } end describe file('/etc/passwd') do it 'be_mode is not implemented' do expect { should be_mode 644 }.to raise_exception end end describe file('/etc/passwd') do it { should be_owned_by 'root' } end describe file('/etc/passwd') do it { should be_grouped_into 'root' } end serverspec-2.18.0/spec/type/redhat7/0000755000004100000410000000000012537110645017270 5ustar www-datawww-dataserverspec-2.18.0/spec/type/redhat7/service_spec.rb0000644000004100000410000000023312537110645022265 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'redhat', :release => 7 describe service('sshd') do it { should be_enabled } it { should be_running } end serverspec-2.18.0/spec/type/openbsd/0000755000004100000410000000000012537110645017364 5ustar www-datawww-dataserverspec-2.18.0/spec/type/openbsd/mail_alias_spec.rb0000644000004100000410000000020012537110645023006 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'openbsd' describe mail_alias('daemon') do it { should be_aliased_to "root" } end serverspec-2.18.0/spec/type/openbsd/service_spec.rb0000644000004100000410000000025712537110645022367 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'openbsd' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_running } end serverspec-2.18.0/spec/type/openbsd/interface_spec.rb0000644000004100000410000000066012537110645022665 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'openbsd' describe interface('eth0') do let(:stdout) { '1000' } its(:speed) { should eq 1000 } end describe interface('eth0') do it { should have_ipv4_address("192.168.10.10") } end describe interface('eth0') do it { should have_ipv4_address("192.168.10.10/24") } end describe interface('invalid-interface') do let(:stdout) { '1000' } its(:speed) { should_not eq 100 } end serverspec-2.18.0/spec/type/openbsd/port_spec.rb0000644000004100000410000000015412537110645021707 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'openbsd' describe port(80) do it { should be_listening } end serverspec-2.18.0/spec/type/openbsd/package_spec.rb0000644000004100000410000000032112537110645022312 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'openbsd' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } end serverspec-2.18.0/spec/type/openbsd/user_spec.rb0000644000004100000410000000031312537110645021676 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'openbsd' describe user('root') do it { should have_login_shell '/bin/bash' } end describe user('root') do it { should have_home_directory '/root' } end serverspec-2.18.0/spec/type/openbsd/file_spec.rb0000644000004100000410000000732212537110645021646 0ustar www-datawww-datarequire 'spec_helper' set :os, {:family => 'openbsd'} describe file('/etc/passwd') do it { should be_mode 644 } end describe file('/etc/passwd') do it { should be_owned_by 'root' } end describe file('/etc/passwd') do it { should be_grouped_into 'root' } end describe file('/etc/pam.d/system-auth') do it { should be_linked_to '/etc/pam.d/system-auth-ac' } end describe file('/') do it { should 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('/') 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/services') do let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" } its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' } end describe file('/etc/services') do let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } its(:sha256sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } end serverspec-2.18.0/spec/type/arch/0000755000004100000410000000000012537110645016647 5ustar www-datawww-dataserverspec-2.18.0/spec/type/arch/service_spec.rb0000644000004100000410000000021212537110645021641 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'arch' describe service('sshd') do it { should be_enabled } it { should be_running } end serverspec-2.18.0/spec/type/arch/package_spec.rb0000644000004100000410000000064612537110645021607 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'arch' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } 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' } end serverspec-2.18.0/spec/type/arch/file_spec.rb0000644000004100000410000000042212537110645021123 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'arch' describe file('/tmp') do it { should be_readable.by_user('mail') } end describe file('/tmp') do it { should be_writable.by_user('mail') } end describe file('/tmp') do it { should be_executable.by_user('mail') } end serverspec-2.18.0/spec/type/debian/0000755000004100000410000000000012537110645017154 5ustar www-datawww-dataserverspec-2.18.0/spec/type/debian/service_spec.rb0000644000004100000410000000027212537110645022154 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'debian' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end serverspec-2.18.0/spec/type/debian/package_spec.rb0000644000004100000410000000101712537110645022105 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'debian' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } end describe package('httpd') do it { should be_installed.by('apt').with_version('2.2.15-28.el6') } 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' } end serverspec-2.18.0/spec/type/linux/0000755000004100000410000000000012537110645017071 5ustar www-datawww-dataserverspec-2.18.0/spec/type/linux/zfs_spec.rb0000644000004100000410000000045212537110645021233 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe zfs('rpool') do it { should exist } end describe zfs('rpool') do it { should have_property 'mountpoint' => '/rpool' } end describe zfs('rpool') do it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' } end serverspec-2.18.0/spec/type/linux/iptables_spec.rb0000644000004100000410000000035112537110645022232 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe iptables do it { should have_rule '-P INPUT ACCEPT' } end describe iptables do it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') } end serverspec-2.18.0/spec/type/linux/fstab_spec.rb0000644000004100000410000000125212537110645021527 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe fstab do let(:stdout) { "/dev/sda1 /mnt ext4 ro,errors=remount-ro,barrier=0 0 2\r\n" } it { should have_entry( :mount_point => '/mnt' ) } end describe fstab do let(:exit_status) { 1 } it { should_not have_entry( :mount_point => '/mnt' ) } end describe fstab do let(:stdout) { "/dev/sda1 /mnt ext4 ro,errors=remount-ro,barrier=0 0 2\r\n" } it do should have_entry( :device => '/dev/sda1', :mount_point => '/mnt', :type => 'ext4', :options => { :ro => true, :errors => 'remount-ro', :barrier => 0 }, :dump => 0, :pass => 2 ) end end serverspec-2.18.0/spec/type/linux/linux_kernel_parameter_spec.rb0000644000004100000410000000163412537110645025173 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do let(:stdout) { "1\n" } its(:value) { should eq 1 } 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" } 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/ } end describe linux_kernel_parameter('net.ipv4.tcp_wmem') do let(:stdout) { "4096 16384 4194304\n" } its(:value) { should_not match /123456/ } end serverspec-2.18.0/spec/type/linux/kernel_module_spec.rb0000644000004100000410000000016212537110645023254 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe kernel_module('lp') do it { should be_loaded } end serverspec-2.18.0/spec/type/linux/interface_spec.rb0000644000004100000410000000115712537110645022374 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe interface('eth0') do let(:stdout) { '1000' } its(:speed) { should eq 1000 } end describe interface('eth0') do it { should have_ipv4_address('192.168.10.10') } end describe interface('eth0') do it { should have_ipv4_address('192.168.10.10/24') } end describe interface('eth0') do it { should have_ipv6_address('2001:0db8:bd05:01d2:288a:1fc0:0001:10ee') } end describe interface('eth0') do let(:stdout) { 'up' } it { should be_up } end describe interface('invalid-interface') do let(:stdout) { '1000' } its(:speed) { should_not eq 100 } end serverspec-2.18.0/spec/type/linux/x509_certificate_spec.rb0000644000004100000410000000214212537110645023476 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe x509_certificate('test.pem') do let(:exit_status) { 0 } it { should be_certificate } end describe x509_certificate('test.pem') do let(:exit_status) { 1 } it { should_not be_certificate } end describe x509_certificate('test.pem') do let(:stdout) { sample_subj } its(:subject) { should eq '/O=some/OU=thing' } end describe x509_certificate('test.pem') do let(:stdout) { sample_issuer } its(:issuer) { should eq '/O=some/OU=issuer' } end describe x509_certificate('test.pem') do let(:stdout) { sample_validity } it { should be_valid } its(:validity_in_days) { should be >= 1000 } end describe x509_certificate('test.pem') do let(:stdout) { sample_validity2 } it { should_not be_valid } end def sample_subj <<'EOS' subject= /O=some/OU=thing EOS end def sample_issuer <<'EOS' issuer= /O=some/OU=issuer EOS end def sample_validity <<'EOS' notBefore=Jul 1 11:11:00 2000 GMT notAfter=Jul 1 11:11:00 2050 GMT EOS end def sample_validity2 <<'EOS' notBefore=Jul 1 11:11:00 2000 GMT notAfter=Jul 1 11:11:00 2010 GMT EOS end serverspec-2.18.0/spec/type/linux/lxc_container_spec.rb0000644000004100000410000000023712537110645023262 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe lxc('ct01') do it { should exist } end describe lxc('ct01') do it { should be_running } end serverspec-2.18.0/spec/type/linux/docker_container_spec.rb0000644000004100000410000000544112537110645023745 0ustar www-datawww-data# -*- coding: utf-8 -*- require 'spec_helper' property[:os] = nil set :os, {:family => 'linux'} describe docker_container('c1') do it { should exist } end describe docker_container('c1') do let(:stdout) { inspect_container } it { should be_running } it { should have_volume('/tmp', '/data') } its(:inspection) { should include 'Driver' => 'aufs' } its(['Config.Cmd']) { should include '/bin/sh' } end def inspect_container <<'EOS' [{ "Args": [], "Config": { "AttachStderr": false, "AttachStdin": false, "AttachStdout": false, "Cmd": [ "/bin/sh" ], "CpuShares": 0, "Cpuset": "", "Domainname": "", "Entrypoint": null, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "ExposedPorts": null, "Hostname": "65cd2e2d7963", "Image": "busybox", "Memory": 0, "MemorySwap": 0, "NetworkDisabled": false, "OnBuild": null, "OpenStdin": true, "PortSpecs": null, "StdinOnce": false, "Tty": true, "User": "", "Volumes": null, "WorkingDir": "" }, "Created": "2014-09-26T15:08:37.527931773Z", "Driver": "aufs", "ExecDriver": "native-0.2", "HostConfig": { "Binds": [ "/data:/tmp" ], "ContainerIDFile": "", "Dns": null, "DnsSearch": null, "Links": null, "LxcConf": [], "NetworkMode": "bridge", "PortBindings": {}, "Privileged": false, "PublishAllPorts": false, "VolumesFrom": null }, "HostnamePath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/hostname", "HostsPath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/hosts", "Id": "65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545", "Image": "e72ac664f4f0c6a061ac4ef332557a70d69b0c624b6add35f1c181ff7fff2287", "MountLabel": "", "Name": "/c1", "NetworkSettings": { "Bridge": "docker0", "Gateway": "172.17.42.1", "IPAddress": "172.17.0.24", "IPPrefixLen": 16, "PortMapping": null, "Ports": {} }, "Path": "/bin/sh", "ProcessLabel": "", "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/resolv.conf", "State": { "ExitCode": 0, "FinishedAt": "0001-01-01T00:00:00Z", "Paused": false, "Pid": 4123, "Running": true, "StartedAt": "2014-09-26T15:08:37.737780273Z" }, "Volumes": { "/tmp": "/data" }, "VolumesRW": { "/tmp": true } } ] EOS end serverspec-2.18.0/spec/type/linux/ip6tables_spec.rb0000644000004100000410000000036312537110645022323 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe ip6tables do it { should have_rule '-P INPUT ACCEPT' } end describe ip6tables do it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') } end serverspec-2.18.0/spec/type/linux/file_spec.rb0000644000004100000410000000105412537110645021347 0ustar www-datawww-datarequire 'spec_helper' property[:os] = nil set :os, {:family => 'linux'} describe file('/tmp') do it { should be_readable.by_user('mail') } end describe file('/tmp') do it { should be_writable.by_user('mail') } end describe file('/tmp') do it { should be_executable.by_user('mail') } end describe file('/tmp') do it { should be_immutable } end describe file('/tmp') do let(:exit_status) { 0 } let(:stdout) { 'unconfined_u:unconfined_r:unconfined_t:s0' } its(:selinux_label) { should eq 'unconfined_u:unconfined_r:unconfined_t:s0' } end serverspec-2.18.0/spec/type/linux/x509_private_key_spec.rb0000644000004100000410000000123412537110645023537 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe x509_private_key('key.pem') do let(:exit_status) { 0 } let(:stdout) { 'RSA key ok' } it { should be_valid } end describe x509_private_key('key.pem') do let(:exit_status) { 1 } let(:stdout) { 'RSA key ok' } it { should_not be_valid } end describe x509_private_key('key.pem') do let(:exit_status) { 0 } it { should be_encrypted } end describe x509_private_key('key.pem') do let(:exit_status) { 1 } it { should_not be_encrypted } end describe x509_private_key('key.pem') do let(:exit_status) { 0 } let(:stdout) { 'SHA1SUM' } it { should have_matching_certificate('cert.pem') } endserverspec-2.18.0/spec/type/linux/selinux_module_spec.rb0000644000004100000410000000030712537110645023464 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe selinux_module('bootloader') do it { should be_installed } end describe selinux_module('bootloader') do it { should be_enabled } end serverspec-2.18.0/spec/type/linux/selinux_spec.rb0000644000004100000410000000032512537110645022117 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe selinux do it { should be_enforcing } end describe selinux do it { should be_permissive } end describe selinux do it { should be_disabled } end serverspec-2.18.0/spec/type/linux/bond_spec.rb0000644000004100000410000000030712537110645021352 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe bond('bond0') do it { should exist } end describe bond('bond0') do let(:stdout) { 'eth0' } it { should have_interface 'eth0' } end serverspec-2.18.0/spec/type/linux/cgroup_spec.rb0000644000004100000410000000037312537110645021732 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe cgroup('group1') do let(:stdout) { "1\r\n" } its('cpuset.cpus') { should eq 1 } end describe cgroup('group1') do let(:stdout) { "1\r\n" } its('cpuset.cpus') { should_not eq 0 } end serverspec-2.18.0/spec/type/linux/docker_image_spec.rb0000644000004100000410000000503712537110645023046 0ustar www-datawww-data# -*- coding: utf-8 -*- require 'spec_helper' property[:os] = nil set :os, {:family => 'linux'} describe docker_image('busybox:latest') do it { should exist } end describe docker_image('busybox:latest') do let(:stdout) { inspect_image } its(:inspection) { should include 'Architecture' => 'amd64' } its(['Architecture']) { should eq 'amd64' } its(['Config.Cmd']) { should include '/bin/sh' } end def inspect_image <<'EOS' [{ "Architecture": "amd64", "Author": "Jérôme Petazzoni \u003cjerome@docker.com\u003e", "Comment": "", "Config": { "AttachStderr": false, "AttachStdin": false, "AttachStdout": false, "Cmd": [ "/bin/sh" ], "CpuShares": 0, "Cpuset": "", "Domainname": "", "Entrypoint": null, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "ExposedPorts": null, "Hostname": "88f18f678e5d", "Image": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644", "Memory": 0, "MemorySwap": 0, "NetworkDisabled": false, "OnBuild": [], "OpenStdin": false, "PortSpecs": null, "StdinOnce": false, "Tty": false, "User": "", "Volumes": null, "WorkingDir": "" }, "Container": "8e73b239682fe73338323d9af83d3c5aa5bb7d22a3fe84cbfcf5f47e756d6636", "ContainerConfig": { "AttachStderr": false, "AttachStdin": false, "AttachStdout": false, "Cmd": [ "/bin/sh", "-c", "#(nop) CMD [/bin/sh]" ], "CpuShares": 0, "Cpuset": "", "Domainname": "", "Entrypoint": null, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], "ExposedPorts": null, "Hostname": "88f18f678e5d", "Image": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644", "Memory": 0, "MemorySwap": 0, "NetworkDisabled": false, "OnBuild": [], "OpenStdin": false, "PortSpecs": null, "StdinOnce": false, "Tty": false, "User": "", "Volumes": null, "WorkingDir": "" }, "Created": "2014-10-01T20:46:08.914288461Z", "DockerVersion": "1.2.0", "Id": "e72ac664f4f0c6a061ac4ef332557a70d69b0c624b6add35f1c181ff7fff2287", "Os": "linux", "Parent": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644", "Size": 0 } ] EOS end serverspec-2.18.0/spec/type/linux/bridge_spec.rb0000644000004100000410000000030712537110645021664 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'linux' describe bridge('br0') do it { should exist } end describe bridge('br0') do let(:stdout) { 'eth0' } it { should have_interface 'eth0' } end serverspec-2.18.0/spec/type/darwin/0000755000004100000410000000000012537110645017216 5ustar www-datawww-dataserverspec-2.18.0/spec/type/darwin/service_spec.rb0000644000004100000410000000036712537110645022223 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'darwin' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end describe service('sshd') do it { should be_running } end serverspec-2.18.0/spec/type/darwin/port_spec.rb0000644000004100000410000000076312537110645021547 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'darwin' describe port(80) do it { should be_listening } end describe port(80) do it { should be_listening.with('tcp') } end describe port(80) do it do expect { should be_listening.with('not implemented') }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/) end end describe port(80) do it { should be_listening.on('127.0.0.1') } end describe port(53) do it { should be_listening.with('udp') } end serverspec-2.18.0/spec/type/darwin/package_spec.rb0000644000004100000410000000055312537110645022153 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'darwin' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } end describe package('httpd') do it { should be_installed.by('homebrew') } end describe package('httpd') do it { should be_installed.by('pkgutil') } end serverspec-2.18.0/spec/type/darwin/file_spec.rb0000644000004100000410000000172112537110645021475 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'darwin' describe file('/tmp') do it { should be_readable.by_user('mail') } end describe file('/tmp') do it { should be_writable.by_user('mail') } end describe file('/tmp') do it { should be_executable.by_user('mail') } end describe file('/etc/services') do let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" } its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' } end describe file('/etc/services') do let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" } its(:sha256sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' } end describe file('/etc/pam.d/system-auth') do it { should be_linked_to '/etc/pam.d/system-auth-ac' } end describe file('/etc/passwd') do it { should be_mode 644 } end describe file('/etc/passwd') do it { should be_owned_by 'root' } end describe file('/etc/passwd') do it { should be_grouped_into 'root' } end serverspec-2.18.0/spec/type/gentoo/0000755000004100000410000000000012537110645017225 5ustar www-datawww-dataserverspec-2.18.0/spec/type/gentoo/service_spec.rb0000644000004100000410000000025512537110645022226 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'gentoo' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_running } end serverspec-2.18.0/spec/type/gentoo/package_spec.rb0000644000004100000410000000016312537110645022157 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'gentoo' describe package('httpd') do it { should be_installed } end serverspec-2.18.0/spec/type/ubuntu/0000755000004100000410000000000012537110645017254 5ustar www-datawww-dataserverspec-2.18.0/spec/type/ubuntu/service_spec.rb0000644000004100000410000000016012537110645022250 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'ubuntu' describe service('sshd') do it { should be_running } end serverspec-2.18.0/spec/type/ubuntu/ppa_spec.rb0000644000004100000410000000027112537110645021373 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'ubuntu' describe ppa('username/ppa-name') do it { should exist } end describe ppa('username/ppa-name') do it { should be_enabled } end serverspec-2.18.0/spec/type/redhat/0000755000004100000410000000000012537110645017201 5ustar www-datawww-dataserverspec-2.18.0/spec/type/redhat/service_spec.rb0000644000004100000410000000027212537110645022201 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'redhat' describe service('sshd') do it { should be_enabled } end describe service('sshd') do it { should be_enabled.with_level(4) } end serverspec-2.18.0/spec/type/redhat/package_spec.rb0000644000004100000410000000101712537110645022132 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'redhat' describe package('httpd') do it { should be_installed } end describe package('httpd') do it { should be_installed.with_version('2.2.15-28.el6') } end describe package('httpd') do it { should be_installed.by('rpm').with_version('2.2.15-28.el6') } 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' } end serverspec-2.18.0/spec/type/redhat/yumrepo_spec.rb0000644000004100000410000000024712537110645022243 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'redhat' describe yumrepo('epel') do it { should exist } end describe yumrepo('epel') do it { should be_enabled } end serverspec-2.18.0/spec/type/redhat/file_spec.rb0000644000004100000410000000051712537110645021462 0ustar www-datawww-datarequire 'spec_helper' set :os, :family => 'redhat' describe file('/tmp') do it { should be_readable.by_user('mail') } end describe file('/tmp') do it { should be_writable.by_user('mail') } end describe file('/tmp') do it { should be_executable.by_user('mail') } end describe file('/tmp') do it { should be_immutable } end serverspec-2.18.0/spec/spec_helper.rb0000644000004100000410000000133012537110645017564 0ustar www-datawww-datarequire 'serverspec' set :backend, :exec module Specinfra module Backend class Exec < Base def run_command cmd CommandResult.new({ :stdout => ::Specinfra.configuration.stdout, :stderr => ::Specinfra.configuration.stderr, :exit_status => ::Specinfra.configuration.exit_status, :exit_signal => nil, }) end end class Cmd < Base def run_command cmd CommandResult.new({ :stdout => ::Specinfra.configuration.stdout, :stderr => ::Specinfra.configuration.stderr, :exit_status => ::Specinfra.configuration.exit_status, :exit_signal => nil, }) end end end end serverspec-2.18.0/spec/helper/0000755000004100000410000000000012537110645016230 5ustar www-datawww-dataserverspec-2.18.0/spec/helper/type_spec.rb0000644000004100000410000000015412537110645020550 0ustar www-datawww-datarequire 'spec_helper' describe String do subject { String.new } it { should_not respond_to :host } end serverspec-2.18.0/.travis.yml0000644000004100000410000000056512537110645016136 0ustar www-datawww-datalanguage: ruby rvm: - 1.8.7 - 1.9.3 - 2.0.0 - 2.1.1 before_install: - gem update bundler script: - bundle exec rake spec sudo: false cache: bundler notifications: slack: secure: X1umGErES0zd+LXX1EqZZxrPZv2YOzbCNxiLLiSGmJLlZAEtlSkMPyr+M00Lrs2DFhn4blwKPm+5YCBvU7f9F4K5GthSl0qZYNpNX/lGNn6EGeBnzJ8rFVgwXPUv1rvrJq0NjeSGni3yAK69K/uX6QohGojAI3iI28/EbJ+uYQM= serverspec-2.18.0/lib/0000755000004100000410000000000012537110645014565 5ustar www-datawww-dataserverspec-2.18.0/lib/serverspec.rb0000644000004100000410000000223512537110645017275 0ustar www-datawww-datarequire 'rubygems' require 'specinfra' require 'rspec' require 'rspec/its' require 'serverspec/version' require 'serverspec/matcher' require 'serverspec/helper' require 'serverspec/setup' require 'serverspec/subject' require 'serverspec/commands/base' require 'rspec/core/formatters/base_formatter' require 'specinfra/helper/set' include Specinfra::Helper::Set module RSpec::Core::Notifications class FailedExampleNotification < ExampleNotification def failure_lines host = ENV['TARGET_HOST'] || Specinfra.configuration.host @failure_lines ||= begin lines = [] lines << "On host `#{host}'" if host lines << "Failure/Error: #{read_failed_line.strip}" lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/ exception.message.to_s.split("\n").each do |line| lines << " #{line}" if exception.message end lines << " #{example.metadata[:command]}" lines << " #{example.metadata[:stdout]}" if example.metadata[:stdout] lines << " #{example.metadata[:stderr]}" if example.metadata[:stderr] lines end end end end serverspec-2.18.0/lib/serverspec/0000755000004100000410000000000012537110645016746 5ustar www-datawww-dataserverspec-2.18.0/lib/serverspec/helper.rb0000644000004100000410000000030112537110645020544 0ustar www-datawww-data# Subject type helper require 'serverspec/helper/type' extend Serverspec::Helper::Type class RSpec::Core::ExampleGroup extend Serverspec::Helper::Type include Serverspec::Helper::Type end serverspec-2.18.0/lib/serverspec/subject.rb0000644000004100000410000000023512537110645020732 0ustar www-datawww-datamodule Serverspec class Subject def value(v=nil) if v.nil? @value else @value = v self end end end end serverspec-2.18.0/lib/serverspec/type/0000755000004100000410000000000012537110645017727 5ustar www-datawww-dataserverspec-2.18.0/lib/serverspec/type/yumrepo.rb0000644000004100000410000000030312537110645021750 0ustar www-datawww-datamodule Serverspec::Type class Yumrepo < Base def exists? @runner.check_yumrepo_exists(@name) end def enabled? @runner.check_yumrepo_is_enabled(@name) end end end serverspec-2.18.0/lib/serverspec/type/docker_image.rb0000644000004100000410000000010312537110645022657 0ustar www-datawww-datamodule Serverspec::Type class DockerImage < DockerBase end end serverspec-2.18.0/lib/serverspec/type/interface.rb0000644000004100000410000000114412537110645022214 0ustar www-datawww-datamodule Serverspec::Type class Interface < Base def exists? @runner.check_interface_exists(@name) end def speed ret = @runner.get_interface_speed_of(@name) val = ret.stdout.strip val = val.to_i if val.match(/^\d+$/) val end def has_ipv4_address?(ip_address) @runner.check_interface_has_ipv4_address(@name, ip_address) end def has_ipv6_address?(ip_address) @runner.check_interface_has_ipv6_address(@name, ip_address) end def up? ret = @runner.get_interface_link_state(@name) ret.stdout.strip == 'up' end end end serverspec-2.18.0/lib/serverspec/type/ppa.rb0000644000004100000410000000026712537110645021041 0ustar www-datawww-datamodule Serverspec::Type class Ppa < Base def exists? @runner.check_ppa_exists(@name) end def enabled? @runner.check_ppa_is_enabled(@name) end end end serverspec-2.18.0/lib/serverspec/type/selinux.rb0000644000004100000410000000051012537110645021737 0ustar www-datawww-datamodule Serverspec::Type class Selinux < Base def disabled? @runner.check_selinux_has_mode('disabled') end def enforcing? @runner.check_selinux_has_mode('enforcing') end def permissive? @runner.check_selinux_has_mode('permissive') end def to_s 'SELinux' end end end serverspec-2.18.0/lib/serverspec/type/routing_table.rb0000644000004100000410000000027712537110645023120 0ustar www-datawww-datamodule Serverspec::Type class RoutingTable < Base def has_entry?(entry) @runner.check_routing_table_has_entry(entry) end def to_s 'Routing Table' end end end serverspec-2.18.0/lib/serverspec/type/x509_private_key.rb0000644000004100000410000000133412537110645023364 0ustar www-datawww-datarequire 'time' module Serverspec::Type class X509PrivateKey < Base def valid? runner_res = @runner.run_command("openssl rsa -in #{name} -check -noout") ( runner_res.exit_status == 0 && runner_res.stdout.chomp == 'RSA key ok' ) end def encrypted? @runner.run_command("grep -wq \"^Proc-Type.*ENCRYPTED$\" #{name}").exit_status == 0 end def has_matching_certificate?(cert_file) mac_op = "openssl sha -sha512" h1 = @runner.run_command("openssl x509 -noout -modulus -in #{cert_file} | #{mac_op}") h2 = @runner.run_command("openssl rsa -noout -modulus -in #{name} | #{mac_op}") (h1.stdout == h2.stdout) && (h1.exit_status == 0) && (h2.exit_status == 0) end end end serverspec-2.18.0/lib/serverspec/type/bond.rb0000644000004100000410000000033112537110645021173 0ustar www-datawww-datamodule Serverspec::Type class Bond < Base def exists? @runner.check_bond_exists(@name) end def has_interface?(interface) @runner.check_bond_has_interface(@name, interface) end end end serverspec-2.18.0/lib/serverspec/type/iis_app_pool.rb0000644000004100000410000000207512537110645022735 0ustar www-datawww-datamodule Serverspec::Type class IisAppPool < Base def exists?() @runner.check_iis_app_pool_exists(@name) end def has_dotnet_version?(dotnet) @runner.check_iis_app_pool_has_dotnet_version(@name, dotnet) end def has_32bit_enabled?() @runner.check_iis_app_pool_has_32bit_enabled(@name) end def has_idle_timeout?(minutes) @runner.check_iis_app_pool_has_idle_timeout(@name, minutes) end def has_identity_type?(identity_type) @runner.check_iis_app_pool_has_identity_type(@name, identity_type) end def has_periodic_restart?(minutes) @runner.check_iis_app_pool_has_periodic_restart(@name, minutes) end def has_user_profile_enabled?() @runner.check_iis_app_pool_has_user_profile(@name) end def has_username?(username) @runner.check_iis_app_pool_has_username(@name, username) end def has_managed_pipeline_mode?(mode) @runner.check_iis_app_pool_has_managed_pipeline_mode(@name, mode) end def to_s %Q[IIS Application Pool "#{@name}"] end end end serverspec-2.18.0/lib/serverspec/type/selinux_module.rb0000644000004100000410000000037412537110645023314 0ustar www-datawww-datamodule Serverspec::Type class SelinuxModule < Base def enabled? @runner.check_selinux_module_is_enabled(@name) end def installed?(name, version=nil) @runner.check_selinux_module_is_installed(@name, version) end end end serverspec-2.18.0/lib/serverspec/type/process.rb0000644000004100000410000000100212537110645021723 0ustar www-datawww-datamodule Serverspec::Type class Process < Base def running? pid = @runner.get_process(@name, :format => "pid=").stdout not pid.empty? end def user get_column("user") end def group get_column("group") end def method_missing(meth) get_column(meth.to_s) end def get_column(keyword) ret = @runner.get_process(@name, :format => "#{keyword}=") val = ret.stdout.strip val = val.to_i if val.match(/^\d+$/) val end end end serverspec-2.18.0/lib/serverspec/type/windows_hot_fix.rb0000644000004100000410000000024612537110645023470 0ustar www-datawww-datamodule Serverspec::Type class WindowsHotFix < Base def installed?(provider, version) @runner.check_hot_fix_is_installed(@name, version) end end end serverspec-2.18.0/lib/serverspec/type/x509_certificate.rb0000644000004100000410000000421112537110645023321 0ustar www-datawww-datarequire 'time' module Serverspec::Type class X509Certificate < Base def certificate? (run_openssl_command_with("-noout").exit_status == 0) end def subject run_openssl_command_with("-subject -noout").stdout.chomp.gsub(/^subject= /,'') end def issuer run_openssl_command_with("-issuer -noout").stdout.chomp.gsub(/^issuer= /,'') end def email run_openssl_command_with("-email -noout").stdout.chomp end def fingerprint run_openssl_command_with("-fingerprint -noout").stdout.chomp end def alias run_openssl_command_with("-alias -noout").stdout.chomp end # Modern openssl use following output format for key length: # Public-Key: (4096 bit) # while ancient (0.9.8 for example) use # RSA Public Key: (2048 bit) def keylength len_str = run_openssl_command_with("-text -noout | grep -E 'Public(-| )Key: \\([[:digit:]]+ bit\\)'").stdout.chomp len_str.gsub(/^.*\(/,'').gsub(/ bit\)$/,'').to_i end def has_purpose?(p) grep_str = "#{p} : Yes" ( run_openssl_command_with("-purpose -noout | grep -wq \"#{grep_str}\""). exit_status == 0 ) end def valid? runner_res = run_openssl_command_with("-startdate -enddate -noout") return false if runner_res.exit_status != 0 date_map = parse_dates_str_to_map(runner_res.stdout) now = Time.now ( now >= date_map[:notBefore] && now <= date_map[:notAfter]) end def validity_in_days runner_res = run_openssl_command_with("-enddate -noout") return 0 if runner_res.exit_status != 0 date_map = parse_dates_str_to_map(runner_res.stdout) diff = date_map[:notAfter] - Time.now ( diff/(60*60*24) ) end private def run_openssl_command_with(param_str) @runner.run_command("openssl x509 -in #{name} #{param_str}") end def parse_dates_str_to_map(dates_str) dates_str.split("\n").inject({}) do |res,line| kv_arr = line.split '=' time = Time.strptime(kv_arr[1],'%b %e %T %Y %Z') rescue Time.parse(kv_arr[1] || '') res.merge({ kv_arr[0].to_sym => time }) end end end end serverspec-2.18.0/lib/serverspec/type/command.rb0000644000004100000410000000050612537110645021673 0ustar www-datawww-datamodule Serverspec::Type class Command < Base def stdout command_result.stdout end def stderr command_result.stderr end def exit_status command_result.exit_status.to_i end private def command_result() @command_result ||= @runner.run_command(@name) end end end serverspec-2.18.0/lib/serverspec/type/bridge.rb0000644000004100000410000000034012537110645021505 0ustar www-datawww-datamodule Serverspec::Type class Bridge < Base def exists? @runner.check_bridge_exists(@name) end def has_interface?(interface) @runner.check_bridge_has_interface(@name, interface) end end end serverspec-2.18.0/lib/serverspec/type/iptables.rb0000644000004100000410000000031112537110645022052 0ustar www-datawww-datamodule Serverspec::Type class Iptables < Base def has_rule?(rule, table, chain) @runner.check_iptables_has_rule(rule, table, chain) end def to_s 'iptables' end end end serverspec-2.18.0/lib/serverspec/type/lxc.rb0000644000004100000410000000035512537110645021045 0ustar www-datawww-datamodule Serverspec::Type class Lxc < Base def exists? @runner.check_lxc_container_exists(@name) end def running? @runner.check_lxc_container_is_running(@name) end def to_s 'LXC' end end end serverspec-2.18.0/lib/serverspec/type/user.rb0000644000004100000410000000170512537110645021235 0ustar www-datawww-datamodule Serverspec::Type class User < Base def exists? @runner.check_user_exists(@name) end def belongs_to_group?(group) @runner.check_user_belongs_to_group(@name, group) end def belongs_to_primary_group?(group) @runner.check_user_belongs_to_primary_group(@name, group) end def has_uid?(uid) @runner.check_user_has_uid(@name, uid) end def has_home_directory?(path) @runner.check_user_has_home_directory(@name, path) end def has_login_shell?(shell) @runner.check_user_has_login_shell(@name, shell) end def has_authorized_key?(key) @runner.check_user_has_authorized_key(@name, key) end def minimum_days_between_password_change @runner.get_user_minimum_days_between_password_change(@name).stdout.to_i end def maximum_days_between_password_change @runner.get_user_maximum_days_between_password_change(@name).stdout.to_i end end end serverspec-2.18.0/lib/serverspec/type/file.rb0000644000004100000410000000562212537110645021200 0ustar www-datawww-datarequire 'date' module Serverspec::Type class File < Base attr_accessor :content def file? cmd = Specinfra.command.get(:check_file_is_file, @name) @inspection = Specinfra.backend.build_command(cmd) @runner.check_file_is_file(@name) end def block_device? @runner.check_file_is_block_device(@name) end def character_device? @runner.check_file_is_character_device(@name) end def socket? @runner.check_file_is_socket(@name) end def directory? @runner.check_file_is_directory(@name) end def symlink? @runner.check_file_is_symlink(@name) end def pipe? @runner.check_file_is_pipe(@name) end def contain(pattern, from, to) if pattern.is_a?(Array) @runner.check_file_contains_lines(@name, pattern, from, to) else if (from || to).nil? @runner.check_file_contains(@name, pattern) else @runner.check_file_contains_within(@name, pattern, from, to) end end end def mode?(mode) @runner.check_file_has_mode(@name, mode) end def owned_by?(owner) @runner.check_file_is_owned_by(@name, owner) end def grouped_into?(group) @runner.check_file_is_grouped(@name, group) end def linked_to?(target) @runner.check_file_is_linked_to(@name, target) end def readable?(by_whom, by_user) if by_user != nil @runner.check_file_is_accessible_by_user(@name, by_user, 'r') else @runner.check_file_is_readable(@name, by_whom) end end def writable?(by_whom, by_user) if by_user != nil @runner.check_file_is_accessible_by_user(@name, by_user, 'w') else @runner.check_file_is_writable(@name, by_whom) end end def executable?(by_whom, by_user) if by_user != nil @runner.check_file_is_accessible_by_user(@name, by_user, 'x') else @runner.check_file_is_executable(@name, by_whom) end end def mounted?(attr, only_with) @runner.check_file_is_mounted(@name, attr, only_with) end def immutable? @runner.check_file_is_immutable(@name) end def exists? @runner.check_file_exists(@name) end def md5sum @runner.get_file_md5sum(@name).stdout.strip end def sha256sum @runner.get_file_sha256sum(@name).stdout.strip end def content if @content.nil? @content = @runner.get_file_content(@name).stdout end @content end def version?(version) @runner.check_file_has_version(@name, version) end def mtime d = @runner.get_file_mtime(@name).stdout.strip DateTime.strptime(d, '%s').new_offset(DateTime.now.offset) end def size @runner.get_file_size(@name).stdout.strip.to_i end def selinux_label @runner.get_file_selinuxlabel(@name).stdout.strip end end end serverspec-2.18.0/lib/serverspec/type/fstab.rb0000644000004100000410000000025012537110645021350 0ustar www-datawww-datamodule Serverspec::Type class Fstab < Base def has_entry?(entry) @runner.check_fstab_has_entry(entry) end def to_s 'Fstab' end end end serverspec-2.18.0/lib/serverspec/type/php_config.rb0000644000004100000410000000035312537110645022371 0ustar www-datawww-datamodule Serverspec::Type class PhpConfig < Base def value ret = @runner.run_command("php -r 'echo get_cfg_var( \"#{@name}\" );'") val = ret.stdout val = val.to_i if val.match(/^\d+$/) val end end end serverspec-2.18.0/lib/serverspec/type/cron.rb0000644000004100000410000000026112537110645021214 0ustar www-datawww-datamodule Serverspec::Type class Cron < Base def has_entry?(user, entry) @runner.check_cron_has_entry(user, entry) end def to_s 'Cron' end end end serverspec-2.18.0/lib/serverspec/type/cgroup.rb0000644000004100000410000000065712537110645021563 0ustar www-datawww-datamodule Serverspec::Type class Cgroup < Base attr_accessor :subsystem def method_missing(meth) if @subsystem.nil? @subsystem = meth.to_s self else param = "#{@subsystem}.#{meth.to_s}" ret = @runner.run_command("cgget -n -r #{param} #{@name} | awk '{print $2}'") val = ret.stdout.strip val = val.to_i if val.match(/^\d+$/) val end end end end serverspec-2.18.0/lib/serverspec/type/host.rb0000644000004100000410000000052112537110645021227 0ustar www-datawww-datamodule Serverspec::Type class Host < Base def resolvable?(type) @runner.check_host_is_resolvable(@name, type) end def reachable?(port, proto, timeout) @runner.check_host_is_reachable(@name, port, proto, timeout) end def ipaddress @runner.get_host_ipaddress(@name).stdout.strip end end end serverspec-2.18.0/lib/serverspec/type/kernel_module.rb0000644000004100000410000000021112537110645023073 0ustar www-datawww-datamodule Serverspec::Type class KernelModule < Base def loaded? @runner.check_kernel_module_is_loaded(@name) end end end serverspec-2.18.0/lib/serverspec/type/package.rb0000644000004100000410000000324312537110645021651 0ustar www-datawww-datamodule Serverspec::Type class Package < Base def installed?(provider=nil, version=nil) if provider.nil? @inspection = Specinfra.command.get(:check_package_is_installed, @name, version) @runner.check_package_is_installed(@name, version) else check_method = "check_package_is_installed_by_#{provider}".to_sym @runner.send(check_method, @name, version) end end def version ret = @runner.get_package_version(@name).stdout.strip if ret.empty? nil else Version.new(ret) end end class Version include Comparable attr_reader :epoch, :version def initialize(val) matches = val.match(/^(?:(\d+):)?(\d[0-9a-zA-Z.+:~_-]*)$/) if matches.nil? raise ArgumentError, "Malformed version number string #{val}" end @epoch = matches[1].to_i @version = matches[2].to_s end def <=>(other) other = Version.new(other) if other.is_a?(String) rv = @epoch <=> other.epoch return rv if rv != 0 self.ver_array <=> other.ver_array end def ver_array val = @version re = /^(?:(\d+)|(\D+))(.*)$/ res = [] until val.empty? matches = val.match(re) if matches[1].nil? # String matches[2].to_s.each_byte do |b| code_point = defined?("~".ord) ? "~".ord : ?~ res << ((b == code_point) ? -2 : b) end else # Digits res << matches[1].to_i end val = matches[3].to_s end res << -1 end end end end serverspec-2.18.0/lib/serverspec/type/group.rb0000644000004100000410000000030412537110645021405 0ustar www-datawww-datamodule Serverspec::Type class Group < Base def exists? @runner.check_group_exists(@name) end def has_gid?(gid) @runner.check_group_has_gid(@name, gid) end end end serverspec-2.18.0/lib/serverspec/type/mail_alias.rb0000644000004100000410000000023312537110645022345 0ustar www-datawww-datamodule Serverspec::Type class MailAlias < Base def aliased_to?(target) @runner.check_mail_alias_is_aliased_to(@name, target) end end end serverspec-2.18.0/lib/serverspec/type/windows_scheduled_task.rb0000644000004100000410000000021712537110645025010 0ustar www-datawww-datamodule Serverspec::Type class WindowsScheduledTask < Base def exists? @runner.check_scheduled_task_exists(@name) end end end serverspec-2.18.0/lib/serverspec/type/ipfilter.rb0000644000004100000410000000025512537110645022074 0ustar www-datawww-datamodule Serverspec::Type class Ipfilter < Base def has_rule?(rule) @runner.check_ipfilter_has_rule(rule) end def to_s 'ipfilter' end end end serverspec-2.18.0/lib/serverspec/type/iis_website.rb0000644000004100000410000000176012537110645022566 0ustar www-datawww-datamodule Serverspec::Type class IisWebsite < Base def exists?() @runner.check_iis_website_is_installed(@name) end def enabled?() @runner.check_iis_website_is_enabled(@name) end def running?() @runner.check_iis_website_is_running(@name) end def in_app_pool?(app_pool) @runner.check_iis_website_is_in_app_pool(@name, app_pool) end def has_physical_path?(path) @runner.check_iis_website_has_physical_path(@name, path) end def has_site_bindings?(port, protocol, ipaddress, host_header) @runner.check_iis_website_has_site_bindings(@name, port, protocol, ipaddress, host_header) end def has_virtual_dir?(vdir, path) @runner.check_iis_website_has_virtual_dir(@name, vdir, path) end def has_site_application?(app, pool, physical_path) @runner.check_iis_website_has_site_application(@name, app, pool, physical_path) end def to_s %Q[IIS Website "#{@name}"] end end end serverspec-2.18.0/lib/serverspec/type/port.rb0000644000004100000410000000202312537110645021235 0ustar www-datawww-datarequire 'resolv' module Serverspec::Type class Port < Base def protocols %w(udp tcp tcp6 udp6) end def options @options ||= {} end def protocol_matcher(protocol) protocol = protocol.to_s.downcase if protocols.include?(protocol) options[:protocol] = protocol else raise ArgumentError.new("`be_listening` matcher doesn't support #{protocol}") end end def local_address_matcher(local_address) if valid_ip_address?(local_address) options[:local_address] = local_address else raise ArgumentError.new("`be_listening` matcher requires valid IPv4 or IPv6 address") end end def listening?(protocol, local_address) protocol_matcher(protocol) if protocol local_address_matcher(local_address) if local_address @runner.check_port_is_listening(@name, options) end def valid_ip_address?(ip_address) !!(ip_address =~ Resolv::IPv4::Regex) || !!(ip_address =~ Resolv::IPv6::Regex) end end end serverspec-2.18.0/lib/serverspec/type/ipnat.rb0000644000004100000410000000024412537110645021367 0ustar www-datawww-datamodule Serverspec::Type class Ipnat < Base def has_rule?(rule) @runner.check_ipnat_has_rule(rule) end def to_s 'ipnat' end end end serverspec-2.18.0/lib/serverspec/type/windows_registry_key.rb0000644000004100000410000000121112537110645024541 0ustar www-datawww-datamodule Serverspec::Type class WindowsRegistryKey < Base def exists? @runner.check_registry_key_exists(@name) end def has_property?(property_name, property_type = :type_string) @runner.check_registry_key_has_property(@name, {:name => property_name, :type => property_type}) end def has_value?(value) @runner.check_registry_key_has_value(@name, {:name => '', :type => :type_string, :value => value}) end def has_property_value?(property_name, property_type, value) @runner.check_registry_key_has_value(@name, {:name => property_name, :type => property_type, :value => value}) end end end serverspec-2.18.0/lib/serverspec/type/windows_feature.rb0000644000004100000410000000024612537110645023463 0ustar www-datawww-datamodule Serverspec::Type class WindowsFeature < Base def installed?(provider, version) @runner.check_feature_is_enabled(@name, provider) end end end serverspec-2.18.0/lib/serverspec/type/docker_container.rb0000644000004100000410000000036612537110645023572 0ustar www-datawww-datamodule Serverspec::Type class DockerContainer < DockerBase def running? inspection['State']['Running'] end def has_volume?(container_path, host_path) inspection['Volumes'][container_path] == host_path end end end serverspec-2.18.0/lib/serverspec/type/default_gateway.rb0000644000004100000410000000037512537110645023426 0ustar www-datawww-datamodule Serverspec::Type class DefaultGateway < Base def ipaddress @runner.get_default_gateway(:gateway) end def interface @runner.get_default_gateway(:interface) end def to_s 'Default Gateway' end end end serverspec-2.18.0/lib/serverspec/type/linux_kernel_parameter.rb0000644000004100000410000000035512537110645025016 0ustar www-datawww-datamodule Serverspec::Type class LinuxKernelParameter < Base def value ret = @runner.run_command("/sbin/sysctl -q -n #{@name}") val = ret.stdout.strip val = val.to_i if val.match(/^\d+$/) val end end end serverspec-2.18.0/lib/serverspec/type/base.rb0000644000004100000410000000075312537110645021173 0ustar www-datawww-datamodule Serverspec::Type class Base attr_reader :name def initialize(name=nil) @name = name @runner = Specinfra::Runner end def to_s type = self.class.name.split(':')[-1] type.gsub!(/([a-z\d])([A-Z])/, '\1 \2') type.capitalize! %Q!#{type} "#{@name}"! end def inspect if defined?(PowerAssert) @inspection else to_s end end def to_ary to_s.split(" ") end end end serverspec-2.18.0/lib/serverspec/type/zfs.rb0000644000004100000410000000105212537110645021054 0ustar www-datawww-datamodule Serverspec::Type class Zfs < Base def exists? @runner.check_zfs_exists(@name) end def has_property?(property) @runner.check_zfs_has_property(@name, property) end def to_s 'ZFS' end def property get_property if @property.nil? @property end private def get_property @property = Hash.new @runner.get_zfs_property(@name).stdout.split(/\n/).each do |line| property, value = line.split(/\s+/) @property[property] = value end end end end serverspec-2.18.0/lib/serverspec/type/ip6tables.rb0000644000004100000410000000035212537110645022145 0ustar www-datawww-datamodule Serverspec module Type class Ip6tables < Base def has_rule?(rule, table, chain) @runner.check_ip6tables_has_rule(rule, table, chain) end def to_s 'ip6tables' end end end end serverspec-2.18.0/lib/serverspec/type/docker_base.rb0000644000004100000410000000105712537110645022520 0ustar www-datawww-datarequire 'multi_json' module Serverspec::Type class DockerBase < Base def exist? get_inspection.success? end def [](key) value = inspection key.split('.').each do |k| value = value[k] end value end def inspection return @inspection if @inspection @inspection = ::MultiJson.load(get_inspection.stdout)[0] end private def get_inspection return @get_inspection if @get_inspection @get_inspection = @runner.run_command("docker inspect #{@name}") end end end serverspec-2.18.0/lib/serverspec/type/service.rb0000644000004100000410000000233712537110645021721 0ustar www-datawww-datamodule Serverspec::Type class Service < Base def enabled?(level) if level @runner.check_service_is_enabled(@name, level) else @runner.check_service_is_enabled(@name) end end def installed?(name, version) @runner.check_service_is_installed(@name) end def has_start_mode?(mode) @runner.check_service_has_start_mode(@name, mode) end def running?(under) if under check_method = "check_service_is_running_under_#{under}".to_sym @runner.send(check_method, @name) else @runner.check_service_is_running(@name) end end def monitored_by?(monitor) check_method = "check_service_is_monitored_by_#{monitor}".to_sym res = @runner.send(check_method, @name) end def has_property?(property) @runner.check_service_has_property(@name, property) end def property get_property if @property.nil? @property end private def get_property @property = {} props = @runner.get_service_property(@name).stdout props.split(/\n/).each do |line| property, _type, *value = line.split(/\s+/) @property[property] = value.join(' ') end end end end serverspec-2.18.0/lib/serverspec/commands/0000755000004100000410000000000012537110645020547 5ustar www-datawww-dataserverspec-2.18.0/lib/serverspec/commands/base.rb0000644000004100000410000000014112537110645022002 0ustar www-datawww-datamodule Serverspec module Commands class Base < Specinfra::Command::Base end end end serverspec-2.18.0/lib/serverspec/version.rb0000644000004100000410000000005312537110645020756 0ustar www-datawww-datamodule Serverspec VERSION = "2.18.0" end serverspec-2.18.0/lib/serverspec/matcher/0000755000004100000410000000000012537110645020371 5ustar www-datawww-dataserverspec-2.18.0/lib/serverspec/matcher/have_site_application.rb0000644000004100000410000000070712537110645025254 0ustar www-datawww-dataRSpec::Matchers.define :have_site_application do |app| match do |subject| if subject.class.name == 'Serverspec::Type::IisWebsite' subject.has_site_application?(app, @pool, @physical_path) else className = subject.class.name raise "not supported class #{className}" end end chain :with_pool do |pool| @pool = pool end chain :with_physical_path do |physical_path| @physical_path = physical_path end end serverspec-2.18.0/lib/serverspec/matcher/be_installed.rb0000644000004100000410000000035012537110645023341 0ustar www-datawww-dataRSpec::Matchers.define :be_installed do match do |name| name.installed?(@provider, @version) end chain :by do |provider| @provider = provider end chain :with_version do |version| @version = version end end serverspec-2.18.0/lib/serverspec/matcher/have_site_bindings.rb0000644000004100000410000000104012537110645024535 0ustar www-datawww-dataRSpec::Matchers.define :have_site_bindings do |port| match do |subject| if subject.class.name == 'Serverspec::Type::IisWebsite' subject.has_site_bindings?(port, @protocol, @ipaddress, @host_header) else className = subject.class.name raise "not supported class #{className}" end end chain :with_protocol do |protocol| @protocol = protocol end chain :with_ipaddress do |ipaddress| @ipaddress = ipaddress end chain :with_host_header do |host_header| @host_header = host_header end end serverspec-2.18.0/lib/serverspec/matcher/be_listening.rb0000644000004100000410000000034712537110645023364 0ustar www-datawww-dataRSpec::Matchers.define :be_listening do match do |port| port.listening? @with, @local_address end chain :with do |with| @with = with end chain :on do |local_address| @local_address = local_address end end serverspec-2.18.0/lib/serverspec/matcher/be_writable.rb0000644000004100000410000000033512537110645023176 0ustar www-datawww-dataRSpec::Matchers.define :be_writable do match do |file| file.writable?(@by_whom, @by_user) end chain :by do |by_whom| @by_whom = by_whom end chain :by_user do |by_user| @by_user = by_user end end serverspec-2.18.0/lib/serverspec/matcher/be_executable.rb0000644000004100000410000000034112537110645023503 0ustar www-datawww-dataRSpec::Matchers.define :be_executable do match do |file| file.executable?(@by_whom, @by_user) end chain :by do |by_whom| @by_whom = by_whom end chain :by_user do |by_user| @by_user = by_user end end serverspec-2.18.0/lib/serverspec/matcher/be_mounted.rb0000644000004100000410000000040312537110645023034 0ustar www-datawww-dataRSpec::Matchers.define :be_mounted do match do |path| path.mounted?(@attr, @only_with) end chain :with do |attr| @attr = attr @only_with = false end chain :only_with do |attr| @attr = attr @only_with = true end end serverspec-2.18.0/lib/serverspec/matcher/contain.rb0000644000004100000410000000122312537110645022347 0ustar www-datawww-dataRSpec::Matchers.define :contain do |pattern| match do |resource| if resource.is_a?(String) resource.match(Regexp.new([@from, pattern, @to].compact.join.gsub('/', '.*'), Regexp::MULTILINE)) else resource.contain(pattern, @from, @to) end end # for contain(pattern).from(/A/).to(/B/) chain :from do |from| @from = Regexp.new(from).inspect end chain :to do |to| @to = Regexp.new(to).inspect end # for contain(pattern).after(/A/) chain :after do |after| @from = Regexp.new(after).inspect end # for contain(pattern).before(/B/) chain :before do |before| @to = Regexp.new(before).inspect end end serverspec-2.18.0/lib/serverspec/matcher/have_virtual_dir.rb0000644000004100000410000000052412537110645024246 0ustar www-datawww-dataRSpec::Matchers.define :have_virtual_dir do |vdir| match do |subject| if subject.class.name == 'Serverspec::Type::IisWebsite' subject.has_virtual_dir?(vdir, @path) else className = subject.class.name raise "not supported class #{className}" end end chain :with_path do |path| @path = path end end serverspec-2.18.0/lib/serverspec/matcher/be_running.rb0000644000004100000410000000037112537110645023045 0ustar www-datawww-dataRSpec::Matchers.define :be_running do match do |subject| if subject.class.name == 'Serverspec::Type::Service' subject.running?(@under) else subject.running? end end chain :under do |under| @under = under end end serverspec-2.18.0/lib/serverspec/matcher/have_rule.rb0000644000004100000410000000061312537110645022670 0ustar www-datawww-dataRSpec::Matchers.define :have_rule do |rule| match do |subject| if subject.class.name == 'Serverspec::Type::Iptables' || subject.class.name == 'Serverspec::Type::Ip6tables' subject.has_rule?(rule, @table, @chain) else subject.has_rule?(rule) end end chain :with_table do |table| @table = table end chain :with_chain do |chain| @chain = chain end end serverspec-2.18.0/lib/serverspec/matcher/have_entry.rb0000644000004100000410000000050412537110645023061 0ustar www-datawww-dataRSpec::Matchers.define :have_entry do |entry| match do |subject| if subject.class.name == 'Serverspec::Type::Cron' subject.has_entry?(@user, entry) elsif subject.respond_to?(:has_entry?) subject.has_entry?(entry) end end # For cron type chain :with_user do |user| @user = user end end serverspec-2.18.0/lib/serverspec/matcher/be_resolvable.rb0000644000004100000410000000021712537110645023522 0ustar www-datawww-dataRSpec::Matchers.define :be_resolvable do match do |name| name.resolvable?(@type) end chain :by do |type| @type = type end end serverspec-2.18.0/lib/serverspec/matcher/belong_to_primary_group.rb0000644000004100000410000000020112537110645025636 0ustar www-datawww-dataRSpec::Matchers.define :belong_to_primary_group do |group| match do |user| user.belongs_to_primary_group?(group) end end serverspec-2.18.0/lib/serverspec/matcher/be_enabled.rb0000644000004100000410000000037612537110645022764 0ustar www-datawww-dataRSpec::Matchers.define :be_enabled do match do |subject| if subject.class.name == 'Serverspec::Type::Service' subject.enabled?(@level) else subject.enabled? end end chain :with_level do |level| @level = level end end serverspec-2.18.0/lib/serverspec/matcher/belong_to_group.rb0000644000004100000410000000016112537110645024100 0ustar www-datawww-dataRSpec::Matchers.define :belong_to_group do |group| match do |user| user.belongs_to_group?(group) end end serverspec-2.18.0/lib/serverspec/matcher/be_readable.rb0000644000004100000410000000033512537110645023124 0ustar www-datawww-dataRSpec::Matchers.define :be_readable do match do |file| file.readable?(@by_whom, @by_user) end chain :by do |by_whom| @by_whom = by_whom end chain :by_user do |by_user| @by_user = by_user end end serverspec-2.18.0/lib/serverspec/matcher/be_reachable.rb0000644000004100000410000000053212537110645023272 0ustar www-datawww-dataRSpec::Matchers.define :be_reachable do match do |host| proto = 'tcp' timeout = 5 if @attr port = @attr[:port] proto = @attr[:proto] if @attr[:proto] timeout = @attr[:timeout] if @attr[:timeout] end host.reachable?(port, proto, timeout) end chain :with do |attr| @attr = attr end end serverspec-2.18.0/lib/serverspec/power_assert.rb0000644000004100000410000000040412537110645022006 0ustar www-datawww-datarequire 'test/unit' require 'specinfra' require 'serverspec/helper/type' PowerAssert.configure do |c| c.lazy_inspection = true end class Serverspec::TestCase < Test::Unit::TestCase extend Serverspec::Helper::Type include Serverspec::Helper::Type end serverspec-2.18.0/lib/serverspec/matcher.rb0000644000004100000410000000161612537110645020722 0ustar www-datawww-data# file require 'serverspec/matcher/be_mounted' require 'serverspec/matcher/contain' require 'serverspec/matcher/be_readable' require 'serverspec/matcher/be_writable' require 'serverspec/matcher/be_executable' # port require 'serverspec/matcher/be_listening' # host require 'serverspec/matcher/be_resolvable' require 'serverspec/matcher/be_reachable' # package require 'serverspec/matcher/be_installed' # service require 'serverspec/matcher/be_enabled' require 'serverspec/matcher/be_running' # user require 'serverspec/matcher/belong_to_group' require 'serverspec/matcher/belong_to_primary_group' # ipfiter, ipnat, iptables, ip6tables require 'serverspec/matcher/have_rule' # cron, fstab, routing_table require 'serverspec/matcher/have_entry' # iis_website require 'serverspec/matcher/have_site_application' require 'serverspec/matcher/have_site_bindings' require 'serverspec/matcher/have_virtual_dir' serverspec-2.18.0/lib/serverspec/helper/0000755000004100000410000000000012537110645020225 5ustar www-datawww-dataserverspec-2.18.0/lib/serverspec/helper/type.rb0000644000004100000410000000151112537110645021531 0ustar www-datawww-datamodule Serverspec module Helper module Type types = %w( base bridge bond cgroup command cron default_gateway file fstab group host iis_website iis_app_pool interface ipfilter ipnat iptables ip6tables kernel_module linux_kernel_parameter lxc mail_alias package php_config port ppa process routing_table selinux selinux_module service user yumrepo windows_feature windows_hot_fix windows_registry_key windows_scheduled_task zfs docker_base docker_image docker_container x509_certificate x509_private_key ) types.each {|type| require "serverspec/type/#{type}" } types.each do |type| define_method type do |*args| name = args.first eval "Serverspec::Type::#{type.to_camel_case}.new(name)" end end end end end serverspec-2.18.0/lib/serverspec/setup.rb0000644000004100000410000002005012537110645020430 0ustar www-datawww-datarequire 'pathname' require 'fileutils' require 'erb' module Serverspec class Setup def self.run ask_os_type if @os_type == 'UN*X' ask_unix_backend else ask_windows_backend end if @backend_type == 'ssh' print 'Vagrant instance y/n: ' @vagrant = $stdin.gets.chomp if @vagrant =~ (/(true|t|yes|y|1)$/i) @vagrant = true print 'Auto-configure Vagrant from Vagrantfile? y/n: ' auto_config = $stdin.gets.chomp if auto_config =~ (/(true|t|yes|y|1)$/i) auto_vagrant_configuration else print('Input vagrant instance name: ') @hostname = $stdin.gets.chomp end else @vagrant = false print('Input target host name: ') @hostname = $stdin.gets.chomp end elsif @backend_type == 'winrm' print('Input target host name: ') @hostname = $stdin.gets.chomp else @hostname = 'localhost' end ['spec', "spec/#{@hostname}"].each { |dir| safe_mkdir(dir) } safe_create_spec safe_create_spec_helper safe_create_rakefile safe_create_dotrspec end def self.ask_os_type prompt = <<-EOF Select OS type: 1) UN*X 2) Windows Select number: EOF print prompt.chop num = $stdin.gets.to_i - 1 puts @os_type = ['UN*X', 'Windows'][num] || 'UN*X' end def self.ask_unix_backend prompt = <<-EOF Select a backend type: 1) SSH 2) Exec (local) Select number: EOF print prompt.chop num = $stdin.gets.to_i - 1 puts @backend_type = ['ssh', 'exec'][num] || 'exec' end def self.ask_windows_backend prompt = <<-EOF Select a backend type: 1) WinRM 2) Cmd (local) Select number: EOF print prompt.chop num = $stdin.gets.to_i - 1 puts @backend_type = ['winrm', 'cmd'][num] || 'exec' end def self.safe_create_spec content = <<-EOF require 'spec_helper' describe package('httpd'), :if => os[:family] == 'redhat' do it { should be_installed } end describe package('apache2'), :if => os[:family] == 'ubuntu' do it { should be_installed } end describe service('httpd'), :if => os[:family] == 'redhat' do it { should be_enabled } it { should be_running } end describe service('apache2'), :if => os[:family] == 'ubuntu' do it { should be_enabled } it { should be_running } end describe service('org.apache.httpd'), :if => os[:family] == 'darwin' do it { should be_enabled } it { should be_running } end describe port(80) do it { should be_listening } end EOF if File.exists? "spec/#{@hostname}/sample_spec.rb" old_content = File.read("spec/#{@hostname}/sample_spec.rb") if old_content != content $stderr.puts "!! spec/#{@hostname}/sample_spec.rb already exists and differs from template" end else File.open("spec/#{@hostname}/sample_spec.rb", 'w') do |f| f.puts content end puts " + spec/#{@hostname}/sample_spec.rb" end end def self.safe_mkdir(dir) if File.exists? dir unless File.directory? dir $stderr.puts "!! #{dir} already exists and is not a directory" end else FileUtils.mkdir dir puts " + #{dir}/" end end def self.safe_create_spec_helper content = ERB.new(spec_helper_template, nil, '-').result(binding) if File.exists? 'spec/spec_helper.rb' old_content = File.read('spec/spec_helper.rb') if old_content != content $stderr.puts "!! spec/spec_helper.rb already exists and differs from template" end else File.open('spec/spec_helper.rb', 'w') do |f| f.puts content end puts ' + spec/spec_helper.rb' end end def self.safe_create_rakefile content = <<-'EOF' require 'rake' require 'rspec/core/rake_task' task :spec => 'spec:all' task :default => :spec namespace :spec do targets = [] Dir.glob('./spec/*').each do |dir| next unless File.directory?(dir) target = File.basename(dir) target = "_#{target}" if target == "default" targets << target end task :all => targets task :default => :all targets.each do |target| original_target = target == "_default" ? target[1..-1] : target desc "Run serverspec tests to #{original_target}" RSpec::Core::RakeTask.new(target.to_sym) do |t| ENV['TARGET_HOST'] = original_target t.pattern = "spec/#{original_target}/*_spec.rb" end end end EOF if File.exists? 'Rakefile' old_content = File.read('Rakefile') if old_content != content $stderr.puts '!! Rakefile already exists and differs from template' end else File.open('Rakefile', 'w') do |f| f.puts content end puts ' + Rakefile' end end def self.find_vagrantfile Pathname.new(Dir.pwd).ascend do |dir| path = File.expand_path('Vagrantfile', dir) return path if File.exists?(path) end nil end def self.auto_vagrant_configuration if find_vagrantfile vagrant_list = `vagrant status` list_of_vms = [] if vagrant_list != '' vagrant_list.each_line do |line| if match = /([\w-]+[\s]+)(created|aborted|not created|poweroff|running|saved)[\s](\(virtualbox\)|\(vmware\)|\(vmware_fusion\)|\(libvirt\))/.match(line) list_of_vms << match[1].strip! end end if list_of_vms.length == 1 @hostname = list_of_vms[0] else list_of_vms.each_with_index { |vm, index | puts "#{index}) #{vm}\n" } print 'Choose a VM from the Vagrantfile: ' chosen_vm = $stdin.gets.chomp @hostname = list_of_vms[chosen_vm.to_i] end else $stderr.puts 'Vagrant status error - Check your Vagrantfile or .vagrant' exit 1 end else $stderr.puts 'Vagrantfile not found in directory!' exit 1 end end def self.spec_helper_template template = <<-'EOF' require 'serverspec' <% if @backend_type == 'ssh' -%> require 'net/ssh' <% end -%> <%- if @vagrant -%> require 'tempfile' <% end -%> <% if @backend_type == 'winrm' -%> require 'winrm' <% end -%> set :backend, :<%= @backend_type %> <% if @os_type == 'UN*X' && @backend_type == 'ssh' -%> if ENV['ASK_SUDO_PASSWORD'] begin require 'highline/import' rescue LoadError fail "highline is not available. Try installing it." end set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false } else set :sudo_password, ENV['SUDO_PASSWORD'] end <%- if @backend_type == 'ssh' -%> host = ENV['TARGET_HOST'] <%- if @vagrant -%> `vagrant up #{host}` config = Tempfile.new('', Dir.tmpdir) config.write(`vagrant ssh-config #{host}`) config.close options = Net::SSH::Config.for(host, [config.path]) <%- else -%> options = Net::SSH::Config.for(host) <%- end -%> options[:user] ||= Etc.getlogin set :host, options[:host_name] || host set :ssh_options, options # Disable sudo # set :disable_sudo, true <%- end -%> # Set environment variables # set :env, :LANG => 'C', :LC_MESSAGES => 'C' # Set PATH # set :path, '/sbin:/usr/local/sbin:$PATH' <%- end -%> <% if @backend_type == 'winrm'-%> user = pass = endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true) winrm.set_timeout 300 # 5 minutes max timeout for any operation Specinfra.configuration.winrm = winrm <% end -%> EOF template end def self.safe_create_dotrspec content = <<-'EOF' --color --format documentation EOF if File.exists? '.rspec' old_content = File.read('.rspec') if old_content != content $stderr.puts '!! .rspec already exists and differs from template' end else File.open('.rspec', 'w') do |f| f.puts content end puts ' + .rspec' end end end end serverspec-2.18.0/metadata.yml0000644000004100000410000003270512537110645016331 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: serverspec version: !ruby/object:Gem::Version version: 2.18.0 platform: ruby authors: - Gosuke Miyashita autorequire: bindir: bin cert_chain: [] date: 2015-06-10 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '3.0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '3.0' - !ruby/object:Gem::Dependency name: rspec-its requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: multi_json requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: specinfra requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '2.35' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '2.35' - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.3' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.3' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 10.1.1 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 10.1.1 description: RSpec tests for your servers configured by Puppet, Chef, Itamae or anything else email: - gosukenator@gmail.com executables: - serverspec-init extensions: [] extra_rdoc_files: [] files: - ".gitignore" - ".gitmodules" - ".travis.yml" - Gemfile - Guardfile - LICENSE.txt - README.md - Rakefile - WINDOWS_SUPPORT.md - appveyor.yml - bin/serverspec-init - lib/serverspec.rb - lib/serverspec/commands/base.rb - lib/serverspec/helper.rb - lib/serverspec/helper/type.rb - lib/serverspec/matcher.rb - lib/serverspec/matcher/be_enabled.rb - lib/serverspec/matcher/be_executable.rb - lib/serverspec/matcher/be_installed.rb - lib/serverspec/matcher/be_listening.rb - lib/serverspec/matcher/be_mounted.rb - lib/serverspec/matcher/be_reachable.rb - lib/serverspec/matcher/be_readable.rb - lib/serverspec/matcher/be_resolvable.rb - lib/serverspec/matcher/be_running.rb - lib/serverspec/matcher/be_writable.rb - lib/serverspec/matcher/belong_to_group.rb - lib/serverspec/matcher/belong_to_primary_group.rb - lib/serverspec/matcher/contain.rb - lib/serverspec/matcher/have_entry.rb - lib/serverspec/matcher/have_rule.rb - lib/serverspec/matcher/have_site_application.rb - lib/serverspec/matcher/have_site_bindings.rb - lib/serverspec/matcher/have_virtual_dir.rb - lib/serverspec/power_assert.rb - lib/serverspec/setup.rb - lib/serverspec/subject.rb - lib/serverspec/type/base.rb - lib/serverspec/type/bond.rb - lib/serverspec/type/bridge.rb - lib/serverspec/type/cgroup.rb - lib/serverspec/type/command.rb - lib/serverspec/type/cron.rb - lib/serverspec/type/default_gateway.rb - lib/serverspec/type/docker_base.rb - lib/serverspec/type/docker_container.rb - lib/serverspec/type/docker_image.rb - lib/serverspec/type/file.rb - lib/serverspec/type/fstab.rb - lib/serverspec/type/group.rb - lib/serverspec/type/host.rb - lib/serverspec/type/iis_app_pool.rb - lib/serverspec/type/iis_website.rb - lib/serverspec/type/interface.rb - lib/serverspec/type/ip6tables.rb - lib/serverspec/type/ipfilter.rb - lib/serverspec/type/ipnat.rb - lib/serverspec/type/iptables.rb - lib/serverspec/type/kernel_module.rb - lib/serverspec/type/linux_kernel_parameter.rb - lib/serverspec/type/lxc.rb - lib/serverspec/type/mail_alias.rb - lib/serverspec/type/package.rb - lib/serverspec/type/php_config.rb - lib/serverspec/type/port.rb - lib/serverspec/type/ppa.rb - lib/serverspec/type/process.rb - lib/serverspec/type/routing_table.rb - lib/serverspec/type/selinux.rb - lib/serverspec/type/selinux_module.rb - lib/serverspec/type/service.rb - lib/serverspec/type/user.rb - lib/serverspec/type/windows_feature.rb - lib/serverspec/type/windows_hot_fix.rb - lib/serverspec/type/windows_registry_key.rb - lib/serverspec/type/windows_scheduled_task.rb - lib/serverspec/type/x509_certificate.rb - lib/serverspec/type/x509_private_key.rb - lib/serverspec/type/yumrepo.rb - lib/serverspec/type/zfs.rb - lib/serverspec/version.rb - serverspec.gemspec - spec/helper/type_spec.rb - spec/spec_helper.rb - spec/type/aix/file_spec.rb - spec/type/aix/group_spec.rb - spec/type/aix/package_spec.rb - spec/type/aix/port_spec.rb - spec/type/aix/service_spec.rb - spec/type/aix/user_spec.rb - spec/type/arch/file_spec.rb - spec/type/arch/package_spec.rb - spec/type/arch/service_spec.rb - spec/type/base/command_spec.rb - spec/type/base/cron_spec.rb - spec/type/base/default_gateway_spec.rb - spec/type/base/file_spec.rb - spec/type/base/group_spec.rb - spec/type/base/host_spec.rb - spec/type/base/mail_alias_spec.rb - spec/type/base/package_spec.rb - spec/type/base/php_config_spec.rb - spec/type/base/port_spec.rb - spec/type/base/process_spec.rb - spec/type/base/routing_table_spec.rb - spec/type/base/service_spec.rb - spec/type/base/user_spec.rb - spec/type/darwin/file_spec.rb - spec/type/darwin/package_spec.rb - spec/type/darwin/port_spec.rb - spec/type/darwin/service_spec.rb - spec/type/debian/package_spec.rb - spec/type/debian/service_spec.rb - spec/type/fedora/service_spec.rb - spec/type/fedora15/service_spec.rb - spec/type/fedora20/service_spec.rb - spec/type/freebsd/file_spec.rb - spec/type/freebsd/package_spec.rb - spec/type/freebsd/port_spec.rb - spec/type/freebsd/service_spec.rb - spec/type/freebsd10/package_spec.rb - spec/type/gentoo/package_spec.rb - spec/type/gentoo/service_spec.rb - spec/type/linux/bond_spec.rb - spec/type/linux/bridge_spec.rb - spec/type/linux/cgroup_spec.rb - spec/type/linux/docker_container_spec.rb - spec/type/linux/docker_image_spec.rb - spec/type/linux/file_spec.rb - spec/type/linux/fstab_spec.rb - spec/type/linux/interface_spec.rb - spec/type/linux/ip6tables_spec.rb - spec/type/linux/iptables_spec.rb - spec/type/linux/kernel_module_spec.rb - spec/type/linux/linux_kernel_parameter_spec.rb - spec/type/linux/lxc_container_spec.rb - spec/type/linux/selinux_module_spec.rb - spec/type/linux/selinux_spec.rb - spec/type/linux/x509_certificate_spec.rb - spec/type/linux/x509_private_key_spec.rb - spec/type/linux/zfs_spec.rb - spec/type/nixos/package_spec.rb - spec/type/nixos/service_spec.rb - spec/type/openbsd/file_spec.rb - spec/type/openbsd/interface_spec.rb - spec/type/openbsd/mail_alias_spec.rb - spec/type/openbsd/package_spec.rb - spec/type/openbsd/port_spec.rb - spec/type/openbsd/service_spec.rb - spec/type/openbsd/user_spec.rb - spec/type/opensuse/service_spec.rb - spec/type/plamo/package_spec.rb - spec/type/plamo/service_spec.rb - spec/type/redhat/file_spec.rb - spec/type/redhat/package_spec.rb - spec/type/redhat/service_spec.rb - spec/type/redhat/yumrepo_spec.rb - spec/type/redhat5/iptables_spec.rb - spec/type/redhat7/service_spec.rb - spec/type/smartos/package_spec.rb - spec/type/smartos/service_spec.rb - spec/type/solaris/cron_spec.rb - spec/type/solaris/file_spec.rb - spec/type/solaris/group_spec.rb - spec/type/solaris/host_spec.rb - spec/type/solaris/ipfilter_spec.rb - spec/type/solaris/ipnat_spec.rb - spec/type/solaris/package_spec.rb - spec/type/solaris/port_spec.rb - spec/type/solaris/service_spec.rb - spec/type/solaris/user_spec.rb - spec/type/solaris/zfs_spec.rb - spec/type/solaris10/file_spec.rb - spec/type/solaris10/group_spec.rb - spec/type/solaris10/host_spec.rb - spec/type/solaris10/package_spec.rb - spec/type/solaris10/user_spec.rb - spec/type/suse/package_spec.rb - spec/type/suse/service_spec.rb - spec/type/ubuntu/ppa_spec.rb - spec/type/ubuntu/service_spec.rb - spec/type/windows/command_spec.rb - spec/type/windows/feature_spec.rb - spec/type/windows/file_spec.rb - spec/type/windows/group_spec.rb - spec/type/windows/host_spec.rb - spec/type/windows/hot_fix_spec.rb - spec/type/windows/iis_app_pool_spec.rb - spec/type/windows/iis_webisite_spec.rb - spec/type/windows/package_spec.rb - spec/type/windows/port_spec.rb - spec/type/windows/registry_key_spec.rb - spec/type/windows/scheduled_task_spec.rb - spec/type/windows/service_spec.rb - spec/type/windows/user_spec.rb - wercker.yml homepage: http://serverspec.org/ licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: RSpec tests for your servers configured by Puppet, Chef, Itamae or anything else test_files: - spec/helper/type_spec.rb - spec/spec_helper.rb - spec/type/aix/file_spec.rb - spec/type/aix/group_spec.rb - spec/type/aix/package_spec.rb - spec/type/aix/port_spec.rb - spec/type/aix/service_spec.rb - spec/type/aix/user_spec.rb - spec/type/arch/file_spec.rb - spec/type/arch/package_spec.rb - spec/type/arch/service_spec.rb - spec/type/base/command_spec.rb - spec/type/base/cron_spec.rb - spec/type/base/default_gateway_spec.rb - spec/type/base/file_spec.rb - spec/type/base/group_spec.rb - spec/type/base/host_spec.rb - spec/type/base/mail_alias_spec.rb - spec/type/base/package_spec.rb - spec/type/base/php_config_spec.rb - spec/type/base/port_spec.rb - spec/type/base/process_spec.rb - spec/type/base/routing_table_spec.rb - spec/type/base/service_spec.rb - spec/type/base/user_spec.rb - spec/type/darwin/file_spec.rb - spec/type/darwin/package_spec.rb - spec/type/darwin/port_spec.rb - spec/type/darwin/service_spec.rb - spec/type/debian/package_spec.rb - spec/type/debian/service_spec.rb - spec/type/fedora/service_spec.rb - spec/type/fedora15/service_spec.rb - spec/type/fedora20/service_spec.rb - spec/type/freebsd/file_spec.rb - spec/type/freebsd/package_spec.rb - spec/type/freebsd/port_spec.rb - spec/type/freebsd/service_spec.rb - spec/type/freebsd10/package_spec.rb - spec/type/gentoo/package_spec.rb - spec/type/gentoo/service_spec.rb - spec/type/linux/bond_spec.rb - spec/type/linux/bridge_spec.rb - spec/type/linux/cgroup_spec.rb - spec/type/linux/docker_container_spec.rb - spec/type/linux/docker_image_spec.rb - spec/type/linux/file_spec.rb - spec/type/linux/fstab_spec.rb - spec/type/linux/interface_spec.rb - spec/type/linux/ip6tables_spec.rb - spec/type/linux/iptables_spec.rb - spec/type/linux/kernel_module_spec.rb - spec/type/linux/linux_kernel_parameter_spec.rb - spec/type/linux/lxc_container_spec.rb - spec/type/linux/selinux_module_spec.rb - spec/type/linux/selinux_spec.rb - spec/type/linux/x509_certificate_spec.rb - spec/type/linux/x509_private_key_spec.rb - spec/type/linux/zfs_spec.rb - spec/type/nixos/package_spec.rb - spec/type/nixos/service_spec.rb - spec/type/openbsd/file_spec.rb - spec/type/openbsd/interface_spec.rb - spec/type/openbsd/mail_alias_spec.rb - spec/type/openbsd/package_spec.rb - spec/type/openbsd/port_spec.rb - spec/type/openbsd/service_spec.rb - spec/type/openbsd/user_spec.rb - spec/type/opensuse/service_spec.rb - spec/type/plamo/package_spec.rb - spec/type/plamo/service_spec.rb - spec/type/redhat/file_spec.rb - spec/type/redhat/package_spec.rb - spec/type/redhat/service_spec.rb - spec/type/redhat/yumrepo_spec.rb - spec/type/redhat5/iptables_spec.rb - spec/type/redhat7/service_spec.rb - spec/type/smartos/package_spec.rb - spec/type/smartos/service_spec.rb - spec/type/solaris/cron_spec.rb - spec/type/solaris/file_spec.rb - spec/type/solaris/group_spec.rb - spec/type/solaris/host_spec.rb - spec/type/solaris/ipfilter_spec.rb - spec/type/solaris/ipnat_spec.rb - spec/type/solaris/package_spec.rb - spec/type/solaris/port_spec.rb - spec/type/solaris/service_spec.rb - spec/type/solaris/user_spec.rb - spec/type/solaris/zfs_spec.rb - spec/type/solaris10/file_spec.rb - spec/type/solaris10/group_spec.rb - spec/type/solaris10/host_spec.rb - spec/type/solaris10/package_spec.rb - spec/type/solaris10/user_spec.rb - spec/type/suse/package_spec.rb - spec/type/suse/service_spec.rb - spec/type/ubuntu/ppa_spec.rb - spec/type/ubuntu/service_spec.rb - spec/type/windows/command_spec.rb - spec/type/windows/feature_spec.rb - spec/type/windows/file_spec.rb - spec/type/windows/group_spec.rb - spec/type/windows/host_spec.rb - spec/type/windows/hot_fix_spec.rb - spec/type/windows/iis_app_pool_spec.rb - spec/type/windows/iis_webisite_spec.rb - spec/type/windows/package_spec.rb - spec/type/windows/port_spec.rb - spec/type/windows/registry_key_spec.rb - spec/type/windows/scheduled_task_spec.rb - spec/type/windows/service_spec.rb - spec/type/windows/user_spec.rb serverspec-2.18.0/.gitignore0000644000004100000410000000036012537110645016006 0ustar www-datawww-data*.gem *.rbc *.swp .bundle .rvmrc .versions.conf .config .yardoc .rspec .idea/ Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp Vagrantfile vendor/ .DS_Store Gemfile.local serverspec-2.18.0/WINDOWS_SUPPORT.md0000644000004100000410000000763612537110645016743 0ustar www-datawww-data## Windows support Serverspec is now providing a limited support for Microsoft Windows. If you want to test Windows based machines you need to set the target host's OS explicitly in your `spec/spec_helper.rb` For local testing (equivalent to the Exec option in Linux/Unix systems) simply do: ```ruby require 'serverspec' set :backend, :cmd set :os, :family => 'windows' ``` For remote testing you have to configure Windows Remote Management in order to communicate to the target host: ```ruby require 'serverspec' require 'winrm' set :backend, :winrm set :os, :family => 'windows' user = pass = endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true) winrm.set_timeout 300 # 5 minutes max timeout for any operation Specinfra.configuration.winrm = winrm ``` For how to configure the guest to accept WinRM connections and the different authentication mechanisms check the Microsoft WinRM documentation and verify the ones that are supported by [WinRb/WinRM](https://github.com/WinRb/WinRM). ###RSpec Examples for windows target hosts ```ruby describe file('c:/windows') do it { should be_directory } it { should be_readable } it { should_not be_writable.by('Everyone') } end describe file('c:/temp/test.txt') do it { should be_file } it { should contain "some text" } end describe package('Adobe AIR') do it { should be_installed} end describe service('DNS Client') do it { should be_installed } it { should be_enabled } it { should be_running } it { should have_start_mode("Manual") } end describe port(139) do it { should be_listening } end describe user('some.admin') do it { should exist } it { should belong_to_group('Administrators')} end describe group('Guests') do it { should exist } end describe group('MYDOMAIN\Domain Users') do it { should exist } end describe command('& "ipconfig"') do it { should return_stdout(/IPv4 Address(\.| )*: 192\.168\.1\.100/) } end describe windows_registry_key('HKEY_USERS\S-1-5-21-1319311448-2088773778-316617838-32407\Test MyKey') do it { should exist } it { should have_property('string value') } it { should have_property('binary value', :type_binary) } it { should have_property('dword value', :type_dword) } it { should have_value('test default data') } it { should have_property_value('multistring value', :type_multistring, "test\nmulti\nstring\ndata") } it { should have_property_value('qword value', :type_qword, 'adff32') } it { should have_property_value('binary value', :type_binary, 'dfa0f066') } end describe windows_feature('Minesweeper') do it{ should be_installed } it{ should be_installed.by("dism") } it{ should be_installed.by("powershell") } end describe iis_website("Default Website") do it { should exist } it { should be_enabled } it { should be_running } it { should be_in_app_pool "DefaultAppPool" } it { should have_physical_path "c:/inetpub/wwwroot" } end describe iis_app_pool("DefaultAppPool") do it { should exist } it { should have_dotnet_version "2.0" } end ``` ###Notes: * Not all the matchers you are used to in Linux-like OS are supported in Windows, some because of differences between the operating systems (e.g. users and permissions model), some because they haven't been yet implemented. * All commands in the windows backend are run via powershell, so the output in case of stderr is a pretty ugly xml-like thing. Still it should contain some information to help troubleshooting. * The *command* type is executed again through powershell, so bear that in mind if you mean to run old CMD windows batch or programs. (i.e run the command using the **Invoke-Expression** Cmdlet, or the **&** Call Operator) * You may have to change Exectution Policy on the machine at both, machine and user level in order for tests to run: Get-ExecutionPolicy -list|%{set-executionpolicy bypass -scope $_.scope} serverspec-2.18.0/README.md0000644000004100000410000000164612537110645015305 0ustar www-datawww-data# Serverspec [![Gem Version](https://badge.fury.io/rb/serverspec.png)](http://badge.fury.io/rb/serverspec) [![BuildStatus](https://secure.travis-ci.org/serverspec/serverspec.png)](http://travis-ci.org/serverspec/serverspec) [![Code Climate](https://codeclimate.com/github/serverspec/serverspec.png)](https://codeclimate.com/github/serverspec/serverspec) [![wercker status](https://app.wercker.com/status/526d1ff4df6eadaa793dca1affcaed35/s/ "wercker status")](https://app.wercker.com/project/bykey/526d1ff4df6eadaa793dca1affcaed35) RSpec tests for your servers configured by Puppet, Chef or anything else You can see the details of serverspec on [serverspec.org](http://serverspec.org/). ---- ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request serverspec-2.18.0/.gitmodules0000644000004100000410000000017512537110645016177 0ustar www-datawww-data[submodule "integration-test"] path = integration-test url = https://github.com/serverspec/serverspec-integration-test.git serverspec-2.18.0/Guardfile0000644000004100000410000000014212537110645015641 0ustar www-datawww-dataguard :rspec do watch(%r{^spec/.+/.+_spec\.rb$}) watch('spec/spec_helper.rb') { "spec" } end