serverspec-clc 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +26 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +14 -0
  5. data/Gemfile +8 -0
  6. data/Guardfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +15 -0
  9. data/Rakefile +30 -0
  10. data/WINDOWS_SUPPORT.md +116 -0
  11. data/bin/serverspec-init +7 -0
  12. data/lib/serverspec.rb +33 -0
  13. data/lib/serverspec/commands/base.rb +7 -0
  14. data/lib/serverspec/helper.rb +8 -0
  15. data/lib/serverspec/helper/type.rb +23 -0
  16. data/lib/serverspec/matcher.rb +35 -0
  17. data/lib/serverspec/matcher/be_enabled.rb +13 -0
  18. data/lib/serverspec/matcher/be_executable.rb +13 -0
  19. data/lib/serverspec/matcher/be_installed.rb +13 -0
  20. data/lib/serverspec/matcher/be_listening.rb +13 -0
  21. data/lib/serverspec/matcher/be_mounted.rb +15 -0
  22. data/lib/serverspec/matcher/be_reachable.rb +17 -0
  23. data/lib/serverspec/matcher/be_readable.rb +13 -0
  24. data/lib/serverspec/matcher/be_resolvable.rb +9 -0
  25. data/lib/serverspec/matcher/be_running.rb +13 -0
  26. data/lib/serverspec/matcher/be_writable.rb +13 -0
  27. data/lib/serverspec/matcher/belong_to_group.rb +5 -0
  28. data/lib/serverspec/matcher/belong_to_primary_group.rb +5 -0
  29. data/lib/serverspec/matcher/contain.rb +24 -0
  30. data/lib/serverspec/matcher/have_entry.rb +14 -0
  31. data/lib/serverspec/matcher/have_rule.rb +17 -0
  32. data/lib/serverspec/matcher/have_site_application.rb +18 -0
  33. data/lib/serverspec/matcher/have_site_bindings.rb +22 -0
  34. data/lib/serverspec/matcher/have_virtual_dir.rb +14 -0
  35. data/lib/serverspec/setup.rb +333 -0
  36. data/lib/serverspec/subject.rb +12 -0
  37. data/lib/serverspec/type/base.rb +21 -0
  38. data/lib/serverspec/type/cgroup.rb +17 -0
  39. data/lib/serverspec/type/command.rb +20 -0
  40. data/lib/serverspec/type/cron.rb +11 -0
  41. data/lib/serverspec/type/default_gateway.rb +15 -0
  42. data/lib/serverspec/type/file.rb +113 -0
  43. data/lib/serverspec/type/group.rb +11 -0
  44. data/lib/serverspec/type/host.rb +15 -0
  45. data/lib/serverspec/type/iis_app_pool.rb +43 -0
  46. data/lib/serverspec/type/iis_website.rb +40 -0
  47. data/lib/serverspec/type/interface.rb +18 -0
  48. data/lib/serverspec/type/ip6tables.rb +13 -0
  49. data/lib/serverspec/type/ipfilter.rb +11 -0
  50. data/lib/serverspec/type/ipnat.rb +11 -0
  51. data/lib/serverspec/type/iptables.rb +11 -0
  52. data/lib/serverspec/type/kernel_module.rb +7 -0
  53. data/lib/serverspec/type/linux_kernel_parameter.rb +10 -0
  54. data/lib/serverspec/type/lxc.rb +15 -0
  55. data/lib/serverspec/type/mail_alias.rb +7 -0
  56. data/lib/serverspec/type/package.rb +65 -0
  57. data/lib/serverspec/type/php_config.rb +10 -0
  58. data/lib/serverspec/type/port.rb +40 -0
  59. data/lib/serverspec/type/ppa.rb +11 -0
  60. data/lib/serverspec/type/process.rb +27 -0
  61. data/lib/serverspec/type/routing_table.rb +11 -0
  62. data/lib/serverspec/type/selinux.rb +19 -0
  63. data/lib/serverspec/type/selinux_module.rb +11 -0
  64. data/lib/serverspec/type/service.rb +33 -0
  65. data/lib/serverspec/type/user.rb +31 -0
  66. data/lib/serverspec/type/windows_feature.rb +7 -0
  67. data/lib/serverspec/type/windows_hot_fix.rb +7 -0
  68. data/lib/serverspec/type/windows_registry_key.rb +19 -0
  69. data/lib/serverspec/type/windows_scheduled_task.rb +7 -0
  70. data/lib/serverspec/type/yumrepo.rb +11 -0
  71. data/lib/serverspec/type/zfs.rb +15 -0
  72. data/lib/serverspec/version.rb +3 -0
  73. data/serverspec.gemspec +26 -0
  74. data/spec/helper/type_spec.rb +6 -0
  75. data/spec/spec_helper.rb +28 -0
  76. data/spec/type/aix/file_spec.rb +31 -0
  77. data/spec/type/aix/group_spec.rb +7 -0
  78. data/spec/type/aix/package_spec.rb +7 -0
  79. data/spec/type/aix/port_spec.rb +20 -0
  80. data/spec/type/aix/service_spec.rb +12 -0
  81. data/spec/type/aix/user_spec.rb +16 -0
  82. data/spec/type/arch/file_spec.rb +15 -0
  83. data/spec/type/arch/package_spec.rb +19 -0
  84. data/spec/type/arch/service_spec.rb +9 -0
  85. data/spec/type/base/command_spec.rb +62 -0
  86. data/spec/type/base/cron_spec.rb +11 -0
  87. data/spec/type/base/default_gateway_spec.rb +11 -0
  88. data/spec/type/base/file_spec.rb +336 -0
  89. data/spec/type/base/group_spec.rb +11 -0
  90. data/spec/type/base/host_spec.rb +36 -0
  91. data/spec/type/base/mail_alias_spec.rb +7 -0
  92. data/spec/type/base/package_spec.rb +43 -0
  93. data/spec/type/base/php_config_spec.rb +33 -0
  94. data/spec/type/base/port_spec.rb +34 -0
  95. data/spec/type/base/process_spec.rb +35 -0
  96. data/spec/type/base/routing_table_spec.rb +118 -0
  97. data/spec/type/base/service_spec.rb +45 -0
  98. data/spec/type/base/user_spec.rb +31 -0
  99. data/spec/type/darwin/file_spec.rb +41 -0
  100. data/spec/type/darwin/package_spec.rb +19 -0
  101. data/spec/type/darwin/port_spec.rb +27 -0
  102. data/spec/type/darwin/service_spec.rb +16 -0
  103. data/spec/type/debian/package_spec.rb +23 -0
  104. data/spec/type/debian/service_spec.rb +11 -0
  105. data/spec/type/fedora/service_spec.rb +15 -0
  106. data/spec/type/fedora15/service_spec.rb +15 -0
  107. data/spec/type/fedora20/service_spec.rb +15 -0
  108. data/spec/type/freebsd/file_spec.rb +29 -0
  109. data/spec/type/freebsd/package_spec.rb +19 -0
  110. data/spec/type/freebsd/port_spec.rb +27 -0
  111. data/spec/type/freebsd/service_spec.rb +8 -0
  112. data/spec/type/freebsd10/package_spec.rb +19 -0
  113. data/spec/type/gentoo/package_spec.rb +7 -0
  114. data/spec/type/gentoo/service_spec.rb +12 -0
  115. data/spec/type/linux/cgroup_spec.rb +13 -0
  116. data/spec/type/linux/file_spec.rb +21 -0
  117. data/spec/type/linux/interface_spec.rb +25 -0
  118. data/spec/type/linux/ip6tables_spec.rb +19 -0
  119. data/spec/type/linux/iptables_spec.rb +11 -0
  120. data/spec/type/linux/kernel_module_spec.rb +7 -0
  121. data/spec/type/linux/linux_kernel_parameter_spec.rb +33 -0
  122. data/spec/type/linux/lxc_container_spec.rb +12 -0
  123. data/spec/type/linux/selinux_module_spec.rb +11 -0
  124. data/spec/type/linux/selinux_spec.rb +15 -0
  125. data/spec/type/linux/zfs_spec.rb +15 -0
  126. data/spec/type/nixos/package_spec.rb +15 -0
  127. data/spec/type/nixos/service_spec.rb +9 -0
  128. data/spec/type/openbsd/file_spec.rb +134 -0
  129. data/spec/type/openbsd/interface_spec.rb +21 -0
  130. data/spec/type/openbsd/mail_alias_spec.rb +7 -0
  131. data/spec/type/openbsd/package_spec.rb +11 -0
  132. data/spec/type/openbsd/port_spec.rb +7 -0
  133. data/spec/type/openbsd/service_spec.rb +13 -0
  134. data/spec/type/openbsd/user_spec.rb +12 -0
  135. data/spec/type/opensuse/service_spec.rb +16 -0
  136. data/spec/type/plamo/package_spec.rb +8 -0
  137. data/spec/type/plamo/service_spec.rb +8 -0
  138. data/spec/type/redhat/file_spec.rb +19 -0
  139. data/spec/type/redhat/package_spec.rb +23 -0
  140. data/spec/type/redhat/service_spec.rb +11 -0
  141. data/spec/type/redhat/yumrepo_spec.rb +11 -0
  142. data/spec/type/redhat5/iptables_spec.rb +11 -0
  143. data/spec/type/redhat7/service_spec.rb +9 -0
  144. data/spec/type/smartos/package_spec.rb +19 -0
  145. data/spec/type/smartos/service_spec.rb +16 -0
  146. data/spec/type/solaris/cron_spec.rb +11 -0
  147. data/spec/type/solaris/file_spec.rb +15 -0
  148. data/spec/type/solaris/group_spec.rb +7 -0
  149. data/spec/type/solaris/host_spec.rb +19 -0
  150. data/spec/type/solaris/ipfilter_spec.rb +7 -0
  151. data/spec/type/solaris/ipnat_spec.rb +7 -0
  152. data/spec/type/solaris/package_spec.rb +7 -0
  153. data/spec/type/solaris/port_spec.rb +34 -0
  154. data/spec/type/solaris/service_spec.rb +16 -0
  155. data/spec/type/solaris/user_spec.rb +16 -0
  156. data/spec/type/solaris/zfs_spec.rb +15 -0
  157. data/spec/type/solaris10/file_spec.rb +313 -0
  158. data/spec/type/solaris10/group_spec.rb +8 -0
  159. data/spec/type/solaris10/host_spec.rb +16 -0
  160. data/spec/type/solaris10/package_spec.rb +8 -0
  161. data/spec/type/solaris10/user_spec.rb +8 -0
  162. data/spec/type/suse/package_spec.rb +23 -0
  163. data/spec/type/suse/service_spec.rb +11 -0
  164. data/spec/type/ubuntu/ppa_spec.rb +11 -0
  165. data/spec/type/ubuntu/service_spec.rb +7 -0
  166. data/spec/type/windows/command_spec.rb +64 -0
  167. data/spec/type/windows/feature_spec.rb +17 -0
  168. data/spec/type/windows/file_spec.rb +121 -0
  169. data/spec/type/windows/group_spec.rb +23 -0
  170. data/spec/type/windows/host_spec.rb +32 -0
  171. data/spec/type/windows/hot_fix_spec.rb +22 -0
  172. data/spec/type/windows/iis_app_pool_spec.rb +17 -0
  173. data/spec/type/windows/iis_webisite_spec.rb +16 -0
  174. data/spec/type/windows/package_spec.rb +10 -0
  175. data/spec/type/windows/port_spec.rb +25 -0
  176. data/spec/type/windows/registry_key_spec.rb +58 -0
  177. data/spec/type/windows/scheduled_task_spec.rb +9 -0
  178. data/spec/type/windows/service_spec.rb +30 -0
  179. data/spec/type/windows/user_spec.rb +33 -0
  180. metadata +400 -0
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'aix'
4
+
5
+ describe group('root') do
6
+ it { should have_gid 0 }
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'aix'
4
+
5
+ describe package('httpd') do
6
+ it { should be_installed }
7
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'aix'
4
+
5
+ describe port(80) do
6
+ it { should be_listening }
7
+ end
8
+
9
+ describe port(80) do
10
+ it { should be_listening.with('tcp') }
11
+ end
12
+
13
+ describe port(80) do
14
+ it { should be_listening.on('127.0.0.1') }
15
+ end
16
+
17
+ describe port(53) do
18
+ it { should be_listening.with('udp') }
19
+ end
20
+
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'aix'
4
+
5
+ describe service('sshd') do
6
+ it { should be_enabled }
7
+ end
8
+
9
+ describe service('sshd') do
10
+ it { should be_enabled.with_level(4) }
11
+ end
12
+
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'aix'
4
+
5
+ describe user('root') do
6
+ it { should belong_to_group 'root' }
7
+ end
8
+
9
+ describe user('root') do
10
+ it { should have_login_shell '/bin/bash' }
11
+ end
12
+
13
+ describe user('root') do
14
+ it { should have_home_directory '/root' }
15
+ end
16
+
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'arch'
4
+
5
+ describe file('/tmp') do
6
+ it { should be_readable.by_user('mail') }
7
+ end
8
+
9
+ describe file('/tmp') do
10
+ it { should be_writable.by_user('mail') }
11
+ end
12
+
13
+ describe file('/tmp') do
14
+ it { should be_executable.by_user('mail') }
15
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'arch'
4
+
5
+ describe package('httpd') do
6
+ it { should be_installed }
7
+ end
8
+
9
+ describe package('httpd') do
10
+ it { should be_installed.with_version('2.2.15-28.el6') }
11
+ end
12
+
13
+ describe package('httpd') do
14
+ let(:stdout) { "2.2.15\n" }
15
+ its(:version) { should eq '2.2.15' }
16
+ its(:version) { should > '2.2.14' }
17
+ its(:version) { should < '2.2.16' }
18
+ its(:version) { should > '2.2.9' }
19
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'arch'
4
+
5
+ describe service('sshd') do
6
+ it { should be_enabled }
7
+ it { should be_running }
8
+ end
9
+
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'base'
4
+
5
+ describe command('cat /etc/resolv.conf') do
6
+ let(:stdout) { "nameserver 127.0.0.1\r\n" }
7
+ its(:stdout) { should match /nameserver 127.0.0.1/ }
8
+ end
9
+
10
+ describe 'complete matching of stdout' do
11
+ context command('cat /etc/resolv.conf') do
12
+ let(:stdout) { "foocontent-should-be-includedbar\r\n" }
13
+ its(:stdout) { should_not eq 'content-should-be-included' }
14
+ end
15
+ end
16
+
17
+ describe 'regexp matching of stdout' do
18
+ context command('cat /etc/resolv.conf') do
19
+ let(:stdout) { "nameserver 127.0.0.1\r\n" }
20
+ its(:stdout) { should match /127\.0\.0\.1/ }
21
+ end
22
+ end
23
+
24
+ describe command('cat /etc/resolv.conf') do
25
+ let(:stderr) { "No such file or directory\r\n" }
26
+ its(:stderr) { should match /No such file or directory/ }
27
+ end
28
+
29
+ describe 'complete matching of stderr' do
30
+ context command('cat /etc/resolv.conf') do
31
+ let(:stderr) { "No such file or directory\r\n" }
32
+ its(:stdout) { should_not eq 'file' }
33
+ end
34
+ end
35
+
36
+ describe 'regexp matching of stderr' do
37
+ context command('cat /etc/resolv.conf') do
38
+ let(:stderr) { "No such file or directory\r\n" }
39
+ its(:stderr) { should match /file/ }
40
+ end
41
+ end
42
+
43
+ describe command('cat /etc/resolv.conf') do
44
+ its(:exit_status) { should eq 0 }
45
+ end
46
+
47
+ describe command('ls -al /') do
48
+ let(:stdout) { <<EOF
49
+ total 88
50
+ drwxr-xr-x 23 root root 4096 Oct 10 17:19 .
51
+ drwxr-xr-x 23 root root 4096 Oct 10 17:19 ..
52
+ drwxr-xr-x 2 root root 4096 Sep 11 16:43 bin
53
+ drwxr-xr-x 3 root root 4096 Sep 23 18:14 boot
54
+ drwxr-xr-x 14 root root 4260 Oct 14 16:14 dev
55
+ drwxr-xr-x 104 root root 4096 Oct 14 17:34 etc
56
+ drwxr-xr-x 8 root root 4096 Oct 1 15:09 home
57
+ EOF
58
+ }
59
+
60
+ its(:stdout) { should match /bin/ }
61
+ its(:stdout) { should eq stdout }
62
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'base'
4
+
5
+ describe cron do
6
+ it { should have_entry '* * * * * /usr/local/bin/batch.sh' }
7
+ end
8
+
9
+ describe cron do
10
+ it { should have_entry('* * * * * /usr/local/bin/batch.sh').with_user('root') }
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'base'
4
+
5
+ describe default_gateway do
6
+ let(:stdout) { "default via 192.168.1.1 dev eth1 \r\n" }
7
+ its(:ipaddress) { should eq '192.168.1.1' }
8
+ its(:interface) { should eq 'eth1' }
9
+ its(:ipaddress) { should_not eq '192.168.1.2' }
10
+ its(:interface) { should_not eq 'eth0' }
11
+ end
@@ -0,0 +1,336 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, {:family => 'base'}
4
+
5
+ describe file('/etc/ssh/sshd_config') do
6
+ it { should be_file }
7
+ end
8
+
9
+ describe file('/etc/ssh') do
10
+ it { should be_directory }
11
+ end
12
+
13
+ describe file('/var/run/unicorn.sock') do
14
+ it { should be_socket }
15
+ end
16
+
17
+ describe file('/etc/ssh/sshd_config') do
18
+ it { should contain 'This is the sshd server system-wide configuration file' }
19
+ end
20
+
21
+ describe file('/etc/ssh/sshd_config') do
22
+ it { should contain /^This is the sshd server system-wide configuration file/ }
23
+ end
24
+
25
+ describe file('Gemfile') do
26
+ it { should contain('rspec').from(/^group :test do/).to(/^end/) }
27
+ end
28
+
29
+ describe file('Gemfile') do
30
+ it { should contain('rspec').after(/^group :test do/) }
31
+ end
32
+
33
+ describe file('Gemfile') do
34
+ it { should contain('rspec').before(/^end/) }
35
+ end
36
+
37
+ describe file('/etc/passwd') do
38
+ it { should be_mode 644 }
39
+ end
40
+
41
+ describe file('/etc/passwd') do
42
+ it { should be_owned_by 'root' }
43
+ end
44
+
45
+ describe file('/etc/passwd') do
46
+ it { should be_grouped_into 'root' }
47
+ end
48
+
49
+ describe file('/etc/pam.d/system-auth') do
50
+ it { should be_linked_to '/etc/pam.d/system-auth-ac' }
51
+ end
52
+
53
+ describe file('/dev') do
54
+ let(:stdout) { "755\r\n" }
55
+ it { should be_readable }
56
+ end
57
+
58
+ describe file('/dev') do
59
+ let(:stdout) { "333\r\n" }
60
+ it { should_not be_readable }
61
+ end
62
+
63
+ describe file('/dev') do
64
+ let(:stdout) { "400\r\n" }
65
+ it { should be_readable.by('owner') }
66
+ end
67
+
68
+ describe file('/dev') do
69
+ let(:stdout) { "044\r\n" }
70
+ it { should_not be_readable.by('owner') }
71
+ end
72
+
73
+ describe file('/dev') do
74
+ let(:stdout) { "040\r\n" }
75
+ it { should be_readable.by('group') }
76
+ end
77
+
78
+ describe file('/dev') do
79
+ let(:stdout) { "404\r\n" }
80
+ it { should_not be_readable.by('group') }
81
+ end
82
+
83
+ describe file('/dev') do
84
+ let(:stdout) { "044\r\n" }
85
+ it { should be_readable.by('others') }
86
+ end
87
+
88
+ describe file('/dev') do
89
+ let(:stdout) { "443\r\n" }
90
+ it { should_not be_readable.by('others') }
91
+ end
92
+
93
+ describe file('/dev') do
94
+ let(:stdout) { "755\r\n" }
95
+ it { should be_writable }
96
+ end
97
+
98
+ describe file('/dev') do
99
+ let(:stdout) { "555\r\n" }
100
+ it { should_not be_writable }
101
+ end
102
+
103
+ describe file('/dev') do
104
+ let(:stdout) { "200\r\n" }
105
+ it { should be_writable.by('owner') }
106
+ end
107
+
108
+ describe file('/dev') do
109
+ let(:stdout) { "555\r\n" }
110
+ it { should_not be_writable.by('owner') }
111
+ end
112
+
113
+ describe file('/dev') do
114
+ let(:stdout) { "030\r\n" }
115
+ it { should be_writable.by('group') }
116
+ end
117
+
118
+ describe file('/dev') do
119
+ let(:stdout) { "555\r\n" }
120
+ it { should_not be_writable.by('group') }
121
+ end
122
+
123
+ describe file('/dev') do
124
+ let(:stdout) { "666\r\n" }
125
+ it { should be_writable.by('others') }
126
+ end
127
+
128
+ describe file('/dev') do
129
+ let(:stdout) { "555\r\n" }
130
+ it { should_not be_writable.by('others') }
131
+ end
132
+
133
+
134
+ describe file('/dev') do
135
+ let(:stdout) { "755\r\n" }
136
+ it { should be_executable }
137
+ end
138
+
139
+ describe file('/dev') do
140
+ let(:stdout) { "666\r\n" }
141
+ it { should_not be_executable }
142
+ end
143
+
144
+ describe file('/dev') do
145
+ let(:stdout) { "100\r\n" }
146
+ it { should be_executable.by('owner') }
147
+ end
148
+
149
+ describe file('/dev') do
150
+ let(:stdout) { "666\r\n" }
151
+ it { should_not be_executable.by('owner') }
152
+ end
153
+
154
+ describe file('/dev') do
155
+ let(:stdout) { "070\r\n" }
156
+ it { should be_executable.by('group') }
157
+ end
158
+
159
+ describe file('/dev') do
160
+ let(:stdout) { "666\r\n" }
161
+ it { should_not be_executable.by('group') }
162
+ end
163
+
164
+ describe file('/dev') do
165
+ let(:stdout) { "001\r\n" }
166
+ it { should be_executable.by('others') }
167
+ end
168
+
169
+ describe file('/dev') do
170
+ let(:stdout) { "666\r\n" }
171
+ it { should_not be_executable.by('others') }
172
+ end
173
+
174
+ describe file('/') do
175
+ it { should be_mounted }
176
+ end
177
+
178
+ describe file('/') do
179
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
180
+ it { should be_mounted.with( :type => 'ext4' ) }
181
+ end
182
+
183
+ describe file('/') do
184
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
185
+ it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) }
186
+ end
187
+
188
+ describe file('/') do
189
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
190
+ it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) }
191
+ end
192
+
193
+ describe file('/') do
194
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
195
+ it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) }
196
+ end
197
+
198
+ describe file('/') do
199
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
200
+ it { should_not be_mounted.with( :type => 'xfs' ) }
201
+ end
202
+
203
+ describe file('/') do
204
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
205
+ it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) }
206
+ end
207
+
208
+ describe file('/') do
209
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
210
+ it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) }
211
+ end
212
+
213
+ describe file('/') do
214
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
215
+ it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) }
216
+ end
217
+
218
+ describe file('/') do
219
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
220
+ it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) }
221
+ end
222
+
223
+ describe file('/') do
224
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
225
+ it do
226
+ should be_mounted.only_with(
227
+ :device => '/dev/mapper/VolGroup-lv_root',
228
+ :type => 'ext4',
229
+ :options => {
230
+ :rw => true,
231
+ :mode => 620,
232
+ }
233
+ )
234
+ end
235
+ end
236
+
237
+ describe file('/') do
238
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
239
+ it do
240
+ should_not be_mounted.only_with(
241
+ :device => '/dev/mapper/VolGroup-lv_root',
242
+ :type => 'ext4',
243
+ :options => {
244
+ :rw => true,
245
+ :mode => 620,
246
+ :bind => true,
247
+ }
248
+ )
249
+ end
250
+ end
251
+
252
+ describe file('/') do
253
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
254
+ it do
255
+ should_not be_mounted.only_with(
256
+ :device => '/dev/mapper/VolGroup-lv_root',
257
+ :type => 'ext4',
258
+ :options => {
259
+ :rw => true,
260
+ }
261
+ )
262
+ end
263
+ end
264
+
265
+ describe file('/') do
266
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
267
+ it do
268
+ should_not be_mounted.only_with(
269
+ :device => '/dev/mapper/VolGroup-lv_roooooooooot',
270
+ :type => 'ext4',
271
+ :options => {
272
+ :rw => true,
273
+ :mode => 620,
274
+ }
275
+ )
276
+ end
277
+ end
278
+
279
+ describe file('/etc/invalid-mount') do
280
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
281
+ it { should_not be_mounted.only_with( :type => 'ext4' ) }
282
+ end
283
+
284
+ describe file('/etc/services') do
285
+ let(:stdout) { "35435ea447c19f0ea5ef971837ab9ced\n" }
286
+ its(:md5sum) { should eq '35435ea447c19f0ea5ef971837ab9ced' }
287
+ end
288
+
289
+ describe file('invalid-file') do
290
+ its(:md5sum) { should_not eq 'INVALIDMD5CHECKSUM' }
291
+ end
292
+
293
+ describe file('/etc/services') do
294
+ let(:stdout) {"0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a" }
295
+ its(:sha256sum) { should eq '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
296
+ end
297
+
298
+ describe file('invalid-file') do
299
+ its(:sha256sum) { should_not eq 'INVALIDSHA256CHECKSUM' }
300
+ end
301
+
302
+ describe file('/etc/passwd') do
303
+ let(:stdout) {<<EOF
304
+ root:x:0:0:root:/root:/bin/bash
305
+ bin:x:1:1:bin:/bin:/sbin/nologin
306
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
307
+ sync:x:5:0:sync:/sbin:/bin/sync
308
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
309
+ halt:x:7:0:halt:/sbin:/sbin/halt
310
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
311
+ operator:x:11:0:operator:/root:/sbin/nologin
312
+ nobody:x:99:99:Nobody:/:/sbin/nologin
313
+ dbus:x:81:81:System message bus:/:/sbin/nologin
314
+ EOF
315
+ }
316
+
317
+ its(:content) { should match /root:x:0:0/ }
318
+ end
319
+
320
+ describe file('/etc/passwd') do
321
+ let(:stdout) { Time.now.to_i.to_s }
322
+ its(:mtime) { should > DateTime.now - 1 }
323
+ end
324
+
325
+ describe file('/etc/passwod') do
326
+ let(:stdout) { 100.to_s }
327
+ its(:size) { should > 0 }
328
+ end
329
+
330
+ describe file('/etc/passwd') do
331
+ it 'be_immutable is not implemented in base class' do
332
+ expect {
333
+ should be_immutable
334
+ }.to raise_exception
335
+ end
336
+ end