serverspec 2.0.0.beta8 → 2.0.0.beta9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +24 -2
  3. data/lib/serverspec/setup.rb +6 -8
  4. data/lib/serverspec/type/cgroup.rb +1 -0
  5. data/lib/serverspec/type/command.rb +1 -1
  6. data/lib/serverspec/type/cron.rb +1 -1
  7. data/lib/serverspec/type/default_gateway.rb +2 -2
  8. data/lib/serverspec/type/file.rb +21 -17
  9. data/lib/serverspec/type/group.rb +2 -2
  10. data/lib/serverspec/type/host.rb +3 -3
  11. data/lib/serverspec/type/iis_app_pool.rb +2 -2
  12. data/lib/serverspec/type/iis_website.rb +5 -5
  13. data/lib/serverspec/type/interface.rb +1 -1
  14. data/lib/serverspec/type/ipfilter.rb +1 -1
  15. data/lib/serverspec/type/ipnat.rb +1 -1
  16. data/lib/serverspec/type/iptables.rb +1 -1
  17. data/lib/serverspec/type/kernel_module.rb +1 -1
  18. data/lib/serverspec/type/lxc.rb +2 -2
  19. data/lib/serverspec/type/mail_alias.rb +1 -1
  20. data/lib/serverspec/type/package.rb +2 -7
  21. data/lib/serverspec/type/port.rb +1 -1
  22. data/lib/serverspec/type/ppa.rb +2 -2
  23. data/lib/serverspec/type/routing_table.rb +1 -1
  24. data/lib/serverspec/type/selinux.rb +3 -3
  25. data/lib/serverspec/type/service.rb +7 -15
  26. data/lib/serverspec/type/user.rb +12 -6
  27. data/lib/serverspec/type/windows_feature.rb +1 -1
  28. data/lib/serverspec/type/windows_hot_fix.rb +1 -1
  29. data/lib/serverspec/type/windows_registry_key.rb +4 -4
  30. data/lib/serverspec/type/windows_scheduled_task.rb +1 -1
  31. data/lib/serverspec/type/yumrepo.rb +2 -2
  32. data/lib/serverspec/type/zfs.rb +2 -2
  33. data/lib/serverspec/version.rb +1 -1
  34. data/serverspec.gemspec +1 -1
  35. data/spec/spec_helper.rb +11 -0
  36. data/spec/type/aix/file_spec.rb +35 -0
  37. data/spec/type/aix/group_spec.rb +15 -0
  38. data/spec/type/aix/package_spec.rb +15 -0
  39. data/spec/type/aix/port_spec.rb +37 -0
  40. data/spec/type/aix/service_spec.rb +23 -0
  41. data/spec/type/aix/user_spec.rb +32 -0
  42. data/spec/type/arch/file_spec.rb +32 -0
  43. data/spec/type/arch/package_spec.rb +31 -0
  44. data/spec/type/arch/service_spec.rb +13 -0
  45. data/spec/type/{command_spec.rb → base/command_spec.rb} +1 -3
  46. data/spec/type/{cron_spec.rb → base/cron_spec.rb} +5 -1
  47. data/spec/type/{default_gateway_spec.rb → base/default_gateway_spec.rb} +1 -1
  48. data/spec/type/{file_spec.rb → base/file_spec.rb} +23 -24
  49. data/spec/type/{group_spec.rb → base/group_spec.rb} +5 -1
  50. data/spec/type/{host_spec.rb → base/host_spec.rb} +5 -1
  51. data/spec/type/{mail_alias_spec.rb → base/mail_alias_spec.rb} +5 -1
  52. data/spec/type/{package_spec.rb → base/package_spec.rb} +3 -32
  53. data/spec/type/{php_config_spec.rb → base/php_config_spec.rb} +1 -1
  54. data/spec/type/{port_spec.rb → base/port_spec.rb} +5 -1
  55. data/spec/type/{process_spec.rb → base/process_spec.rb} +5 -1
  56. data/spec/type/{routing_table_spec.rb → base/routing_table_spec.rb} +5 -1
  57. data/spec/type/{service_spec.rb → base/service_spec.rb} +5 -25
  58. data/spec/type/{user_spec.rb → base/user_spec.rb} +5 -1
  59. data/spec/type/darwin/file_spec.rb +43 -0
  60. data/spec/type/darwin/package_spec.rb +24 -0
  61. data/spec/type/darwin/port_spec.rb +37 -0
  62. data/spec/type/darwin/service_spec.rb +32 -0
  63. data/spec/type/debian/package_spec.rb +39 -0
  64. data/spec/type/debian/service_spec.rb +23 -0
  65. data/spec/type/fedora/service_spec.rb +19 -0
  66. data/spec/type/fedora15/service_spec.rb +19 -0
  67. data/spec/type/fedora20/service_spec.rb +19 -0
  68. data/spec/type/freebsd/file_spec.rb +11 -0
  69. data/spec/type/freebsd/package_spec.rb +31 -0
  70. data/spec/type/freebsd/port_spec.rb +37 -0
  71. data/spec/type/freebsd/service_spec.rb +16 -0
  72. data/spec/type/freebsd10/package_spec.rb +31 -0
  73. data/spec/type/gentoo/package_spec.rb +16 -0
  74. data/spec/type/gentoo/service_spec.rb +24 -0
  75. data/spec/type/{cgroup_spec.rb → linux/cgroup_spec.rb} +1 -1
  76. data/spec/type/linux/file_spec.rb +38 -0
  77. data/spec/type/{interface_spec.rb → linux/interface_spec.rb} +5 -1
  78. data/spec/type/{iptables_spec.rb → linux/iptables_spec.rb} +6 -2
  79. data/spec/type/linux/kernel_module_spec.rb +15 -0
  80. data/spec/type/{linux_kernel_parameter_spec.rb → linux/linux_kernel_parameter_spec.rb} +1 -1
  81. data/spec/type/{lxc_spec.rb → linux/lxc_container_spec.rb} +5 -1
  82. data/spec/type/{selinux_spec.rb → linux/selinux_spec.rb} +5 -1
  83. data/spec/type/{zfs_spec.rb → linux/zfs_spec.rb} +5 -1
  84. data/spec/type/nixos/package_spec.rb +31 -0
  85. data/spec/type/nixos/service_spec.rb +13 -0
  86. data/spec/type/openbsd/file_spec.rb +174 -0
  87. data/spec/type/openbsd/interface_spec.rb +25 -0
  88. data/spec/type/openbsd/mail_alias_spec.rb +15 -0
  89. data/spec/type/openbsd/package_spec.rb +24 -0
  90. data/spec/type/openbsd/port_spec.rb +11 -0
  91. data/spec/type/openbsd/service_spec.rb +24 -0
  92. data/spec/type/openbsd/user_spec.rb +24 -0
  93. data/spec/type/opensuse/service_spec.rb +32 -0
  94. data/spec/type/plamo/package_spec.rb +16 -0
  95. data/spec/type/plamo/service_spec.rb +16 -0
  96. data/spec/type/redhat/file_spec.rb +36 -0
  97. data/spec/type/redhat/package_spec.rb +39 -0
  98. data/spec/type/redhat/service_spec.rb +23 -0
  99. data/spec/type/{yumrepo_spec.rb → redhat/yumrepo_spec.rb} +5 -1
  100. data/spec/type/redhat5/iptables_spec.rb +23 -0
  101. data/spec/type/redhat7/service_spec.rb +13 -0
  102. data/spec/type/smartos/package_spec.rb +31 -0
  103. data/spec/type/smartos/service_spec.rb +32 -0
  104. data/spec/type/solaris/cron_spec.rb +23 -0
  105. data/spec/type/solaris/file_spec.rb +33 -0
  106. data/spec/type/solaris/group_spec.rb +15 -0
  107. data/spec/type/solaris/host_spec.rb +31 -0
  108. data/spec/type/solaris/ipfilter_spec.rb +11 -0
  109. data/spec/type/solaris/ipnat_spec.rb +11 -0
  110. data/spec/type/solaris/package_spec.rb +15 -0
  111. data/spec/type/solaris/port_spec.rb +37 -0
  112. data/spec/type/solaris/service_spec.rb +32 -0
  113. data/spec/type/solaris/user_spec.rb +32 -0
  114. data/spec/type/solaris/zfs_spec.rb +19 -0
  115. data/spec/type/solaris10/file_spec.rb +391 -0
  116. data/spec/type/solaris10/group_spec.rb +16 -0
  117. data/spec/type/solaris10/host_spec.rb +24 -0
  118. data/spec/type/solaris10/package_spec.rb +15 -0
  119. data/spec/type/solaris10/user_spec.rb +16 -0
  120. data/spec/type/suse/package_spec.rb +39 -0
  121. data/spec/type/suse/service_spec.rb +23 -0
  122. data/spec/type/ubuntu/ppa_spec.rb +23 -0
  123. data/spec/type/ubuntu/service_spec.rb +15 -0
  124. data/spec/type/windows/command_spec.rb +65 -0
  125. data/spec/type/windows/feature_spec.rb +13 -0
  126. data/spec/type/windows/file_spec.rb +161 -0
  127. data/spec/type/windows/group_spec.rb +31 -0
  128. data/spec/type/windows/host_spec.rb +56 -0
  129. data/spec/type/windows/hot_fix_spec.rb +26 -0
  130. data/spec/type/windows/iis_app_pool_spec.rb +18 -0
  131. data/spec/type/windows/iis_webisite_spec.rb +30 -0
  132. data/spec/type/windows/package_spec.rb +14 -0
  133. data/spec/type/windows/port_spec.rb +33 -0
  134. data/spec/type/windows/registry_key_spec.rb +62 -0
  135. data/spec/type/windows/scheduled_task_spec.rb +13 -0
  136. data/spec/type/windows/service_spec.rb +42 -0
  137. data/spec/type/windows/user_spec.rb +45 -0
  138. metadata +208 -50
  139. data/spec/type/kernel_module_spec.rb +0 -11
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris'
4
+
5
+ describe commands.command_class('host').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::Base::Host) }
7
+ end
8
+
9
+ describe host('127.0.0.1') do
10
+ it { should be_reachable }
11
+ end
12
+
13
+ describe host('invalid-host') do
14
+ it { should_not be_reachable }
15
+ end
16
+
17
+ describe host('127.0.0.1') do
18
+ it { should be_reachable.with(:proto => "icmp", :timeout=> 1) }
19
+ end
20
+
21
+ describe host('127.0.0.1') do
22
+ it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) }
23
+ end
24
+
25
+ describe host('127.0.0.1') do
26
+ it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
27
+ end
28
+
29
+ describe host('invalid-host') do
30
+ it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
31
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris'
4
+
5
+ describe commands.command_class('ipfilter').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::Base::Ipfilter) }
7
+ end
8
+
9
+ describe ipfilter do
10
+ it { should have_rule 'pass in quick on lo0 all' }
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris'
4
+
5
+ describe commands.command_class('ipfilter').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::Base::Ipfilter) }
7
+ end
8
+
9
+ describe ipnat do
10
+ it { should have_rule 'map net1 192.168.0.0/24 -> 0.0.0.0/32' }
11
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris'
4
+
5
+ describe commands.command_class('package').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::Base::Package) }
7
+ end
8
+
9
+ describe package('httpd') do
10
+ it { should be_installed }
11
+ end
12
+
13
+ describe package('invalid-package') do
14
+ it { should_not be_installed }
15
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris'
4
+
5
+ describe commands.command_class('port').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::Base::Port) }
7
+ end
8
+
9
+ describe Serverspec::Type::Port do
10
+ describe port(80) do
11
+ it { should be_listening }
12
+
13
+ it('protocol: tcp') { should be_listening.with('tcp') }
14
+
15
+ it 'invalid protocol raises error' do
16
+ expect {
17
+ should be_listening.with('not implemented')
18
+ }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/)
19
+ end
20
+
21
+ it('on: 127.0.0.1') do
22
+ should be_listening.on('127.0.0.1')
23
+ end
24
+
25
+ it 'invalid local address raises error' do
26
+ expect{ should be_listening.on('') }.to raise_error(ArgumentError)
27
+ end
28
+ end
29
+
30
+ describe port('invalid') do
31
+ it { should_not be_listening }
32
+ end
33
+
34
+ describe port(123) do
35
+ it { should be_listening.with("udp") }
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris'
4
+
5
+ describe commands.command_class('service').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::Base::Service) }
7
+ end
8
+
9
+ describe service('sshd') do
10
+ it { should be_enabled }
11
+ end
12
+
13
+ describe service('invalid-service') do
14
+ it { should_not be_enabled }
15
+ end
16
+
17
+ describe service('sshd') do
18
+ it { should be_running }
19
+ end
20
+
21
+ describe service('invalid-service') do
22
+ it { should_not be_running }
23
+ end
24
+
25
+ describe service('sshd') do
26
+ it { should have_property :foo => 'bar' }
27
+ end
28
+
29
+ describe service('invalid-service') do
30
+ it { should_not have_property :foo => 'bar' }
31
+ end
32
+
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris'
4
+
5
+ describe commands.command_class('user').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::Base::User) }
7
+ end
8
+
9
+ describe user('root') do
10
+ it { should belong_to_group 'root' }
11
+ end
12
+
13
+ describe user('root') do
14
+ it { should_not belong_to_group 'invalid-group' }
15
+ end
16
+
17
+ describe user('root') do
18
+ it { should have_login_shell '/bin/bash' }
19
+ end
20
+
21
+ describe user('root') do
22
+ it { should_not have_login_shell 'invalid-login-shell' }
23
+ end
24
+
25
+ describe user('root') do
26
+ it { should have_home_directory '/root' }
27
+ end
28
+
29
+ describe user('root') do
30
+ it { should_not have_home_directory 'invalid-home-directory' }
31
+ end
32
+
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris'
4
+
5
+ describe commands.command_class('zfs').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::Base::Zfs) }
7
+ end
8
+
9
+ describe zfs('rpool') do
10
+ it { should exist }
11
+ end
12
+
13
+ describe zfs('rpool') do
14
+ it { should have_property 'mountpoint' => '/rpool' }
15
+ end
16
+
17
+ describe zfs('rpool') do
18
+ it { should have_property 'mountpoint' => '/rpool', 'compression' => 'off' }
19
+ end
@@ -0,0 +1,391 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris', :release => 10
4
+
5
+ describe commands.command_class('file').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::V10::File) }
7
+ end
8
+
9
+ describe file('/etc/ssh/sshd_config') do
10
+ it { should be_file }
11
+ end
12
+
13
+ describe file('/etc/invalid_file') do
14
+ it { should_not be_file }
15
+ end
16
+
17
+ describe file('/etc/ssh') do
18
+ it { should be_directory }
19
+ end
20
+
21
+ describe file('/etc/invalid_directory') do
22
+ it { should_not be_directory }
23
+ end
24
+
25
+ describe file('/var/run/unicorn.sock') do
26
+ it { should be_socket }
27
+ end
28
+
29
+ describe file('/etc/invalid_socket') do
30
+ it { should_not be_socket }
31
+ end
32
+
33
+ describe file('/etc/ssh/sshd_config') do
34
+ it { should contain 'This is the sshd server system-wide configuration file' }
35
+ end
36
+
37
+ describe file('/etc/ssh/sshd_config') do
38
+ it { should contain /^This is the sshd server system-wide configuration file/ }
39
+ end
40
+
41
+ describe file('/etc/ssh/sshd_config') do
42
+ it { should_not contain 'This is invalid text!!' }
43
+ end
44
+
45
+ describe file('Gemfile') do
46
+ it { should contain('rspec').from(/^group :test do/).to(/^end/) }
47
+ end
48
+
49
+ describe file('/etc/ssh/sshd_config') do
50
+ it { should_not contain('This is invalid text!!').from(/^group :test do/).to(/^end/) }
51
+ end
52
+
53
+ describe file('Gemfile') do
54
+ it { should contain('rspec').after(/^group :test do/) }
55
+ end
56
+
57
+ describe file('/etc/ssh/sshd_config') do
58
+ it { should_not contain('This is invalid text!!').after(/^group :test do/) }
59
+ end
60
+
61
+ describe file('Gemfile') do
62
+ it { should contain('rspec').before(/^end/) }
63
+ end
64
+
65
+ describe file('/etc/ssh/sshd_config') do
66
+ it { should_not contain('This is invalid text!!').before(/^end/) }
67
+ end
68
+
69
+ describe file('/etc/passwd') do
70
+ it { should be_mode 644 }
71
+ end
72
+
73
+ describe file('/etc/passwd') do
74
+ it { should_not be_mode 'invalid' }
75
+ end
76
+
77
+ describe file('/etc/passwd') do
78
+ it { should be_owned_by 'root' }
79
+ end
80
+
81
+ describe file('/etc/passwd') do
82
+ it { should_not be_owned_by 'invalid-owner' }
83
+ end
84
+
85
+ describe file('/etc/passwd') do
86
+ it { should be_grouped_into 'root' }
87
+ end
88
+
89
+ describe file('/etc/passwd') do
90
+ it { should_not be_grouped_into 'invalid-group' }
91
+ end
92
+
93
+ describe file('/etc/pam.d/system-auth') do
94
+ it { should be_linked_to '/etc/pam.d/system-auth-ac' }
95
+ end
96
+
97
+ describe file('dummy-link') do
98
+ it { should_not be_linked_to '/invalid/target' }
99
+ end
100
+
101
+ describe file('/dev') do
102
+ let(:stdout) { "755\r\n" }
103
+ it { should be_readable }
104
+ end
105
+
106
+ describe file('/dev') do
107
+ let(:stdout) { "333\r\n" }
108
+ it { should_not be_readable }
109
+ end
110
+
111
+ describe file('/dev') do
112
+ let(:stdout) { "400\r\n" }
113
+ it { should be_readable.by('owner') }
114
+ end
115
+
116
+ describe file('/dev') do
117
+ let(:stdout) { "044\r\n" }
118
+ it { should_not be_readable.by('owner') }
119
+ end
120
+
121
+ describe file('/dev') do
122
+ let(:stdout) { "040\r\n" }
123
+ it { should be_readable.by('group') }
124
+ end
125
+
126
+ describe file('/dev') do
127
+ let(:stdout) { "404\r\n" }
128
+ it { should_not be_readable.by('group') }
129
+ end
130
+
131
+ describe file('/dev') do
132
+ let(:stdout) { "044\r\n" }
133
+ it { should be_readable.by('others') }
134
+ end
135
+
136
+ describe file('/dev') do
137
+ let(:stdout) { "443\r\n" }
138
+ it { should_not be_readable.by('others') }
139
+ end
140
+
141
+ describe file('/dev') do
142
+ let(:stdout) { "755\r\n" }
143
+ it { should be_writable }
144
+ end
145
+
146
+ describe file('/dev') do
147
+ let(:stdout) { "555\r\n" }
148
+ it { should_not be_writable }
149
+ end
150
+
151
+ describe file('/dev') do
152
+ let(:stdout) { "200\r\n" }
153
+ it { should be_writable.by('owner') }
154
+ end
155
+
156
+ describe file('/dev') do
157
+ let(:stdout) { "555\r\n" }
158
+ it { should_not be_writable.by('owner') }
159
+ end
160
+
161
+ describe file('/dev') do
162
+ let(:stdout) { "030\r\n" }
163
+ it { should be_writable.by('group') }
164
+ end
165
+
166
+ describe file('/dev') do
167
+ let(:stdout) { "555\r\n" }
168
+ it { should_not be_writable.by('group') }
169
+ end
170
+
171
+ describe file('/dev') do
172
+ let(:stdout) { "666\r\n" }
173
+ it { should be_writable.by('others') }
174
+ end
175
+
176
+ describe file('/dev') do
177
+ let(:stdout) { "555\r\n" }
178
+ it { should_not be_writable.by('others') }
179
+ end
180
+
181
+
182
+ describe file('/dev') do
183
+ let(:stdout) { "755\r\n" }
184
+ it { should be_executable }
185
+ end
186
+
187
+ describe file('/dev') do
188
+ let(:stdout) { "666\r\n" }
189
+ it { should_not be_executable }
190
+ end
191
+
192
+ describe file('/dev') do
193
+ let(:stdout) { "100\r\n" }
194
+ it { should be_executable.by('owner') }
195
+ end
196
+
197
+ describe file('/dev') do
198
+ let(:stdout) { "666\r\n" }
199
+ it { should_not be_executable.by('owner') }
200
+ end
201
+
202
+ describe file('/dev') do
203
+ let(:stdout) { "070\r\n" }
204
+ it { should be_executable.by('group') }
205
+ end
206
+
207
+ describe file('/dev') do
208
+ let(:stdout) { "666\r\n" }
209
+ it { should_not be_executable.by('group') }
210
+ end
211
+
212
+ describe file('/dev') do
213
+ let(:stdout) { "001\r\n" }
214
+ it { should be_executable.by('others') }
215
+ end
216
+
217
+ describe file('/dev') do
218
+ let(:stdout) { "666\r\n" }
219
+ it { should_not be_executable.by('others') }
220
+ end
221
+
222
+ describe file('/') do
223
+ it { should be_mounted }
224
+ end
225
+
226
+ describe file('/etc/invalid-mount') do
227
+ it { should_not be_mounted }
228
+ end
229
+
230
+ describe file('/') do
231
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
232
+ it { should be_mounted.with( :type => 'ext4' ) }
233
+ end
234
+
235
+ describe file('/') do
236
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
237
+ it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) }
238
+ end
239
+
240
+ describe file('/') do
241
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
242
+ it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) }
243
+ end
244
+
245
+ describe file('/') do
246
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
247
+ it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) }
248
+ end
249
+
250
+ describe file('/') do
251
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
252
+ it { should_not be_mounted.with( :type => 'xfs' ) }
253
+ end
254
+
255
+ describe file('/') do
256
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
257
+ it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) }
258
+ end
259
+
260
+ describe file('/') do
261
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
262
+ it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) }
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 { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) }
268
+ end
269
+
270
+ describe file('/') do
271
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
272
+ it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) }
273
+ end
274
+
275
+ describe file('/etc/invalid-mount') do
276
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
277
+ it { should_not be_mounted.with( :type => 'ext4' ) }
278
+ end
279
+
280
+ describe file('/') do
281
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
282
+ it do
283
+ should be_mounted.only_with(
284
+ :device => '/dev/mapper/VolGroup-lv_root',
285
+ :type => 'ext4',
286
+ :options => {
287
+ :rw => true,
288
+ :mode => 620,
289
+ }
290
+ )
291
+ end
292
+ end
293
+
294
+ describe file('/') do
295
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
296
+ it do
297
+ should_not be_mounted.only_with(
298
+ :device => '/dev/mapper/VolGroup-lv_root',
299
+ :type => 'ext4',
300
+ :options => {
301
+ :rw => true,
302
+ :mode => 620,
303
+ :bind => true,
304
+ }
305
+ )
306
+ end
307
+ end
308
+
309
+ describe file('/') do
310
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
311
+ it do
312
+ should_not be_mounted.only_with(
313
+ :device => '/dev/mapper/VolGroup-lv_root',
314
+ :type => 'ext4',
315
+ :options => {
316
+ :rw => true,
317
+ }
318
+ )
319
+ end
320
+ end
321
+
322
+ describe file('/') do
323
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
324
+ it do
325
+ should_not be_mounted.only_with(
326
+ :device => '/dev/mapper/VolGroup-lv_roooooooooot',
327
+ :type => 'ext4',
328
+ :options => {
329
+ :rw => true,
330
+ :mode => 620,
331
+ }
332
+ )
333
+ end
334
+ end
335
+
336
+ describe file('/etc/invalid-mount') do
337
+ let(:stdout) { "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n" }
338
+ it { should_not be_mounted.only_with( :type => 'ext4' ) }
339
+ end
340
+
341
+ describe file('/etc/services') do
342
+ it { should match_md5checksum '35435ea447c19f0ea5ef971837ab9ced' }
343
+ end
344
+
345
+ describe file('invalid-file') do
346
+ it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
347
+ end
348
+
349
+ describe file('/etc/services') do
350
+ it { should match_sha256checksum '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a' }
351
+ end
352
+
353
+ describe file('invalid-file') do
354
+ it { should_not match_sha256checksum 'INVALIDSHA256CHECKSUM' }
355
+ end
356
+
357
+ describe file('/etc/passwd') do
358
+ let(:stdout) {<<EOF
359
+ root:x:0:0:root:/root:/bin/bash
360
+ bin:x:1:1:bin:/bin:/sbin/nologin
361
+ daemon:x:2:2:daemon:/sbin:/sbin/nologin
362
+ sync:x:5:0:sync:/sbin:/bin/sync
363
+ shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
364
+ halt:x:7:0:halt:/sbin:/sbin/halt
365
+ mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
366
+ operator:x:11:0:operator:/root:/sbin/nologin
367
+ nobody:x:99:99:Nobody:/:/sbin/nologin
368
+ dbus:x:81:81:System message bus:/:/sbin/nologin
369
+ EOF
370
+ }
371
+
372
+ its(:content) { should match /root:x:0:0/ }
373
+ end
374
+
375
+ describe file('/etc/passwd') do
376
+ let(:stdout) { Time.now.to_i.to_s }
377
+ its(:mtime) { should > DateTime.now.prev_day(1) }
378
+ end
379
+
380
+ describe file('/etc/passwod') do
381
+ let(:stdout) { 100.to_s }
382
+ its(:size) { should > 0 }
383
+ end
384
+
385
+ describe file('/etc/passwd') do
386
+ it 'be_immutable is not implemented in base class' do
387
+ expect {
388
+ should be_immutable
389
+ }.to raise_error(Specinfra::Command::Base::NotImplementedError)
390
+ end
391
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris', :release => 10
4
+
5
+ describe commands.command_class('group').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::V10::Group) }
7
+ end
8
+
9
+ describe group('root') do
10
+ it { should exist }
11
+ end
12
+
13
+ describe group('invalid-group') do
14
+ it { should_not exist }
15
+ end
16
+
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris', :release => 10
4
+
5
+ describe commands.command_class('host').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::V10::Host) }
7
+ end
8
+
9
+ describe host('127.0.0.1') do
10
+ it { should be_reachable }
11
+ end
12
+
13
+ describe host('invalid-host') do
14
+ it { should_not be_reachable }
15
+ end
16
+
17
+ describe host('127.0.0.1') do
18
+ it { should be_reachable.with(:proto => "icmp", :timeout=> 1) }
19
+ end
20
+
21
+ describe host('127.0.0.1') do
22
+ it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) }
23
+ end
24
+
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris', :release => 10
4
+
5
+ describe commands.command_class('package').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::V10::Package) }
7
+ end
8
+
9
+ describe package('httpd') do
10
+ it { should be_installed }
11
+ end
12
+
13
+ describe package('invalid-package') do
14
+ it { should_not be_installed }
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'solaris', :release => 10
4
+
5
+ describe commands.command_class('user').create do
6
+ it { should be_an_instance_of(Specinfra::Command::Solaris::V10::User) }
7
+ end
8
+
9
+ describe user('root') do
10
+ it { should have_authorized_key 'XXXXXXXXXXXXXXX' }
11
+ end
12
+
13
+ describe user('root') do
14
+ it { should_not have_authorized_key 'invalid-key' }
15
+ end
16
+