rouster 0.5

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/LICENSE +9 -0
  4. data/README.md +175 -0
  5. data/Rakefile +65 -0
  6. data/Vagrantfile +23 -0
  7. data/examples/bootstrap.rb +113 -0
  8. data/examples/demo.rb +71 -0
  9. data/examples/error.rb +30 -0
  10. data/lib/rouster.rb +737 -0
  11. data/lib/rouster/deltas.rb +481 -0
  12. data/lib/rouster/puppet.rb +398 -0
  13. data/lib/rouster/testing.rb +743 -0
  14. data/lib/rouster/tests.rb +596 -0
  15. data/path_helper.rb +21 -0
  16. data/rouster.gemspec +30 -0
  17. data/test/basic.rb +10 -0
  18. data/test/functional/deltas/test_get_crontab.rb +99 -0
  19. data/test/functional/deltas/test_get_groups.rb +48 -0
  20. data/test/functional/deltas/test_get_packages.rb +71 -0
  21. data/test/functional/deltas/test_get_ports.rb +119 -0
  22. data/test/functional/deltas/test_get_services.rb +43 -0
  23. data/test/functional/deltas/test_get_users.rb +45 -0
  24. data/test/functional/puppet/test_facter.rb +59 -0
  25. data/test/functional/test_caching.rb +124 -0
  26. data/test/functional/test_destroy.rb +51 -0
  27. data/test/functional/test_dirs.rb +88 -0
  28. data/test/functional/test_files.rb +64 -0
  29. data/test/functional/test_get.rb +76 -0
  30. data/test/functional/test_inspect.rb +31 -0
  31. data/test/functional/test_is_dir.rb +118 -0
  32. data/test/functional/test_is_file.rb +119 -0
  33. data/test/functional/test_new.rb +92 -0
  34. data/test/functional/test_put.rb +81 -0
  35. data/test/functional/test_rebuild.rb +49 -0
  36. data/test/functional/test_restart.rb +44 -0
  37. data/test/functional/test_run.rb +77 -0
  38. data/test/functional/test_status.rb +38 -0
  39. data/test/functional/test_suspend.rb +31 -0
  40. data/test/functional/test_up.rb +27 -0
  41. data/test/functional/test_validate_file.rb +30 -0
  42. data/test/puppet/manifests/default.pp +9 -0
  43. data/test/puppet/manifests/hiera.yaml +12 -0
  44. data/test/puppet/manifests/hieradata/common.json +3 -0
  45. data/test/puppet/manifests/hieradata/vagrant.json +3 -0
  46. data/test/puppet/manifests/manifest.pp +78 -0
  47. data/test/puppet/modules/role/manifests/ui.pp +5 -0
  48. data/test/puppet/test_apply.rb +149 -0
  49. data/test/puppet/test_roles.rb +186 -0
  50. data/test/tunnel_vs_scp.rb +41 -0
  51. data/test/unit/puppet/test_get_puppet_star.rb +68 -0
  52. data/test/unit/test_generate_unique_mac.rb +43 -0
  53. data/test/unit/test_new.rb +31 -0
  54. data/test/unit/test_parse_ls_string.rb +334 -0
  55. data/test/unit/test_traverse_up.rb +43 -0
  56. data/test/unit/testing/test_meets_constraint.rb +55 -0
  57. data/test/unit/testing/test_validate_file.rb +112 -0
  58. data/test/unit/testing/test_validate_group.rb +72 -0
  59. data/test/unit/testing/test_validate_package.rb +69 -0
  60. data/test/unit/testing/test_validate_port.rb +98 -0
  61. data/test/unit/testing/test_validate_service.rb +73 -0
  62. data/test/unit/testing/test_validate_user.rb +92 -0
  63. metadata +203 -0
@@ -0,0 +1,186 @@
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
+
13
+ piab_vagrantfile = sprintf('%s/../../../piab/Vagrantfile', File.dirname(File.expand_path(__FILE__)))
14
+
15
+ unless File.file?(piab_vagrantfile)
16
+ skip(sprintf('missing SFDC specific Vagrantfile[%s], skipping', piab_vagrantfile))
17
+ end
18
+
19
+ assert_nothing_raised do
20
+ @ppm = Rouster.new(:name => 'ppm', :vagrantfile => piab_vagrantfile)
21
+ @ppm.up()
22
+ @ppm.remove_existing_certs('ppm')
23
+ #@ppm.rebuild() unless @ppm.status.eql?('running') # destroy / rebuild
24
+ end
25
+
26
+ assert_nothing_raised do
27
+ @app = Rouster.new(:name => 'app', :vagrantfile => piab_vagrantfile)
28
+ end
29
+
30
+ assert_nothing_raised do
31
+ @ppm.run_puppet('master', { :expected_exitcode => [0,2] })
32
+ end
33
+
34
+ assert_match(/Finished catalog run in/, @ppm.get_output())
35
+
36
+ # define base here
37
+ @expected_packages = {
38
+ 'puppet' => { :ensure => true },
39
+ 'facter' => { :ensure => 'present' }
40
+ }
41
+
42
+ @expected_files = {
43
+ '/etc/passwd' => {
44
+ :contains => [ 'vagrant', 'root'],
45
+ :ensure => 'file',
46
+ :group => 'root',
47
+ :mode => '0644',
48
+ :owner => 'root'
49
+ },
50
+
51
+ '/tmp' => {
52
+ :ensure => 'directory',
53
+ :group => 'root',
54
+ :owner => 'root',
55
+ }
56
+ }
57
+
58
+ @expected_groups = {
59
+ 'root' => { :ensure => 'true' }
60
+ }
61
+
62
+ @expected_services = Hash.new()
63
+ @expected_users = {
64
+ 'root' => {
65
+ :ensure => 'present',
66
+ :group => 'root',
67
+ }
68
+ }
69
+
70
+ # manually specified testing
71
+ @expected_files.each_pair do |f,e|
72
+ assert_equal(true, @ppm.validate_file(f,e))
73
+ end
74
+
75
+ @expected_groups.each_pair do |g,e|
76
+ assert_equal(true, @ppm.validate_group(g,e))
77
+ end
78
+
79
+ @expected_packages.each_pair do |p,e|
80
+ assert_equal(true, @ppm.validate_package(p, e))
81
+ end
82
+
83
+ @expected_services.each_pair do |s,e|
84
+ assert_equal(true, @ppm.validate_service(s,e))
85
+ end
86
+
87
+ @expected_users.each_pair do |u,e|
88
+ assert_equal(true, @ppm.validate_user(u,e))
89
+ end
90
+
91
+ end
92
+
93
+ def test_app
94
+ app_expected_packages = {
95
+ 'rsync' => { :ensure => 'present' }
96
+ }.merge(@expected_packages)
97
+
98
+ app_expected_files = {
99
+ '/etc/hosts' => {
100
+ :contains => [ 'localhost', 'app' ],
101
+ :ensure => 'present',
102
+ :group => 'root',
103
+ :owner => 'root',
104
+ },
105
+ }.merge(@expected_files)
106
+
107
+ app_expected_groups = {
108
+ 'vagrant' => {
109
+ :ensure => 'present',
110
+ }
111
+ }.merge(@expected_groups)
112
+
113
+ app_expected_services = {}.merge(@expected_services)
114
+
115
+ app_expected_users = {
116
+ 'vagrant' => {
117
+ :ensure => 'present',
118
+ },
119
+ }.merge(@expected_users)
120
+
121
+ assert_nothing_raised do
122
+ @app.up()
123
+ @app.run_puppet('master', { :expected_exitcode => [0, 2] })
124
+ end
125
+
126
+ assert_match(/Finished catalog run in/, @app.get_output())
127
+
128
+ # manually specified testing
129
+ app_expected_files.each_pair do |f,e|
130
+ assert_equal(true, @app.validate_file(f,e))
131
+ end
132
+
133
+ app_expected_groups.each_pair do |g,e|
134
+ assert_equal(true, @app.validate_group(g,e))
135
+ end
136
+
137
+ app_expected_packages.each_pair do |p,e|
138
+ assert_equal(true, @app.validate_package(p, e))
139
+ end
140
+
141
+ app_expected_services.each_pair do |s,e|
142
+ assert_equal(true, @app.validate_service(s,e))
143
+ end
144
+
145
+ app_expected_users.each_pair do |u,e|
146
+ assert_equal(true, @app.validate_user(u,e))
147
+ end
148
+
149
+ end
150
+
151
+ def dont_test_app_automated
152
+ catalog = @app.get_catalog()
153
+ expectations = @app.parse_catalog(catalog)
154
+
155
+ assert_nothing_raised do
156
+ @app.up()
157
+ @app.run_puppet('master', { :expected_exitcode => 2 })
158
+ end
159
+
160
+ assert_match(/Finished catalog run in/, @app.get_output())
161
+
162
+ expectations.each_pair do |k,v|
163
+ res = nil
164
+ case v[:type]
165
+ when :dir, :file
166
+ res = @app.validate_file(k, v)
167
+ when :group
168
+ res = @app.validate_group(k, v)
169
+ when :package
170
+ res = @app.validate_package(k, v)
171
+ when :user
172
+ res = @app.validate_user(k, v)
173
+ when :service
174
+ res = @app.validate_service(k, v)
175
+ end
176
+
177
+ assert_equal(true, res, sprintf('failed[%s]: %s',v, res))
178
+ end
179
+
180
+ end
181
+
182
+ def teardown
183
+ # noop
184
+ end
185
+
186
+ end
@@ -0,0 +1,41 @@
1
+ require sprintf('%s/../%s', File.dirname(File.expand_path(__FILE__)), 'path_helper')
2
+ require 'rouster'
3
+ require 'rouster/tests'
4
+
5
+ # 'performance' test to determine if we should implement the scp option
6
+ # in is_in_file()? -- first run says yes, probably make it off by default
7
+
8
+ w = Rouster.new(:name => 'app', :verbose => 3)
9
+ w.up()
10
+
11
+ file = '/etc/hosts'
12
+ look_for = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
13
+
14
+ print w.is_available_via_ssh?
15
+
16
+ ## through the scp tunnel
17
+ start = Time.now
18
+ look_for.each do |element|
19
+ print w.is_in_file?(file, element)
20
+ end
21
+
22
+ finish = Time.now
23
+
24
+ print "\nscp tunnel took #{finish - start}\n"
25
+ local = '/tmp/test-ing'
26
+
27
+ ## get the file, then _run against it
28
+
29
+ w.get(file, local)
30
+
31
+ start = Time.now
32
+ look_for.each do |element|
33
+ begin
34
+ print w._run(sprintf("grep -c '%s' %s", element, local))
35
+ rescue
36
+ end
37
+
38
+ end
39
+ finish = Time.now
40
+
41
+ print "\nwith a get, took #{finish - start}\n"
@@ -0,0 +1,68 @@
1
+ require sprintf('%s/../../../path_helper', File.dirname(File.expand_path(__FILE__)))
2
+
3
+ require 'rouster'
4
+ require 'rouster/puppet'
5
+ require 'test/unit'
6
+
7
+ # this is technically a unit test, no need for a real Rouster VM
8
+
9
+ class TestGetPuppetStar < Test::Unit::TestCase
10
+
11
+ def setup
12
+ assert_nothing_raised do
13
+ @app = Rouster.new(:name => 'app', :unittest => true)
14
+ end
15
+
16
+ # expose private methods
17
+ Rouster.send(:public, *Rouster.protected_instance_methods)
18
+ end
19
+
20
+ def test_happy_get_errors
21
+
22
+ output = "[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [api_vip] in Hiera (YAML/CMS)\nfizzybang\n[1;35merr: Could not retrieve catalog from remote server: Error 400 on SERVER: no result for [foobar] in Hiera (YAML/CMS)"
23
+ @app.output.push(output)
24
+
25
+ assert_not_nil(@app.get_puppet_errors())
26
+ assert_equal(2, @app.get_puppet_errors().size)
27
+ assert_equal(@app.get_puppet_errors(), @app.get_puppet_errors(output)) # could be split out to a different test
28
+
29
+ assert_nil(@app.get_puppet_notices())
30
+
31
+ end
32
+
33
+ def test_happy_get_notices
34
+
35
+ output = "[0;36mnotice: Not using cache on failed catalog\nfizzbang\n[0;36mnotice: Not using cache on failed catalog"
36
+ @app.output.push(output)
37
+
38
+ assert_not_nil(@app.get_puppet_notices())
39
+ assert_equal(2, @app.get_puppet_notices().size)
40
+ assert_equal(@app.get_puppet_notices(), @app.get_puppet_notices(output))
41
+
42
+ assert_nil(@app.get_puppet_errors())
43
+
44
+ end
45
+
46
+ def test_no_errors
47
+
48
+ output = 'there are no errors here'
49
+ @app.output.push(output)
50
+
51
+ assert_nil(@app.get_puppet_errors())
52
+ end
53
+
54
+ def test_no_notices
55
+
56
+ output = 'there are no notices here'
57
+ @app.output.push(output)
58
+
59
+ assert_nil(@app.get_puppet_notices())
60
+
61
+ end
62
+
63
+ def teardown
64
+ # noop
65
+ end
66
+
67
+ end
68
+
@@ -0,0 +1,43 @@
1
+ require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
2
+
3
+ require 'rouster'
4
+ require 'test/unit'
5
+
6
+ class TestGenerateUniqueMac < Test::Unit::TestCase
7
+
8
+ def setup
9
+ assert_nothing_raised do
10
+ @app = Rouster.new(:name => 'app', :unittest => true)
11
+ end
12
+
13
+ def @app.exposed_generate_unique_mac(*args)
14
+ generate_unique_mac
15
+ end
16
+
17
+ end
18
+
19
+ def test_happy_path
20
+
21
+ assert_nothing_raised do
22
+ @app.exposed_generate_unique_mac
23
+ end
24
+
25
+ end
26
+
27
+ def test_uniqueness
28
+
29
+ # is this really a valid test?
30
+ (0..100).each do |i|
31
+ a = @app.exposed_generate_unique_mac
32
+ b = @app.exposed_generate_unique_mac
33
+
34
+ assert_not_equal(a, b)
35
+ end
36
+
37
+ end
38
+
39
+ def teardown
40
+ # noop
41
+ end
42
+
43
+ end
@@ -0,0 +1,31 @@
1
+ require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
2
+
3
+ require 'rouster'
4
+ require 'test/unit'
5
+
6
+ # TODO add a bad perms test -- though it should be fixed automagically
7
+
8
+ class TestNew < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @app = nil
12
+ end
13
+
14
+ # TODO this is an awful pattern, do better
15
+
16
+ def test_1_good_basic_instantiation
17
+
18
+ assert_nothing_raised do
19
+ @app = Rouster.new(:name => 'app', :unittest => true)
20
+ end
21
+
22
+ assert_equal('app', @app.name)
23
+ assert_equal(false, @app.is_passthrough?())
24
+ assert_equal(true, @app.uses_sudo?())
25
+ end
26
+
27
+ def teardown
28
+ # noop
29
+ end
30
+
31
+ end
@@ -0,0 +1,334 @@
1
+ require sprintf('%s/../../path_helper', File.dirname(File.expand_path(__FILE__)))
2
+
3
+ # this is based on RHEL output, how cross compatible is this?
4
+
5
+ require 'rouster'
6
+ require 'rouster/tests'
7
+ require 'test/unit'
8
+
9
+ class TestParseLsString < Test::Unit::TestCase
10
+
11
+ def setup
12
+
13
+ @app = Rouster.new(:name => 'app', :unittest => true)
14
+
15
+ def @app.exposed_parse_ls_string(*args)
16
+ parse_ls_string(*args)
17
+ end
18
+
19
+ end
20
+
21
+ def test_readable_by_all
22
+ str = "-r--r--r-- 1 root root 199 May 27 22:51 readable\n"
23
+
24
+ expectation = {
25
+ :directory? => false,
26
+ :file? => true,
27
+ :mode => '0444',
28
+ :name => 'readable',
29
+ :owner => 'root',
30
+ :group => 'root',
31
+ :size => '199',
32
+ :executable? => [false, false, false],
33
+ :readable? => [true, true, true],
34
+ :writeable? => [false, false, false]
35
+ }
36
+
37
+ res = @app.exposed_parse_ls_string(str)
38
+
39
+ assert_equal(expectation, res)
40
+ end
41
+
42
+ def test_readable_by_u
43
+ str = "-r-------- 1 root root 199 May 27 22:51 readable\n"
44
+
45
+ expectation = {
46
+ :directory? => false,
47
+ :file? => true,
48
+ :mode => '0400',
49
+ :name => 'readable',
50
+ :owner => 'root',
51
+ :group => 'root',
52
+ :size => '199',
53
+ :executable? => [false, false, false],
54
+ :readable? => [true, false, false],
55
+ :writeable? => [false, false, false]
56
+ }
57
+
58
+ res = @app.exposed_parse_ls_string(str)
59
+
60
+ assert_equal(expectation, res)
61
+ end
62
+
63
+ def test_readable_by_g
64
+ str = "----r----- 1 root root 199 May 27 22:51 readable\n"
65
+
66
+ expectation = {
67
+ :directory? => false,
68
+ :file? => true,
69
+ :mode => '0040',
70
+ :name => 'readable',
71
+ :owner => 'root',
72
+ :group => 'root',
73
+ :size => '199',
74
+ :executable? => [false, false, false],
75
+ :readable? => [false, true, false],
76
+ :writeable? => [false, false, false]
77
+ }
78
+
79
+ res = @app.exposed_parse_ls_string(str)
80
+
81
+ assert_equal(expectation, res)
82
+ end
83
+
84
+ def test_readable_by_o
85
+ str = "-------r-- 1 root root 199 May 27 22:51 readable\n"
86
+
87
+ expectation = {
88
+ :directory? => false,
89
+ :file? => true,
90
+ :mode => '0004',
91
+ :name => 'readable',
92
+ :owner => 'root',
93
+ :group => 'root',
94
+ :size => '199',
95
+ :executable? => [false, false, false],
96
+ :readable? => [false, false, true],
97
+ :writeable? => [false, false, false]
98
+ }
99
+
100
+ res = @app.exposed_parse_ls_string(str)
101
+
102
+ assert_equal(expectation, res)
103
+ end
104
+
105
+ def test_executable_by_all
106
+ str = "---x--x--x 1 root root 199 May 27 22:51 executable\n"
107
+
108
+ expectation = {
109
+ :directory? => false,
110
+ :file? => true,
111
+ :mode => '0111',
112
+ :name => 'executable',
113
+ :owner => 'root',
114
+ :group => 'root',
115
+ :size => '199',
116
+ :executable? => [true, true, true],
117
+ :readable? => [false, false, false],
118
+ :writeable? => [false, false, false]
119
+ }
120
+
121
+ res = @app.exposed_parse_ls_string(str)
122
+
123
+ assert_equal(expectation, res)
124
+ end
125
+
126
+ def test_executable_by_u
127
+ str = "---x------ 1 root root 199 May 27 22:51 executable\n"
128
+
129
+ expectation = {
130
+ :directory? => false,
131
+ :file? => true,
132
+ :mode => '0100',
133
+ :name => 'executable',
134
+ :owner => 'root',
135
+ :group => 'root',
136
+ :size => '199',
137
+ :executable? => [true, false, false],
138
+ :readable? => [false, false, false],
139
+ :writeable? => [false, false, false]
140
+ }
141
+
142
+ res = @app.exposed_parse_ls_string(str)
143
+
144
+ assert_equal(expectation, res)
145
+ end
146
+
147
+ def test_executable_by_g
148
+ str = "------x--- 1 root root 199 May 27 22:51 executable\n"
149
+
150
+ expectation = {
151
+ :directory? => false,
152
+ :file? => true,
153
+ :mode => '0010',
154
+ :name => 'executable',
155
+ :owner => 'root',
156
+ :group => 'root',
157
+ :size => '199',
158
+ :executable? => [false, true, false],
159
+ :readable? => [false, false, false],
160
+ :writeable? => [false, false, false]
161
+ }
162
+
163
+ res = @app.exposed_parse_ls_string(str)
164
+
165
+ assert_equal(expectation, res)
166
+ end
167
+
168
+ def test_executable_by_o
169
+ str = "---------x 1 root root 199 May 27 22:51 executable\n"
170
+
171
+ expectation = {
172
+ :directory? => false,
173
+ :file? => true,
174
+ :mode => '0001',
175
+ :name => 'executable',
176
+ :owner => 'root',
177
+ :group => 'root',
178
+ :size => '199',
179
+ :executable? => [false, false, true],
180
+ :readable? => [false, false, false],
181
+ :writeable? => [false, false, false]
182
+ }
183
+
184
+ res = @app.exposed_parse_ls_string(str)
185
+
186
+ assert_equal(expectation, res)
187
+ end
188
+
189
+ def test_writeable_by_all
190
+ str = "--w--w--w- 1 root root 199 May 27 22:51 writeable\n"
191
+
192
+ expectation = {
193
+ :directory? => false,
194
+ :file? => true,
195
+ :mode => '0222',
196
+ :name => 'writeable',
197
+ :owner => 'root',
198
+ :group => 'root',
199
+ :size => '199',
200
+ :executable? => [false, false, false],
201
+ :readable? => [false, false, false],
202
+ :writeable? => [true, true, true]
203
+ }
204
+
205
+ res = @app.exposed_parse_ls_string(str)
206
+
207
+ assert_equal(expectation, res)
208
+ end
209
+
210
+ def test_writeable_by_u
211
+ str = "--w------- 1 root root 199 May 27 22:51 writeable\n"
212
+
213
+ expectation = {
214
+ :directory? => false,
215
+ :file? => true,
216
+ :mode => '0200',
217
+ :name => 'writeable',
218
+ :owner => 'root',
219
+ :group => 'root',
220
+ :size => '199',
221
+ :executable? => [false, false, false],
222
+ :readable? => [false, false, false],
223
+ :writeable? => [true, false, false]
224
+ }
225
+
226
+ res = @app.exposed_parse_ls_string(str)
227
+
228
+ assert_equal(expectation, res)
229
+ end
230
+
231
+ def test_writeable_by_g
232
+ str = "-----w---- 1 root root 199 May 27 22:51 writeable\n"
233
+
234
+ expectation = {
235
+ :directory? => false,
236
+ :file? => true,
237
+ :mode => '0020',
238
+ :name => 'writeable',
239
+ :owner => 'root',
240
+ :group => 'root',
241
+ :size => '199',
242
+ :executable? => [false, false, false],
243
+ :readable? => [false, false, false],
244
+ :writeable? => [false, true, false]
245
+ }
246
+
247
+ res = @app.exposed_parse_ls_string(str)
248
+
249
+ assert_equal(expectation, res)
250
+ end
251
+
252
+ def test_writeable_by_o
253
+ str = "--------w- 1 root root 199 May 27 22:51 writeable\n"
254
+
255
+ expectation = {
256
+ :directory? => false,
257
+ :file? => true,
258
+ :mode => '0002',
259
+ :name => 'writeable',
260
+ :owner => 'root',
261
+ :group => 'root',
262
+ :size => '199',
263
+ :executable? => [false, false, false],
264
+ :readable? => [false, false, false],
265
+ :writeable? => [false, false, true]
266
+ }
267
+
268
+ res = @app.exposed_parse_ls_string(str)
269
+
270
+ assert_equal(expectation, res)
271
+ end
272
+
273
+ def test_mix_and_match_1
274
+ str = "-------rwx 1 vagrant vagrant 1909 May 27 22:51 able\n"
275
+
276
+ expectation = {
277
+ :directory? => false,
278
+ :file? => true,
279
+ :mode => '0007',
280
+ :name => 'able',
281
+ :owner => 'vagrant',
282
+ :group => 'vagrant',
283
+ :size => '1909',
284
+ :executable? => [false, false, true],
285
+ :readable? => [false, false, true],
286
+ :writeable? => [false, false, true]
287
+ }
288
+
289
+ res = @app.exposed_parse_ls_string(str)
290
+
291
+ assert_equal(expectation, res)
292
+ end
293
+
294
+ def test_mix_and_match_2
295
+ str = "-rw-r--r-- 1 vagrant root 0 Jun 13 09:35 foo\n"
296
+
297
+ expectation = {
298
+ :directory? => false,
299
+ :file? => true,
300
+ :mode => '0644',
301
+ :name => 'foo',
302
+ :owner => 'vagrant',
303
+ :group => 'root',
304
+ :size => '0',
305
+ :executable? => [false, false, false],
306
+ :readable? => [true, true, true],
307
+ :writeable? => [true, false, false]
308
+ }
309
+
310
+ res = @app.exposed_parse_ls_string(str)
311
+
312
+ assert_equal(expectation, res)
313
+ end
314
+
315
+ def test_dir_detection
316
+ dir_str = "drwxrwxrwt 5 root root 4096 May 28 00:26 /tmp/\n"
317
+ file_str = "-rw-r--r-- 1 root root 906 Oct 2 2012 grub.conf\n"
318
+
319
+ dir = @app.exposed_parse_ls_string(dir_str)
320
+ file = @app.exposed_parse_ls_string(file_str)
321
+
322
+ assert_equal(true, dir[:directory?])
323
+ assert_equal(false, dir[:file?])
324
+
325
+ assert_equal(false, file[:directory?])
326
+ assert_equal(true, file[:file?])
327
+
328
+ end
329
+
330
+ def teardown
331
+ # noop
332
+ end
333
+
334
+ end