kanrisuru 0.8.16 → 0.8.20
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/CHANGELOG.md +19 -1
- data/lib/kanrisuru/core/apt.rb +4 -4
- data/lib/kanrisuru/core/disk.rb +1 -1
- data/lib/kanrisuru/core/find.rb +12 -5
- data/lib/kanrisuru/core/socket.rb +9 -1
- data/lib/kanrisuru/core/transfer.rb +13 -2
- data/lib/kanrisuru/core/yum.rb +7 -7
- data/lib/kanrisuru/core/zypper.rb +4 -4
- data/lib/kanrisuru/util.rb +4 -0
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/find_spec.rb +169 -0
- data/spec/functional/core/path_spec.rb +9 -4
- data/spec/functional/core/socket_spec.rb +67 -0
- data/spec/functional/core/stat_spec.rb +12 -9
- data/spec/functional/core/stream_spec.rb +33 -28
- data/spec/functional/core/transfer_spec.rb +187 -0
- data/spec/helper/expect_helpers.rb +2 -1
- data/spec/helper/stub_network.rb +45 -27
- data/spec/integration/core/disk_spec.rb +1 -1
- data/spec/integration/core/file_spec.rb +8 -5
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/core/find_spec.rb +3 -0
- data/spec/unit/core/socket_spec.rb +5 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0969518ec2898fe5ceaa74c897cdb0df384541d8cd8cd51e311e7f4915ce4155'
|
|
4
|
+
data.tar.gz: b57d0acd7d23116f2bf6934feaa77d83f007eede49a48f93efb47a241baf0434
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de82086f075e8deb1fcec6b8ca3205c384192a3dcf9a24d5852a75dcbaf1127e65c2121cc247cc64ac86647735447bfb3e5065f1aa808f0d0f279cf34e6ec3bd
|
|
7
|
+
data.tar.gz: e6944d4a4727ced09f581e10e5a55aba3f32147fc65d5ffa7857cbfa73e4e448b0ecaacaadd0bb332cf572f17771f7225ea74dcd2ada656ff10f8320f5e09a81
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
## Kanrisuru 0.8.
|
|
1
|
+
## Kanrisuru 0.8.20 (November 13, 2021)
|
|
2
|
+
* Unstub network requests for full rspec test-suite run
|
|
3
|
+
|
|
4
|
+
## Kanrisuru 0.8.19 (October 31, 2021)
|
|
5
|
+
* Add functional test cases for `ss` command.
|
|
6
|
+
* Enforce contraints on `family` parameter for `ss` command.
|
|
7
|
+
* Deprecating `string_join_array` in favor of `array_join_string`. Both methods do the same thing, and the `array_join_string` has a better nameing interface; will be removed in the next major release.
|
|
8
|
+
* Replace `string_join_array` method calls in `apt`, `transfer`, `yum`, and `zypper` with `array_join_string`.
|
|
9
|
+
|
|
10
|
+
## Kanrisuru 0.8.18 (October 19, 2021)
|
|
11
|
+
* Add functional test cases for `find` commmand.
|
|
12
|
+
* Add `regex_type` option for `find` command.
|
|
13
|
+
* Fix bug with `size` option when using number in a string format, regex testing has been simplified on matching correctness for size with options like `100`, `+100`, `-100M` for comparitive fields.
|
|
14
|
+
|
|
15
|
+
## Kanrisuru 0.8.17 (October 16, 2021)
|
|
16
|
+
* Add functional test cases for `transfer` module
|
|
17
|
+
* Update wget command to accept hash for `headers` opt.
|
|
18
|
+
|
|
19
|
+
## Kanrisuru 0.8.16 (October 14, 2021)
|
|
2
20
|
* Add functional test cases for `stream` and `path` modules
|
|
3
21
|
* Create `expect_command` helper for quick testing on raw command result
|
|
4
22
|
|
data/lib/kanrisuru/core/apt.rb
CHANGED
|
@@ -142,7 +142,7 @@ module Kanrisuru
|
|
|
142
142
|
command = Kanrisuru::Command.new('apt-get purge')
|
|
143
143
|
command.append_flag('-y')
|
|
144
144
|
|
|
145
|
-
packages = Kanrisuru::Util.
|
|
145
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
146
146
|
command << packages
|
|
147
147
|
|
|
148
148
|
execute_shell(command)
|
|
@@ -153,7 +153,7 @@ module Kanrisuru
|
|
|
153
153
|
command = Kanrisuru::Command.new('apt-get remove')
|
|
154
154
|
command.append_flag('-y')
|
|
155
155
|
|
|
156
|
-
packages = Kanrisuru::Util.
|
|
156
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
157
157
|
command << packages
|
|
158
158
|
|
|
159
159
|
execute_shell(command)
|
|
@@ -168,7 +168,7 @@ module Kanrisuru
|
|
|
168
168
|
command.append_flag('--only-upgrade', opts[:only_upgrade])
|
|
169
169
|
command.append_flag('--reinstall', opts[:reinstall])
|
|
170
170
|
|
|
171
|
-
packages = Kanrisuru::Util.
|
|
171
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
172
172
|
command << packages
|
|
173
173
|
|
|
174
174
|
execute_shell(command)
|
|
@@ -200,7 +200,7 @@ module Kanrisuru
|
|
|
200
200
|
command = Kanrisuru::Command.new('apt show')
|
|
201
201
|
command.append_flag('-a')
|
|
202
202
|
|
|
203
|
-
packages = Kanrisuru::Util.
|
|
203
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
204
204
|
command << packages
|
|
205
205
|
|
|
206
206
|
execute_shell(command)
|
data/lib/kanrisuru/core/disk.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Kanrisuru
|
|
|
23
23
|
:name, :label, :uuid, :type, :uuid_sub, :label_fatboot, :version, :usage,
|
|
24
24
|
:part_uuid, :part_entry_scheme, :part_entry_uuid, :part_entry_type,
|
|
25
25
|
:part_entry_number, :part_entry_offset, :part_entry_size, :part_entry_disk,
|
|
26
|
-
:minimum_io_size, :physical_sector_size, :logical_sector_size
|
|
26
|
+
:minimum_io_size, :physical_sector_size, :logical_sector_size
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
def du(opts = {})
|
data/lib/kanrisuru/core/find.rb
CHANGED
|
@@ -10,6 +10,7 @@ module Kanrisuru
|
|
|
10
10
|
os_define :linux, :find
|
|
11
11
|
|
|
12
12
|
FilePath = Struct.new(:path)
|
|
13
|
+
REGEX_TYPES = ['emacs', 'posix-awk', 'posix-basic', 'posix-egrep', 'posix-extended']
|
|
13
14
|
|
|
14
15
|
def find(opts = {})
|
|
15
16
|
paths = opts[:paths]
|
|
@@ -32,7 +33,7 @@ module Kanrisuru
|
|
|
32
33
|
if paths.instance_of?(Array)
|
|
33
34
|
paths = paths.join(' ')
|
|
34
35
|
elsif paths.class != String
|
|
35
|
-
raise 'Invalid paths type'
|
|
36
|
+
raise ArgumentError, 'Invalid paths type'
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
command << paths
|
|
@@ -64,13 +65,19 @@ module Kanrisuru
|
|
|
64
65
|
command.append_arg('-cmin', opts[:cmin])
|
|
65
66
|
command.append_arg('-mmin', opts[:mmin])
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
if Kanrisuru::Util.present?(opts[:regex_type])
|
|
69
|
+
unless REGEX_TYPES.include?(opts[:regex_type])
|
|
70
|
+
raise ArgumentError, 'invalid regex type'
|
|
71
|
+
end
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
command.append_arg('-regextype', opts[:regex_type])
|
|
74
|
+
end
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
command.append_arg('-regex', "'#{regex}'") if Kanrisuru::Util.present?(regex)
|
|
73
77
|
|
|
78
|
+
if size.instance_of?(String)
|
|
79
|
+
regex = Regexp.new(/^([-+])?(\d+)([bcwkMG])*$/)
|
|
80
|
+
raise ArgumentError, "invalid size string: '#{@size}'" unless regex.match?(size)
|
|
74
81
|
command.append_arg('-size', size)
|
|
75
82
|
elsif size.instance_of?(Integer)
|
|
76
83
|
command.append_arg('-size', size)
|
|
@@ -38,9 +38,14 @@ module Kanrisuru
|
|
|
38
38
|
'LAST-ACK' => 'last-ack', 'CLOSING' => 'closing'
|
|
39
39
|
}.freeze
|
|
40
40
|
|
|
41
|
+
NETWORK_FAMILIES = %w[
|
|
42
|
+
unix inet inet6 link netlink
|
|
43
|
+
].freeze
|
|
44
|
+
|
|
41
45
|
def ss(opts = {})
|
|
42
46
|
state = opts[:state]
|
|
43
47
|
expression = opts[:expression]
|
|
48
|
+
family = opts[:family]
|
|
44
49
|
|
|
45
50
|
command = Kanrisuru::Command.new('ss')
|
|
46
51
|
|
|
@@ -53,7 +58,10 @@ module Kanrisuru
|
|
|
53
58
|
command.append_flag('-x', opts[:unix])
|
|
54
59
|
command.append_flag('-w', opts[:raw])
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
if Kanrisuru::Util.present?(family)
|
|
62
|
+
raise ArgumentError, 'invalid family type' if !NETWORK_FAMILIES.include?(family)
|
|
63
|
+
command.append_arg('-f', family)
|
|
64
|
+
end
|
|
57
65
|
|
|
58
66
|
if Kanrisuru::Util.present?(state)
|
|
59
67
|
raise ArgumentError, 'invalid filter state' if !TCP_STATES.include?(state) && !OTHER_STATES.include?(state)
|
|
@@ -87,7 +87,7 @@ module Kanrisuru
|
|
|
87
87
|
command.append_arg('--quota', opts[:quota])
|
|
88
88
|
|
|
89
89
|
if Kanrisuru::Util.present?(opts[:restrict_file_names])
|
|
90
|
-
command.append_arg('--restrict-file-names', Kanrisuru::Util.
|
|
90
|
+
command.append_arg('--restrict-file-names', Kanrisuru::Util.array_join_string(opts[:restrict_file_names]))
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
case opts[:family]
|
|
@@ -124,7 +124,6 @@ module Kanrisuru
|
|
|
124
124
|
command.append_flag('--no-cookies', opts[:no_cookies])
|
|
125
125
|
command.append_flag('--keep-session-cookies', opts[:keep_session_cookies])
|
|
126
126
|
command.append_flag('--ignore-length', opts[:ignore_length])
|
|
127
|
-
command.append_arg('--header', opts[:header])
|
|
128
127
|
command.append_arg('--max-redirect', opts[:max_redirect])
|
|
129
128
|
command.append_arg('--proxy-user', opts[:proxy_user])
|
|
130
129
|
command.append_arg('--proxy-password', opts[:proxy_password])
|
|
@@ -132,6 +131,18 @@ module Kanrisuru
|
|
|
132
131
|
command.append_flag('--save-headers', opts[:save_headers])
|
|
133
132
|
command.append_arg('--user-agent', opts[:user_agent])
|
|
134
133
|
|
|
134
|
+
headers = opts[:headers]
|
|
135
|
+
if Kanrisuru::Util.present?(headers)
|
|
136
|
+
if headers.instance_of?(Hash)
|
|
137
|
+
headers.each do |key, value|
|
|
138
|
+
header = "'#{key}: #{value}'"
|
|
139
|
+
command.append_arg('--header', header)
|
|
140
|
+
end
|
|
141
|
+
elsif headers.instance_of?(String)
|
|
142
|
+
command.append_arg('--header', headers)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
135
146
|
post_data = opts[:post_data]
|
|
136
147
|
|
|
137
148
|
if Kanrisuru::Util.present?(post_data)
|
data/lib/kanrisuru/core/yum.rb
CHANGED
|
@@ -78,7 +78,7 @@ module Kanrisuru
|
|
|
78
78
|
command = Kanrisuru::Command.new('yum install')
|
|
79
79
|
command.append_flag('-y')
|
|
80
80
|
|
|
81
|
-
packages = Kanrisuru::Util.
|
|
81
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
82
82
|
command << packages
|
|
83
83
|
|
|
84
84
|
execute_shell(command)
|
|
@@ -91,7 +91,7 @@ module Kanrisuru
|
|
|
91
91
|
command.append_flag('-y')
|
|
92
92
|
|
|
93
93
|
if Kanrisuru::Util.present?(opts[:repos])
|
|
94
|
-
repos = Kanrisuru::Util.
|
|
94
|
+
repos = Kanrisuru::Util.array_join_string(opts[:repos], ' ')
|
|
95
95
|
command << repos
|
|
96
96
|
end
|
|
97
97
|
|
|
@@ -136,7 +136,7 @@ module Kanrisuru
|
|
|
136
136
|
command = Kanrisuru::Command.new('yum remove')
|
|
137
137
|
command.append_flag('-y')
|
|
138
138
|
|
|
139
|
-
packages = Kanrisuru::Util.
|
|
139
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
140
140
|
raise ArugmentError, "can't remove yum" if packages.include?('yum')
|
|
141
141
|
|
|
142
142
|
command << packages
|
|
@@ -172,7 +172,7 @@ module Kanrisuru
|
|
|
172
172
|
command = Kanrisuru::Command.new('yum erase')
|
|
173
173
|
command.append_flag('-y')
|
|
174
174
|
|
|
175
|
-
packages = Kanrisuru::Util.
|
|
175
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
176
176
|
raise ArugmentError, "can't erase yum" if packages.include?('yum')
|
|
177
177
|
|
|
178
178
|
command << packages
|
|
@@ -198,7 +198,7 @@ module Kanrisuru
|
|
|
198
198
|
def yum_search(opts)
|
|
199
199
|
command = Kanrisuru::Command.new('yum search')
|
|
200
200
|
command.append_flag('all', opts[:all])
|
|
201
|
-
command << Kanrisuru::Util.
|
|
201
|
+
command << Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
202
202
|
|
|
203
203
|
pipe_output_newline(command)
|
|
204
204
|
|
|
@@ -228,7 +228,7 @@ module Kanrisuru
|
|
|
228
228
|
command = Kanrisuru::Command.new('yum repolist')
|
|
229
229
|
command.append_flag('--verbose')
|
|
230
230
|
|
|
231
|
-
command << Kanrisuru::Util.
|
|
231
|
+
command << Kanrisuru::Util.array_join_string(opts[:repos], ' ') if opts[:repos]
|
|
232
232
|
|
|
233
233
|
execute_shell(command)
|
|
234
234
|
|
|
@@ -287,7 +287,7 @@ module Kanrisuru
|
|
|
287
287
|
command.append_flag('--quiet')
|
|
288
288
|
command.append_flag('installed', opts[:installed])
|
|
289
289
|
|
|
290
|
-
command << Kanrisuru::Util.
|
|
290
|
+
command << Kanrisuru::Util.array_join_string(opts[:packages], ' ') if opts[:packages]
|
|
291
291
|
|
|
292
292
|
execute_shell(command)
|
|
293
293
|
|
|
@@ -567,7 +567,7 @@ module Kanrisuru
|
|
|
567
567
|
zypper_repos_opt(command, opts)
|
|
568
568
|
zypper_package_type_opt(command, opts)
|
|
569
569
|
|
|
570
|
-
packages = Kanrisuru::Util.
|
|
570
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
571
571
|
command << packages
|
|
572
572
|
|
|
573
573
|
execute_shell(command)
|
|
@@ -663,7 +663,7 @@ module Kanrisuru
|
|
|
663
663
|
zypper_download_and_install_opts(command, opts)
|
|
664
664
|
zypper_expert_opts(command, opts)
|
|
665
665
|
|
|
666
|
-
packages = Kanrisuru::Util.
|
|
666
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
667
667
|
command << packages
|
|
668
668
|
|
|
669
669
|
execute_shell(command)
|
|
@@ -714,7 +714,7 @@ module Kanrisuru
|
|
|
714
714
|
zypper_package_type_opt(command, opts)
|
|
715
715
|
zypper_solver_opts(command, opts)
|
|
716
716
|
|
|
717
|
-
packages = Kanrisuru::Util.
|
|
717
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
718
718
|
command << packages
|
|
719
719
|
|
|
720
720
|
execute_shell(command)
|
|
@@ -783,7 +783,7 @@ module Kanrisuru
|
|
|
783
783
|
zypper_repos_opt(command, opts)
|
|
784
784
|
zypper_package_type_opt(command, opts)
|
|
785
785
|
|
|
786
|
-
packages = Kanrisuru::Util.
|
|
786
|
+
packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
|
|
787
787
|
command << packages
|
|
788
788
|
|
|
789
789
|
execute_shell(command)
|
data/lib/kanrisuru/util.rb
CHANGED
|
@@ -21,6 +21,10 @@ module Kanrisuru
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def self.string_join_array(arg, field = ',')
|
|
24
|
+
Kanrisuru.logger.info do
|
|
25
|
+
'DEPRECATION WARNING: string_join_array will be removed in the upcoming major release. Use array_join_string instead.'
|
|
26
|
+
end
|
|
27
|
+
|
|
24
28
|
array = arg.instance_of?(String) ? [arg] : arg
|
|
25
29
|
array.join(field)
|
|
26
30
|
end
|
data/lib/kanrisuru/version.rb
CHANGED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Kanrisuru::Core::Find do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:host) do
|
|
15
|
+
Kanrisuru::Remote::Host.new(
|
|
16
|
+
host: 'localhost',
|
|
17
|
+
username: 'ubuntu',
|
|
18
|
+
keys: ['id_rsa']
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'prepares find command' do
|
|
23
|
+
expect_command(host.find, "find")
|
|
24
|
+
|
|
25
|
+
expect_command(host.find(follow: 'never'), "find -P")
|
|
26
|
+
expect_command(host.find(follow: 'always'), "find -L")
|
|
27
|
+
expect_command(host.find(follow: 'command'), "find -H")
|
|
28
|
+
|
|
29
|
+
expect_command(host.find(paths: '/etc'), "find /etc")
|
|
30
|
+
expect_command(host.find(paths: ['/etc', '/var', '/home']), "find /etc /var /home")
|
|
31
|
+
|
|
32
|
+
expect {
|
|
33
|
+
host.find(paths: 1)
|
|
34
|
+
}.to raise_error(ArgumentError)
|
|
35
|
+
|
|
36
|
+
expect_command(host.find(paths: '/',
|
|
37
|
+
executable: true,
|
|
38
|
+
empty: true,
|
|
39
|
+
readable: true,
|
|
40
|
+
writeable: true,
|
|
41
|
+
nogroup: true,
|
|
42
|
+
nouser: true,
|
|
43
|
+
mount: true
|
|
44
|
+
),
|
|
45
|
+
"find / -executable -empty -readable -nogroup -nouser -mount"
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
expect_command(host.find(paths: '/',
|
|
49
|
+
path: "/lib",
|
|
50
|
+
name: '*.so',
|
|
51
|
+
gid: 0,
|
|
52
|
+
uid: 0,
|
|
53
|
+
user: 'root',
|
|
54
|
+
group: 'root',
|
|
55
|
+
links: 2,
|
|
56
|
+
mindepth: 0,
|
|
57
|
+
maxdepth: 100
|
|
58
|
+
),
|
|
59
|
+
"find / -path /lib -name *.so -gid 0 -uid 0 -user root -group root -links 2 -maxdepth 100 -mindepth 0"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
expect_command(host.find(paths: '/var/log',
|
|
63
|
+
atime: '+1',
|
|
64
|
+
ctime: '+2',
|
|
65
|
+
mtime: '+3',
|
|
66
|
+
amin: '100',
|
|
67
|
+
cmin: '200',
|
|
68
|
+
mmin: '300'
|
|
69
|
+
),
|
|
70
|
+
"find /var/log -atime +1 -ctime +2 -mtime +3 -amin 100 -cmin 200 -mmin 300"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
expect_command(host.find(
|
|
74
|
+
paths: '/dev',
|
|
75
|
+
regex: '/dev/tty[0-9]*'
|
|
76
|
+
),
|
|
77
|
+
"find /dev -regex '/dev/tty[0-9]*'"
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
expect_command(host.find(
|
|
81
|
+
paths: '/dev',
|
|
82
|
+
regex_type: 'posix-egrep',
|
|
83
|
+
regex: '/dev/tty[0-9]*'
|
|
84
|
+
),
|
|
85
|
+
"find /dev -regextype posix-egrep -regex '/dev/tty[0-9]*'"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
expect_command(host.find(
|
|
89
|
+
paths: '/var/log',
|
|
90
|
+
size: 100
|
|
91
|
+
),
|
|
92
|
+
"find /var/log -size 100"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
expect_command(host.find(
|
|
96
|
+
paths: '/var/log',
|
|
97
|
+
size: "100"
|
|
98
|
+
),
|
|
99
|
+
"find /var/log -size 100"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
expect {
|
|
103
|
+
host.find(size: "100n")
|
|
104
|
+
}.to raise_error(ArgumentError)
|
|
105
|
+
|
|
106
|
+
expect_command(host.find(
|
|
107
|
+
paths: '/var/log',
|
|
108
|
+
size: "-100k"
|
|
109
|
+
),
|
|
110
|
+
"find /var/log -size -100k"
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
expect_command(host.find(
|
|
114
|
+
paths: '/var/log',
|
|
115
|
+
size: "+10M"
|
|
116
|
+
),
|
|
117
|
+
"find /var/log -size +10M"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
expect_command(host.find(
|
|
121
|
+
paths: "/dev",
|
|
122
|
+
type: 'directory'
|
|
123
|
+
),
|
|
124
|
+
"find /dev -type d"
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
expect_command(host.find(
|
|
128
|
+
paths: "/dev",
|
|
129
|
+
type: 'file'
|
|
130
|
+
),
|
|
131
|
+
"find /dev -type f"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
expect_command(host.find(
|
|
135
|
+
paths: "/dev",
|
|
136
|
+
type: 'symlinks'
|
|
137
|
+
),
|
|
138
|
+
"find /dev -type l"
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
expect_command(host.find(
|
|
142
|
+
paths: "/dev",
|
|
143
|
+
type: 'block'
|
|
144
|
+
),
|
|
145
|
+
"find /dev -type b"
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
expect_command(host.find(
|
|
149
|
+
paths: "/dev",
|
|
150
|
+
type: 'character'
|
|
151
|
+
),
|
|
152
|
+
"find /dev -type c"
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
expect_command(host.find(
|
|
156
|
+
paths: "/dev",
|
|
157
|
+
type: 'pipe'
|
|
158
|
+
),
|
|
159
|
+
"find /dev -type p"
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
expect_command(host.find(
|
|
163
|
+
paths: "/dev",
|
|
164
|
+
type: 'socket'
|
|
165
|
+
),
|
|
166
|
+
"find /dev -type s"
|
|
167
|
+
)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
-
StubNetwork.stub!
|
|
6
|
-
|
|
7
5
|
RSpec.describe Kanrisuru::Core::Path do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
let(:host) do
|
|
9
15
|
Kanrisuru::Remote::Host.new(
|
|
10
16
|
host: 'localhost',
|
|
11
|
-
username: 'ubuntu',
|
|
17
|
+
username: 'ubuntu',
|
|
12
18
|
keys: ['id_rsa']
|
|
13
19
|
)
|
|
14
20
|
end
|
|
@@ -42,5 +48,4 @@ RSpec.describe Kanrisuru::Core::Path do
|
|
|
42
48
|
expect_command(host.readlink('/etc/os-release', canonicalize_existing: true), 'readlink -e /etc/os-release')
|
|
43
49
|
expect_command(host.readlink('/etc/os-release', canonicalize_missing: true), 'readlink -m /etc/os-release')
|
|
44
50
|
end
|
|
45
|
-
|
|
46
51
|
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Kanrisuru::Core::Socket do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:host) do
|
|
15
|
+
Kanrisuru::Remote::Host.new(
|
|
16
|
+
host: 'localhost',
|
|
17
|
+
username: 'ubuntu',
|
|
18
|
+
keys: ['id_rsa']
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'prepares ss command' do
|
|
23
|
+
expect_command(host.ss, 'ss -a -m')
|
|
24
|
+
|
|
25
|
+
expect_command(host.ss(
|
|
26
|
+
numeric: true,
|
|
27
|
+
tcp: true,
|
|
28
|
+
udp: true,
|
|
29
|
+
unix: true,
|
|
30
|
+
raw: true
|
|
31
|
+
),
|
|
32
|
+
'ss -a -m -n -t -u -x -w'
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
expect_command(host.ss(
|
|
36
|
+
family: 'inet'
|
|
37
|
+
),
|
|
38
|
+
'ss -a -m -f inet'
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
expect {
|
|
42
|
+
host.ss(family: 'inet5')
|
|
43
|
+
}.to raise_error(ArgumentError)
|
|
44
|
+
|
|
45
|
+
expect_command(host.ss(
|
|
46
|
+
state: 'established'
|
|
47
|
+
),
|
|
48
|
+
'ss -a -m state established'
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
expect_command(host.ss(
|
|
52
|
+
state: 'connected'
|
|
53
|
+
),
|
|
54
|
+
'ss -a -m state connected'
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
expect {
|
|
58
|
+
host.ss(state: 'test')
|
|
59
|
+
}.to raise_error(ArgumentError)
|
|
60
|
+
|
|
61
|
+
expect_command(host.ss(
|
|
62
|
+
expression: "'( dport = :ssh or sport = :ssh )'"
|
|
63
|
+
),
|
|
64
|
+
"ss -a -m '( dport = :ssh or sport = :ssh )'"
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -2,25 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
-
StubNetwork.stub!
|
|
6
|
-
|
|
7
5
|
RSpec.describe Kanrisuru::Core::Stat do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
let(:host) do
|
|
9
15
|
Kanrisuru::Remote::Host.new(
|
|
10
16
|
host: 'localhost',
|
|
11
|
-
username: 'ubuntu',
|
|
17
|
+
username: 'ubuntu',
|
|
12
18
|
keys: ['id_rsa']
|
|
13
19
|
)
|
|
14
20
|
end
|
|
15
21
|
|
|
16
22
|
it 'prepares stat command' do
|
|
17
|
-
expect_command(host.stat('~/file1.txt'),
|
|
18
|
-
|
|
19
|
-
)
|
|
23
|
+
expect_command(host.stat('~/file1.txt'),
|
|
24
|
+
'stat -c %A,%b,%D,%F,%g,%G,%h,%i,%n,%s,%u,%U,%x,%y,%z ~/file1.txt')
|
|
20
25
|
|
|
21
26
|
expect_command(host.stat('~/file2.txt', follow: true),
|
|
22
|
-
|
|
23
|
-
)
|
|
27
|
+
'stat -L -c %A,%b,%D,%F,%g,%G,%h,%i,%n,%s,%u,%U,%x,%y,%z ~/file2.txt')
|
|
24
28
|
end
|
|
25
|
-
|
|
26
29
|
end
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
-
StubNetwork.stub!
|
|
6
|
-
|
|
7
5
|
RSpec.describe Kanrisuru::Core::Stream do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
let(:host) do
|
|
9
15
|
Kanrisuru::Remote::Host.new(
|
|
10
16
|
host: 'localhost',
|
|
11
|
-
username: 'ubuntu',
|
|
17
|
+
username: 'ubuntu',
|
|
12
18
|
keys: ['id_rsa']
|
|
13
19
|
)
|
|
14
20
|
end
|
|
@@ -26,13 +32,13 @@ RSpec.describe Kanrisuru::Core::Stream do
|
|
|
26
32
|
|
|
27
33
|
it 'prepares tail command' do
|
|
28
34
|
result = host.tail('/var/log/syslog')
|
|
29
|
-
expect_command(result, 'tail /var/log/syslog'
|
|
35
|
+
expect_command(result, 'tail /var/log/syslog')
|
|
30
36
|
|
|
31
37
|
result = host.tail('/var/log/syslog', bytes: 1024)
|
|
32
38
|
expect_command(result, 'tail -c 1024 /var/log/syslog')
|
|
33
39
|
|
|
34
40
|
result = host.tail('/var/log/syslog', lines: 50)
|
|
35
|
-
expect_command(result, 'tail -n 50 /var/log/syslog'
|
|
41
|
+
expect_command(result, 'tail -n 50 /var/log/syslog')
|
|
36
42
|
end
|
|
37
43
|
|
|
38
44
|
it 'prepares read_file_chunk command' do
|
|
@@ -42,59 +48,59 @@ RSpec.describe Kanrisuru::Core::Stream do
|
|
|
42
48
|
result = host.read_file_chunk('/var/log/apache2/access.log', 0, 0)
|
|
43
49
|
expect_command(result, 'tail -n +0 /var/log/apache2/access.log | head -n 1')
|
|
44
50
|
|
|
45
|
-
expect
|
|
51
|
+
expect do
|
|
46
52
|
host.read_file_chunk('file.log', 10, '20')
|
|
47
|
-
|
|
53
|
+
end.to raise_error(ArgumentError)
|
|
48
54
|
|
|
49
|
-
expect
|
|
55
|
+
expect do
|
|
50
56
|
host.read_file_chunk('file.log', '10', 20)
|
|
51
|
-
|
|
57
|
+
end.to raise_error(ArgumentError)
|
|
52
58
|
|
|
53
|
-
expect
|
|
59
|
+
expect do
|
|
54
60
|
host.read_file_chunk('file.log', 10, 9)
|
|
55
|
-
|
|
61
|
+
end.to raise_error(ArgumentError)
|
|
56
62
|
|
|
57
|
-
expect
|
|
63
|
+
expect do
|
|
58
64
|
host.read_file_chunk('file.log', -1, 1)
|
|
59
|
-
|
|
65
|
+
end.to raise_error(ArgumentError)
|
|
60
66
|
|
|
61
|
-
expect
|
|
67
|
+
expect do
|
|
62
68
|
host.read_file_chunk('file.log', 10, -2)
|
|
63
|
-
|
|
69
|
+
end.to raise_error(ArgumentError)
|
|
64
70
|
end
|
|
65
71
|
|
|
66
72
|
it 'prepares sed command' do
|
|
67
|
-
result = host.sed(
|
|
73
|
+
result = host.sed('~/file.txt', 'Cat', 'Dog')
|
|
68
74
|
expect_command(result, "sed 's/Cat/Dog/g' '~/file.txt'")
|
|
69
75
|
|
|
70
|
-
result = host.sed(
|
|
76
|
+
result = host.sed('~/file.txt', 'Cat', 'Doggz', in_place: true, new_file: '~/file2.txt', mode: 'write')
|
|
71
77
|
expect_command(result, "sed -i 's/Cat/Doggz/g' '~/file.txt' > ~/file2.txt")
|
|
72
78
|
|
|
73
|
-
result = host.sed(
|
|
79
|
+
result = host.sed('~/file.txt', 'Cat', 'Dogo', regexp_extended: true, new_file: '~/file2.txt', mode: 'append')
|
|
74
80
|
expect_command(result, "sed -r 's/Cat/Dogo/g' '~/file.txt' >> ~/file2.txt")
|
|
75
81
|
end
|
|
76
82
|
|
|
77
83
|
it 'prepares echo command' do
|
|
78
|
-
expect_command(host.echo('Hello world')
|
|
79
|
-
expect_command(host.echo(
|
|
84
|
+
expect_command(host.echo('Hello world'), "echo 'Hello world'")
|
|
85
|
+
expect_command(host.echo('Hello\\n world', backslash: true), "echo -e 'Hello\\n world'")
|
|
80
86
|
|
|
81
87
|
expect_command(host.echo('Hello world', new_file: '~/file1.txt', mode: 'write'),
|
|
82
88
|
"echo 'Hello world' > ~/file1.txt")
|
|
83
|
-
|
|
89
|
+
|
|
90
|
+
expect_command(host.echo('Goodbye', new_file: '~/file1.txt', mode: 'append'),
|
|
84
91
|
"echo 'Goodbye' >> ~/file1.txt")
|
|
85
92
|
end
|
|
86
93
|
|
|
87
94
|
it 'prepares cat command' do
|
|
88
95
|
expect_command(host.cat('/etc/group'), 'cat /etc/group')
|
|
89
96
|
expect_command(host.cat('/etc/group', show_all: true), 'cat -A /etc/group')
|
|
90
|
-
expect_command(host.cat('/etc/group',
|
|
91
|
-
show_tabs: true,
|
|
92
|
-
number: true,
|
|
93
|
-
squeeze_blank: true,
|
|
97
|
+
expect_command(host.cat('/etc/group',
|
|
98
|
+
show_tabs: true,
|
|
99
|
+
number: true,
|
|
100
|
+
squeeze_blank: true,
|
|
94
101
|
show_nonprinting: true,
|
|
95
102
|
show_ends: true,
|
|
96
|
-
number_nonblank: true
|
|
97
|
-
), 'cat -T -n -s -v -E -b /etc/group')
|
|
103
|
+
number_nonblank: true), 'cat -T -n -s -v -E -b /etc/group')
|
|
98
104
|
|
|
99
105
|
expect_command(host.cat(['~/file1.txt', '~/file2.txt', '~/file3.txt']),
|
|
100
106
|
'cat ~/file1.txt ~/file2.txt ~/file3.txt')
|
|
@@ -105,5 +111,4 @@ RSpec.describe Kanrisuru::Core::Stream do
|
|
|
105
111
|
expect_command(host.cat(['~/file1.txt', '~/file2.txt', '~/file3.txt'], mode: 'append', new_file: 'combined.txt'),
|
|
106
112
|
'cat ~/file1.txt ~/file2.txt ~/file3.txt >> combined.txt')
|
|
107
113
|
end
|
|
108
|
-
|
|
109
114
|
end
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Kanrisuru::Core::Stat do
|
|
6
|
+
before(:all) do
|
|
7
|
+
StubNetwork.stub!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after(:all) do
|
|
11
|
+
StubNetwork.unstub!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
let(:host) do
|
|
15
|
+
Kanrisuru::Remote::Host.new(
|
|
16
|
+
host: 'localhost',
|
|
17
|
+
username: 'ubuntu',
|
|
18
|
+
keys: ['id_rsa']
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'prepares wget command' do
|
|
23
|
+
url = 'https://rubygems.org'
|
|
24
|
+
|
|
25
|
+
expect_command(host.wget(url),
|
|
26
|
+
"wget #{url}"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
## Output options
|
|
30
|
+
expect_command(host.wget(url,
|
|
31
|
+
quiet: true, verbose: false, log_file: '/var/log/wget.log'),
|
|
32
|
+
"wget --quiet --no-verbose --output-file /var/log/wget.log #{url}"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
expect_command(host.wget(url,
|
|
36
|
+
verbose: true, append_log_file: '/var/log/wget.log'),
|
|
37
|
+
"wget --verbose --append-output /var/log/wget.log #{url}"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
## Download options
|
|
41
|
+
expect_command(host.wget(url,
|
|
42
|
+
bind_address: '0.0.0.0',
|
|
43
|
+
retries: 3,
|
|
44
|
+
output_document: '/home/ubuntu/index.html',
|
|
45
|
+
no_clobber: true,
|
|
46
|
+
timeout: 30,
|
|
47
|
+
dns_timeout: 60,
|
|
48
|
+
connect_timeout: 60,
|
|
49
|
+
read_timeout: 15,
|
|
50
|
+
limit_rate: '120k',
|
|
51
|
+
wait: 5,
|
|
52
|
+
waitretry: 15,
|
|
53
|
+
random_wait: true,
|
|
54
|
+
no_proxy: true,
|
|
55
|
+
no_dns_cache: true
|
|
56
|
+
),
|
|
57
|
+
"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"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
## Other Options
|
|
61
|
+
expect_command(host.wget(url,
|
|
62
|
+
quota: 'inf',
|
|
63
|
+
family: 'inet',
|
|
64
|
+
restrict_file_names: ['unix', 'ascii', 'lowercase', 'uppercase'],
|
|
65
|
+
retry_connrefused: true,
|
|
66
|
+
user: 'admin',
|
|
67
|
+
password: 'admin',
|
|
68
|
+
no_iri: true,
|
|
69
|
+
),
|
|
70
|
+
"wget --quota inf --restrict-file-names unix,ascii,lowercase,uppercase --inet4-only --retry-connrefused --user admin --password admin --no-iri #{url}"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
## Directories
|
|
74
|
+
expect_command(host.wget(url,
|
|
75
|
+
no_directories: true,
|
|
76
|
+
no_host_directories: true,
|
|
77
|
+
cut_dirs: 3,
|
|
78
|
+
directory_prefix: '~/downloads/'
|
|
79
|
+
),
|
|
80
|
+
"wget --no-directories --no-host-directories --cut-dirs 3 --directory-prefix ~/downloads/ #{url}"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
## HTTP
|
|
84
|
+
expect_command(host.wget(url,
|
|
85
|
+
default_page: 'index.html',
|
|
86
|
+
adjust_extension: true,
|
|
87
|
+
http_user: 'admin',
|
|
88
|
+
http_password: 'admin',
|
|
89
|
+
load_cookies: '~/cookies.txt',
|
|
90
|
+
save_cookies: '~/cookies.txt',
|
|
91
|
+
no_cache: true,
|
|
92
|
+
keep_session_cookies: true,
|
|
93
|
+
ignore_length: true,
|
|
94
|
+
headers: {
|
|
95
|
+
'Accept-Language' => 'hr',
|
|
96
|
+
'Authorization' => 'Bearer 1234'
|
|
97
|
+
},
|
|
98
|
+
max_redirect: 5,
|
|
99
|
+
proxy_user: 'admin',
|
|
100
|
+
proxy_password: '12345678'
|
|
101
|
+
),
|
|
102
|
+
"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}"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
expect_command(host.wget(url,
|
|
106
|
+
post_data: {
|
|
107
|
+
url: "https://example.com?param=123"
|
|
108
|
+
},
|
|
109
|
+
content_disposition: true,
|
|
110
|
+
secure_protocol: 'SSLv3',
|
|
111
|
+
no_check_certificate: true,
|
|
112
|
+
),
|
|
113
|
+
"wget --post-data url=https%3A%2F%2Fexample.com%3Fparam%3D123 --content-disposition --secure-protocol SSLv3 --no-check-certificate #{url}"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
expect {
|
|
117
|
+
host.wget(url, secure_protocol: 'SSL')
|
|
118
|
+
}.to raise_error(ArgumentError)
|
|
119
|
+
|
|
120
|
+
expect_command(host.wget(url,
|
|
121
|
+
certificate: '~/cert.pem',
|
|
122
|
+
certificate_type: 'PEM',
|
|
123
|
+
private_key: '~/key.pem',
|
|
124
|
+
private_key_type: 'PEM',
|
|
125
|
+
ca_certificate: '~/ca.pem',
|
|
126
|
+
random_file: '~/random'
|
|
127
|
+
),
|
|
128
|
+
"wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}"
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
expect_command(host.wget(url,
|
|
132
|
+
certificate: '~/cert.pem',
|
|
133
|
+
certificate_type: 'PEM',
|
|
134
|
+
private_key: '~/key.pem',
|
|
135
|
+
private_key_type: 'PEM',
|
|
136
|
+
ca_certificate: '~/ca.pem',
|
|
137
|
+
random_file: '~/random'
|
|
138
|
+
),
|
|
139
|
+
"wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}"
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
## FTP
|
|
143
|
+
expect_command(host.wget(url,
|
|
144
|
+
ftp_user: 'admin',
|
|
145
|
+
ftp_password: '12345678',
|
|
146
|
+
no_remove_listing: true,
|
|
147
|
+
no_glob: true,
|
|
148
|
+
no_passive_ftp: true,
|
|
149
|
+
retr_symlinks: true
|
|
150
|
+
),
|
|
151
|
+
"wget --ftp-user admin --ftp-password 12345678 --no-remove-listing --no-glob --no-passive-ftp --retr-symlinks #{url}"
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
## Recursive Retrieval
|
|
155
|
+
expect_command(host.wget(url,
|
|
156
|
+
recursive: true,
|
|
157
|
+
depth: 10,
|
|
158
|
+
delete_after: true,
|
|
159
|
+
convert_links: true,
|
|
160
|
+
backup_converted: true,
|
|
161
|
+
mirror: true,
|
|
162
|
+
page_requisites: true,
|
|
163
|
+
strict_comments: true
|
|
164
|
+
),
|
|
165
|
+
"wget --recursive --level 10 --delete-after --convert-links --backup-converted --mirror --page-requisites --strict-comments #{url}"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
## Recursive Accept/Reject
|
|
169
|
+
expect_command(host.wget(url,
|
|
170
|
+
accept_list: ['.txt', '.html'],
|
|
171
|
+
reject_list: ['.csv'],
|
|
172
|
+
domain_list: ['example.com'],
|
|
173
|
+
exclude_domain_list: ['hackernews.com'],
|
|
174
|
+
follow_tags: ['a', 'div', 'span'],
|
|
175
|
+
ignore_tags: ['area', 'link'],
|
|
176
|
+
include_directories: ['/gems'],
|
|
177
|
+
exclude_directories: ['/releases'],
|
|
178
|
+
follow_ftp: true,
|
|
179
|
+
ignore_case: true,
|
|
180
|
+
span_hosts: true,
|
|
181
|
+
relative: true,
|
|
182
|
+
no_parent: true
|
|
183
|
+
),
|
|
184
|
+
"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}"
|
|
185
|
+
)
|
|
186
|
+
end
|
|
187
|
+
end
|
data/spec/helper/stub_network.rb
CHANGED
|
@@ -2,44 +2,62 @@
|
|
|
2
2
|
|
|
3
3
|
class StubNetwork
|
|
4
4
|
class << self
|
|
5
|
-
|
|
6
5
|
def stub!
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
unless Kanrisuru::Remote::Host.instance_methods(false).include?(:execute_with_retries_alias)
|
|
7
|
+
Kanrisuru::Remote::Host.class_eval do
|
|
8
|
+
alias_method :execute_with_retries_alias, :execute_with_retries
|
|
9
|
+
def execute_with_retries(command)
|
|
10
|
+
command.handle_status(0)
|
|
11
|
+
command.handle_data(nil)
|
|
12
|
+
|
|
13
|
+
command
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
unless Kanrisuru::Remote::Os.instance_methods(false).include?(:initialize_alias)
|
|
19
|
+
Kanrisuru::Remote::Os.class_eval do
|
|
20
|
+
alias_method :initialize_alias, :initialize
|
|
21
|
+
def initialize(host)
|
|
22
|
+
@host = host
|
|
23
|
+
|
|
24
|
+
@kernel_name = 'Linux'
|
|
25
|
+
@kernel_version = '#91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021'
|
|
26
|
+
@operating_system = 'GNU/Linux'
|
|
27
|
+
@hardware_platform = 'x86_64'
|
|
28
|
+
@processor = 'x86_64'
|
|
29
|
+
@release = 'ubuntu'
|
|
30
|
+
@version = 20.0
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
11
34
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
35
|
+
unless Kanrisuru::Result.instance_methods(false).include?(:initialize_alias)
|
|
36
|
+
Kanrisuru::Result.class_eval do
|
|
37
|
+
alias_method :initialize_alias, :initialize
|
|
38
|
+
def initialize(command)
|
|
39
|
+
@command = command
|
|
40
|
+
@data = nil
|
|
15
41
|
|
|
16
|
-
|
|
42
|
+
@error = @command.to_a if @command.failure?
|
|
43
|
+
end
|
|
17
44
|
end
|
|
18
45
|
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def unstub!
|
|
49
|
+
Kanrisuru::Remote::Host.class_eval do
|
|
50
|
+
alias_method :execute_with_retries, :execute_with_retries_alias
|
|
51
|
+
end
|
|
19
52
|
|
|
20
53
|
Kanrisuru::Remote::Os.class_eval do
|
|
21
|
-
|
|
22
|
-
@host = host
|
|
23
|
-
|
|
24
|
-
@kernel_name = 'Linux'
|
|
25
|
-
@kernel_version = '#91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021'
|
|
26
|
-
@operating_system = 'GNU/Linux'
|
|
27
|
-
@hardware_platform = "x86_64"
|
|
28
|
-
@processor = "x86_64"
|
|
29
|
-
@release = "ubuntu"
|
|
30
|
-
@version = 20.0
|
|
31
|
-
end
|
|
54
|
+
alias_method :initialize, :initialize_alias
|
|
32
55
|
end
|
|
33
56
|
|
|
34
57
|
Kanrisuru::Result.class_eval do
|
|
35
|
-
|
|
36
|
-
@command = command
|
|
37
|
-
@data = nil
|
|
38
|
-
|
|
39
|
-
@error = @command.to_a if @command.failure?
|
|
40
|
-
end
|
|
58
|
+
alias_method :initialize, :initialize_alias
|
|
41
59
|
end
|
|
42
|
-
end
|
|
60
|
+
end
|
|
43
61
|
|
|
44
62
|
end
|
|
45
63
|
end
|
|
@@ -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
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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)
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/core/find_spec.rb
CHANGED
|
@@ -5,5 +5,8 @@ require 'spec_helper'
|
|
|
5
5
|
RSpec.describe Kanrisuru::Core::Find do
|
|
6
6
|
it 'responds to find fields' do
|
|
7
7
|
expect(Kanrisuru::Core::Find::FilePath.new).to respond_to(:path)
|
|
8
|
+
expect(Kanrisuru::Core::Find::REGEX_TYPES).to(
|
|
9
|
+
eq(['emacs', 'posix-awk', 'posix-basic', 'posix-egrep', 'posix-extended'])
|
|
10
|
+
)
|
|
8
11
|
end
|
|
9
12
|
end
|
|
@@ -20,6 +20,11 @@ RSpec.describe Kanrisuru::Core::Socket do
|
|
|
20
20
|
closed close-wait last-ack listening closing
|
|
21
21
|
]
|
|
22
22
|
)
|
|
23
|
+
expect(Kanrisuru::Core::Socket::NETWORK_FAMILIES).to eq(
|
|
24
|
+
%w[
|
|
25
|
+
unix inet inet6 link netlink
|
|
26
|
+
]
|
|
27
|
+
)
|
|
23
28
|
expect(Kanrisuru::Core::Socket::OTHER_STATES).to eq(
|
|
24
29
|
%w[
|
|
25
30
|
all connected synchronized bucket syn-recv
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kanrisuru
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.20
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Mammina
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-11-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -173,9 +173,12 @@ files:
|
|
|
173
173
|
- lib/kanrisuru/util/os_family.rb
|
|
174
174
|
- lib/kanrisuru/util/signal.rb
|
|
175
175
|
- lib/kanrisuru/version.rb
|
|
176
|
+
- spec/functional/core/find_spec.rb
|
|
176
177
|
- spec/functional/core/path_spec.rb
|
|
178
|
+
- spec/functional/core/socket_spec.rb
|
|
177
179
|
- spec/functional/core/stat_spec.rb
|
|
178
180
|
- spec/functional/core/stream_spec.rb
|
|
181
|
+
- spec/functional/core/transfer_spec.rb
|
|
179
182
|
- spec/functional/os_package_spec.rb
|
|
180
183
|
- spec/helper/expect_helpers.rb
|
|
181
184
|
- spec/helper/stub_network.rb
|