rouster 0.7 → 0.41
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.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/README.md +7 -241
- data/Rakefile +18 -55
- data/Vagrantfile +8 -26
- data/lib/rouster.rb +183 -404
- data/lib/rouster/deltas.rb +118 -577
- data/lib/rouster/puppet.rb +34 -209
- data/lib/rouster/testing.rb +59 -366
- data/lib/rouster/tests.rb +19 -70
- data/path_helper.rb +7 -5
- data/rouster.gemspec +1 -3
- data/test/basic.rb +1 -4
- data/test/functional/deltas/test_get_groups.rb +2 -74
- data/test/functional/deltas/test_get_packages.rb +4 -86
- data/test/functional/deltas/test_get_ports.rb +1 -26
- data/test/functional/deltas/test_get_services.rb +4 -43
- data/test/functional/deltas/test_get_users.rb +2 -35
- data/test/functional/puppet/test_facter.rb +1 -41
- data/test/functional/puppet/test_get_puppet_star.rb +68 -0
- data/test/functional/test_caching.rb +1 -5
- data/test/functional/test_dirs.rb +0 -25
- data/test/functional/test_get.rb +6 -10
- data/test/functional/test_inspect.rb +1 -1
- data/test/functional/test_is_file.rb +1 -17
- data/test/functional/test_new.rb +22 -233
- data/test/functional/test_put.rb +11 -9
- data/test/functional/test_restart.rb +4 -1
- data/test/functional/test_run.rb +3 -2
- data/test/puppet/test_apply.rb +11 -13
- data/test/puppet/test_roles.rb +173 -0
- data/test/unit/test_new.rb +0 -88
- data/test/unit/test_parse_ls_string.rb +0 -67
- data/test/unit/testing/test_validate_file.rb +47 -39
- data/test/unit/testing/test_validate_package.rb +10 -36
- metadata +6 -46
- data/.reek +0 -63
- data/.travis.yml +0 -11
- data/Gemfile +0 -17
- data/Gemfile.lock +0 -102
- data/LICENSE +0 -9
- data/examples/aws.rb +0 -85
- data/examples/openstack.rb +0 -61
- data/examples/passthrough.rb +0 -71
- data/lib/rouster/vagrant.rb +0 -311
- data/plugins/aws.rb +0 -347
- data/plugins/openstack.rb +0 -136
- data/test/functional/deltas/test_get_crontab.rb +0 -161
- data/test/functional/deltas/test_get_os.rb +0 -68
- data/test/functional/test_is_in_file.rb +0 -40
- data/test/functional/test_passthroughs.rb +0 -94
- data/test/functional/test_validate_file.rb +0 -131
- data/test/unit/puppet/resources/puppet_run_with_failed_exec +0 -59
- data/test/unit/puppet/resources/puppet_run_with_successful_exec +0 -61
- data/test/unit/puppet/test_get_puppet_star.rb +0 -91
- data/test/unit/puppet/test_puppet_parsing.rb +0 -44
- data/test/unit/testing/resources/osx-launchd +0 -285
- data/test/unit/testing/resources/rhel-systemd +0 -46
- data/test/unit/testing/resources/rhel-systemv +0 -41
- data/test/unit/testing/resources/rhel-upstart +0 -20
- data/test/unit/testing/test_get_services.rb +0 -178
- data/test/unit/testing/test_validate_cron.rb +0 -78
- data/test/unit/testing/test_validate_port.rb +0 -103
@@ -0,0 +1,173 @@
|
|
1
|
+
require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
|
2
|
+
|
3
|
+
require 'rouster'
|
4
|
+
require 'rouster/puppet'
|
5
|
+
require 'rouster/testing'
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
class TestPuppetRoles < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@ppm = Rouster.new(:name => 'ppm', :vagrantfile => '../piab/Vagrantfile')
|
13
|
+
@ppm.rebuild() unless @ppm.status.eql?('running') # destroy / rebuild
|
14
|
+
|
15
|
+
@app = Rouster.new(:name => 'app', :vagrantfile => '../piab/Vagrantfile')
|
16
|
+
|
17
|
+
assert_nothing_raised do
|
18
|
+
@ppm.run_puppet('master', { :expected_exitcode => [0,2] })
|
19
|
+
end
|
20
|
+
|
21
|
+
assert_match(/Finished catalog run in/, @ppm.get_output())
|
22
|
+
|
23
|
+
# define base here
|
24
|
+
@expected_packages = {
|
25
|
+
'puppet' => { :ensure => true },
|
26
|
+
'facter' => { :ensure => 'present' }
|
27
|
+
}
|
28
|
+
|
29
|
+
@expected_files = {
|
30
|
+
'/etc/passwd' => {
|
31
|
+
:contains => [ 'vagrant', 'root'],
|
32
|
+
:ensure => 'file',
|
33
|
+
:group => 'root',
|
34
|
+
:mode => '0644',
|
35
|
+
:owner => 'root'
|
36
|
+
},
|
37
|
+
|
38
|
+
'/tmp' => {
|
39
|
+
:ensure => 'directory',
|
40
|
+
:group => 'root',
|
41
|
+
:owner => 'root',
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
@expected_groups = {
|
46
|
+
'root' => { :ensure => 'true' }
|
47
|
+
}
|
48
|
+
|
49
|
+
@expected_services = Hash.new()
|
50
|
+
@expected_users = {
|
51
|
+
'root' => {
|
52
|
+
:ensure => 'present',
|
53
|
+
:group => 'root',
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
# manually specified testing
|
58
|
+
@expected_files.each_pair do |f,e|
|
59
|
+
assert_equal(true, @ppm.validate_file(f,e))
|
60
|
+
end
|
61
|
+
|
62
|
+
@expected_groups.each_pair do |g,e|
|
63
|
+
assert_equal(true, @ppm.validate_group(g,e))
|
64
|
+
end
|
65
|
+
|
66
|
+
@expected_packages.each_pair do |p,e|
|
67
|
+
assert_equal(true, @ppm.validate_package(p, e))
|
68
|
+
end
|
69
|
+
|
70
|
+
@expected_services.each_pair do |s,e|
|
71
|
+
assert_equal(true, @ppm.validate_service(s,e))
|
72
|
+
end
|
73
|
+
|
74
|
+
@expected_users.each_pair do |u,e|
|
75
|
+
assert_equal(true, @ppm.validate_user(u,e))
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_app
|
81
|
+
app_expected_packages = {
|
82
|
+
'rsync' => { :ensure => 'present' }
|
83
|
+
}.merge(@expected_packages)
|
84
|
+
|
85
|
+
app_expected_files = {
|
86
|
+
'/etc/hosts' => {
|
87
|
+
:contains => [ 'localhost', 'app' ],
|
88
|
+
:ensure => 'present',
|
89
|
+
:group => 'root',
|
90
|
+
:owner => 'root',
|
91
|
+
},
|
92
|
+
}.merge(@expected_files)
|
93
|
+
|
94
|
+
app_expected_groups = {
|
95
|
+
'vagrant' => {
|
96
|
+
:ensure => 'present',
|
97
|
+
}
|
98
|
+
}.merge(@expected_groups)
|
99
|
+
|
100
|
+
app_expected_services = {}.merge(@expected_services)
|
101
|
+
|
102
|
+
app_expected_users = {
|
103
|
+
'vagrant' => {
|
104
|
+
:ensure => 'present',
|
105
|
+
},
|
106
|
+
}.merge(@expected_users)
|
107
|
+
|
108
|
+
assert_nothing_raised do
|
109
|
+
@app.up()
|
110
|
+
@app.run_puppet('master', { :expected_exitcode => [0, 2] })
|
111
|
+
end
|
112
|
+
|
113
|
+
assert_match(/Finished catalog run in/, @app.get_output())
|
114
|
+
|
115
|
+
# manually specified testing
|
116
|
+
app_expected_files.each_pair do |f,e|
|
117
|
+
assert_equal(true, @app.validate_file(f,e))
|
118
|
+
end
|
119
|
+
|
120
|
+
app_expected_groups.each_pair do |g,e|
|
121
|
+
assert_equal(true, @app.validate_group(g,e))
|
122
|
+
end
|
123
|
+
|
124
|
+
app_expected_packages.each_pair do |p,e|
|
125
|
+
assert_equal(true, @app.validate_package(p, e))
|
126
|
+
end
|
127
|
+
|
128
|
+
app_expected_services.each_pair do |s,e|
|
129
|
+
assert_equal(true, @app.validate_service(s,e))
|
130
|
+
end
|
131
|
+
|
132
|
+
app_expected_users.each_pair do |u,e|
|
133
|
+
assert_equal(true, @app.validate_user(u,e))
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
def dont_test_app_automated
|
139
|
+
catalog = @app.get_catalog()
|
140
|
+
expectations = @app.parse_catalog(catalog)
|
141
|
+
|
142
|
+
assert_nothing_raised do
|
143
|
+
@app.up()
|
144
|
+
@app.run_puppet('master', { :expected_exitcode => 2 })
|
145
|
+
end
|
146
|
+
|
147
|
+
assert_match(/Finished catalog run in/, @app.get_output())
|
148
|
+
|
149
|
+
expectations.each_pair do |k,v|
|
150
|
+
res = nil
|
151
|
+
case v[:type]
|
152
|
+
when :dir, :file
|
153
|
+
res = @app.validate_file(k, v)
|
154
|
+
when :group
|
155
|
+
res = @app.validate_group(k, v)
|
156
|
+
when :package
|
157
|
+
res = @app.validate_package(k, v)
|
158
|
+
when :user
|
159
|
+
res = @app.validate_user(k, v)
|
160
|
+
when :service
|
161
|
+
res = @app.validate_service(k, v)
|
162
|
+
end
|
163
|
+
|
164
|
+
assert_equal(true, res, sprintf('failed[%s]: %s',v, res))
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
def teardown
|
170
|
+
# noop
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
data/test/unit/test_new.rb
CHANGED
@@ -9,8 +9,6 @@ class TestNew < Test::Unit::TestCase
|
|
9
9
|
|
10
10
|
def setup
|
11
11
|
@app = nil
|
12
|
-
# TODO make this work, don't want to have to instance_variable_get everything..
|
13
|
-
#Rouster.send(:public, *Rouster.instance_variables)
|
14
12
|
end
|
15
13
|
|
16
14
|
# TODO this is an awful pattern, do better
|
@@ -26,92 +24,6 @@ class TestNew < Test::Unit::TestCase
|
|
26
24
|
assert_equal(true, @app.uses_sudo?())
|
27
25
|
end
|
28
26
|
|
29
|
-
def test_2_good_instantiation
|
30
|
-
|
31
|
-
assert_nothing_raised do
|
32
|
-
@app = Rouster.new(
|
33
|
-
:cache_timeout => 10,
|
34
|
-
:name => 'ppm',
|
35
|
-
:retries => 3,
|
36
|
-
:verbosity => [3,2],
|
37
|
-
:unittest => true,
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
assert_equal(10, @app.cache_timeout)
|
42
|
-
assert_equal('ppm', @app.name)
|
43
|
-
assert_equal(3, @app.retries)
|
44
|
-
|
45
|
-
assert_equal(3, @app.instance_variable_get(:@verbosity_console))
|
46
|
-
assert_equal(2, @app.instance_variable_get(:@verbosity_logfile))
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
def test_default_overrides_aws_passthrough
|
52
|
-
|
53
|
-
key = sprintf('%s/.ssh/id_rsa', ENV['HOME'])
|
54
|
-
omit(sprintf('no suitable private key found at [%s]', key)) unless File.file?(key)
|
55
|
-
|
56
|
-
@app = Rouster.new(
|
57
|
-
:name => 'aws',
|
58
|
-
:passthrough => {
|
59
|
-
:type => :aws,
|
60
|
-
:ami => 'ami-1234',
|
61
|
-
:keypair => 'you@aws',
|
62
|
-
:key => key,
|
63
|
-
:key_id => 'key',
|
64
|
-
:secret_key => 'secret_access_key',
|
65
|
-
|
66
|
-
# aws specific overrides
|
67
|
-
:region => 'us-east-2',
|
68
|
-
:user => 'cloud-user',
|
69
|
-
|
70
|
-
# generic passthrough overrides
|
71
|
-
:ssh_sleep_ceiling => 1,
|
72
|
-
:ssh_sleep_time => 1,
|
73
|
-
},
|
74
|
-
|
75
|
-
:unittest => true,
|
76
|
-
)
|
77
|
-
|
78
|
-
passthrough = @app.passthrough
|
79
|
-
|
80
|
-
assert_equal('us-east-2', passthrough[:region])
|
81
|
-
assert_equal('cloud-user', passthrough[:user])
|
82
|
-
assert_equal(1, passthrough[:ssh_sleep_ceiling])
|
83
|
-
assert_equal(1, passthrough[:ssh_sleep_time])
|
84
|
-
|
85
|
-
assert_not_nil(passthrough[:ami])
|
86
|
-
assert_not_nil(passthrough[:key_id])
|
87
|
-
assert_not_nil(passthrough[:min_count])
|
88
|
-
assert_not_nil(passthrough[:max_count])
|
89
|
-
assert_not_nil(passthrough[:size])
|
90
|
-
assert_not_nil(passthrough[:ssh_port])
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_default_overrides_passthrough
|
95
|
-
|
96
|
-
@app = Rouster.new(
|
97
|
-
:name => 'local',
|
98
|
-
:passthrough => {
|
99
|
-
:type => :local,
|
100
|
-
:paranoid => :secure,
|
101
|
-
:ssh_sleep_ceiling => 100,
|
102
|
-
},
|
103
|
-
|
104
|
-
:unittest => true,
|
105
|
-
)
|
106
|
-
|
107
|
-
passthrough = @app.passthrough
|
108
|
-
|
109
|
-
assert_equal(:secure, passthrough[:paranoid])
|
110
|
-
assert_equal(100, passthrough[:ssh_sleep_ceiling])
|
111
|
-
assert_not_equal(100, passthrough[:ssh_sleep_time])
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
27
|
def teardown
|
116
28
|
# noop
|
117
29
|
end
|
@@ -29,7 +29,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
29
29
|
:owner => 'root',
|
30
30
|
:group => 'root',
|
31
31
|
:size => '199',
|
32
|
-
:symlink? => false,
|
33
32
|
:executable? => [false, false, false],
|
34
33
|
:readable? => [true, true, true],
|
35
34
|
:writeable? => [false, false, false]
|
@@ -51,7 +50,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
51
50
|
:owner => 'root',
|
52
51
|
:group => 'root',
|
53
52
|
:size => '199',
|
54
|
-
:symlink? => false,
|
55
53
|
:executable? => [false, false, false],
|
56
54
|
:readable? => [true, false, false],
|
57
55
|
:writeable? => [false, false, false]
|
@@ -73,7 +71,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
73
71
|
:owner => 'root',
|
74
72
|
:group => 'root',
|
75
73
|
:size => '199',
|
76
|
-
:symlink? => false,
|
77
74
|
:executable? => [false, false, false],
|
78
75
|
:readable? => [false, true, false],
|
79
76
|
:writeable? => [false, false, false]
|
@@ -95,7 +92,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
95
92
|
:owner => 'root',
|
96
93
|
:group => 'root',
|
97
94
|
:size => '199',
|
98
|
-
:symlink? => false,
|
99
95
|
:executable? => [false, false, false],
|
100
96
|
:readable? => [false, false, true],
|
101
97
|
:writeable? => [false, false, false]
|
@@ -117,7 +113,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
117
113
|
:owner => 'root',
|
118
114
|
:group => 'root',
|
119
115
|
:size => '199',
|
120
|
-
:symlink? => false,
|
121
116
|
:executable? => [true, true, true],
|
122
117
|
:readable? => [false, false, false],
|
123
118
|
:writeable? => [false, false, false]
|
@@ -139,7 +134,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
139
134
|
:owner => 'root',
|
140
135
|
:group => 'root',
|
141
136
|
:size => '199',
|
142
|
-
:symlink? => false,
|
143
137
|
:executable? => [true, false, false],
|
144
138
|
:readable? => [false, false, false],
|
145
139
|
:writeable? => [false, false, false]
|
@@ -161,7 +155,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
161
155
|
:owner => 'root',
|
162
156
|
:group => 'root',
|
163
157
|
:size => '199',
|
164
|
-
:symlink? => false,
|
165
158
|
:executable? => [false, true, false],
|
166
159
|
:readable? => [false, false, false],
|
167
160
|
:writeable? => [false, false, false]
|
@@ -183,7 +176,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
183
176
|
:owner => 'root',
|
184
177
|
:group => 'root',
|
185
178
|
:size => '199',
|
186
|
-
:symlink? => false,
|
187
179
|
:executable? => [false, false, true],
|
188
180
|
:readable? => [false, false, false],
|
189
181
|
:writeable? => [false, false, false]
|
@@ -205,7 +197,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
205
197
|
:owner => 'root',
|
206
198
|
:group => 'root',
|
207
199
|
:size => '199',
|
208
|
-
:symlink? => false,
|
209
200
|
:executable? => [false, false, false],
|
210
201
|
:readable? => [false, false, false],
|
211
202
|
:writeable? => [true, true, true]
|
@@ -227,7 +218,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
227
218
|
:owner => 'root',
|
228
219
|
:group => 'root',
|
229
220
|
:size => '199',
|
230
|
-
:symlink? => false,
|
231
221
|
:executable? => [false, false, false],
|
232
222
|
:readable? => [false, false, false],
|
233
223
|
:writeable? => [true, false, false]
|
@@ -249,7 +239,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
249
239
|
:owner => 'root',
|
250
240
|
:group => 'root',
|
251
241
|
:size => '199',
|
252
|
-
:symlink? => false,
|
253
242
|
:executable? => [false, false, false],
|
254
243
|
:readable? => [false, false, false],
|
255
244
|
:writeable? => [false, true, false]
|
@@ -271,7 +260,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
271
260
|
:owner => 'root',
|
272
261
|
:group => 'root',
|
273
262
|
:size => '199',
|
274
|
-
:symlink? => false,
|
275
263
|
:executable? => [false, false, false],
|
276
264
|
:readable? => [false, false, false],
|
277
265
|
:writeable? => [false, false, true]
|
@@ -293,7 +281,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
293
281
|
:owner => 'vagrant',
|
294
282
|
:group => 'vagrant',
|
295
283
|
:size => '1909',
|
296
|
-
:symlink? => false,
|
297
284
|
:executable? => [false, false, true],
|
298
285
|
:readable? => [false, false, true],
|
299
286
|
:writeable? => [false, false, true]
|
@@ -315,7 +302,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
315
302
|
:owner => 'vagrant',
|
316
303
|
:group => 'root',
|
317
304
|
:size => '0',
|
318
|
-
:symlink? => false,
|
319
305
|
:executable? => [false, false, false],
|
320
306
|
:readable? => [true, true, true],
|
321
307
|
:writeable? => [true, false, false]
|
@@ -326,25 +312,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
326
312
|
assert_equal(expectation, res)
|
327
313
|
end
|
328
314
|
|
329
|
-
def test_uid_forced
|
330
|
-
uid = 501
|
331
|
-
str = "-rw-r--r-- 1 #{uid} root 0 Jun 13 09:35 foo\n"
|
332
|
-
|
333
|
-
res = @app.exposed_parse_ls_string(str)
|
334
|
-
|
335
|
-
assert_equal('501', res[:owner])
|
336
|
-
|
337
|
-
end
|
338
|
-
|
339
|
-
def test_gid_forced
|
340
|
-
gid = 10
|
341
|
-
str = "-rw-r--r-- 1 vagrant #{gid} 0 Jun 13 09:35 foo\n"
|
342
|
-
|
343
|
-
res = @app.exposed_parse_ls_string(str)
|
344
|
-
|
345
|
-
assert_equal('10', res[:group])
|
346
|
-
end
|
347
|
-
|
348
315
|
def test_dir_detection
|
349
316
|
dir_str = "drwxrwxrwt 5 root root 4096 May 28 00:26 /tmp/\n"
|
350
317
|
file_str = "-rw-r--r-- 1 root root 906 Oct 2 2012 grub.conf\n"
|
@@ -360,40 +327,6 @@ class TestParseLsString < Test::Unit::TestCase
|
|
360
327
|
|
361
328
|
end
|
362
329
|
|
363
|
-
def test_symlink_detection
|
364
|
-
link = "lrwxrwxrwx 1 vagrant vagrant 10 Mar 13 22:53 foo -> /etc/hosts\n"
|
365
|
-
file = "-rw-r--r-- 2 root root 166 Mar 13 22:50 /etc/hosts\n"
|
366
|
-
|
367
|
-
assert_equal(true, @app.exposed_parse_ls_string(link)[:symlink?])
|
368
|
-
assert_equal(false, @app.exposed_parse_ls_string(file)[:symlink?])
|
369
|
-
|
370
|
-
end
|
371
|
-
|
372
|
-
def test_suid
|
373
|
-
str = "drwxr-sr-x 2 root root 4096 Oct 7 17:09 /etc/nagios/objects\n"
|
374
|
-
|
375
|
-
omit('need to improve (read: implement) actual suid support')
|
376
|
-
|
377
|
-
expectation = {
|
378
|
-
:directory? => true,
|
379
|
-
:file? => false,
|
380
|
-
:mode => '4755', # right now, we return '0755', if we detect an 's', do we just +4000?
|
381
|
-
:name => '/etc/nagios/objects',
|
382
|
-
:owner => 'root',
|
383
|
-
:group => 'root',
|
384
|
-
:size => '4096',
|
385
|
-
:symlink? => false,
|
386
|
-
:executable? => [true, true, true], # right now, we return [true,false,true]
|
387
|
-
:readable? => [true, true, true],
|
388
|
-
:writeable? => [true, false, false],
|
389
|
-
}
|
390
|
-
|
391
|
-
res = @app.exposed_parse_ls_string(str)
|
392
|
-
|
393
|
-
assert_equal(expectation, res)
|
394
|
-
|
395
|
-
end
|
396
|
-
|
397
330
|
def teardown
|
398
331
|
# noop
|
399
332
|
end
|
@@ -48,60 +48,68 @@ class TestValidateFile < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
def test_positive_basic
|
50
50
|
|
51
|
-
assert(@app.validate_file('/etc/hosts', { :ensure => 'file', :mode => '0644', :file => true, :directory => false, :owner => 'root', :group => 'root' },
|
52
|
-
assert(@app.validate_file('/etc/hosts', { :exists => 'present' },
|
53
|
-
assert(@app.validate_file('/etc/hosts', { },
|
54
|
-
assert(@app.validate_file('/etc/hosts', { :mode => '0644' },
|
55
|
-
assert(@app.validate_file('/etc/hosts', { :permissions => '0644' },
|
56
|
-
assert(@app.validate_file('/etc/hosts', { :size => 166 },
|
57
|
-
assert(@app.validate_file('/etc/hosts', { :size => '166' },
|
58
|
-
assert(@app.validate_file('/etc/hosts', { :file => 'true' },
|
59
|
-
assert(@app.validate_file('/etc/hosts', { :file => true },
|
60
|
-
assert(@app.validate_file('/etc/hosts', { :directory => 'false' },
|
61
|
-
assert(@app.validate_file('/etc/hosts', { :directory => false },
|
62
|
-
assert(@app.validate_file('/etc/hosts', { :owner => 'root' },
|
63
|
-
assert(@app.validate_file('/etc/hosts', { :group => 'root' },
|
64
|
-
|
65
|
-
|
66
|
-
assert(@app.validate_file('/etc/fizzbang', { :ensure =>
|
67
|
-
|
68
|
-
|
69
|
-
assert(@app.validate_file('/etc', { :ensure => '
|
70
|
-
assert(@app.validate_file('/etc', { :ensure => 'dir'
|
71
|
-
assert(@app.validate_file('/etc', { :ensure => 'dir', :
|
72
|
-
assert(@app.validate_file('/etc', { :ensure => 'dir', :
|
73
|
-
|
74
|
-
|
75
|
-
assert(@app.validate_file('/fizzy', { :ensure =>
|
76
|
-
assert(@app.validate_file('/fizzy', { :
|
77
|
-
assert(@app.validate_file('/fizzy', { :exists => false },
|
51
|
+
assert(@app.validate_file('/etc/hosts', { :ensure => 'file', :mode => '0644', :file => true, :directory => false, :owner => 'root', :group => 'root' }, true))
|
52
|
+
assert(@app.validate_file('/etc/hosts', { :exists => 'present' }, true ))
|
53
|
+
assert(@app.validate_file('/etc/hosts', { }, true ))
|
54
|
+
assert(@app.validate_file('/etc/hosts', { :mode => '0644' }, true))
|
55
|
+
assert(@app.validate_file('/etc/hosts', { :permissions => '0644' }, true))
|
56
|
+
assert(@app.validate_file('/etc/hosts', { :size => 166 }, true ))
|
57
|
+
assert(@app.validate_file('/etc/hosts', { :size => '166' }, true ))
|
58
|
+
assert(@app.validate_file('/etc/hosts', { :file => 'true' }, true))
|
59
|
+
assert(@app.validate_file('/etc/hosts', { :file => true }, true))
|
60
|
+
assert(@app.validate_file('/etc/hosts', { :directory => 'false' }, true))
|
61
|
+
assert(@app.validate_file('/etc/hosts', { :directory => false }, true))
|
62
|
+
assert(@app.validate_file('/etc/hosts', { :owner => 'root' }, true))
|
63
|
+
assert(@app.validate_file('/etc/hosts', { :group => 'root' }, true))
|
64
|
+
|
65
|
+
# TODO figure out how to run these in a truly unit-y way, since the data is not present in faked hash, we will fall through to functional testing
|
66
|
+
#assert(@app.validate_file('/etc/fizzbang', { :ensure => 'absent' }, true))
|
67
|
+
#assert(@app.validate_file('/etc/fizzbang', { :ensure => false }, true ))
|
68
|
+
|
69
|
+
assert(@app.validate_file('/etc', { :ensure => 'directory' }, true))
|
70
|
+
assert(@app.validate_file('/etc', { :ensure => 'dir' }, true))
|
71
|
+
assert(@app.validate_file('/etc', { :ensure => 'dir', :file => 'false' }, true))
|
72
|
+
assert(@app.validate_file('/etc', { :ensure => 'dir', :directory => 'true' }, true))
|
73
|
+
assert(@app.validate_file('/etc', { :ensure => 'dir', :file => 'false', :directory => 'true' }, true))
|
74
|
+
|
75
|
+
assert(@app.validate_file('/fizzy', { :ensure => 'absent' }, true))
|
76
|
+
assert(@app.validate_file('/fizzy', { :ensure => false }, true))
|
77
|
+
assert(@app.validate_file('/fizzy', { :exists => 'false' }, true))
|
78
|
+
assert(@app.validate_file('/fizzy', { :exists => false }, true))
|
79
|
+
|
80
|
+
# TODO need to do :contains testing in a non-unit context
|
78
81
|
|
79
82
|
end
|
80
83
|
|
81
84
|
def test_positive_constrained
|
82
85
|
|
83
|
-
assert(@app.validate_file('/etc/hosts', { :mode => '0644', :constrain => 'is_virtual true' },
|
86
|
+
assert(@app.validate_file('/etc/hosts', { :mode => '0644', :constrain => 'is_virtual true' }, true))
|
84
87
|
|
85
88
|
end
|
86
89
|
|
87
90
|
def test_negative_basic
|
88
91
|
|
89
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :mode => '0777' },
|
90
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :permissions => '0777' },
|
91
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :file => 'false' },
|
92
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :file => false },
|
93
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :directory => 'true' },
|
94
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :directory => true },
|
95
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :size => 'foo' },
|
96
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :size => 100 },
|
97
|
-
assert_equal(false, @app.validate_file('/etc/hosts', { :size => '100'},
|
92
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :mode => '0777' }, true))
|
93
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :permissions => '0777' }, true))
|
94
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :file => 'false' }, true ))
|
95
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :file => false }, true))
|
96
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :directory => 'true' }, true))
|
97
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :directory => true }, true))
|
98
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :size => 'foo' }, true))
|
99
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :size => 100 }, true))
|
100
|
+
assert_equal(false, @app.validate_file('/etc/hosts', { :size => '100'}, true))
|
101
|
+
|
102
|
+
# TODO figure out how to run these in a truly unit-y way, since the data is not present in faked hash, we will fall through to functional testing
|
103
|
+
#assert_equal(false, @app.validate_file('/foo', {}, true))
|
104
|
+
#assert_equal(false, @app.validate_file('/fizzy', { :ensure => 'directory' }, true))
|
105
|
+
#assert_equal(false, @app.validate_file('/bang', { :ensure => 'file' }, true))
|
98
106
|
|
99
107
|
end
|
100
108
|
|
101
109
|
def test_negative_constrained
|
102
110
|
|
103
|
-
assert(@app.validate_file('/etc/hosts', { :mode => '0644', :constrain => 'is_virtual false' },
|
104
|
-
assert(@app.validate_file('/etc/hosts', { :mode => '0999', :constrain => 'is_virtual false' },
|
111
|
+
assert(@app.validate_file('/etc/hosts', { :mode => '0644', :constrain => 'is_virtual false' }, true))
|
112
|
+
assert(@app.validate_file('/etc/hosts', { :mode => '0999', :constrain => 'is_virtual false' }, true))
|
105
113
|
|
106
114
|
end
|
107
115
|
|