serverspec 0.6.16 → 0.6.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/README.md +1 -1
  2. data/lib/serverspec/backend/exec.rb +16 -0
  3. data/lib/serverspec/commands/base.rb +9 -1
  4. data/lib/serverspec/helper/configuration.rb +1 -0
  5. data/lib/serverspec/type/service.rb +9 -1
  6. data/lib/serverspec/version.rb +1 -1
  7. data/spec/backend/exec/configuration_spec.rb +12 -8
  8. data/spec/backend/ssh/configuration_spec.rb +21 -14
  9. data/spec/darwin/command_spec.rb +41 -6
  10. data/spec/darwin/commands_spec.rb +1 -8
  11. data/spec/darwin/cron_spec.rb +16 -3
  12. data/spec/darwin/default_gateway_spec.rb +11 -2
  13. data/spec/darwin/host_spec.rb +52 -6
  14. data/spec/darwin/port_spec.rb +7 -2
  15. data/spec/darwin/routing_table_spec.rb +115 -2
  16. data/spec/darwin/service_spec.rb +2 -0
  17. data/spec/debian/command_spec.rb +41 -6
  18. data/spec/debian/commands_spec.rb +5 -11
  19. data/spec/debian/cron_spec.rb +16 -3
  20. data/spec/debian/default_gateway_spec.rb +11 -2
  21. data/spec/debian/host_spec.rb +52 -6
  22. data/spec/debian/interface_spec.rb +9 -2
  23. data/spec/debian/iptables_spec.rb +16 -3
  24. data/spec/debian/linux_kernel_parameter_spec.rb +31 -4
  25. data/spec/debian/port_spec.rb +7 -2
  26. data/spec/debian/routing_table_spec.rb +115 -2
  27. data/spec/debian/service_spec.rb +3 -0
  28. data/spec/gentoo/command_spec.rb +41 -6
  29. data/spec/gentoo/commands_spec.rb +1 -11
  30. data/spec/gentoo/cron_spec.rb +16 -3
  31. data/spec/gentoo/default_gateway_spec.rb +11 -2
  32. data/spec/gentoo/host_spec.rb +52 -6
  33. data/spec/gentoo/interface_spec.rb +9 -2
  34. data/spec/gentoo/iptables_spec.rb +16 -3
  35. data/spec/gentoo/linux_kernel_parameter_spec.rb +31 -4
  36. data/spec/gentoo/port_spec.rb +7 -2
  37. data/spec/gentoo/routing_table_spec.rb +120 -0
  38. data/spec/gentoo/service_spec.rb +2 -0
  39. data/spec/redhat/command_spec.rb +41 -6
  40. data/spec/redhat/commands_spec.rb +5 -11
  41. data/spec/redhat/cron_spec.rb +16 -3
  42. data/spec/redhat/default_gateway_spec.rb +11 -2
  43. data/spec/redhat/host_spec.rb +52 -6
  44. data/spec/redhat/interface_spec.rb +9 -2
  45. data/spec/redhat/iptables_spec.rb +16 -3
  46. data/spec/redhat/linux_kernel_parameter_spec.rb +31 -4
  47. data/spec/redhat/port_spec.rb +7 -2
  48. data/spec/redhat/routing_table_spec.rb +115 -2
  49. data/spec/redhat/service_spec.rb +3 -0
  50. data/spec/smartos/commands_spec.rb +1 -30
  51. data/spec/solaris/command_spec.rb +41 -6
  52. data/spec/solaris/commands_spec.rb +1 -35
  53. data/spec/solaris/cron_spec.rb +16 -3
  54. data/spec/solaris/default_gateway_spec.rb +11 -2
  55. data/spec/solaris/host_spec.rb +52 -6
  56. data/spec/solaris/port_spec.rb +7 -2
  57. data/spec/solaris/routing_table_spec.rb +115 -2
  58. data/spec/solaris/service_spec.rb +2 -0
  59. data/spec/spec_helper.rb +36 -2
  60. data/spec/support/shared_commands_examples.rb +11 -69
  61. data/spec/support/shared_service_examples.rb +48 -0
  62. metadata +4 -20
  63. data/spec/support/shared_command_examples.rb +0 -77
  64. data/spec/support/shared_cron_examples.rb +0 -23
  65. data/spec/support/shared_default_gateway_examples.rb +0 -13
  66. data/spec/support/shared_host_examples.rb +0 -53
  67. data/spec/support/shared_interface_examples.rb +0 -12
  68. data/spec/support/shared_iptables_examples.rb +0 -23
  69. data/spec/support/shared_linux_kernel_parameter_examples.rb +0 -41
  70. data/spec/support/shared_port_examples.rb +0 -11
  71. data/spec/support/shared_routing_table_examples.rb +0 -118
@@ -1,77 +0,0 @@
1
- shared_examples_for 'support command return_stdout matcher' do |name, content|
2
- describe 'return_stdout' do
3
- describe command(name) do
4
- let(:stdout) { "#{content}\r\n" }
5
- it { should return_stdout(content) }
6
- end
7
-
8
- describe command(name) do
9
- let(:stdout) { "foo#{content}bar\r\n" }
10
- it { should_not return_stdout(content) }
11
- end
12
-
13
-
14
- describe command('invalid-command') do
15
- let(:stdout) { "foo bar\r\n" }
16
- it { should_not return_stdout(content) }
17
- end
18
- end
19
- end
20
-
21
- shared_examples_for 'support command return_stdout matcher with regexp' do |name, content|
22
- describe 'return_stdout' do
23
- describe command(name) do
24
- let(:stdout) { "foo#{content}bar\r\n" }
25
- it { should return_stdout(content) }
26
- end
27
-
28
- describe command(name) do
29
- let(:stdout) { "foobar\r\n" }
30
- it { should_not return_stdout(content) }
31
- end
32
-
33
- describe command('invalid-command') do
34
- it { should_not return_stdout(content) }
35
- end
36
- end
37
- end
38
-
39
- shared_examples_for 'support command return_stderr matcher' do |name, content|
40
- describe 'return_stderr' do
41
- describe command(name) do
42
- let(:stdout) { "#{content}\r\n" }
43
- it { should return_stderr(content) }
44
- end
45
-
46
- describe command(name) do
47
- let(:stdout) { "No such file or directory\r\n" }
48
- it { should_not return_stderr(content) }
49
- end
50
- end
51
- end
52
-
53
- shared_examples_for 'support command return_stderr matcher with regexp' do |name, content|
54
- describe 'return_stderr' do
55
- describe command(name) do
56
- let(:stdout) { "cat: /foo: No such file or directory\r\n" }
57
- it { should return_stdout(content) }
58
- end
59
-
60
- describe command(name) do
61
- let(:stdout) { "foobar\r\n" }
62
- it { should_not return_stdout(content) }
63
- end
64
- end
65
- end
66
-
67
- shared_examples_for 'support command return_exit_status matcher' do |name, status|
68
- describe 'return_exit_status' do
69
- describe command(name) do
70
- it { should return_exit_status(status) }
71
- end
72
-
73
- describe command('invalid-command') do
74
- it { should_not return_exit_status(status) }
75
- end
76
- end
77
- end
@@ -1,23 +0,0 @@
1
- shared_examples_for 'support cron have_entry matcher' do |entry|
2
- describe 'have_cron_entry' do
3
- describe cron do
4
- it { should have_entry entry }
5
- end
6
-
7
- describe cron do
8
- it { should_not have_entry 'invalid entry' }
9
- end
10
- end
11
- end
12
-
13
- shared_examples_for 'support cron have_entry with user matcher' do |entry, user|
14
- describe 'have_cron_entry' do
15
- describe cron do
16
- it { should have_entry(entry).with_user(user) }
17
- end
18
-
19
- describe cron do
20
- it { should_not have_entry('invalid entry').with_user(user) }
21
- end
22
- end
23
- end
@@ -1,13 +0,0 @@
1
- shared_examples_for 'support default gateway matcher' do
2
- describe 'default_gateway' do
3
- let(:stdout) { "default via 192.168.1.1 dev eth1 \r\n" }
4
-
5
- describe default_gateway do
6
- its(:ipaddress) { should eq '192.168.1.1' }
7
- its(:interface) { should eq 'eth1' }
8
-
9
- its(:ipaddress) { should_not eq '192.168.1.2' }
10
- its(:interface) { should_not eq 'eth0' }
11
- end
12
- end
13
- end
@@ -1,53 +0,0 @@
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
@@ -1,12 +0,0 @@
1
- shared_examples_for 'support interface matcher' do |name|
2
- describe 'interface' do
3
- let(:stdout) { '1000' }
4
- describe interface(name) do
5
- its(:speed) { should eq 1000 }
6
- end
7
-
8
- describe interface('invalid-interface') do
9
- its(:speed) { should_not eq 100 }
10
- end
11
- end
12
- end
@@ -1,23 +0,0 @@
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_rule(rule).with_table(table).with_chain(chain) }
17
- end
18
-
19
- describe iptables do
20
- it { should_not have_rule('invalid-rule').with_table(table).with_chain(chain) }
21
- end
22
- end
23
- end
@@ -1,41 +0,0 @@
1
- shared_examples_for 'support explicit linux kernel parameter checking with integer' do |param, value|
2
- describe 'linux kernel parameter' do
3
- let(:stdout) { "#{value}\n" }
4
-
5
- context linux_kernel_parameter(param) do
6
- its(:value) { should eq value }
7
- end
8
-
9
- context linux_kernel_parameter(param) do
10
- its(:value) { should_not eq value + 1 }
11
- end
12
- end
13
- end
14
-
15
- shared_examples_for 'support explicit linux kernel parameter checking with string' do |param, value|
16
- describe 'linux kernel parameter' do
17
- let(:stdout) { "#{value}\n" }
18
-
19
- context linux_kernel_parameter(param) do
20
- its(:value) { should eq value }
21
- end
22
-
23
- context linux_kernel_parameter(param) do
24
- its(:value) { should_not eq value + '_suffix' }
25
- end
26
- end
27
- end
28
-
29
- shared_examples_for 'support explicit linux kernel parameter checking with regexp' do |param, regexp|
30
- describe 'linux kernel parameter' do
31
- let(:stdout) { "4096 16384 4194304\n" }
32
-
33
- context linux_kernel_parameter(param) do
34
- its(:value) { should match regexp }
35
- end
36
-
37
- context linux_kernel_parameter(param) do
38
- its(:value) { should_not match /invalid-string/ }
39
- end
40
- end
41
- end
@@ -1,11 +0,0 @@
1
- shared_examples_for 'support port listening matcher' do |num|
2
- describe 'listening' do
3
- describe port(num) do
4
- it { should be_listening }
5
- end
6
-
7
- describe port('invalid') do
8
- it { should_not be_listening }
9
- end
10
- end
11
- end
@@ -1,118 +0,0 @@
1
- shared_examples_for 'support routing table have_entry matcher' do
2
- describe 'routing table have_entry pattern #1' do
3
- let(:stdout) { "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
4
-
5
- context routing_table do
6
- it { should have_entry( :destination => '192.168.100.0/24' ) }
7
- it { should_not have_entry( :destination => '192.168.100.100/24' ) }
8
-
9
- it do
10
- should have_entry(
11
- :destination => '192.168.100.0/24',
12
- :gateway => '192.168.100.1'
13
- )
14
- end
15
-
16
- it do
17
- should have_entry(
18
- :destination => '192.168.100.0/24',
19
- :gateway => '192.168.100.1',
20
- :interface => 'eth1'
21
- )
22
- end
23
-
24
- it do
25
- should_not have_entry(
26
- :gateway => '192.168.100.1',
27
- :interface => 'eth1'
28
- )
29
- end
30
-
31
- it do
32
- should_not have_entry(
33
- :destination => '192.168.100.0/32',
34
- :gateway => '192.168.100.1',
35
- :interface => 'eth1'
36
- )
37
- end
38
- end
39
- end
40
-
41
- describe 'routing table have_entry pattern #2' do
42
- let(:stdout) { "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n" }
43
-
44
- context routing_table do
45
- it { should have_entry( :destination => '192.168.200.0/24' ) }
46
- it { should_not have_entry( :destination => '192.168.200.200/24' ) }
47
-
48
- it do
49
- should have_entry(
50
- :destination => '192.168.200.0/24',
51
- :gateway => '192.168.200.1'
52
- )
53
- end
54
-
55
- it do
56
- should have_entry(
57
- :destination => '192.168.200.0/24',
58
- :gateway => '192.168.200.1',
59
- :interface => 'eth0'
60
- )
61
- end
62
-
63
- it do
64
- should_not have_entry(
65
- :gateway => '192.168.200.1',
66
- :interface => 'eth0'
67
- )
68
- end
69
-
70
- it do
71
- should_not have_entry(
72
- :destination => '192.168.200.0/32',
73
- :gateway => '192.168.200.1',
74
- :interface => 'eth0'
75
- )
76
- end
77
- end
78
- end
79
-
80
- describe 'routing table have_entry #3' do
81
- let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" }
82
-
83
- context routing_table do
84
- it { should have_entry( :destination => 'default' ) }
85
- it { should_not have_entry( :destination => 'defaulth' ) }
86
-
87
- it do
88
- should have_entry(
89
- :destination => 'default',
90
- :gateway => '10.0.2.2'
91
- )
92
- end
93
-
94
- it do
95
- should have_entry(
96
- :destination => 'default',
97
- :gateway => '10.0.2.2',
98
- :interface => 'eth0'
99
- )
100
- end
101
-
102
- it do
103
- should_not have_entry(
104
- :gateway => '10.0.2.2',
105
- :interface => 'eth0'
106
- )
107
- end
108
-
109
- it do
110
- should_not have_entry(
111
- :destination => 'default',
112
- :gateway => '10.0.2.1',
113
- :interface => 'eth0'
114
- )
115
- end
116
- end
117
- end
118
- end