serverspec 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/lib/serverspec/helper/type.rb +7 -8
  2. data/lib/serverspec/matchers.rb +2 -0
  3. data/lib/serverspec/matchers/be_reachable.rb +6 -1
  4. data/lib/serverspec/matchers/be_resolvable.rb +6 -1
  5. data/lib/serverspec/matchers/have_entry.rb +2 -0
  6. data/lib/serverspec/matchers/have_rule.rb +11 -0
  7. data/lib/serverspec/type/default_gateway.rb +21 -0
  8. data/lib/serverspec/type/host.rb +13 -0
  9. data/lib/serverspec/type/iptables.rb +12 -0
  10. data/lib/serverspec/type/linux_kernel_parameter.rb +12 -0
  11. data/lib/serverspec/type/routing_table.rb +13 -0
  12. data/lib/serverspec/version.rb +1 -1
  13. data/spec/darwin/default_gateway_spec.rb +7 -0
  14. data/spec/darwin/host_spec.rb +12 -0
  15. data/spec/darwin/routing_table_spec.rb +7 -0
  16. data/spec/debian/default_gateway_spec.rb +7 -0
  17. data/spec/debian/host_spec.rb +12 -0
  18. data/spec/debian/iptables_spec.rb +8 -0
  19. data/spec/debian/linux_kernel_parameter_spec.rb +9 -0
  20. data/spec/debian/routing_table_spec.rb +7 -0
  21. data/spec/gentoo/default_gateway_spec.rb +7 -0
  22. data/spec/gentoo/host_spec.rb +12 -0
  23. data/spec/gentoo/iptables_spec.rb +8 -0
  24. data/spec/gentoo/linux_kernel_parameter_spec.rb +9 -0
  25. data/spec/redhat/default_gateway_spec.rb +7 -0
  26. data/spec/redhat/host_spec.rb +12 -0
  27. data/spec/redhat/iptables_spec.rb +8 -0
  28. data/spec/redhat/linux_kernel_parameter_spec.rb +9 -0
  29. data/spec/redhat/routing_table_spec.rb +7 -0
  30. data/spec/solaris/default_gateway_spec.rb +7 -0
  31. data/spec/solaris/host_spec.rb +12 -0
  32. data/spec/solaris/routing_table_spec.rb +7 -0
  33. data/spec/support/shared_default_gateway_examples.rb +17 -0
  34. data/spec/support/shared_host_examples.rb +53 -0
  35. data/spec/support/shared_iptables_examples.rb +23 -0
  36. data/spec/support/shared_linux_kernel_parameter_examples.rb +53 -0
  37. data/spec/support/shared_routing_table_examples.rb +130 -0
  38. metadata +57 -1
@@ -2,13 +2,8 @@ module Serverspec
2
2
  module Helper
3
3
  module Type
4
4
  types = %w(
5
- base
6
- service
7
- package
8
- port
9
- file
10
- cron
11
- command
5
+ base service package port file cron command linux_kernel_parameter iptables host
6
+ routing_table default_gateway
12
7
  )
13
8
 
14
9
  types.each {|type| require "serverspec/type/#{type}" }
@@ -16,9 +11,13 @@ module Serverspec
16
11
  types.each do |type|
17
12
  define_method type do |*args|
18
13
  name = args.first
19
- self.class.const_get('Serverspec').const_get('Type').const_get(type.capitalize).new(name)
14
+ self.class.const_get('Serverspec').const_get('Type').const_get(camelize(type)).new(name)
20
15
  end
21
16
  end
17
+
18
+ def camelize(string)
19
+ string.split("_").each {|s| s.capitalize! }.join("")
20
+ end
22
21
  end
23
22
  end
24
23
  end
@@ -40,3 +40,5 @@ require 'serverspec/matchers/return_exit_status'
40
40
  require 'serverspec/matchers/return_stdout'
41
41
  require 'serverspec/matchers/return_stderr'
42
42
  require 'serverspec/matchers/match_md5checksum'
43
+
44
+ require 'serverspec/matchers/have_rule'
@@ -8,10 +8,15 @@ RSpec::Matchers.define :be_reachable do
8
8
  timeout = @attr[:timeout] if @attr[:timeout]
9
9
  end
10
10
 
11
- backend.check_reachable(example, host, port, proto, timeout)
11
+ if host.respond_to?(:reachable?)
12
+ host.reachable?(port, proto, timeout)
13
+ else
14
+ backend.check_reachable(example, host, port, proto, timeout)
15
+ end
12
16
  end
13
17
 
14
18
  chain :with do |attr|
15
19
  @attr = attr
16
20
  end
17
21
  end
22
+
@@ -1,8 +1,13 @@
1
1
  RSpec::Matchers.define :be_resolvable do
2
2
  match do |name|
3
- backend.check_resolvable(example, name, @type)
3
+ if name.respond_to?(:resolvable?)
4
+ name.resolvable?(@type)
5
+ else
6
+ backend.check_resolvable(example, name, @type)
7
+ end
4
8
  end
5
9
  chain :by do |type|
6
10
  @type = type
7
11
  end
8
12
  end
13
+
@@ -2,6 +2,8 @@ RSpec::Matchers.define :have_entry do |entry|
2
2
  match do |subject|
3
3
  if subject.class.name == 'Serverspec::Type::Cron'
4
4
  subject.has_entry?(@user, entry)
5
+ elsif subject.respond_to?(:has_entry?)
6
+ subject.has_entry?(entry)
5
7
  else
6
8
  backend.check_routing_table(example, entry)
7
9
  end
@@ -0,0 +1,11 @@
1
+ RSpec::Matchers.define :have_rule do |rule|
2
+ match do |iptables|
3
+ iptables.has_rule?(rule, @table, @chain)
4
+ end
5
+ chain :with_table do |table|
6
+ @table = table
7
+ end
8
+ chain :with_chain do |chain|
9
+ @chain = chain
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ module Serverspec
2
+ module Type
3
+ class DefaultGateway < Base
4
+ def ipaddress
5
+ ret = backend.run_command(commands.check_routing_table('default'))
6
+ ret[:stdout] =~ /^(\S+)(?: via (\S+))? dev (\S+).+\r\n(?:default via (\S+))?/
7
+ $2 ? $2 : $4
8
+ end
9
+
10
+ def interface
11
+ ret = backend.run_command(commands.check_routing_table('default'))
12
+ ret[:stdout] =~ /^(\S+)(?: via (\S+))? dev (\S+).+\r\n(?:default via (\S+))?/
13
+ $3
14
+ end
15
+
16
+ def to_s
17
+ 'Default Gateway'
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ module Serverspec
2
+ module Type
3
+ class Host < Base
4
+ def resolvable?(type)
5
+ backend.check_resolvable(nil, @name, type)
6
+ end
7
+
8
+ def reachable?(port, proto, timeout)
9
+ backend.check_reachable(nil, @name, port, proto, timeout)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Serverspec
2
+ module Type
3
+ class Iptables < Base
4
+ def has_rule?(rule, table, chain)
5
+ backend.check_iptables_rule(nil, rule, table, chain)
6
+ end
7
+ def to_s
8
+ 'iptables'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Serverspec
2
+ module Type
3
+ class LinuxKernelParameter < Base
4
+ def value
5
+ ret = backend.run_command("/sbin/sysctl -q -n #{@name}")
6
+ val = ret[:stdout].strip
7
+ val = val.to_i if val.match(/^\d+$/)
8
+ val
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module Serverspec
2
+ module Type
3
+ class RoutingTable < Base
4
+ def has_entry?(entry)
5
+ backend.check_routing_table(nil, entry)
6
+ end
7
+
8
+ def to_s
9
+ 'Routing Table'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Darwin
4
+
5
+ describe 'Serverspec default gateway matchers of Darwin family' do
6
+ it_behaves_like 'support default gateway matcher'
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Darwin
4
+
5
+ describe 'Serverspec host matchers of Darwin family' do
6
+ it_behaves_like 'support host be_reachable matcher', '127.0.0.1'
7
+ it_behaves_like 'support host be_reachable with matcher', '127.0.0.1'
8
+
9
+ it_behaves_like 'support host be_resolvable matcher', 'localhost'
10
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'hosts'
11
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'dns'
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Darwin
4
+
5
+ describe 'Serverspec routing table matchers of Darwin family' do
6
+ it_behaves_like 'support routing table have_entry matcher'
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Debian
4
+
5
+ describe 'Serverspec default gateway matchers of Debian family' do
6
+ it_behaves_like 'support default gateway matcher'
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Debian
4
+
5
+ describe 'Serverspec host matchers of Debian family' do
6
+ it_behaves_like 'support host be_reachable matcher', '127.0.0.1'
7
+ it_behaves_like 'support host be_reachable with matcher', '127.0.0.1'
8
+
9
+ it_behaves_like 'support host be_resolvable matcher', 'localhost'
10
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'hosts'
11
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'dns'
12
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Debian
4
+
5
+ describe 'Serverspec iptables matchers of Debian family' do
6
+ it_behaves_like 'support iptables have_rule matcher', '-P INPUT ACCEPT'
7
+ it_behaves_like 'support iptables have_rule with_table and with_chain matcher', '-P INPUT ACCEPT', 'mangle', 'INPUT'
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Debian
4
+
5
+ describe 'Serverspec linux kernel parameter matchers of Debian family' do
6
+ it_behaves_like 'support explicit linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
7
+ it_behaves_like 'support explicit linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
8
+ it_behaves_like 'support explicit linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Debian
4
+
5
+ describe 'Serverspec routing table matchers of Debian family' do
6
+ it_behaves_like 'support routing table have_entry matcher'
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Gentoo
4
+
5
+ describe 'Serverspec default gateway matchers of Gentoo family' do
6
+ it_behaves_like 'support default gateway matcher'
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Gentoo
4
+
5
+ describe 'Serverspec host matchers of Gentoo family' do
6
+ it_behaves_like 'support host be_reachable matcher', '127.0.0.1'
7
+ it_behaves_like 'support host be_reachable with matcher', '127.0.0.1'
8
+
9
+ it_behaves_like 'support host be_resolvable matcher', 'localhost'
10
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'hosts'
11
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'dns'
12
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Gentoo
4
+
5
+ describe 'Serverspec iptables matchers of Gentoo family' do
6
+ it_behaves_like 'support iptables have_rule matcher', '-P INPUT ACCEPT'
7
+ it_behaves_like 'support iptables have_rule with_table and with_chain matcher', '-P INPUT ACCEPT', 'mangle', 'INPUT'
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Gentoo
4
+
5
+ describe 'Serverspec linux kernel parameter matchers of Gentoo family' do
6
+ it_behaves_like 'support explicit linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
7
+ it_behaves_like 'support explicit linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
8
+ it_behaves_like 'support explicit linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::RedHat
4
+
5
+ describe 'Serverspec default gateway matchers of Red Hat family' do
6
+ it_behaves_like 'support default gateway matcher'
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::RedHat
4
+
5
+ describe 'Serverspec host matchers of Red Hat family' do
6
+ it_behaves_like 'support host be_reachable matcher', '127.0.0.1'
7
+ it_behaves_like 'support host be_reachable with matcher', '127.0.0.1'
8
+
9
+ it_behaves_like 'support host be_resolvable matcher', 'localhost'
10
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'hosts'
11
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'dns'
12
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::RedHat
4
+
5
+ describe 'Serverspec iptables matchers of Red Hat family' do
6
+ it_behaves_like 'support iptables have_rule matcher', '-P INPUT ACCEPT'
7
+ it_behaves_like 'support iptables have_rule with_table and with_chain matcher', '-P INPUT ACCEPT', 'mangle', 'INPUT'
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::RedHat
4
+
5
+ describe 'Serverspec linux kernel parameter matchers of Red Hat family' do
6
+ it_behaves_like 'support explicit linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
7
+ it_behaves_like 'support explicit linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
8
+ it_behaves_like 'support explicit linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::RedHat
4
+
5
+ describe 'Serverspec routing table matchers of Red Hat family' do
6
+ it_behaves_like 'support routing table have_entry matcher'
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris
4
+
5
+ describe 'Serverspec default gateway matchers of Solaris family' do
6
+ it_behaves_like 'support default gateway matcher'
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris
4
+
5
+ describe 'Serverspec host matchers of Solaris family' do
6
+ it_behaves_like 'support host be_reachable matcher', '127.0.0.1'
7
+ it_behaves_like 'support host be_reachable with matcher', '127.0.0.1'
8
+
9
+ it_behaves_like 'support host be_resolvable matcher', 'localhost'
10
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'hosts'
11
+ it_behaves_like 'support host be_resolvable by matcher', 'localhost', 'dns'
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Solaris
4
+
5
+ describe 'Serverspec routing table matchers of Solaris family' do
6
+ it_behaves_like 'support routing table have_entry matcher'
7
+ end
@@ -0,0 +1,17 @@
1
+ shared_examples_for 'support default gateway matcher' do
2
+ describe 'default_gateway' do
3
+ before :all do
4
+ RSpec.configure do |c|
5
+ c.stdout = "default via 192.168.1.1 dev eth1 \r\n"
6
+ end
7
+ end
8
+
9
+ describe default_gateway do
10
+ its(:ipaddress) { should eq '192.168.1.1' }
11
+ its(:interface) { should eq 'eth1' }
12
+
13
+ its(:ipaddress) { should_not eq '192.168.1.2' }
14
+ its(:interface) { should_not eq 'eth0' }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,53 @@
1
+ shared_examples_for 'support host be_resolvable matcher' do |name|
2
+ describe 'be_resolvable' do
3
+ describe host(name) do
4
+ it { should be_resolvable }
5
+ end
6
+
7
+ describe host('invalid-name') do
8
+ it { should_not be_resolvable }
9
+ end
10
+ end
11
+ end
12
+
13
+
14
+ shared_examples_for 'support host be_resolvable by matcher' do |name, type|
15
+ describe 'be_resolvable.by' do
16
+ describe host(name) do
17
+ it { should be_resolvable.by(type) }
18
+ end
19
+
20
+ describe host('invalid-name') do
21
+ it { should_not be_resolvable.by(type) }
22
+ end
23
+ end
24
+ end
25
+
26
+ shared_examples_for 'support host be_reachable matcher' do |name|
27
+ describe 'be_reachable' do
28
+ context host(name) do
29
+ it { should be_reachable }
30
+ end
31
+
32
+ describe host('invalid-host') do
33
+ it { should_not be_reachable }
34
+ end
35
+ end
36
+ end
37
+
38
+ shared_examples_for 'support host be_reachable with matcher' do |name|
39
+ describe 'be_reachable.with' do
40
+ context host(name) do
41
+ it { should be_reachable.with(:proto => "icmp", :timeout=> 1) }
42
+ end
43
+ context host(name) do
44
+ it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) }
45
+ end
46
+ context host(name) do
47
+ it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
48
+ end
49
+ context host('invalid-host') do
50
+ it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,23 @@
1
+ shared_examples_for 'support iptables have_rule matcher' do |rule|
2
+ describe 'have_rule' do
3
+ describe iptables do
4
+ it { should have_rule rule }
5
+ end
6
+
7
+ describe iptables do
8
+ it { should_not have_rule 'invalid-rule' }
9
+ end
10
+ end
11
+ end
12
+
13
+ shared_examples_for 'support iptables have_rule with_table and with_chain matcher' do |rule, table, chain|
14
+ describe 'have_rule with_table and with_chain' do
15
+ describe iptables do
16
+ it { should have_iptables_rule(rule).with_table(table).with_chain(chain) }
17
+ end
18
+
19
+ describe iptables do
20
+ it { should_not have_iptables_rule('invalid-rule').with_table(table).with_chain(chain) }
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,53 @@
1
+ shared_examples_for 'support explicit linux kernel parameter checking with integer' do |param, value|
2
+ describe 'linux kernel parameter' do
3
+ before :all do
4
+ RSpec.configure do |c|
5
+ c.stdout = "#{value}\n"
6
+ end
7
+ end
8
+
9
+ context linux_kernel_parameter(param) do
10
+ its(:value) { should eq value }
11
+ end
12
+
13
+ context linux_kernel_parameter(param) do
14
+ its(:value) { should_not eq value + 1 }
15
+ end
16
+ end
17
+ end
18
+
19
+ shared_examples_for 'support explicit linux kernel parameter checking with string' do |param, value|
20
+ describe 'linux kernel parameter' do
21
+ before :all do
22
+ RSpec.configure do |c|
23
+ c.stdout = "#{value}\n"
24
+ end
25
+ end
26
+
27
+ context linux_kernel_parameter(param) do
28
+ its(:value) { should eq value }
29
+ end
30
+
31
+ context linux_kernel_parameter(param) do
32
+ its(:value) { should_not eq value + '_suffix' }
33
+ end
34
+ end
35
+ end
36
+
37
+ shared_examples_for 'support explicit linux kernel parameter checking with regexp' do |param, regexp|
38
+ describe 'linux kernel parameter' do
39
+ before :all do
40
+ RSpec.configure do |c|
41
+ c.stdout = "4096 16384 4194304\n"
42
+ end
43
+ end
44
+
45
+ context linux_kernel_parameter(param) do
46
+ its(:value) { should match regexp }
47
+ end
48
+
49
+ context linux_kernel_parameter(param) do
50
+ its(:value) { should_not match /invalid-string/ }
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,130 @@
1
+ shared_examples_for 'support routing table have_entry matcher' do
2
+ describe 'routing table have_entry pattern #1' do
3
+ before :all do
4
+ RSpec.configure do |c|
5
+ c.stdout = "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n"
6
+ end
7
+ end
8
+
9
+ context routing_table do
10
+ it { should have_entry( :destination => '192.168.100.0/24' ) }
11
+ it { should_not have_entry( :destination => '192.168.100.100/24' ) }
12
+
13
+ it do
14
+ should have_entry(
15
+ :destination => '192.168.100.0/24',
16
+ :gateway => '192.168.100.1'
17
+ )
18
+ end
19
+
20
+ it do
21
+ should have_entry(
22
+ :destination => '192.168.100.0/24',
23
+ :gateway => '192.168.100.1',
24
+ :interface => 'eth1'
25
+ )
26
+ end
27
+
28
+ it do
29
+ should_not have_entry(
30
+ :gateway => '192.168.100.1',
31
+ :interface => 'eth1'
32
+ )
33
+ end
34
+
35
+ it do
36
+ should_not have_entry(
37
+ :destination => '192.168.100.0/32',
38
+ :gateway => '192.168.100.1',
39
+ :interface => 'eth1'
40
+ )
41
+ end
42
+ end
43
+ end
44
+
45
+ describe 'routing table have_entry pattern #2' do
46
+ before :all do
47
+ RSpec.configure do |c|
48
+ c.stdout = "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n"
49
+ end
50
+ end
51
+
52
+ context routing_table do
53
+ it { should have_entry( :destination => '192.168.200.0/24' ) }
54
+ it { should_not have_entry( :destination => '192.168.200.200/24' ) }
55
+
56
+ it do
57
+ should have_entry(
58
+ :destination => '192.168.200.0/24',
59
+ :gateway => '192.168.200.1'
60
+ )
61
+ end
62
+
63
+ it do
64
+ should have_entry(
65
+ :destination => '192.168.200.0/24',
66
+ :gateway => '192.168.200.1',
67
+ :interface => 'eth0'
68
+ )
69
+ end
70
+
71
+ it do
72
+ should_not have_entry(
73
+ :gateway => '192.168.200.1',
74
+ :interface => 'eth0'
75
+ )
76
+ end
77
+
78
+ it do
79
+ should_not have_entry(
80
+ :destination => '192.168.200.0/32',
81
+ :gateway => '192.168.200.1',
82
+ :interface => 'eth0'
83
+ )
84
+ end
85
+ end
86
+ end
87
+
88
+ describe 'routing table have_entry #3' do
89
+ before :all do
90
+ RSpec.configure do |c|
91
+ c.stdout = "default via 10.0.2.2 dev eth0 \r\n"
92
+ end
93
+ end
94
+
95
+ context routing_table do
96
+ it { should have_entry( :destination => 'default' ) }
97
+ it { should_not have_entry( :destination => 'defaulth' ) }
98
+
99
+ it do
100
+ should have_entry(
101
+ :destination => 'default',
102
+ :gateway => '10.0.2.2'
103
+ )
104
+ end
105
+
106
+ it do
107
+ should have_entry(
108
+ :destination => 'default',
109
+ :gateway => '10.0.2.2',
110
+ :interface => 'eth0'
111
+ )
112
+ end
113
+
114
+ it do
115
+ should_not have_entry(
116
+ :gateway => '10.0.2.2',
117
+ :interface => 'eth0'
118
+ )
119
+ end
120
+
121
+ it do
122
+ should_not have_entry(
123
+ :destination => 'default',
124
+ :gateway => '10.0.2.1',
125
+ :interface => 'eth0'
126
+ )
127
+ end
128
+ end
129
+ end
130
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -203,6 +203,7 @@ files:
203
203
  - lib/serverspec/matchers/have_ipnat_rule.rb
204
204
  - lib/serverspec/matchers/have_iptables_rule.rb
205
205
  - lib/serverspec/matchers/have_login_shell.rb
206
+ - lib/serverspec/matchers/have_rule.rb
206
207
  - lib/serverspec/matchers/have_svcprop.rb
207
208
  - lib/serverspec/matchers/have_svcprops.rb
208
209
  - lib/serverspec/matchers/have_uid.rb
@@ -215,32 +216,49 @@ files:
215
216
  - lib/serverspec/type/base.rb
216
217
  - lib/serverspec/type/command.rb
217
218
  - lib/serverspec/type/cron.rb
219
+ - lib/serverspec/type/default_gateway.rb
218
220
  - lib/serverspec/type/file.rb
221
+ - lib/serverspec/type/host.rb
222
+ - lib/serverspec/type/iptables.rb
223
+ - lib/serverspec/type/linux_kernel_parameter.rb
219
224
  - lib/serverspec/type/package.rb
220
225
  - lib/serverspec/type/port.rb
226
+ - lib/serverspec/type/routing_table.rb
221
227
  - lib/serverspec/type/service.rb
222
228
  - lib/serverspec/version.rb
223
229
  - serverspec.gemspec
224
230
  - spec/darwin/command_spec.rb
225
231
  - spec/darwin/commands_spec.rb
226
232
  - spec/darwin/cron_spec.rb
233
+ - spec/darwin/default_gateway_spec.rb
227
234
  - spec/darwin/file_spec.rb
235
+ - spec/darwin/host_spec.rb
228
236
  - spec/darwin/matchers_spec.rb
229
237
  - spec/darwin/package_spec.rb
230
238
  - spec/darwin/port_spec.rb
239
+ - spec/darwin/routing_table_spec.rb
231
240
  - spec/darwin/service_spec.rb
232
241
  - spec/debian/command_spec.rb
233
242
  - spec/debian/commands_spec.rb
234
243
  - spec/debian/cron_spec.rb
244
+ - spec/debian/default_gateway_spec.rb
235
245
  - spec/debian/file_spec.rb
246
+ - spec/debian/host_spec.rb
247
+ - spec/debian/iptables_spec.rb
248
+ - spec/debian/linux_kernel_parameter_spec.rb
236
249
  - spec/debian/matchers_spec.rb
237
250
  - spec/debian/package_spec.rb
238
251
  - spec/debian/port_spec.rb
252
+ - spec/debian/routing_table_spec.rb
239
253
  - spec/debian/service_spec.rb
240
254
  - spec/gentoo/command_spec.rb
241
255
  - spec/gentoo/commands_spec.rb
242
256
  - spec/gentoo/cron_spec.rb
257
+ - spec/gentoo/default_gateway_spec.rb
243
258
  - spec/gentoo/file_spec.rb
259
+ - spec/gentoo/host_spec.rb
260
+ - spec/gentoo/iptables_spec.rb
261
+ - spec/gentoo/linux_kernel_parameter_spec.rb
244
262
  - spec/gentoo/matchers_spec.rb
245
263
  - spec/gentoo/package_spec.rb
246
264
  - spec/gentoo/port_spec.rb
@@ -249,26 +267,39 @@ files:
249
267
  - spec/redhat/command_spec.rb
250
268
  - spec/redhat/commands_spec.rb
251
269
  - spec/redhat/cron_spec.rb
270
+ - spec/redhat/default_gateway_spec.rb
252
271
  - spec/redhat/file_spec.rb
272
+ - spec/redhat/host_spec.rb
273
+ - spec/redhat/iptables_spec.rb
274
+ - spec/redhat/linux_kernel_parameter_spec.rb
253
275
  - spec/redhat/matchers_spec.rb
254
276
  - spec/redhat/package_spec.rb
255
277
  - spec/redhat/port_spec.rb
278
+ - spec/redhat/routing_table_spec.rb
256
279
  - spec/redhat/service_spec.rb
257
280
  - spec/solaris/command_spec.rb
258
281
  - spec/solaris/commands_spec.rb
259
282
  - spec/solaris/cron_spec.rb
283
+ - spec/solaris/default_gateway_spec.rb
260
284
  - spec/solaris/file_spec.rb
285
+ - spec/solaris/host_spec.rb
261
286
  - spec/solaris/matchers_spec.rb
262
287
  - spec/solaris/package_spec.rb
263
288
  - spec/solaris/port_spec.rb
289
+ - spec/solaris/routing_table_spec.rb
264
290
  - spec/solaris/service_spec.rb
265
291
  - spec/spec_helper.rb
266
292
  - spec/support/shared_command_examples.rb
267
293
  - spec/support/shared_cron_examples.rb
294
+ - spec/support/shared_default_gateway_examples.rb
268
295
  - spec/support/shared_file_examples.rb
296
+ - spec/support/shared_host_examples.rb
297
+ - spec/support/shared_iptables_examples.rb
298
+ - spec/support/shared_linux_kernel_parameter_examples.rb
269
299
  - spec/support/shared_matcher_examples.rb
270
300
  - spec/support/shared_package_examples.rb
271
301
  - spec/support/shared_port_examples.rb
302
+ - spec/support/shared_routing_table_examples.rb
272
303
  - spec/support/shared_service_examples.rb
273
304
  homepage: http://serverspec.org/
274
305
  licenses:
@@ -299,23 +330,35 @@ test_files:
299
330
  - spec/darwin/command_spec.rb
300
331
  - spec/darwin/commands_spec.rb
301
332
  - spec/darwin/cron_spec.rb
333
+ - spec/darwin/default_gateway_spec.rb
302
334
  - spec/darwin/file_spec.rb
335
+ - spec/darwin/host_spec.rb
303
336
  - spec/darwin/matchers_spec.rb
304
337
  - spec/darwin/package_spec.rb
305
338
  - spec/darwin/port_spec.rb
339
+ - spec/darwin/routing_table_spec.rb
306
340
  - spec/darwin/service_spec.rb
307
341
  - spec/debian/command_spec.rb
308
342
  - spec/debian/commands_spec.rb
309
343
  - spec/debian/cron_spec.rb
344
+ - spec/debian/default_gateway_spec.rb
310
345
  - spec/debian/file_spec.rb
346
+ - spec/debian/host_spec.rb
347
+ - spec/debian/iptables_spec.rb
348
+ - spec/debian/linux_kernel_parameter_spec.rb
311
349
  - spec/debian/matchers_spec.rb
312
350
  - spec/debian/package_spec.rb
313
351
  - spec/debian/port_spec.rb
352
+ - spec/debian/routing_table_spec.rb
314
353
  - spec/debian/service_spec.rb
315
354
  - spec/gentoo/command_spec.rb
316
355
  - spec/gentoo/commands_spec.rb
317
356
  - spec/gentoo/cron_spec.rb
357
+ - spec/gentoo/default_gateway_spec.rb
318
358
  - spec/gentoo/file_spec.rb
359
+ - spec/gentoo/host_spec.rb
360
+ - spec/gentoo/iptables_spec.rb
361
+ - spec/gentoo/linux_kernel_parameter_spec.rb
319
362
  - spec/gentoo/matchers_spec.rb
320
363
  - spec/gentoo/package_spec.rb
321
364
  - spec/gentoo/port_spec.rb
@@ -324,24 +367,37 @@ test_files:
324
367
  - spec/redhat/command_spec.rb
325
368
  - spec/redhat/commands_spec.rb
326
369
  - spec/redhat/cron_spec.rb
370
+ - spec/redhat/default_gateway_spec.rb
327
371
  - spec/redhat/file_spec.rb
372
+ - spec/redhat/host_spec.rb
373
+ - spec/redhat/iptables_spec.rb
374
+ - spec/redhat/linux_kernel_parameter_spec.rb
328
375
  - spec/redhat/matchers_spec.rb
329
376
  - spec/redhat/package_spec.rb
330
377
  - spec/redhat/port_spec.rb
378
+ - spec/redhat/routing_table_spec.rb
331
379
  - spec/redhat/service_spec.rb
332
380
  - spec/solaris/command_spec.rb
333
381
  - spec/solaris/commands_spec.rb
334
382
  - spec/solaris/cron_spec.rb
383
+ - spec/solaris/default_gateway_spec.rb
335
384
  - spec/solaris/file_spec.rb
385
+ - spec/solaris/host_spec.rb
336
386
  - spec/solaris/matchers_spec.rb
337
387
  - spec/solaris/package_spec.rb
338
388
  - spec/solaris/port_spec.rb
389
+ - spec/solaris/routing_table_spec.rb
339
390
  - spec/solaris/service_spec.rb
340
391
  - spec/spec_helper.rb
341
392
  - spec/support/shared_command_examples.rb
342
393
  - spec/support/shared_cron_examples.rb
394
+ - spec/support/shared_default_gateway_examples.rb
343
395
  - spec/support/shared_file_examples.rb
396
+ - spec/support/shared_host_examples.rb
397
+ - spec/support/shared_iptables_examples.rb
398
+ - spec/support/shared_linux_kernel_parameter_examples.rb
344
399
  - spec/support/shared_matcher_examples.rb
345
400
  - spec/support/shared_package_examples.rb
346
401
  - spec/support/shared_port_examples.rb
402
+ - spec/support/shared_routing_table_examples.rb
347
403
  - spec/support/shared_service_examples.rb