[DRE-commits] [ruby-serverspec] 01/09: New upstream version 2.38.0

Daisuke Higuchi dai at moszumanska.debian.org
Sun Aug 13 02:41:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

dai pushed a commit to branch master
in repository ruby-serverspec.

commit 8e0fb4e38e81c16b189620ff622e19fa33cfeed4
Author: HIGUCHI Daisuke (VDR dai) <dai at debian.org>
Date:   Sun Aug 13 11:28:38 2017 +0900

    New upstream version 2.38.0
---
 .gitignore                                         |   2 +
 .travis.yml                                        |   2 +
 Gemfile                                            |   7 +-
 README.md                                          |  23 +-
 Rakefile                                           |   1 +
 WINDOWS_SUPPORT.md                                 |   2 +-
 appveyor.yml                                       |  25 +-
 lib/serverspec.rb                                  |  26 ++
 lib/serverspec/helper/type.rb                      |  19 +-
 lib/serverspec/matcher.rb                          |   5 +
 lib/serverspec/matcher/be_enabled.rb               |  13 +-
 lib/serverspec/matcher/be_enforcing.rb             |  10 +
 lib/serverspec/matcher/be_installed.rb             |  13 +-
 lib/serverspec/matcher/be_listening.rb             |   7 +
 lib/serverspec/matcher/be_monitored_by.rb          |  17 +
 lib/serverspec/matcher/be_permissive.rb            |  10 +
 lib/serverspec/matcher/be_running.rb               |   6 +
 lib/serverspec/matcher/have_rule.rb                |   8 +
 lib/serverspec/setup.rb                            |   2 +-
 lib/serverspec/type/base.rb                        |   7 +-
 lib/serverspec/type/command.rb                     |   6 +
 lib/serverspec/type/cron.rb                        |   4 +
 lib/serverspec/type/docker_base.rb                 |   9 +-
 lib/serverspec/type/docker_container.rb            |  18 +-
 lib/serverspec/type/file.rb                        |  30 +-
 lib/serverspec/type/hadoop_config.rb               |  27 ++
 lib/serverspec/type/host.rb                        |   6 +
 lib/serverspec/type/interface.rb                   |  26 +-
 lib/serverspec/type/json_file.rb                   |   9 +
 lib/serverspec/type/linux_audit_system.rb          |  45 +++
 lib/serverspec/type/mysql_config.rb                |  10 +
 lib/serverspec/type/php_config.rb                  |   4 +-
 lib/serverspec/type/php_extension.rb               |  11 +
 lib/serverspec/type/process.rb                     |   4 +
 lib/serverspec/type/selinux.rb                     |   8 +-
 lib/serverspec/type/selinux_module.rb              |   6 +-
 lib/serverspec/type/service.rb                     |  14 +-
 lib/serverspec/type/user.rb                        |   4 +
 lib/serverspec/type/x509_certificate.rb            |   9 +
 lib/serverspec/type/x509_private_key.rb            |   5 +-
 lib/serverspec/version.rb                          |   2 +-
 metadata.yml                                       | 440 ---------------------
 serverspec.gemspec                                 |   3 +-
 spec/type/aix/file_spec.rb                         |   6 +-
 spec/type/base/command_spec.rb                     |  39 ++
 spec/type/base/file_spec.rb                        |  64 ++-
 spec/type/base/host_spec.rb                        |  11 +
 spec/type/base/json_file_spec.rb                   |  27 ++
 spec/type/base/mysql_config_spec.rb                |  13 +
 spec/type/base/php_config_spec.rb                  |   4 +
 spec/type/base/php_extension_spec.rb               |  13 +
 spec/type/base/service_spec.rb                     |   9 +-
 spec/type/base/user_spec.rb                        |   7 +-
 ...er_spec.rb => docker_container_pre_1_8_spec.rb} |  24 +-
 spec/type/linux/docker_container_spec.rb           |  41 +-
 spec/type/linux/interface_spec.rb                  |  20 +
 spec/type/linux/linux_audit_system_spec.rb         | 139 +++++++
 spec/type/linux/selinux_module_spec.rb             |   4 +
 spec/type/linux/selinux_spec.rb                    |   8 +
 spec/type/linux/x509_certificate_spec.rb           |  16 +
 spec/type/openbsd/interface_spec.rb                |  10 +
 spec/type/solaris10/file_spec.rb                   |   2 +-
 spec/type/windows/file_spec.rb                     |  19 +-
 spec/type/windows/group_spec.rb                    |   2 +-
 spec/type/windows/service_spec.rb                  |   4 +-
 spec/type/windows/user_spec.rb                     |   2 +-
 wercker.yml                                        |   2 +-
 67 files changed, 864 insertions(+), 527 deletions(-)

diff --git a/.gitignore b/.gitignore
index 88e8dc0..1c9a4d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,5 @@ Vagrantfile
 vendor/
 .DS_Store
 Gemfile.local
+upstream.sh
+
diff --git a/.travis.yml b/.travis.yml
index 8316b81..7937a0f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,8 @@ rvm:
   - 1.9.3
   - 2.0.0
   - 2.1.1
+  - 2.2.4
+  - 2.3.0
 
 before_install:
   - gem update bundler
diff --git a/Gemfile b/Gemfile
index c48e3eb..7b5fd1a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,7 @@ source '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?
+if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
+  # net-ssh 3.x dropped Ruby 1.8 and 1.9 support.
+  gem 'net-ssh', '~> 2.7'
+end
diff --git a/README.md b/README.md
index bd15e20..c69fa25 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# 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/b [...]
+# Serverspec [![Gem Version](https://badge.fury.io/rb/serverspec.svg)](http://badge.fury.io/rb/serverspec) [![BuildStatus](https://secure.travis-ci.org/mizzy/serverspec.svg)](http://travis-ci.org/mizzy/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
 
@@ -6,6 +6,27 @@ You can see the details of serverspec on [serverspec.org](http://serverspec.org/
 
 ----
 
+## Running the gem's tests
+
+Use
+
+```bundle exec rake```
+
+(Using ```rspec``` alone will not work).
+
+
+
+## Maintenance policy of Serverspec/Specinfra
+
+* The person who found a bug should fix the bug by themself.
+* If you find a bug and cannot fix it by yourself, send a pull request and attach test code to reproduce the bug, please.
+* The person who want a new feature should implement it by themself.
+* For above reasons, I accept pull requests only and disable issues.
+* If you'd like to discuss about a new feature before implement it, make an empty commit and send [a WIP pull request](http://ben.straub.cc/2015/04/02/wip-pull-request/). But It is better that the WIP PR has some code than an empty commit.
+
+
+----
+
 ## Contributing
 
 1. Fork it
diff --git a/Rakefile b/Rakefile
index 5664a44..17c93c7 100644
--- a/Rakefile
+++ b/Rakefile
@@ -6,6 +6,7 @@ rescue LoadError
 end
 
 if defined?(RSpec)
+  task :default => 'spec:all'
   task :spec => 'spec:all'
 
   namespace :spec do
diff --git a/WINDOWS_SUPPORT.md b/WINDOWS_SUPPORT.md
index 67fcfa5..17bbee3 100644
--- a/WINDOWS_SUPPORT.md
+++ b/WINDOWS_SUPPORT.md
@@ -76,7 +76,7 @@ describe group('MYDOMAIN\Domain Users') do
 end
 
 describe command('& "ipconfig"') do
-  it { should return_stdout(/IPv4 Address(\.| )*: 192\.168\.1\.100/) }
+  its(:stdout) { should match /IPv4 Address(\.| )*: 192\.168\.1\.100/ }
 end
 
 describe windows_registry_key('HKEY_USERS\S-1-5-21-1319311448-2088773778-316617838-32407\Test MyKey') do
diff --git a/appveyor.yml b/appveyor.yml
index 3221997..0917fe1 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,6 +1,6 @@
 version: "{build}"
+image: Previous Visual Studio 2015
 
-os: Windows Server 2012
 platform:
   - x64
 
@@ -13,27 +13,29 @@ environment:
     - ruby_version: "200"
     - ruby_version: "21"
     - ruby_version: "22"
+    - ruby_version: "23"
 
 matrix:
   allow_failures:
-    - ruby_version: "22" # waiting for net-ssh update
+    - ruby_version: "193"
 
 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
+  - C:\Ruby193\lib\ruby\gems\1.9.1 -> appveyor.yml
+  - C:\Ruby193\bin                 -> appveyor.yml
+  - C:\Ruby200\lib\ruby\gems\2.0.0 -> appveyor.yml
+  - C:\Ruby200\bin                 -> appveyor.yml
+  - C:\Ruby21\lib\ruby\gems\2.1.0  -> appveyor.yml
+  - C:\Ruby21\bin                  -> appveyor.yml
+  - C:\Ruby22\lib\ruby\gems\2.2.0  -> appveyor.yml
+  - C:\Ruby22\bin                  -> appveyor.yml
+  - C:\Ruby23\lib\ruby\gems\2.2.0  -> appveyor.yml
+  - C:\Ruby23\bin                  -> appveyor.yml
 
 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"}
@@ -45,6 +47,7 @@ install:
   - 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`..?
+  - ps: $PSVersionTable
 
 build_script:
   - ruby -rfileutils -e 'FileUtils.rm_r(File.join(Gem.dir, "cache", "bundler")) if Dir.exists?(File.join(Gem.dir, "cache", "bundler"))'
diff --git a/lib/serverspec.rb b/lib/serverspec.rb
index 9a001f5..38b7ca4 100644
--- a/lib/serverspec.rb
+++ b/lib/serverspec.rb
@@ -33,3 +33,29 @@ module RSpec::Core::Notifications
     end
   end
 end
+
+# For RSpec 3.3.x
+if defined?(RSpec::Core::Formatters::ExceptionPresenter)
+  class RSpec::Core::Formatters::ExceptionPresenter
+    def failure_lines
+      host = ENV['TARGET_HOST'] || Specinfra.configuration.host
+      @failure_lines ||=
+        begin
+          lines = []
+          lines << "On host `#{host}'" if host
+          error_lines = []
+          error_lines = [failure_slash_error_line] if defined?(failure_slash_error_line)
+          error_lines = failure_slash_error_lines if defined?(failure_slash_error_lines)
+          lines += error_lines unless (description == error_lines.join(''))
+          lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
+          encoded_string(exception.message.to_s).split("\n").each do |line|
+            lines << "  #{line}"
+          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
diff --git a/lib/serverspec/helper/type.rb b/lib/serverspec/helper/type.rb
index 7c5153c..aeb5cb3 100644
--- a/lib/serverspec/helper/type.rb
+++ b/lib/serverspec/helper/type.rb
@@ -2,21 +2,22 @@ module 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
+        base bridge bond cgroup command cron default_gateway file fstab
+        group host iis_website iis_app_pool interface ipfilter ipnat
+        iptables ip6tables json_file kernel_module linux_kernel_parameter lxc
+        mail_alias mysql_config 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
+        linux_audit_system hadoop_config php_extension
       )
 
       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)"
+          eval "Serverspec::Type::#{type.to_camel_case}.new(*args)"
         end
       end
     end
diff --git a/lib/serverspec/matcher.rb b/lib/serverspec/matcher.rb
index 5aa695d..203bb66 100644
--- a/lib/serverspec/matcher.rb
+++ b/lib/serverspec/matcher.rb
@@ -15,9 +15,14 @@ require 'serverspec/matcher/be_reachable'
 # package
 require 'serverspec/matcher/be_installed'
 
+# selinux
+require 'serverspec/matcher/be_enforcing'
+require 'serverspec/matcher/be_permissive'
+
 # service
 require 'serverspec/matcher/be_enabled'
 require 'serverspec/matcher/be_running'
+require 'serverspec/matcher/be_monitored_by'
 
 # user
 require 'serverspec/matcher/belong_to_group'
diff --git a/lib/serverspec/matcher/be_enabled.rb b/lib/serverspec/matcher/be_enabled.rb
index 9bcfe84..e17730b 100644
--- a/lib/serverspec/matcher/be_enabled.rb
+++ b/lib/serverspec/matcher/be_enabled.rb
@@ -1,13 +1,24 @@
 RSpec::Matchers.define :be_enabled do
   match do |subject|
     if subject.class.name == 'Serverspec::Type::Service'
-      subject.enabled?(@level)
+      subject.enabled?(@level, @under)
     else
       subject.enabled?
     end
   end
 
+  description do
+    message = 'be enabled'
+    message << " under #{@under}" if @under
+    message << " with level #{@level}" if @level
+    message
+  end
+
   chain :with_level do |level|
     @level = level
   end
+
+  chain :under do |under|
+    @under = under
+  end
 end
diff --git a/lib/serverspec/matcher/be_enforcing.rb b/lib/serverspec/matcher/be_enforcing.rb
new file mode 100644
index 0000000..3832941
--- /dev/null
+++ b/lib/serverspec/matcher/be_enforcing.rb
@@ -0,0 +1,10 @@
+RSpec::Matchers.define :be_enforcing do
+  match do |selinux|
+    selinux.enforcing?(@with_policy)
+  end
+
+  chain :with_policy do |with_policy|
+    @with_policy = with_policy
+  end
+
+end
diff --git a/lib/serverspec/matcher/be_installed.rb b/lib/serverspec/matcher/be_installed.rb
index 6d62100..5d81520 100644
--- a/lib/serverspec/matcher/be_installed.rb
+++ b/lib/serverspec/matcher/be_installed.rb
@@ -1,6 +1,17 @@
 RSpec::Matchers.define :be_installed do
   match do |name|
-    name.installed?(@provider, @version)
+    if subject.class.name == 'Serverspec::Type::SelinuxModule'
+      name.installed?(@version)
+    else
+      name.installed?(@provider, @version)
+    end
+  end
+
+  description do
+    message = 'be installed'
+    message << %( by "#{@provider}") if @provider
+    message << %( with version "#{@version}") if @version
+    message
   end
 
   chain :by do |provider|
diff --git a/lib/serverspec/matcher/be_listening.rb b/lib/serverspec/matcher/be_listening.rb
index 67c99dc..fb026fa 100644
--- a/lib/serverspec/matcher/be_listening.rb
+++ b/lib/serverspec/matcher/be_listening.rb
@@ -3,6 +3,13 @@ RSpec::Matchers.define :be_listening do
     port.listening? @with, @local_address
   end
 
+  description do
+    message = 'be listening'
+    message << " on #{@local_address}" if @local_address
+    message << " with #{@with}" if @with
+    message
+  end
+
   chain :with do |with|
     @with = with
   end
diff --git a/lib/serverspec/matcher/be_monitored_by.rb b/lib/serverspec/matcher/be_monitored_by.rb
new file mode 100644
index 0000000..14a07b5
--- /dev/null
+++ b/lib/serverspec/matcher/be_monitored_by.rb
@@ -0,0 +1,17 @@
+RSpec::Matchers.define :be_monitored_by do |monitor|
+  match do |service|
+    service.monitored_by?(monitor, @monitor_name)
+  end
+  description do 
+    if @monitor_name
+      "be monitored by #{monitor} with name #{@monitor_name}"
+    else 
+      "be monitored by #{monitor}" 
+    end 
+  end 
+
+  chain :with_name do |name|
+    @monitor_name = (name ? name : nil)
+  end
+
+end
diff --git a/lib/serverspec/matcher/be_permissive.rb b/lib/serverspec/matcher/be_permissive.rb
new file mode 100644
index 0000000..d2a5d16
--- /dev/null
+++ b/lib/serverspec/matcher/be_permissive.rb
@@ -0,0 +1,10 @@
+RSpec::Matchers.define :be_permissive do
+  match do |selinux|
+    selinux.permissive?(@with_policy)
+  end
+
+  chain :with_policy do |with_policy|
+    @with_policy = with_policy
+  end
+
+end
diff --git a/lib/serverspec/matcher/be_running.rb b/lib/serverspec/matcher/be_running.rb
index 3f80544..ed7f42b 100644
--- a/lib/serverspec/matcher/be_running.rb
+++ b/lib/serverspec/matcher/be_running.rb
@@ -7,6 +7,12 @@ RSpec::Matchers.define :be_running do
     end
   end
 
+  description do
+    message = 'be running'
+    message << " under #{@under}" if @under
+    message
+  end
+
   chain :under do |under|
     @under = under
   end
diff --git a/lib/serverspec/matcher/have_rule.rb b/lib/serverspec/matcher/have_rule.rb
index 88982ec..53bba1c 100644
--- a/lib/serverspec/matcher/have_rule.rb
+++ b/lib/serverspec/matcher/have_rule.rb
@@ -7,6 +7,14 @@ RSpec::Matchers.define :have_rule do |rule|
     end
   end
 
+  description do
+    message = %Q{have rule "#{rule}"}
+    message << " with table #{@table}" if @table
+    message << ' and' if @table && @chain
+    message << " with chain #{@chain}" if @chain
+    message
+  end
+
   chain :with_table do |table|
     @table = table
   end
diff --git a/lib/serverspec/setup.rb b/lib/serverspec/setup.rb
index 097e65b..379621f 100644
--- a/lib/serverspec/setup.rb
+++ b/lib/serverspec/setup.rb
@@ -298,7 +298,7 @@ set :ssh_options, options
 
 
 # Set environment variables
-# set :env, :LANG => 'C', :LC_MESSAGES => 'C' 
+# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
 
 # Set PATH
 # set :path, '/sbin:/usr/local/sbin:$PATH'
diff --git a/lib/serverspec/type/base.rb b/lib/serverspec/type/base.rb
index f44695e..5503bbc 100644
--- a/lib/serverspec/type/base.rb
+++ b/lib/serverspec/type/base.rb
@@ -3,9 +3,10 @@ module Serverspec::Type
     
     attr_reader :name
     
-    def initialize(name=nil)
-      @name   = name
-      @runner = Specinfra::Runner
+    def initialize(name=nil, options = {})
+      @name    = name
+      @options = options
+      @runner  = Specinfra::Runner
     end
 
     def to_s
diff --git a/lib/serverspec/type/command.rb b/lib/serverspec/type/command.rb
index 2a52e84..d343295 100644
--- a/lib/serverspec/type/command.rb
+++ b/lib/serverspec/type/command.rb
@@ -1,9 +1,15 @@
+require 'multi_json'
+
 module Serverspec::Type
   class Command < Base
     def stdout
       command_result.stdout
     end
 
+    def stdout_as_json
+      MultiJson.load(command_result.stdout)
+    end
+
     def stderr
       command_result.stderr
     end
diff --git a/lib/serverspec/type/cron.rb b/lib/serverspec/type/cron.rb
index 79419a2..e799365 100644
--- a/lib/serverspec/type/cron.rb
+++ b/lib/serverspec/type/cron.rb
@@ -4,6 +4,10 @@ module Serverspec::Type
       @runner.check_cron_has_entry(user, entry)
     end
 
+    def table
+      @runner.get_cron_table.stdout
+    end
+
     def to_s
       'Cron'
     end
diff --git a/lib/serverspec/type/docker_base.rb b/lib/serverspec/type/docker_base.rb
index b5105b6..43410a3 100644
--- a/lib/serverspec/type/docker_base.rb
+++ b/lib/serverspec/type/docker_base.rb
@@ -9,20 +9,19 @@ module Serverspec::Type
     def [](key)
       value = inspection
       key.split('.').each do |k|
-        value = value[k]
+        is_index = k.start_with?('[') && k.end_with?(']')
+        value = value[is_index ? k[1..-2].to_i : k]
       end
       value
     end
 
     def inspection
-      return @inspection if @inspection
-      @inspection = ::MultiJson.load(get_inspection.stdout)[0]
+      @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}")
+      @get_inspection ||= @runner.run_command("docker inspect #{@name}")
     end
   end
 end
diff --git a/lib/serverspec/type/docker_container.rb b/lib/serverspec/type/docker_container.rb
index 0903a4b..217ad19 100644
--- a/lib/serverspec/type/docker_container.rb
+++ b/lib/serverspec/type/docker_container.rb
@@ -1,10 +1,26 @@
 module Serverspec::Type
   class DockerContainer < DockerBase
     def running?
-      inspection['State']['Running']
+      inspection['State']['Running'] && !inspection['State']['Restarting']
     end
 
     def has_volume?(container_path, host_path)
+      if (inspection['Mounts'])
+        check_volume(container_path, host_path)
+      else
+        check_volume_pre_1_8(container_path, host_path)
+      end
+    end
+
+    private
+    def check_volume(container_path, host_path)
+      inspection['Mounts'].find {|mount|
+        mount['Destination'] == container_path &&
+        mount['Source'] == host_path
+      }
+    end
+
+    def check_volume_pre_1_8(container_path, host_path)
       inspection['Volumes'][container_path] == host_path
     end
   end
diff --git a/lib/serverspec/type/file.rb b/lib/serverspec/type/file.rb
index 1513f3c..0a20b76 100644
--- a/lib/serverspec/type/file.rb
+++ b/lib/serverspec/type/file.rb
@@ -1,4 +1,6 @@
 require 'date'
+require 'multi_json'
+require 'yaml'
 
 module Serverspec::Type
   class File < Base
@@ -6,7 +8,7 @@ module Serverspec::Type
 
     def file?
       cmd = Specinfra.command.get(:check_file_is_file, @name)
-      @inspection = Specinfra.backend.build_command(cmd)
+      @inspection = Specinfra.backend.build_command(cmd.to_s)
       @runner.check_file_is_file(@name)
     end
 
@@ -113,15 +115,41 @@ module Serverspec::Type
       @content
     end
 
+    def content_as_json
+      @content_as_json = MultiJson.load(content) if @content_as_json.nil?
+      @content_as_json
+    end
+
+    def content_as_yaml
+      @content_as_yaml = YAML.load(content) if @content_as_yaml.nil?
+      @content_as_yaml
+    end
+
+    def group
+      @runner.get_file_owner_group(@name).stdout.strip
+    end
+
     def version?(version)
       @runner.check_file_has_version(@name, version)
     end
 
+    def link_target
+      @runner.get_file_link_target(@name).stdout.strip
+    end
+
+    def mode
+      @runner.get_file_mode(@name).stdout.strip
+    end
+
     def mtime
       d = @runner.get_file_mtime(@name).stdout.strip
       DateTime.strptime(d, '%s').new_offset(DateTime.now.offset)
     end
 
+    def owner
+      @runner.get_file_owner_user(@name).stdout.strip
+    end
+
     def size
       @runner.get_file_size(@name).stdout.strip.to_i
     end
diff --git a/lib/serverspec/type/hadoop_config.rb b/lib/serverspec/type/hadoop_config.rb
new file mode 100644
index 0000000..9976ce9
--- /dev/null
+++ b/lib/serverspec/type/hadoop_config.rb
@@ -0,0 +1,27 @@
+module Serverspec::Type
+  class HadoopConfig < Base
+    def initialize(name=nil, options={})
+      super
+
+      begin
+        require 'nokogiri'
+      rescue LoadError
+        fail "nokogiri is not available. Try installing it."
+      end
+    end
+
+    def value
+     @runner.run_command("find /etc/hadoop/conf/ -type f -name \"*.xml\" ").stdout.split(/\n/).each do |file| 
+        @doc = ::Nokogiri::XML( @runner.get_file_content("#{file}").stdout.strip )
+        @doc.xpath('/configuration/property').each do |property|
+        case property.xpath('name').text
+          when /#{@name}/
+            ret = property.xpath('value').text
+            val = ret.to_s
+            return val
+          end
+        end
+      end
+    end
+  end
+end
diff --git a/lib/serverspec/type/host.rb b/lib/serverspec/type/host.rb
index 39343d5..6cac086 100644
--- a/lib/serverspec/type/host.rb
+++ b/lib/serverspec/type/host.rb
@@ -11,5 +11,11 @@ module Serverspec::Type
     def ipaddress
       @runner.get_host_ipaddress(@name).stdout.strip
     end
+    def ipv4_address
+      @runner.get_host_ipv4_address(@name).stdout.strip
+    end
+    def ipv6_address
+      @runner.get_host_ipv6_address(@name).stdout.strip
+    end
   end
 end
diff --git a/lib/serverspec/type/interface.rb b/lib/serverspec/type/interface.rb
index 09f9608..3f625ca 100644
--- a/lib/serverspec/type/interface.rb
+++ b/lib/serverspec/type/interface.rb
@@ -6,9 +6,12 @@ module Serverspec::Type
 
     def speed
       ret = @runner.get_interface_speed_of(@name)
-      val = ret.stdout.strip
-      val = val.to_i if val.match(/^\d+$/)
-      val
+      val_to_integer(ret)
+    end
+
+    def mtu
+      ret = @runner.get_interface_mtu_of(@name)
+      val_to_integer(ret)
     end
 
     def has_ipv4_address?(ip_address)
@@ -19,9 +22,26 @@ module Serverspec::Type
       @runner.check_interface_has_ipv6_address(@name, ip_address)
     end
 
+    def ipv4_address
+      @runner.get_interface_ipv4_address(@name).stdout.strip
+    end
+
+    def ipv6_address
+      @runner.get_interface_ipv6_address(@name).stdout.strip
+    end
+
     def up?
       ret = @runner.get_interface_link_state(@name)
       ret.stdout.strip == 'up'
     end
+
+    private
+
+    def val_to_integer(ret)
+      val = ret.stdout.strip
+      val = val.to_i if val.match(/^\d+$/)
+      val
+    end
+
   end
 end
diff --git a/lib/serverspec/type/json_file.rb b/lib/serverspec/type/json_file.rb
new file mode 100644
index 0000000..59cd67a
--- /dev/null
+++ b/lib/serverspec/type/json_file.rb
@@ -0,0 +1,9 @@
+require 'multi_json'
+
+module Serverspec::Type
+  class JsonFile < File
+    def content
+      MultiJson.load(super)
+    end
+  end
+end
diff --git a/lib/serverspec/type/linux_audit_system.rb b/lib/serverspec/type/linux_audit_system.rb
new file mode 100644
index 0000000..672a649
--- /dev/null
+++ b/lib/serverspec/type/linux_audit_system.rb
@@ -0,0 +1,45 @@
+module Serverspec::Type
+  class LinuxAuditSystem < Base
+    def initialize(name=nil)
+      @name = 'linux_audit_system'
+      @runner = Specinfra::Runner
+      @rules_content = nil
+    end
+
+    def enabled?
+      status_of('enabled') == '1'
+    end
+
+    def running?
+      pid = status_of('pid')
+      (!pid.nil? && pid.size > 0 && pid != '0')
+    end
+
+    def rules
+      if @rules_content.nil?
+        @rules_content = @runner.run_command('/sbin/auditctl -l').stdout || ''
+      end
+      @rules_content
+    end
+
+    private
+
+    def status_of(part)
+      cmd = "/sbin/auditctl -s"
+      status_str = @runner.run_command(cmd).stdout.chomp
+      status_map = parse_status(status_str)
+      status_map[part] || ''
+    end
+
+    def parse_status(status_str)
+      map = nil
+      if status_str =~ /^AUDIT_STATUS/ then
+        map = status_str.split(' ')[1..-1].inject({}) { |res,elem| a = elem.split('='); res.store(a[0],a[1] || ''); res }
+      else
+        map = status_str.split("\n").inject({}) { |res,elem| a = elem.split(' '); res.store(a[0],a[1] || ''); res } 
+      end
+      map
+    end
+
+  end
+end
diff --git a/lib/serverspec/type/mysql_config.rb b/lib/serverspec/type/mysql_config.rb
new file mode 100644
index 0000000..939b1ac
--- /dev/null
+++ b/lib/serverspec/type/mysql_config.rb
@@ -0,0 +1,10 @@
+module Serverspec::Type
+  class MysqlConfig < Base
+    def value
+      ret = @runner.run_command("mysqld --verbose --help 2> /dev/null | grep '^#{@name}'")
+      val = ret.stdout.match(/#{@name}\s+(.+)$/)[1]
+      val = val.to_i if val.match(/^\d+$/)
+      val
+    end
+  end
+end
diff --git a/lib/serverspec/type/php_config.rb b/lib/serverspec/type/php_config.rb
index 822c799..7b5847e 100644
--- a/lib/serverspec/type/php_config.rb
+++ b/lib/serverspec/type/php_config.rb
@@ -1,7 +1,9 @@
 module Serverspec::Type
   class PhpConfig < Base
     def value
-      ret = @runner.run_command("php -r 'echo get_cfg_var( \"#{@name}\" );'")
+      extra = '';
+      extra = extra + "-c #{@options[:ini]}" if @options.has_key?(:ini)
+      ret = @runner.run_command("php #{extra} -r 'echo get_cfg_var( \"#{@name}\" );'")
       val = ret.stdout
       val = val.to_i if val.match(/^\d+$/)
       val
diff --git a/lib/serverspec/type/php_extension.rb b/lib/serverspec/type/php_extension.rb
new file mode 100644
index 0000000..4c46549
--- /dev/null
+++ b/lib/serverspec/type/php_extension.rb
@@ -0,0 +1,11 @@
+module Serverspec::Type
+  class PhpExtension < Base
+    def loaded?
+      ret = @runner.run_command("php --ri '#{@name}'")
+
+      return false if ret.exit_status.to_i > 0
+
+      true
+    end
+  end
+end
diff --git a/lib/serverspec/type/process.rb b/lib/serverspec/type/process.rb
index 4f0b262..9d27840 100644
--- a/lib/serverspec/type/process.rb
+++ b/lib/serverspec/type/process.rb
@@ -13,6 +13,10 @@ module Serverspec::Type
       get_column("group")
     end
 
+    def count
+      @runner.count_process(@name).stdout.strip.to_i
+    end
+
     def method_missing(meth)
       get_column(meth.to_s)
     end
diff --git a/lib/serverspec/type/selinux.rb b/lib/serverspec/type/selinux.rb
index c795918..4e19756 100644
--- a/lib/serverspec/type/selinux.rb
+++ b/lib/serverspec/type/selinux.rb
@@ -4,12 +4,12 @@ module Serverspec::Type
       @runner.check_selinux_has_mode('disabled')
     end
 
-    def enforcing?
-      @runner.check_selinux_has_mode('enforcing')
+    def enforcing?(with_policy)
+      @runner.check_selinux_has_mode('enforcing', with_policy)
     end
 
-    def permissive?
-      @runner.check_selinux_has_mode('permissive')
+    def permissive?(with_policy)
+      @runner.check_selinux_has_mode('permissive', with_policy)
     end
 
     def to_s
diff --git a/lib/serverspec/type/selinux_module.rb b/lib/serverspec/type/selinux_module.rb
index bbcfb60..924238c 100644
--- a/lib/serverspec/type/selinux_module.rb
+++ b/lib/serverspec/type/selinux_module.rb
@@ -4,8 +4,12 @@ module Serverspec::Type
       @runner.check_selinux_module_is_enabled(@name)
     end
 
-    def installed?(name, version=nil)
+    def installed?(version = nil)
       @runner.check_selinux_module_is_installed(@name, version)
     end
+
+    def to_s
+      %(SELinux module "#{@name}")
+    end
   end
 end
diff --git a/lib/serverspec/type/service.rb b/lib/serverspec/type/service.rb
index bbe457f..6c295ce 100644
--- a/lib/serverspec/type/service.rb
+++ b/lib/serverspec/type/service.rb
@@ -1,10 +1,12 @@
 module Serverspec::Type
   class Service < Base
-    def enabled?(level)
+    def enabled?(level, under=nil)
+      check_method = "check_service_is_enabled" + (under ? "_#{under}" : '')
+
       if level
-        @runner.check_service_is_enabled(@name, level)
+        @runner.send(check_method.to_sym, @name, level)
       else
-        @runner.check_service_is_enabled(@name)
+        @runner.send(check_method.to_sym, @name)
       end
     end
 
@@ -25,9 +27,11 @@ module Serverspec::Type
       end
     end
 
-    def monitored_by?(monitor)
+    def monitored_by?(monitor, monitor_name)
       check_method = "check_service_is_monitored_by_#{monitor}".to_sym
-      res = @runner.send(check_method, @name)
+      # use the with_name value if set instead of the service name
+      monitor_name = (monitor_name ? monitor_name : @name)
+      res = @runner.send(check_method, monitor_name)
     end
 
     def has_property?(property)
diff --git a/lib/serverspec/type/user.rb b/lib/serverspec/type/user.rb
index 8c6abff..f2ce656 100644
--- a/lib/serverspec/type/user.rb
+++ b/lib/serverspec/type/user.rb
@@ -35,5 +35,9 @@ module Serverspec::Type
     def maximum_days_between_password_change
       @runner.get_user_maximum_days_between_password_change(@name).stdout.to_i
     end
+
+    def encrypted_password
+      @runner.get_user_encrypted_password(@name).stdout.strip
+    end 
   end
 end
diff --git a/lib/serverspec/type/x509_certificate.rb b/lib/serverspec/type/x509_certificate.rb
index 9af7665..9c9ac49 100644
--- a/lib/serverspec/type/x509_certificate.rb
+++ b/lib/serverspec/type/x509_certificate.rb
@@ -60,6 +60,15 @@ module Serverspec::Type
       ( diff/(60*60*24) )
     end
 
+    def subject_alt_names
+      text = run_openssl_command_with('-text -noout').stdout
+      # X509v3 Subject Alternative Name:
+      #     DNS:*.example.com, DNS:www.example.net, IP:192.0.2.10
+      if text =~ /^ *X509v3 Subject Alternative Name: *\n *(.*)$/
+        $1.split(/, +/)
+      end
+    end
+
     private
     def run_openssl_command_with(param_str)
       @runner.run_command("openssl x509 -in #{name} #{param_str}")
diff --git a/lib/serverspec/type/x509_private_key.rb b/lib/serverspec/type/x509_private_key.rb
index 402049e..1bb9568 100644
--- a/lib/serverspec/type/x509_private_key.rb
+++ b/lib/serverspec/type/x509_private_key.rb
@@ -12,9 +12,8 @@ module Serverspec::Type
     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 = @runner.run_command("openssl x509 -noout -modulus -in #{cert_file}")
+      h2 = @runner.run_command("openssl rsa -noout -modulus -in #{name}")
       (h1.stdout == h2.stdout) && (h1.exit_status == 0) && (h2.exit_status == 0)
     end
   end
diff --git a/lib/serverspec/version.rb b/lib/serverspec/version.rb
index 3a5aaa7..303be4a 100644
--- a/lib/serverspec/version.rb
+++ b/lib/serverspec/version.rb
@@ -1,3 +1,3 @@
 module Serverspec
-  VERSION = "2.18.0"
+  VERSION = "2.38.0"
 end
diff --git a/metadata.yml b/metadata.yml
deleted file mode 100644
index 35e5fcc..0000000
--- a/metadata.yml
+++ /dev/null
@@ -1,440 +0,0 @@
---- !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 at 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
diff --git a/serverspec.gemspec b/serverspec.gemspec
index 87ba920..514adb1 100644
--- a/serverspec.gemspec
+++ b/serverspec.gemspec
@@ -21,7 +21,8 @@ Gem::Specification.new do |spec|
   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_runtime_dependency "specinfra", "~> 2.53"
   spec.add_development_dependency "bundler", "~> 1.3"
+  spec.add_development_dependency("json", "~> 1.8") if RUBY_VERSION < "1.9"
   spec.add_development_dependency "rake", "~> 10.1.1"
 end
diff --git a/spec/type/aix/file_spec.rb b/spec/type/aix/file_spec.rb
index bbd1dd5..4725944 100644
--- a/spec/type/aix/file_spec.rb
+++ b/spec/type/aix/file_spec.rb
@@ -15,11 +15,7 @@ describe file('/tmp') do
 end
 
 describe file('/etc/passwd') do
-  it 'be_mode is not implemented' do
-    expect {
-      should be_mode 644
-    }.to raise_exception
-  end
+  it { should be_mode 644 }
 end
 
 describe file('/etc/passwd') do
diff --git a/spec/type/base/command_spec.rb b/spec/type/base/command_spec.rb
index b2407bd..39f805e 100644
--- a/spec/type/base/command_spec.rb
+++ b/spec/type/base/command_spec.rb
@@ -65,3 +65,42 @@ EOF
   its(:stdout) { should contain('4260').before('home') }
   its(:stdout) { should_not contain('4260').before('bin') }
 end
+
+describe command('curl http://localhost:8080/info') do
+  let(:stdout) { <<EOF
+{
+   "sensu":{
+      "version":"0.26.5"
+   },
+   "transport":{
+      "keepalives":{
+         "messages":0,
+         "consumers":1
+      },
+      "results":{
+         "messages":0,
+         "consumers":1
+      },
+      "connected":true
+   },
+   "redis":{
+      "connected":true
+   },
+   "array":[
+      {
+         "title":"array 1"
+      },
+      {
+         "title":"array 2"
+      }
+   ]
+}
+EOF
+  }
+
+  its(:stdout_as_json) { should include('sensu') }
+  its(:stdout_as_json) { should include('sensu' => include('version' => '0.26.5')) }
+  its(:stdout_as_json) { should include('transport' => include('keepalives' => include('consumers' => 1))) }
+  its(:stdout_as_json) { should include('transport' => include('connected' => true)) }
+  its(:stdout_as_json) { should include('array' => include('title' => 'array 2')) }
+end
diff --git a/spec/type/base/file_spec.rb b/spec/type/base/file_spec.rb
index 58f023b..0b80f8a 100644
--- a/spec/type/base/file_spec.rb
+++ b/spec/type/base/file_spec.rb
@@ -320,6 +320,11 @@ describe file('invalid-file') do
 end
 
 describe file('/etc/passwd') do
+  let(:stdout) { "root\r\n" }
+  its(:group) { should eq 'root' }
+end
+
+describe file('/etc/passwd') do
   let(:stdout) {<<EOF
 root:x:0:0:root:/root:/bin/bash
 bin:x:1:1:bin:/bin:/sbin/nologin
@@ -337,11 +342,68 @@ EOF
   its(:content) { should match /root:x:0:0/ }
 end
 
+describe file('example.json') do
+  let(:stdout) {<<EOF
+{
+  "json": {
+    "title": "this is a json",
+    "array" : [
+      {
+        "title": "array 1"
+      },
+      {
+        "title": "array 2"
+      }
+    ]
+  }
+}
+EOF
+  }
+
+  its(:content_as_json) { should include('json') }
+  its(:content_as_json) { should include('json' => include('title' => 'this is a json')) }
+  its(:content_as_json) { should include('json' => include('array' => include('title' => 'array 2'))) }
+end
+
+describe file('example.yml') do
+  let(:stdout) {<<EOF
+---
+yaml:
+  title: 'this is a yaml'
+  array:
+    -
+      title: 'array 1'
+    -
+      title: 'array 2'
+EOF
+  }
+
+  its(:content_as_yaml) { should include('yaml') }
+  its(:content_as_yaml) { should include('yaml' => include('title' => 'this is a yaml')) }
+  its(:content_as_yaml) { should include('yaml' => include('array' => include('title' => 'array 2'))) }
+end
+
+
+describe file('/etc/pam.d/system-auth') do
+  let(:stdout) { "/etc/pam.dsystem-auth-ac\r\n" }
+  its(:link_target) { should eq '/etc/pam.dsystem-auth-ac' }
+end
+
+describe file('/etc/passwd') do
+  let(:stdout) { "644\r\n" }
+  its(:mode) { should eq '644' }
+end
+
 describe file('/etc/passwd') do
   let(:stdout) { Time.now.to_i.to_s }
   its(:mtime) { should > DateTime.now - 1 }
 end
 
+describe file('/etc/passwd') do
+  let(:stdout) { "root\r\n" }
+  its(:owner) { should eq 'root' }
+end
+
 describe file('/etc/passwod') do
   let(:stdout) { 100.to_s }
   its(:size) { should > 0 }
@@ -351,6 +413,6 @@ describe file('/etc/passwd') do
   it 'be_immutable is not implemented in base class' do
     expect {
       should be_immutable
-    }.to raise_exception
+    }.to raise_error(/is not implemented in Specinfra/)
   end
 end
diff --git a/spec/type/base/host_spec.rb b/spec/type/base/host_spec.rb
index 0cc3819..9ead8b8 100644
--- a/spec/type/base/host_spec.rb
+++ b/spec/type/base/host_spec.rb
@@ -34,3 +34,14 @@ describe host('example.jp') do
   let(:stdout) { "1.2.3.4\r\n" }
   its(:ipaddress) { should eq '1.2.3.4' }
 end
+
+describe host('example.jp') do
+  let(:stdout) { "1.2.3.4\r\n" }
+  its(:ipv4_address) { should match(/^[\d.]+$/) }
+end
+
+describe host('example.jp') do
+  let(:stdout) { "2001:db8::1234\r\n" }
+  its(:ipv6_address) { should match(/^[a-f\d:]+$/i) }
+end
+
diff --git a/spec/type/base/json_file_spec.rb b/spec/type/base/json_file_spec.rb
new file mode 100644
index 0000000..1fbdd9c
--- /dev/null
+++ b/spec/type/base/json_file_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+set :os, {:family => 'base'}
+
+describe json_file('example.json') do
+  let(:stdout) {<<EOF
+{
+  "json": {
+    "title": "this is a json",
+    "array" : [
+      {
+        "title": "array 1"
+      },
+      {
+        "title": "array 2"
+      }
+    ]
+  }
+}
+EOF
+  }
+
+  its(:content) { should include('json') }
+  its(:content) { should include('json' => include('title' => 'this is a json')) }
+  its(:content) { should include('json' => include('array' => include('title' => 'array 2'))) }
+end
+
diff --git a/spec/type/base/mysql_config_spec.rb b/spec/type/base/mysql_config_spec.rb
new file mode 100644
index 0000000..0a3d25f
--- /dev/null
+++ b/spec/type/base/mysql_config_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+set :os, :family => 'base'
+
+describe mysql_config('innodb-buffer-pool-size') do
+  let(:stdout) { 'innodb-buffer-pool-size           134217728' }
+  its(:value) { should eq 134217728 }
+end
+
+describe mysql_config('socket') do
+  let(:stdout) { 'socket                            /tmp/mysql.sock' }
+  its(:value) { should eq '/tmp/mysql.sock' }
+end
diff --git a/spec/type/base/php_config_spec.rb b/spec/type/base/php_config_spec.rb
index d5a5f37..d3017ac 100644
--- a/spec/type/base/php_config_spec.rb
+++ b/spec/type/base/php_config_spec.rb
@@ -31,3 +31,7 @@ describe php_config('mbstring.http_output_conv_mimetypes') do
   let(:stdout) { 'application' }
   its(:value) { should_not match /html/ }
 end
+describe php_config('default_mimetype', :ini => '/etc/php5/php.ini') do
+  let(:stdout) { 'text/html' }
+  its(:value) { should eq 'text/html' }
+end
diff --git a/spec/type/base/php_extension_spec.rb b/spec/type/base/php_extension_spec.rb
new file mode 100644
index 0000000..46b02ec
--- /dev/null
+++ b/spec/type/base/php_extension_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+set :os, :family => 'base'
+
+describe php_extension('tillext') do
+  let(:exit_status) { 1 }
+  it { should_not be_loaded }
+end
+
+describe php_extension('session') do
+  let(:exit_status) { 0 }
+  it { should be_loaded }
+end
diff --git a/spec/type/base/service_spec.rb b/spec/type/base/service_spec.rb
index 8b88eba..fc7db9f 100644
--- a/spec/type/base/service_spec.rb
+++ b/spec/type/base/service_spec.rb
@@ -27,7 +27,7 @@ describe service('sshd') do
   it {
     expect {
       should be_running.under('not implemented')
-    }.to raise_exception
+    }.to raise_error(/is not implemented in Specinfra/)
   }
 end
 
@@ -36,6 +36,11 @@ describe service('sshd') do
   it { should be_monitored_by(:monit) }
 end
 
+describe service('tinc') do
+  let(:stdout) { "Process 'tinc-myvpn'\r\n  status running\r\n  monitoring status  monitored" }
+  it { should be_monitored_by(:monit).with_name('tinc-myvpn') }
+end
+
 describe service('unicorn') do
   it { should be_monitored_by(:god) }
 end
@@ -44,6 +49,6 @@ describe service('sshd') do
   it {
     expect {
       should be_monitored_by('not implemented')
-    }.to raise_exception
+    }.to raise_error(NotImplementedError)
   }
 end
diff --git a/spec/type/base/user_spec.rb b/spec/type/base/user_spec.rb
index abcf744..c888cbc 100644
--- a/spec/type/base/user_spec.rb
+++ b/spec/type/base/user_spec.rb
@@ -31,7 +31,12 @@ describe user('root') do
 end
 
 describe user('root') do
-  its(:minimum_days_between_password_change) { should  == 0 }
+  let(:stdout) { "$1$T0aTw9NJ$NdMldLUQ8WqhlEEGToNzl/\n" } 
+  its(:encrypted_password) { should eq '$1$T0aTw9NJ$NdMldLUQ8WqhlEEGToNzl/' } 
+end
+
+describe user('root') do
+  its(:minimum_days_between_password_change) { should == 0 }
 end
 
 describe user('root') do
diff --git a/spec/type/linux/docker_container_spec.rb b/spec/type/linux/docker_container_pre_1_8_spec.rb
similarity index 82%
copy from spec/type/linux/docker_container_spec.rb
copy to spec/type/linux/docker_container_pre_1_8_spec.rb
index 9c07764..7445acd 100644
--- a/spec/type/linux/docker_container_spec.rb
+++ b/spec/type/linux/docker_container_pre_1_8_spec.rb
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 require 'spec_helper'
+require 'json'
 
 property[:os] = nil
 set :os, {:family => 'linux'}
@@ -8,12 +9,24 @@ describe docker_container('c1') do
   it { should exist }
 end
 
-describe docker_container('c1') do
+describe docker_container('c1 pre 1.8') do
   let(:stdout) { inspect_container }
   it { should be_running }
   it { should have_volume('/tmp', '/data') }
+  it { should_not have_volume('/tmp', '/data-bad') }
   its(:inspection) { should include 'Driver' => 'aufs' }
   its(['Config.Cmd']) { should include '/bin/sh' }
+  its(['HostConfig.PortBindings.80.[0].HostPort']) { should eq '8080' }
+end
+
+describe docker_container('restarting pre 1.8') do
+  let(:stdout) do
+    attrs = JSON.parse(inspect_container)
+    attrs.first['State']['Restarting'] = true
+    attrs.to_json
+  end
+
+  it { should_not be_running }
 end
 
 def inspect_container
@@ -62,7 +75,14 @@ def inspect_container
         "Links": null,
         "LxcConf": [],
         "NetworkMode": "bridge",
-        "PortBindings": {},
+        "PortBindings": {
+            "80": [
+                {
+                    "HostIp": "",
+                    "HostPort": "8080"
+                }
+            ]
+        },
         "Privileged": false,
         "PublishAllPorts": false,
         "VolumesFrom": null
diff --git a/spec/type/linux/docker_container_spec.rb b/spec/type/linux/docker_container_spec.rb
index 9c07764..5955419 100644
--- a/spec/type/linux/docker_container_spec.rb
+++ b/spec/type/linux/docker_container_spec.rb
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 require 'spec_helper'
+require 'multi_json'
 
 property[:os] = nil
 set :os, {:family => 'linux'}
@@ -12,8 +13,21 @@ describe docker_container('c1') do
   let(:stdout) { inspect_container }
   it { should be_running }
   it { should have_volume('/tmp', '/data') }
+  it { should_not have_volume('/tmp', '/data-bad') }
   its(:inspection) { should include 'Driver' => 'aufs' }
   its(['Config.Cmd']) { should include '/bin/sh' }
+  its(['HostConfig.PortBindings.80.[0].HostPort']) { should eq '8080' }
+  its(['HostConfig.PortBindings.80.[1].HostPort']) { should eq '8081' }  
+end
+
+describe docker_container('restarting') do
+  let(:stdout) do
+    attrs = MultiJson.load(inspect_container)
+    attrs.first['State']['Restarting'] = true
+    attrs.to_json
+  end
+
+  it { should_not be_running }
 end
 
 def inspect_container
@@ -62,7 +76,18 @@ def inspect_container
         "Links": null,
         "LxcConf": [],
         "NetworkMode": "bridge",
-        "PortBindings": {},
+        "PortBindings": {
+            "80": [
+                {
+                    "HostIp": "",
+                    "HostPort": "8080"
+                },
+                {
+                    "HostIp": "",
+                    "HostPort": "8081"
+                }
+            ]
+        },
         "Privileged": false,
         "PublishAllPorts": false,
         "VolumesFrom": null
@@ -92,12 +117,14 @@ def inspect_container
         "Running": true,
         "StartedAt": "2014-09-26T15:08:37.737780273Z"
     },
-    "Volumes": {
-        "/tmp": "/data"
-    },
-    "VolumesRW": {
-        "/tmp": true
-    }
+    "Mounts": [
+        {
+            "Source": "/data",
+            "Destination": "/tmp",
+            "Mode": "",
+            "RW": true
+        }
+    ]
 }
 ]
 EOS
diff --git a/spec/type/linux/interface_spec.rb b/spec/type/linux/interface_spec.rb
index e48735f..b3b11b2 100644
--- a/spec/type/linux/interface_spec.rb
+++ b/spec/type/linux/interface_spec.rb
@@ -8,6 +8,11 @@ describe interface('eth0') do
 end
 
 describe interface('eth0') do
+  let(:stdout) { '1500' }
+  its(:mtu) { should eq 1500 }
+end
+
+describe interface('eth0') do
   it { should have_ipv4_address('192.168.10.10') }
 end
 
@@ -19,6 +24,16 @@ describe interface('eth0') do
   it { should have_ipv6_address('2001:0db8:bd05:01d2:288a:1fc0:0001:10ee') }
 end
 
+describe interface('eth1') do
+  let(:stdout) { "1.2.3.4/1\r\n" }
+  its(:ipv4_address) { should match(/^[\d.]+\/\d+$/) }
+end
+
+describe interface('eth1') do
+  let(:stdout) { "2001:db8::1234/1\r\n" }
+  its(:ipv6_address) { should match(/^[a-f\d:]+\/\d+$/i) }
+end
+
 describe interface('eth0') do
   let(:stdout) { 'up' }
   it { should be_up }
@@ -28,3 +43,8 @@ describe interface('invalid-interface') do
   let(:stdout) { '1000' }
   its(:speed) { should_not eq 100 }
 end
+
+describe interface('invalid-interface') do
+  let(:stdout) { '9001' }
+  its(:mtu) { should_not eq 1500 }
+end
diff --git a/spec/type/linux/linux_audit_system_spec.rb b/spec/type/linux/linux_audit_system_spec.rb
new file mode 100644
index 0000000..b014a4b
--- /dev/null
+++ b/spec/type/linux/linux_audit_system_spec.rb
@@ -0,0 +1,139 @@
+require 'spec_helper'
+
+set :os, :family => 'linux'
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl1_1 }
+  it { should be_enabled }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl1_2 }
+  it { should_not be_enabled }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl1_1 }
+  it { should be_running }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl1_3 }
+  it { should_not be_running }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl1_4 }
+  it { should_not be_running }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl2_1 }
+  it { should be_enabled }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl2_2 }
+  it { should_not be_enabled }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl2_1 }
+  it { should be_running }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl2_3 }
+  it { should_not be_running }
+end
+
+describe linux_audit_system do
+  let(:stdout) { out_auditctl2_4 }
+  it { should_not be_running }
+end
+
+describe linux_audit_system do
+  let(:stdout) { '-a -w /etc/sysconfig -p wa -k test' }
+  its(:rules) { should match %r!-w /etc/sysconfig.*-k test! }
+end
+
+describe linux_audit_system do
+  let(:stdout) { 'test' }
+  its(:rules) { should eq 'test' }
+  its(:rules) { should match /es/ }
+  its(:rules) { should_not match /ab/ }
+end
+
+# variants of auditctl -s output for different versions
+
+def out_auditctl1_1
+  "AUDIT_STATUS: enabled=1 flag=1 pid=881 rate_limit=0 backlog_limit=320 lost=0 backlog=0"
+end
+
+def out_auditctl1_2
+  "AUDIT_STATUS: enabled=0 flag=1 pid=881 rate_limit=0 backlog_limit=320 lost=0 backlog=0"
+end
+
+def out_auditctl1_3
+  "AUDIT_STATUS: enabled=1 flag=1 pid=0 rate_limit=0 backlog_limit=320 lost=0 backlog=0"
+end
+
+def out_auditctl1_4
+  "AUDIT_STATUS: enabled=1 flag=1 pid= rate_limit=0 backlog_limit=320 lost=0 backlog=0"
+end
+
+def out_auditctl2_1
+  <<EOS
+enabled 1
+failure 1
+pid 5939
+rate_limit 0
+backlog_limit 64
+lost 0
+backlog 0
+backlog_wait_time 60000
+loginuid_immutable 0 unlocked
+EOS
+end
+
+def out_auditctl2_2
+  <<EOS
+enabled 0
+failure 1
+pid 5939
+rate_limit 0
+backlog_limit 64
+lost 0
+backlog 0
+backlog_wait_time 60000
+loginuid_immutable 0 unlocked
+EOS
+end
+
+def out_auditctl2_3
+  <<EOS
+enabled 0
+failure 1
+pid 0
+rate_limit 0
+backlog_limit 64
+lost 0
+backlog 0
+backlog_wait_time 60000
+loginuid_immutable 0 unlocked
+EOS
+end
+
+def out_auditctl2_4
+  <<EOS
+enabled 0
+failure 1
+pid
+rate_limit 0
+backlog_limit 64
+lost 0
+backlog 0
+backlog_wait_time 60000
+loginuid_immutable 0 unlocked
+EOS
+end
diff --git a/spec/type/linux/selinux_module_spec.rb b/spec/type/linux/selinux_module_spec.rb
index a62be6b..7446dc0 100644
--- a/spec/type/linux/selinux_module_spec.rb
+++ b/spec/type/linux/selinux_module_spec.rb
@@ -4,6 +4,10 @@ set :os, :family => 'linux'
 
 describe selinux_module('bootloader') do
   it { should be_installed }
+end 
+
+describe selinux_module('bootloader') do
+  it { should be_installed.with_version('1.10') }
 end
 
 describe selinux_module('bootloader') do
diff --git a/spec/type/linux/selinux_spec.rb b/spec/type/linux/selinux_spec.rb
index 0d8eae6..6995fa5 100644
--- a/spec/type/linux/selinux_spec.rb
+++ b/spec/type/linux/selinux_spec.rb
@@ -7,9 +7,17 @@ describe selinux do
 end
 
 describe selinux do
+  it { should be_enforcing.with_policy('mls') }
+end
+
+describe selinux do
   it { should be_permissive }
 end
 
 describe selinux do
+  it { should be_permissive.with_policy('targeted') }
+end
+
+describe selinux do
   it { should be_disabled }
 end
diff --git a/spec/type/linux/x509_certificate_spec.rb b/spec/type/linux/x509_certificate_spec.rb
index 3bd674f..0f2b6c4 100644
--- a/spec/type/linux/x509_certificate_spec.rb
+++ b/spec/type/linux/x509_certificate_spec.rb
@@ -33,6 +33,10 @@ describe x509_certificate('test.pem') do
   it { should_not be_valid }
 end
 
+describe x509_certificate('test.pem') do
+  let(:stdout) { sample_san }
+  its(:subject_alt_names) { should eq %w[DNS:*.example.com DNS:www.example.net IP:192.0.2.10] }
+end
 
 def sample_subj
   <<'EOS'
@@ -60,3 +64,15 @@ notAfter=Jul  1 11:11:00 2010 GMT
 EOS
 end
 
+def sample_san
+  <<'EOS'
+Certificate:
+    Data:
+        Version: 3 (0x2)
+        X509v3 extensions:
+            X509v3 Extended Key Usage:
+                TLS Web Server Authentication, TLS Web Client Authentication
+            X509v3 Subject Alternative Name:
+                DNS:*.example.com, DNS:www.example.net, IP:192.0.2.10
+EOS
+end
diff --git a/spec/type/openbsd/interface_spec.rb b/spec/type/openbsd/interface_spec.rb
index 69c2127..371ab21 100644
--- a/spec/type/openbsd/interface_spec.rb
+++ b/spec/type/openbsd/interface_spec.rb
@@ -15,6 +15,16 @@ describe interface('eth0') do
   it { should have_ipv4_address("192.168.10.10/24") }
 end
 
+describe interface('eth1') do
+  let(:stdout) { "1.2.3.4/1\r\n" }
+  its(:ipv4_address) { should match(/^[\d.]+\/\d+$/) }
+end
+
+describe interface('eth1') do
+  let(:stdout) { "2001:db8::1234/1\r\n" }
+  its(:ipv6_address) { should match(/^[a-f\d:]+\/\d+$/i) }
+end
+
 describe interface('invalid-interface') do
   let(:stdout) { '1000' }
   its(:speed) { should_not eq 100 }
diff --git a/spec/type/solaris10/file_spec.rb b/spec/type/solaris10/file_spec.rb
index c2bf6cf..8cb61bb 100644
--- a/spec/type/solaris10/file_spec.rb
+++ b/spec/type/solaris10/file_spec.rb
@@ -308,6 +308,6 @@ describe file('/etc/passwd') do
   it 'be_immutable is not implemented in base class' do
     expect {
       should be_immutable
-    }.to raise_exception
+    }.to raise_error(/is not implemented in Specinfra/)
   end
 end
diff --git a/spec/type/windows/file_spec.rb b/spec/type/windows/file_spec.rb
index 8c4ef10..01d360f 100644
--- a/spec/type/windows/file_spec.rb
+++ b/spec/type/windows/file_spec.rb
@@ -39,7 +39,7 @@ 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
+     expect { should be_readable.by(access) }.to raise_error(RuntimeError)
    end
  end
 end
@@ -59,7 +59,7 @@ 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
+     expect { should be_writable.by(access) }.to raise_error(RuntimeError)
    end
  end
 end
@@ -79,7 +79,7 @@ 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
+     expect { should be_executable.by(access) }.to raise_error(RuntimeError)
    end
  end
 end
@@ -97,17 +97,24 @@ describe file('/some/file') do
 end
 
 describe file('/some/test/file') do
-  it "should raise error if command is not supported" do 
+  it "should raise error if command is not implemented" do
     {
       :be_socket => [],
       :be_mode => 644,
       :be_grouped_into => 'root',
       :be_linked_to => '/some/other/file',
-      :be_mounted => [],
+      :be_mounted => []
+    }.each do |method, args|
+      expect { should self.send(method, *args) }.to raise_error(NotImplementedError)
+    end
+  end
+
+  it "should raise error if command is not defined" do
+    {
       :match_md5checksum => '35435ea447c19f0ea5ef971837ab9ced',
       :match_sha256checksum => '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a'
     }.each do |method, args|
-      expect { should self.send(method, *args) }.to raise_exception
+      expect { should self.send(method, *args) }.to raise_error(NoMethodError)
     end
   end
 end
diff --git a/spec/type/windows/group_spec.rb b/spec/type/windows/group_spec.rb
index b0984d5..9d6055c 100644
--- a/spec/type/windows/group_spec.rb
+++ b/spec/type/windows/group_spec.rb
@@ -17,7 +17,7 @@ describe group('test.group') do
     {
       :have_gid => [nil],
     }.each do |method, args|
-      expect { should self.send(method, *args) }.to raise_exception
+      expect { should self.send(method, *args) }.to raise_error(NotImplementedError)
     end
   end
 end
diff --git a/spec/type/windows/service_spec.rb b/spec/type/windows/service_spec.rb
index a620726..0f47b31 100644
--- a/spec/type/windows/service_spec.rb
+++ b/spec/type/windows/service_spec.rb
@@ -22,9 +22,9 @@ 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
+   expect { should be_running.under('supervisor') }.to raise_error(NotImplementedError)
  end
   it "should raise error if trying to check service monitoring" do
-   expect { should_not be_monitored_by('monit') }.to raise_error
+   expect { should_not be_monitored_by('monit') }.to raise_error(NotImplementedError)
  end
 end
diff --git a/spec/type/windows/user_spec.rb b/spec/type/windows/user_spec.rb
index 82cff13..7f9c674 100644
--- a/spec/type/windows/user_spec.rb
+++ b/spec/type/windows/user_spec.rb
@@ -27,7 +27,7 @@ describe user('test.user') do
       :have_login_shell => [nil],
       :have_authorized_key => [nil],
     }.each do |method, args|
-      expect { should self.send(method, *args) }.to raise_exception
+      expect { should self.send(method, *args) }.to raise_error(NotImplementedError)
     end
   end
 end
diff --git a/wercker.yml b/wercker.yml
index 4cc963b..ec0b07a 100644
--- a/wercker.yml
+++ b/wercker.yml
@@ -3,7 +3,7 @@ build:
   steps:
     - script:
         name: Run walter
-        code: ./$WORKING_DIR/walter -c ./$WORKING_DIR/pipeline.yml
+        code: ./$WORKING_DIR/walter -config ./$WORKING_DIR/pipeline.yml -build
   after-steps:
     - wantedly/pretty-slack-notify:
         webhook_url: $SLACK_WEBHOOK_URL

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-serverspec.git



More information about the Pkg-ruby-extras-commits mailing list