kanrisuru 0.8.13 → 0.8.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +2 -2
  4. data/lib/kanrisuru/core/disk.rb +1 -1
  5. data/lib/kanrisuru/core/stat.rb +1 -3
  6. data/lib/kanrisuru/core/transfer.rb +12 -1
  7. data/lib/kanrisuru/remote/cluster.rb +1 -1
  8. data/lib/kanrisuru/version.rb +1 -1
  9. data/spec/functional/core/path_spec.rb +32 -80
  10. data/spec/functional/core/stat_spec.rb +14 -89
  11. data/spec/functional/core/stream_spec.rb +103 -112
  12. data/spec/functional/core/transfer_spec.rb +175 -102
  13. data/spec/functional/os_package_spec.rb +3 -3
  14. data/spec/helper/expect_helpers.rb +8 -0
  15. data/spec/helper/stub_network.rb +43 -0
  16. data/spec/{functional → integration}/core/apt_spec.rb +0 -0
  17. data/spec/{functional → integration}/core/archive_spec.rb +0 -0
  18. data/spec/{functional → integration}/core/disk_spec.rb +1 -1
  19. data/spec/{functional → integration}/core/dmi_spec.rb +0 -0
  20. data/spec/{functional → integration}/core/file_spec.rb +8 -5
  21. data/spec/{functional → integration}/core/find_spec.rb +0 -0
  22. data/spec/{functional → integration}/core/group_spec.rb +0 -0
  23. data/spec/{functional → integration}/core/ip_spec.rb +0 -0
  24. data/spec/integration/core/path_spec.rb +93 -0
  25. data/spec/{functional → integration}/core/socket_spec.rb +0 -0
  26. data/spec/integration/core/stat_spec.rb +98 -0
  27. data/spec/integration/core/stream_spec.rb +117 -0
  28. data/spec/{functional → integration}/core/system_spec.rb +0 -0
  29. data/spec/integration/core/transfer_spec.rb +108 -0
  30. data/spec/{functional → integration}/core/user_spec.rb +0 -0
  31. data/spec/{functional → integration}/core/yum_spec.rb +0 -0
  32. data/spec/{functional → integration}/core/zypper_spec.rb +0 -0
  33. data/spec/{functional → integration}/remote/cluster_spec.rb +4 -4
  34. data/spec/{functional → integration}/remote/cpu_spec.rb +0 -0
  35. data/spec/{functional → integration}/remote/env_spec.rb +0 -0
  36. data/spec/{functional → integration}/remote/fstab_spec.rb +0 -0
  37. data/spec/{functional → integration}/remote/host_spec.rb +0 -0
  38. data/spec/{functional → integration}/remote/memory_spec.rb +0 -0
  39. data/spec/{functional → integration}/remote/os_spec.rb +0 -0
  40. data/spec/{functional → integration}/remote/remote_file_spec.rb +0 -0
  41. data/spec/spec_helper.rb +3 -0
  42. metadata +29 -23
@@ -2,107 +2,180 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- RSpec.describe Kanrisuru::Core::File do
6
- TestHosts.each_os do |os_name|
7
- context "with #{os_name}" do
8
- before(:all) do
9
- host_json = TestHosts.host(os_name)
10
- host = Kanrisuru::Remote::Host.new(
11
- host: host_json['hostname'],
12
- username: host_json['username'],
13
- keys: [host_json['ssh_key']]
14
- )
15
-
16
- host.mkdir("#{host_json['home']}/.kanrisuru_spec_files", silent: true)
17
- host.disconnect
18
- end
19
-
20
- let(:host_json) { TestHosts.host(os_name) }
21
- let(:host) do
22
- Kanrisuru::Remote::Host.new(
23
- host: host_json['hostname'],
24
- username: host_json['username'],
25
- keys: [host_json['ssh_key']]
26
- )
27
- end
28
-
29
- let(:spec_dir) { "#{host_json['home']}/.kanrisuru_spec_files" }
30
-
31
- after do
32
- host.disconnect
33
- end
34
-
35
- after(:all) do
36
- host_json = TestHosts.host(os_name)
37
- host = Kanrisuru::Remote::Host.new(
38
- host: host_json['hostname'],
39
- username: host_json['username'],
40
- keys: [host_json['ssh_key']]
41
- )
42
-
43
- host.rmdir("#{host_json['home']}/.kanrisuru_spec_files")
44
- host.disconnect
45
- end
46
-
47
- it 'uploads a template file' do
48
- path = '../templates/test.conf.erb'
49
- dest_path = "#{spec_dir}/test.conf"
50
-
51
- template = Kanrisuru::Template.new(path, array: %w[this is an array])
52
- result = host.upload(template.read, dest_path)
53
-
54
- expect(result).to be_success
55
- expect(result.mode.numeric).to eq('640')
56
- expect(result.user).to eq(host_json['username'])
57
-
58
- case os_name
59
- when 'sles', 'opensuse'
60
- expect(result.gid).to eq(100)
61
- expect(result.group).to eq('users')
62
- else
63
- expect(result.gid).to eq(1000)
64
- expect(result.group).to eq(host_json['username'])
65
- end
66
-
67
- expect(host.cat(dest_path).to_a).to eq([
68
- '<h1>Hello World</h1>',
69
- 'this',
70
- 'is',
71
- 'an',
72
- 'array'
73
- ])
74
- end
75
-
76
- it 'uploads a dir' do
77
- path = '../meta/'
78
- dest_path = "#{spec_dir}/meta"
79
-
80
- result = host.upload(path, dest_path, recursive: true)
81
- expect(result).to be_success
82
- end
83
-
84
- it 'downloads a file to local fs' do
85
- path = '../hosts-file'
86
- src_path = '/etc/hosts'
87
-
88
- result = host.download(src_path, path)
89
- expect(result).to eq(path)
90
- FileUtils.rm(path)
91
- end
92
-
93
- it 'downloads a file directly' do
94
- src_path = '/etc/hosts'
95
-
96
- result = host.download(src_path)
97
- expect(result).to be_instance_of(String)
98
- lines = result.split("\n")
99
- expect(lines.length).to be >= 1
100
- end
101
-
102
- it 'wgets url' do
103
- result = host.wget('https://example.com', directory_prefix: spec_dir)
104
- expect(result).to be_success
105
- end
106
- end
5
+ StubNetwork.stub!
6
+
7
+ RSpec.describe Kanrisuru::Core::Stat do
8
+ let(:host) do
9
+ Kanrisuru::Remote::Host.new(
10
+ host: 'localhost',
11
+ username: 'ubuntu',
12
+ keys: ['id_rsa']
13
+ )
14
+ end
15
+
16
+ it 'prepares wget command' do
17
+ url = 'https://rubygems.org'
18
+
19
+ expect_command(host.wget(url),
20
+ "wget #{url}"
21
+ )
22
+
23
+ ## Output options
24
+ expect_command(host.wget(url,
25
+ quiet: true, verbose: false, log_file: '/var/log/wget.log'),
26
+ "wget --quiet --no-verbose --output-file /var/log/wget.log #{url}"
27
+ )
28
+
29
+ expect_command(host.wget(url,
30
+ verbose: true, append_log_file: '/var/log/wget.log'),
31
+ "wget --verbose --append-output /var/log/wget.log #{url}"
32
+ )
33
+
34
+ ## Download options
35
+ expect_command(host.wget(url,
36
+ bind_address: '0.0.0.0',
37
+ retries: 3,
38
+ output_document: '/home/ubuntu/index.html',
39
+ no_clobber: true,
40
+ timeout: 30,
41
+ dns_timeout: 60,
42
+ connect_timeout: 60,
43
+ read_timeout: 15,
44
+ limit_rate: '120k',
45
+ wait: 5,
46
+ waitretry: 15,
47
+ random_wait: true,
48
+ no_proxy: true,
49
+ no_dns_cache: true
50
+ ),
51
+ "wget --bind-address 0.0.0.0 --tries 3 --output-document /home/ubuntu/index.html --no-clobber --timeout 30 --dns-timeout 60 --connect-timeout 60 --read-timeout 15 --limit-rate 120k --wait 5 --waitretry 15 --random-wait --no-proxy --no-dns-cache https://rubygems.org"
52
+ )
53
+
54
+ ## Other Options
55
+ expect_command(host.wget(url,
56
+ quota: 'inf',
57
+ family: 'inet',
58
+ restrict_file_names: ['unix', 'ascii', 'lowercase', 'uppercase'],
59
+ retry_connrefused: true,
60
+ user: 'admin',
61
+ password: 'admin',
62
+ no_iri: true,
63
+ ),
64
+ "wget --quota inf --restrict-file-names unix,ascii,lowercase,uppercase --inet4-only --retry-connrefused --user admin --password admin --no-iri #{url}"
65
+ )
66
+
67
+ ## Directories
68
+ expect_command(host.wget(url,
69
+ no_directories: true,
70
+ no_host_directories: true,
71
+ cut_dirs: 3,
72
+ directory_prefix: '~/downloads/'
73
+ ),
74
+ "wget --no-directories --no-host-directories --cut-dirs 3 --directory-prefix ~/downloads/ #{url}"
75
+ )
76
+
77
+ ## HTTP
78
+ expect_command(host.wget(url,
79
+ default_page: 'index.html',
80
+ adjust_extension: true,
81
+ http_user: 'admin',
82
+ http_password: 'admin',
83
+ load_cookies: '~/cookies.txt',
84
+ save_cookies: '~/cookies.txt',
85
+ no_cache: true,
86
+ keep_session_cookies: true,
87
+ ignore_length: true,
88
+ headers: {
89
+ 'Accept-Language' => 'hr',
90
+ 'Authorization' => 'Bearer 1234'
91
+ },
92
+ max_redirect: 5,
93
+ proxy_user: 'admin',
94
+ proxy_password: '12345678'
95
+ ),
96
+ "wget --default-page index.html --adjust-extension --http-user admin --http-password admin --load-cookies ~/cookies.txt --save-cookies ~/cookies.txt --no-cache --keep-session-cookies --ignore-length --max-redirect 5 --proxy-user admin --proxy-password 12345678 --header 'Accept-Language: hr' --header 'Authorization: Bearer 1234' #{url}"
97
+ )
98
+
99
+ expect_command(host.wget(url,
100
+ post_data: {
101
+ url: "https://example.com?param=123"
102
+ },
103
+ content_disposition: true,
104
+ secure_protocol: 'SSLv3',
105
+ no_check_certificate: true,
106
+ ),
107
+ "wget --post-data url=https%3A%2F%2Fexample.com%3Fparam%3D123 --content-disposition --secure-protocol SSLv3 --no-check-certificate #{url}"
108
+ )
109
+
110
+ expect {
111
+ host.wget(url, secure_protocol: 'SSL')
112
+ }.to raise_error(ArgumentError)
113
+
114
+ expect_command(host.wget(url,
115
+ certificate: '~/cert.pem',
116
+ certificate_type: 'PEM',
117
+ private_key: '~/key.pem',
118
+ private_key_type: 'PEM',
119
+ ca_certificate: '~/ca.pem',
120
+ random_file: '~/random'
121
+ ),
122
+ "wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}"
123
+ )
124
+
125
+ expect_command(host.wget(url,
126
+ certificate: '~/cert.pem',
127
+ certificate_type: 'PEM',
128
+ private_key: '~/key.pem',
129
+ private_key_type: 'PEM',
130
+ ca_certificate: '~/ca.pem',
131
+ random_file: '~/random'
132
+ ),
133
+ "wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}"
134
+ )
135
+
136
+ ## FTP
137
+ expect_command(host.wget(url,
138
+ ftp_user: 'admin',
139
+ ftp_password: '12345678',
140
+ no_remove_listing: true,
141
+ no_glob: true,
142
+ no_passive_ftp: true,
143
+ retr_symlinks: true
144
+ ),
145
+ "wget --ftp-user admin --ftp-password 12345678 --no-remove-listing --no-glob --no-passive-ftp --retr-symlinks #{url}"
146
+ )
147
+
148
+ ## Recursive Retrieval
149
+ expect_command(host.wget(url,
150
+ recursive: true,
151
+ depth: 10,
152
+ delete_after: true,
153
+ convert_links: true,
154
+ backup_converted: true,
155
+ mirror: true,
156
+ page_requisites: true,
157
+ strict_comments: true
158
+ ),
159
+ "wget --recursive --level 10 --delete-after --convert-links --backup-converted --mirror --page-requisites --strict-comments #{url}"
160
+ )
161
+
162
+ ## Recursive Accept/Reject
163
+ expect_command(host.wget(url,
164
+ accept_list: ['.txt', '.html'],
165
+ reject_list: ['.csv'],
166
+ domain_list: ['example.com'],
167
+ exclude_domain_list: ['hackernews.com'],
168
+ follow_tags: ['a', 'div', 'span'],
169
+ ignore_tags: ['area', 'link'],
170
+ include_directories: ['/gems'],
171
+ exclude_directories: ['/releases'],
172
+ follow_ftp: true,
173
+ ignore_case: true,
174
+ span_hosts: true,
175
+ relative: true,
176
+ no_parent: true
177
+ ),
178
+ "wget --accept .txt,.html --reject .csv --domains example.com --exclude-domains hackernews.com --follow-tags a,div,span --ignore-tags area,link --include-directories /gems --exclude-directories /releases --follow-ftp --ignore-case --span-hosts --relative --no-parent #{url}"
179
+ )
107
180
  end
108
181
  end
@@ -111,7 +111,7 @@ RSpec.describe Kanrisuru::OsPackage do
111
111
  host = Kanrisuru::Remote::Host.new(host: '127.0.0.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
112
112
  host2 = Kanrisuru::Remote::Host.new(host: 'localhost', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
113
113
 
114
- cluster = Kanrisuru::Remote::Cluster.new([host, host2])
114
+ cluster = Kanrisuru::Remote::Cluster.new(host, host2)
115
115
 
116
116
  expect(host).to respond_to(:tester)
117
117
  expect(host.tester).to eq('hello ubuntu')
@@ -125,7 +125,7 @@ RSpec.describe Kanrisuru::OsPackage do
125
125
  host = Kanrisuru::Remote::Host.new(host: '127.0.0.1', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
126
126
  host2 = Kanrisuru::Remote::Host.new(host: 'localhost', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])
127
127
 
128
- cluster = Kanrisuru::Remote::Cluster.new([host, host2])
128
+ cluster = Kanrisuru::Remote::Cluster.new(host, host2)
129
129
 
130
130
  expect(host).to respond_to(:asdf)
131
131
  expect(host.asdf).to respond_to(:tester)
@@ -151,7 +151,7 @@ RSpec.describe Kanrisuru::OsPackage do
151
151
  host2 = Kanrisuru::Remote::Host.new(host: 'centos-host', username: 'centos', keys: ['~/.ssh/id_rsa'])
152
152
  host3 = Kanrisuru::Remote::Host.new(host: 'opensuse-host', username: 'opensuse', keys: ['~/.ssh/id_rsa'])
153
153
 
154
- cluster = Kanrisuru::Remote::Cluster.new([host1, host2, host3])
154
+ cluster = Kanrisuru::Remote::Cluster.new(host1, host2, host3)
155
155
 
156
156
  expect(host1).to respond_to(:output)
157
157
  expect(host2).to respond_to(:output)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ def expect_command(result, string)
4
+ puts result.command.raw_command
5
+ expect(result.command.raw_command).to eq(
6
+ string
7
+ )
8
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ class StubNetwork
4
+ class << self
5
+ def stub!
6
+ ## Stub out the execute_with_retries method to
7
+ ## test functionality of host commands
8
+ Kanrisuru::Remote::Host.class_eval do
9
+ private
10
+
11
+ def execute_with_retries(command)
12
+ command.handle_status(0)
13
+ command.handle_data(nil)
14
+
15
+ command
16
+ end
17
+ end
18
+
19
+ Kanrisuru::Remote::Os.class_eval do
20
+ def initialize(host)
21
+ @host = host
22
+
23
+ @kernel_name = 'Linux'
24
+ @kernel_version = '#91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021'
25
+ @operating_system = 'GNU/Linux'
26
+ @hardware_platform = 'x86_64'
27
+ @processor = 'x86_64'
28
+ @release = 'ubuntu'
29
+ @version = 20.0
30
+ end
31
+ end
32
+
33
+ Kanrisuru::Result.class_eval do
34
+ def initialize(command)
35
+ @command = command
36
+ @data = nil
37
+
38
+ @error = @command.to_a if @command.failure?
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
File without changes
@@ -41,7 +41,7 @@ RSpec.describe Kanrisuru::Core::Disk do
41
41
  :name, :label, :uuid, :type, :uuid_sub, :label_fatboot, :version, :usage,
42
42
  :part_uuid, :part_entry_scheme, :part_entry_uuid, :part_entry_type,
43
43
  :part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk,
44
- :minimum_io_size, :physical_sector_size, :logical_sector_size,
44
+ :minimum_io_size, :physical_sector_size, :logical_sector_size
45
45
  )
46
46
  end
47
47
 
File without changes
@@ -41,7 +41,10 @@ RSpec.describe Kanrisuru::Core::File do
41
41
  )
42
42
 
43
43
  host.rm("#{host_json['home']}/.kanrisuru_spec_files", force: true, recursive: true)
44
- host.rm("#{host_json['home']}/extract-tar-files", force: true, recursive: true) if host.dir?("#{host_json['home']}/extract-tar-files")
44
+ if host.dir?("#{host_json['home']}/extract-tar-files")
45
+ host.rm("#{host_json['home']}/extract-tar-files", force: true,
46
+ recursive: true)
47
+ end
45
48
  host.disconnect
46
49
  end
47
50
 
@@ -68,9 +71,9 @@ RSpec.describe Kanrisuru::Core::File do
68
71
  expect(mode.symbolic).to eq('-rwxr--r--')
69
72
  expect(mode.to_i).to eq(0o744)
70
73
 
71
- expect {
74
+ expect do
72
75
  host.chmod(path, 600)
73
- }.to raise_error(ArgumentError)
76
+ end.to raise_error(ArgumentError)
74
77
  end
75
78
 
76
79
  it 'changes file owner and group' do
@@ -338,7 +341,7 @@ RSpec.describe Kanrisuru::Core::File do
338
341
  ## Can't delete non empty dir
339
342
  result = host.rmdir("#{spec_dir}/directory")
340
343
  expect(result).to be_failure
341
-
344
+
342
345
  result = host.rmdir("#{spec_dir}/directory/3")
343
346
  expect(result).to be_success
344
347
  end
@@ -355,7 +358,7 @@ RSpec.describe Kanrisuru::Core::File do
355
358
 
356
359
  lines = doc.length
357
360
  words = doc.map(&:split).flatten
358
- chars = doc.map(&:length).flatten
361
+ chars = doc.map(&:length).flatten
359
362
 
360
363
  expect(result.lines).to eq(doc.length)
361
364
  expect(result.words).to eq(words.length)
File without changes
File without changes
File without changes
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Path do
6
+ TestHosts.each_os do |os_name|
7
+ context "with #{os_name}" do
8
+ let(:host_json) { TestHosts.host(os_name) }
9
+ let(:host) do
10
+ Kanrisuru::Remote::Host.new(
11
+ host: host_json['hostname'],
12
+ username: host_json['username'],
13
+ keys: [host_json['ssh_key']]
14
+ )
15
+ end
16
+
17
+ after do
18
+ host.disconnect
19
+ end
20
+
21
+ it 'lists files and directories' do
22
+ result = host.ls(all: true)
23
+ expect(result.data).to be_instance_of(Array)
24
+
25
+ dir = result.find { |file| file.path == '.' }
26
+ expect(dir.path).to eq('.')
27
+
28
+ result = host.ls(path: host_json['home'], id: true, all: true)
29
+ expect(result.data).to be_instance_of(Array)
30
+
31
+ file = result.find { |f| f.path == '.bashrc' }
32
+ expect(file.owner).to eq(1000)
33
+
34
+ case os_name
35
+ when 'opensuse', 'sles'
36
+ expect(file.group).to eq(100)
37
+ else
38
+ expect(file.group).to eq(1000)
39
+ end
40
+ end
41
+
42
+ it 'gets whoami' do
43
+ expect(host.whoami.user).to eq(host_json['username'])
44
+ end
45
+
46
+ it 'gets pwd' do
47
+ expect(host.pwd.path).to eq(host_json['home'])
48
+ end
49
+
50
+ it 'uses which to get path for bash' do
51
+ result = host.which('bash', all: true)
52
+ paths = result.map(&:path)
53
+
54
+ case os_name
55
+ when 'ubuntu'
56
+ if host.os.version <= 18.04
57
+ expect(paths).to include('/bin/bash')
58
+ else
59
+ expect(paths).to include('/usr/bin/bash', '/bin/bash')
60
+ end
61
+ when 'opensuse'
62
+ ## Ignore for local testing
63
+ when 'sles'
64
+ expect(paths).to include('/bin/bash')
65
+ else
66
+ expect(paths).to include('/usr/bin/bash', '/bin/bash')
67
+ end
68
+ end
69
+
70
+ it 'gets realpath for dir' do
71
+ case os_name
72
+ when 'sles'
73
+ expect(host.realpath('/var/run').path).to eq('/run')
74
+ when 'rhel'
75
+ expect(host.realpath('/bin').path).to eq('/usr/bin')
76
+ else
77
+ expect(host.realpath('/etc/os-release').path).to eq('/usr/lib/os-release')
78
+ end
79
+ end
80
+
81
+ it 'gets full path for dir with readlink' do
82
+ case os_name
83
+ when 'sles'
84
+ expect(host.readlink('/var/run', canonicalize: true).path).to eq('/run')
85
+ when 'rhel'
86
+ expect(host.readlink('/bin', canonicalize: true).path).to eq('/usr/bin')
87
+ else
88
+ expect(host.readlink('/etc/os-release', canonicalize: true).path).to eq('/usr/lib/os-release')
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Stat do
6
+ TestHosts.each_os do |os_name|
7
+ context "with #{os_name}" do
8
+ let(:host_json) { TestHosts.host(os_name) }
9
+ let(:host) do
10
+ Kanrisuru::Remote::Host.new(
11
+ host: host_json['hostname'],
12
+ username: host_json['username'],
13
+ keys: [host_json['ssh_key']]
14
+ )
15
+ end
16
+
17
+ after do
18
+ host.disconnect
19
+ end
20
+
21
+ it 'checks file type correctly' do
22
+ expect(host.dir?('/')).to eq(true)
23
+ expect(host.file?('/etc/hosts')).to eq(true)
24
+
25
+ case os_name
26
+ when 'sles'
27
+ expect(host.block_device?('/dev/xvda')).to eq(true)
28
+ else
29
+ expect(host.block_device?('/dev/vda')).to eq(true)
30
+ end
31
+
32
+ expect(host.char_device?('/dev/tty')).to eq(true)
33
+ expect(host.symlink?('/etc/mtab')).to eq(true)
34
+ expect(host.inode?('/proc/uptime')).to eq(true)
35
+ end
36
+
37
+ it 'gets file stat' do
38
+ result = host.stat(host_json['home'])
39
+
40
+ expect(result.mode).to be_instance_of(Kanrisuru::Mode)
41
+ expect(result.mode.directory?).to eq(true)
42
+
43
+ case os_name
44
+ when 'centos', 'rhel', 'fedora'
45
+ expect(result.mode.numeric).to eq('700')
46
+ expect(result.mode.to_i).to eq(0o700)
47
+
48
+ expect(result.mode.group.read?).to eq(false)
49
+ expect(result.mode.group.write?).to eq(false)
50
+ expect(result.mode.group.execute?).to eq(false)
51
+
52
+ expect(result.mode.other.read?).to eq(false)
53
+ expect(result.mode.other.write?).to eq(false)
54
+ expect(result.mode.other.execute?).to eq(false)
55
+
56
+ expect(result.mode.owner.read?).to eq(true)
57
+ expect(result.mode.owner.write?).to eq(true)
58
+ expect(result.mode.owner.execute?).to eq(true)
59
+
60
+ expect(result.mode.symbolic).to eq('drwx------')
61
+ else
62
+ expect(result.mode.numeric).to eq('755')
63
+ expect(result.mode.to_i).to eq(0o755)
64
+
65
+ expect(result.mode.group.read?).to eq(true)
66
+ expect(result.mode.group.write?).to eq(false)
67
+ expect(result.mode.group.execute?).to eq(true)
68
+
69
+ expect(result.mode.other.read?).to eq(true)
70
+ expect(result.mode.other.write?).to eq(false)
71
+ expect(result.mode.other.execute?).to eq(true)
72
+
73
+ expect(result.mode.owner.read?).to eq(true)
74
+ expect(result.mode.owner.write?).to eq(true)
75
+ expect(result.mode.owner.execute?).to eq(true)
76
+
77
+ expect(result.mode.symbolic).to eq('drwxr-xr-x')
78
+ end
79
+
80
+ expect(result.file_type).to eq('directory')
81
+
82
+ case os_name
83
+ when 'opensuse', 'sles'
84
+ expect(result.gid).to eq(100)
85
+ expect(result.group).to eq('users')
86
+ else
87
+ expect(result.gid).to eq(1000)
88
+ expect(result.group).to eq(host_json['username'])
89
+ end
90
+
91
+ expect(result.uid).to eq(1000)
92
+ expect(result.user).to eq(host_json['username'])
93
+
94
+ expect(result.fsize).to be >= 0
95
+ end
96
+ end
97
+ end
98
+ end