serverspec 2.0.0.beta2 → 2.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/Rakefile +2 -27
  4. data/lib/serverspec/helper.rb +0 -1
  5. data/lib/serverspec/helper/os.rb +2 -0
  6. data/lib/serverspec/helper/type.rb +1 -1
  7. data/lib/serverspec/setup.rb +11 -12
  8. data/lib/serverspec/type/base.rb +2 -1
  9. data/lib/serverspec/type/cgroup.rb +1 -1
  10. data/lib/serverspec/type/command.rb +1 -1
  11. data/lib/serverspec/type/cron.rb +1 -1
  12. data/lib/serverspec/type/default_gateway.rb +2 -2
  13. data/lib/serverspec/type/file.rb +22 -22
  14. data/lib/serverspec/type/group.rb +2 -2
  15. data/lib/serverspec/type/host.rb +3 -3
  16. data/lib/serverspec/type/iis_app_pool.rb +2 -2
  17. data/lib/serverspec/type/iis_website.rb +5 -5
  18. data/lib/serverspec/type/interface.rb +2 -2
  19. data/lib/serverspec/type/ipfilter.rb +1 -1
  20. data/lib/serverspec/type/ipnat.rb +1 -1
  21. data/lib/serverspec/type/iptables.rb +1 -1
  22. data/lib/serverspec/type/kernel_module.rb +1 -1
  23. data/lib/serverspec/type/linux_kernel_parameter.rb +1 -1
  24. data/lib/serverspec/type/lxc.rb +2 -2
  25. data/lib/serverspec/type/mail_alias.rb +1 -1
  26. data/lib/serverspec/type/package.rb +4 -4
  27. data/lib/serverspec/type/php_config.rb +1 -1
  28. data/lib/serverspec/type/port.rb +2 -2
  29. data/lib/serverspec/type/process.rb +2 -2
  30. data/lib/serverspec/type/routing_table.rb +1 -1
  31. data/lib/serverspec/type/selinux.rb +3 -3
  32. data/lib/serverspec/type/service.rb +7 -8
  33. data/lib/serverspec/type/user.rb +6 -6
  34. data/lib/serverspec/type/windows_feature.rb +1 -1
  35. data/lib/serverspec/type/windows_hot_fix.rb +1 -1
  36. data/lib/serverspec/type/windows_registry_key.rb +4 -4
  37. data/lib/serverspec/type/windows_scheduled_task.rb +9 -0
  38. data/lib/serverspec/type/yumrepo.rb +2 -2
  39. data/lib/serverspec/type/zfs.rb +2 -2
  40. data/lib/serverspec/version.rb +1 -1
  41. data/spec/spec_helper.rb +2 -33
  42. data/spec/type/cgroup_spec.rb +13 -0
  43. data/spec/type/command_spec.rb +64 -0
  44. data/spec/type/cron_spec.rb +19 -0
  45. data/spec/type/default_gateway_spec.rb +14 -0
  46. data/spec/type/file_spec.rb +392 -0
  47. data/spec/type/group_spec.rb +19 -0
  48. data/spec/type/host_spec.rb +56 -0
  49. data/spec/type/interface_spec.rb +21 -0
  50. data/spec/type/iptables_spec.rb +19 -0
  51. data/spec/type/kernel_module_spec.rb +11 -0
  52. data/spec/type/linux_kernel_parameter_spec.rb +33 -0
  53. data/spec/type/lxc_spec.rb +20 -0
  54. data/spec/type/mail_alias_spec.rb +11 -0
  55. data/spec/type/package_spec.rb +104 -0
  56. data/spec/type/php_config_spec.rb +33 -0
  57. data/spec/type/port_spec.rb +27 -0
  58. data/spec/type/process_spec.rb +35 -0
  59. data/spec/type/routing_table_spec.rb +118 -0
  60. data/spec/type/selinux_spec.rb +15 -0
  61. data/spec/type/service_spec.rb +94 -0
  62. data/spec/type/user_spec.rb +51 -0
  63. data/spec/type/yumrepo_spec.rb +25 -0
  64. data/spec/type/zfs_spec.rb +15 -0
  65. metadata +49 -3
  66. data/lib/serverspec/helper/backend.rb +0 -11
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe interface('eth0') do
6
+ let(:stdout) { '1000' }
7
+ its(:speed) { should eq 1000 }
8
+ end
9
+
10
+ describe interface('eth0') do
11
+ it { should have_ipv4_address("192.168.10.10") }
12
+ end
13
+
14
+ describe interface('eth0') do
15
+ it { should have_ipv4_address("192.168.10.10/24") }
16
+ end
17
+
18
+ describe interface('invalid-interface') do
19
+ let(:stdout) { '1000' }
20
+ its(:speed) { should_not eq 100 }
21
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe iptables do
6
+ it { should have_rule '-P INPUT ACCEPT' }
7
+ end
8
+
9
+ describe iptables do
10
+ it { should_not have_rule 'invalid-rule' }
11
+ end
12
+
13
+ describe iptables do
14
+ it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
15
+ end
16
+
17
+ describe iptables do
18
+ it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') }
19
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe kernel_module('lp') do
6
+ it { should be_loaded }
7
+ end
8
+
9
+ describe kernel_module('invalid-module') do
10
+ it { should_not be_loaded }
11
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do
6
+ let(:stdout) { "1\n" }
7
+ its(:value) { should eq 1 }
8
+ end
9
+
10
+ describe linux_kernel_parameter('net.ipv4.tcp_syncookies') do
11
+ let(:stdout) { "1\n" }
12
+ its(:value) { should_not eq 2 }
13
+ end
14
+
15
+ describe linux_kernel_parameter('kernel.osrelease') do
16
+ let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" }
17
+ its(:value) { should eq "2.6.32-131.0.15.el6.x86_64" }
18
+ end
19
+
20
+ describe linux_kernel_parameter('kernel.osrelease') do
21
+ let(:stdout) { "2.6.32-131.0.15.el6.x86_64\n" }
22
+ its(:value) { should_not eq "2.6.32-131.0.15.el6.i386" }
23
+ end
24
+
25
+ describe linux_kernel_parameter('net.ipv4.tcp_wmem') do
26
+ let(:stdout) { "4096 16384 4194304\n" }
27
+ its(:value) { should match /16384/ }
28
+ end
29
+
30
+ describe linux_kernel_parameter('net.ipv4.tcp_wmem') do
31
+ let(:stdout) { "4096 16384 4194304\n" }
32
+ its(:value) { should_not match /123456/ }
33
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe lxc('ct01') do
6
+ it { should exist }
7
+ end
8
+
9
+ describe lxc('invalid-ct') do
10
+ it { should_not exist }
11
+ end
12
+
13
+ describe lxc('ct01') do
14
+ it { should be_running }
15
+ end
16
+
17
+ describe lxc('invalid-ct') do
18
+ it { should_not be_running }
19
+ end
20
+
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe mail_alias('daemon') do
6
+ it { should be_aliased_to "root" }
7
+ end
8
+
9
+ describe mail_alias('invalid-recipient') do
10
+ it { should_not be_aliased_to "foo" }
11
+ end
@@ -0,0 +1,104 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe package('httpd') do
6
+ it { should be_installed }
7
+ end
8
+
9
+ describe package('invalid-package') do
10
+ it { should_not be_installed }
11
+ end
12
+
13
+ describe package('invalid-package') do
14
+ it { should_not be_installed.by('rpm') }
15
+ end
16
+
17
+ describe package('httpd') do
18
+ it { should be_installed.with_version('2.2.15-28.el6') }
19
+ end
20
+
21
+ describe package('httpd') do
22
+ it { should be_installed.by('rpm').with_version('2.2.15-28.el6') }
23
+ end
24
+
25
+ describe package('httpd') do
26
+ it { should_not be_installed.with_version('invalid-version') }
27
+ end
28
+
29
+ describe package('jekyll') do
30
+ it { should be_installed.by('gem') }
31
+ end
32
+
33
+ describe package('invalid-gem') do
34
+ it { should_not be_installed.by('gem') }
35
+ end
36
+
37
+ describe package('jekyll') do
38
+ it { should be_installed.by('gem').with_version('1.1.1') }
39
+ end
40
+
41
+ describe package('jekyll') do
42
+ it { should_not be_installed.by('gem').with_version('invalid-version') }
43
+ end
44
+
45
+ describe package('bower') do
46
+ it { should be_installed.by('npm') }
47
+ end
48
+
49
+ describe package('invalid-npm-package') do
50
+ it { should_not be_installed.by('npm') }
51
+ end
52
+
53
+ describe package('bower') do
54
+ it { should be_installed.by('npm').with_version('0.9.2') }
55
+ end
56
+
57
+ describe package('bower') do
58
+ it { should_not be_installed.by('npm').with_version('invalid-version') }
59
+ end
60
+
61
+
62
+ describe package('mongo') do
63
+ it { should be_installed.by('pecl') }
64
+ end
65
+
66
+ describe package('invalid-pecl') do
67
+ it { should_not be_installed.by('pecl') }
68
+ end
69
+
70
+ describe package('mongo') do
71
+ it { should be_installed.by('pecl').with_version('1.4.1') }
72
+ end
73
+
74
+ describe package('mongo') do
75
+ it { should_not be_installed.by('pecl').with_version('invalid-version') }
76
+ end
77
+
78
+ describe package('XML_Util') do
79
+ it { should be_installed.by('pear').with_version('1.2.1') }
80
+ end
81
+
82
+ describe package('supervisor') do
83
+ it { should be_installed.by('pip').with_version('3.0') }
84
+ end
85
+
86
+ describe package('invalid-pip') do
87
+ it { should_not be_installed.by('pip').with_version('invalid-version') }
88
+ end
89
+
90
+ describe package('App::Ack') do
91
+ it { should be_installed.by('cpan') }
92
+ end
93
+
94
+ describe package('App::Ack') do
95
+ it { should be_installed.by('cpan').with_version('2.04') }
96
+ end
97
+
98
+ describe package('httpd') do
99
+ let(:stdout) { "2.2.15\n" }
100
+ its(:version) { should eq '2.2.15' }
101
+ its(:version) { should > '2.2.14' }
102
+ its(:version) { should < '2.2.16' }
103
+ its(:version) { should > '2.2.9' }
104
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe php_config('default_mimetype') do
6
+ let(:stdout) { 'text/html' }
7
+ its(:value) { should eq 'text/html' }
8
+ end
9
+
10
+ describe php_config('default_mimetype') do
11
+ let(:stdout) { 'text/html' }
12
+ its(:value) { should_not eq 'text/plain' }
13
+ end
14
+
15
+ describe php_config('session.cache_expire') do
16
+ let(:stdout) { '180' }
17
+ its(:value) { should eq 180 }
18
+ end
19
+
20
+ describe php_config('session.cache_expire') do
21
+ let(:stdout) { '180' }
22
+ its(:value) { should_not eq 360 }
23
+ end
24
+
25
+ describe php_config('mbstring.http_output_conv_mimetypes') do
26
+ let(:stdout) { 'application' }
27
+ its(:value) { should match /application/ }
28
+ end
29
+
30
+ describe php_config('mbstring.http_output_conv_mimetypes') do
31
+ let(:stdout) { 'application' }
32
+ its(:value) { should_not match /html/ }
33
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe port(80) do
6
+ it { should be_listening }
7
+ end
8
+
9
+ describe port('invalid') do
10
+ it { should_not be_listening }
11
+ end
12
+
13
+ describe port(80) do
14
+ it { should be_listening.with("tcp") }
15
+ end
16
+
17
+ describe port(123) do
18
+ it { should be_listening.with("udp") }
19
+ end
20
+
21
+ describe port(80) do
22
+ it {
23
+ expect {
24
+ should be_listening.with('not implemented')
25
+ }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/)
26
+ }
27
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe process("memcached") do
6
+ let(:stdout) { " 1407\n" }
7
+ its(:pid) { should eq 1407 }
8
+ end
9
+
10
+ describe process("memcached") do
11
+ let(:stdout) { "/usr/bin/memcached -m 14386 -p 11211 -u nobody -l 10.11.1.53 -c 30000\n" }
12
+ its(:args) { should match /-c 30000\b/ }
13
+ end
14
+
15
+ describe process("memcached") do
16
+ let(:stdout) { "nobody\n" }
17
+ its(:user) { should eq "nobody" }
18
+ end
19
+
20
+ describe process("memcached") do
21
+ let(:stdout) { "nobody\n" }
22
+ its(:group) { should eq "nobody" }
23
+ end
24
+
25
+ describe process("memcached") do
26
+ context "when running" do
27
+ let(:stdout) { " 1407\n" }
28
+ it { should be_running }
29
+ end
30
+
31
+ context "when not running" do
32
+ let(:stdout) { " 1407\n" }
33
+ it { should be_running }
34
+ end
35
+ end
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+
3
+ include Specinfra::Helper::RedHat
4
+
5
+ describe routing_table do
6
+ 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" }
7
+ it { should have_entry( :destination => '192.168.100.0/24' ) }
8
+ end
9
+
10
+ describe routing_table do
11
+ 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" }
12
+ it { should_not have_entry( :destination => '192.168.100.100/24' ) }
13
+ end
14
+
15
+ describe routing_table do
16
+ 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" }
17
+ it do
18
+ should have_entry(
19
+ :destination => '192.168.100.0/24',
20
+ :gateway => '192.168.100.1'
21
+ )
22
+ end
23
+
24
+ it do
25
+ should have_entry(
26
+ :destination => '192.168.100.0/24',
27
+ :gateway => '192.168.100.1',
28
+ :interface => 'eth1'
29
+ )
30
+ end
31
+
32
+ it do
33
+ should_not have_entry(
34
+ :gateway => '192.168.100.1',
35
+ :interface => 'eth1'
36
+ )
37
+ end
38
+
39
+ it do
40
+ should_not have_entry(
41
+ :destination => '192.168.100.0/32',
42
+ :gateway => '192.168.100.1',
43
+ :interface => 'eth1'
44
+ )
45
+ end
46
+ end
47
+
48
+ describe routing_table do
49
+ 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" }
50
+ it { should have_entry( :destination => '192.168.200.0/24' ) }
51
+ it { should_not have_entry( :destination => '192.168.200.200/24' ) }
52
+
53
+ it do
54
+ should have_entry(
55
+ :destination => '192.168.200.0/24',
56
+ :gateway => '192.168.200.1'
57
+ )
58
+ end
59
+
60
+ it do
61
+ should have_entry(
62
+ :destination => '192.168.200.0/24',
63
+ :gateway => '192.168.200.1',
64
+ :interface => 'eth0'
65
+ )
66
+ end
67
+
68
+ it do
69
+ should_not have_entry(
70
+ :gateway => '192.168.200.1',
71
+ :interface => 'eth0'
72
+ )
73
+ end
74
+
75
+ it do
76
+ should_not have_entry(
77
+ :destination => '192.168.200.0/32',
78
+ :gateway => '192.168.200.1',
79
+ :interface => 'eth0'
80
+ )
81
+ end
82
+ end
83
+
84
+ describe routing_table do
85
+ let(:stdout) { "default via 10.0.2.2 dev eth0 \r\n" }
86
+ it { should have_entry( :destination => 'default' ) }
87
+ it { should_not have_entry( :destination => 'defaulth' ) }
88
+
89
+ it do
90
+ should have_entry(
91
+ :destination => 'default',
92
+ :gateway => '10.0.2.2'
93
+ )
94
+ end
95
+
96
+ it do
97
+ should have_entry(
98
+ :destination => 'default',
99
+ :gateway => '10.0.2.2',
100
+ :interface => 'eth0'
101
+ )
102
+ end
103
+
104
+ it do
105
+ should_not have_entry(
106
+ :gateway => '10.0.2.2',
107
+ :interface => 'eth0'
108
+ )
109
+ end
110
+
111
+ it do
112
+ should_not have_entry(
113
+ :destination => 'default',
114
+ :gateway => '10.0.2.1',
115
+ :interface => 'eth0'
116
+ )
117
+ end
118
+ end