kanrisuru 0.8.18 → 0.8.22
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 +21 -1
- data/lib/kanrisuru/core/apt.rb +4 -4
- data/lib/kanrisuru/core/socket.rb +9 -1
- data/lib/kanrisuru/core/transfer.rb +1 -1
- data/lib/kanrisuru/core/yum.rb +7 -7
- data/lib/kanrisuru/core/zypper.rb +4 -4
- data/lib/kanrisuru/mode.rb +1 -1
- data/lib/kanrisuru/util.rb +4 -0
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/apt_spec.rb +96 -0
- data/spec/functional/core/find_spec.rb +8 -2
- data/spec/functional/core/path_spec.rb +8 -2
- data/spec/functional/core/socket_spec.rb +67 -0
- data/spec/functional/core/stat_spec.rb +8 -2
- data/spec/functional/core/stream_spec.rb +8 -2
- data/spec/functional/core/transfer_spec.rb +8 -2
- data/spec/helper/expect_helpers.rb +1 -1
- data/spec/helper/stub_network.rb +45 -25
- data/spec/unit/core/socket_spec.rb +5 -0
- data/spec/unit/mode_spec.rb +25 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 610fa46fc1f2af6ea5b805092f9528858c586cfad6c9754b18bdad109eaa9e77
|
|
4
|
+
data.tar.gz: 210c27c89350d4b5cbbba4b5677711d2032f8d4bbbc7bac79a2c2a722f0c6caa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd1f29eb444fe67904563cc2f0edaf3480c068e374f75242f7d802d94588c7023549186ddce860f9ac1b79a66413435f18b57f36b3b53cfa5f688ca32689ba8f
|
|
7
|
+
data.tar.gz: 3e784e517b5fa233c97b14dee47ab7f58562ebf2b484c602bd6d59ce1853a8749d7c53268574368269be7b4a711eac02bf6ce60bed1454232bf4d6a8a18b389d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
## Kanrisuru 0.8.
|
|
1
|
+
## Kanrisuru 0.8.22 (November 18, 2021)
|
|
2
|
+
* Add functional test cases for `apt` command
|
|
3
|
+
|
|
4
|
+
## Kanrisuru 0.8.21 (November 15, 2021)
|
|
5
|
+
* Fix bug with `Kanrisuru::Mode` class, lookup table had incorrect value for execute only symbolic to numeric field.
|
|
6
|
+
|
|
7
|
+
## Kanrisuru 0.8.20 (November 13, 2021)
|
|
8
|
+
* Unstub network requests for full rspec test-suite run
|
|
9
|
+
|
|
10
|
+
## Kanrisuru 0.8.19 (October 31, 2021)
|
|
11
|
+
* Add functional test cases for `ss` command.
|
|
12
|
+
* Enforce contraints on `family` parameter for `ss` command.
|
|
13
|
+
* 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.
|
|
14
|
+
* Replace `string_join_array` method calls in `apt`, `transfer`, `yum`, and `zypper` with `array_join_string`.
|
|
15
|
+
|
|
16
|
+
## Kanrisuru 0.8.18 (October 19, 2021)
|
|
17
|
+
* Add functional test cases for `find` commmand.
|
|
18
|
+
* Add `regex_type` option for `find` command.
|
|
19
|
+
* 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.
|
|
20
|
+
|
|
21
|
+
## Kanrisuru 0.8.17 (October 16, 2021)
|
|
2
22
|
* Add functional test cases for `transfer` module
|
|
3
23
|
* Update wget command to accept hash for `headers` opt.
|
|
4
24
|
|
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)
|
|
@@ -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]
|
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/mode.rb
CHANGED
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,96 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Kanrisuru::Core::Apt 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 apt list command' do
|
|
23
|
+
expect_command(host.apt('list'), 'apt list')
|
|
24
|
+
expect_command(host.apt('list',
|
|
25
|
+
installed: true,
|
|
26
|
+
upgradeable: true,
|
|
27
|
+
all_versions: true,
|
|
28
|
+
), 'apt list --installed --upgradeable --all-versions')
|
|
29
|
+
|
|
30
|
+
expect_command(host.apt('list', package_name: 'nginx'), 'apt list -a nginx')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'prepares apt update command' do
|
|
34
|
+
expect_command(host.apt('update'), 'apt-get update -y')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'prepares apt upgrade command' do
|
|
38
|
+
expect_command(host.apt('upgrade'), 'apt-get upgrade -y')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'prepares apt full-upgrade command' do
|
|
42
|
+
expect_command(host.apt('full-upgrade'), 'apt full-upgrade -y')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'prepares apt install command' do
|
|
46
|
+
expect_command(host.apt('install',
|
|
47
|
+
packages: 'nginx'
|
|
48
|
+
),
|
|
49
|
+
'apt-get install -y nginx'
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
expect_command(host.apt('install',
|
|
53
|
+
packages: 'monit',
|
|
54
|
+
no_upgrade: true,
|
|
55
|
+
reinstall: true
|
|
56
|
+
),
|
|
57
|
+
'apt-get install -y --no-upgrade --reinstall monit'
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
expect_command(host.apt('install',
|
|
61
|
+
packages: ['build-essential', 'manpages-dev'],
|
|
62
|
+
only_upgrade: true,
|
|
63
|
+
),
|
|
64
|
+
'apt-get install -y --only-upgrade build-essential manpages-dev'
|
|
65
|
+
)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'prepares apt remove command' do
|
|
69
|
+
expect_command(host.apt('remove', packages: ['python']), 'apt-get remove -y python')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'prepares apt purge command' do
|
|
73
|
+
expect_command(host.apt('purge', packages: ['python']), 'apt-get purge -y python')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'prepares apt autoremove command' do
|
|
77
|
+
expect_command(host.apt('autoremove'), 'apt-get autoremove -y')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'prepares apt search command' do
|
|
81
|
+
expect_command(host.apt('search', query: 'ruby'), 'apt search ruby')
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'prepares apt show command' do
|
|
85
|
+
expect_command(host.apt('show', packages: 'ruby'), 'apt show -a ruby')
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'prepares apt clean command' do
|
|
89
|
+
expect_command(host.apt('clean'), 'apt-get clean')
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'prepares apt autoclean command' do
|
|
93
|
+
expect_command(host.apt('autoclean'), 'apt-get autoclean')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
-
StubNetwork.stub!
|
|
6
|
-
|
|
7
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
|
+
|
|
8
14
|
let(:host) do
|
|
9
15
|
Kanrisuru::Remote::Host.new(
|
|
10
16
|
host: 'localhost',
|
|
@@ -2,9 +2,15 @@
|
|
|
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',
|
|
@@ -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,9 +2,15 @@
|
|
|
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',
|
|
@@ -2,9 +2,15 @@
|
|
|
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',
|
|
@@ -2,9 +2,15 @@
|
|
|
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',
|
data/spec/helper/stub_network.rb
CHANGED
|
@@ -3,41 +3,61 @@
|
|
|
3
3
|
class StubNetwork
|
|
4
4
|
class << self
|
|
5
5
|
def stub!
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
command.handle_status(0)
|
|
13
|
-
command.handle_data(nil)
|
|
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)
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
command
|
|
14
|
+
end
|
|
16
15
|
end
|
|
17
16
|
end
|
|
18
17
|
|
|
19
|
-
Kanrisuru::Remote::Os.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
Kanrisuru::Result.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
@error = @command.to_a if @command.failure?
|
|
43
|
+
end
|
|
39
44
|
end
|
|
40
45
|
end
|
|
41
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
|
|
52
|
+
|
|
53
|
+
Kanrisuru::Remote::Os.class_eval do
|
|
54
|
+
alias_method :initialize, :initialize_alias
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Kanrisuru::Result.class_eval do
|
|
58
|
+
alias_method :initialize, :initialize_alias
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
42
62
|
end
|
|
43
63
|
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
|
data/spec/unit/mode_spec.rb
CHANGED
|
@@ -79,6 +79,31 @@ RSpec.describe Kanrisuru::Mode do
|
|
|
79
79
|
expect(mode.other.all?).to eq(true)
|
|
80
80
|
expect(mode.other.to_i).to eq(7)
|
|
81
81
|
expect(mode.other.symbolic).to eq('rwx')
|
|
82
|
+
|
|
83
|
+
mode = described_class.new("---x--x--x")
|
|
84
|
+
expect(mode.directory?).to eq(false)
|
|
85
|
+
expect(mode.numeric).to eq("111")
|
|
86
|
+
|
|
87
|
+
expect(mode.owner.read?).to eq(false)
|
|
88
|
+
expect(mode.owner.write?).to eq(false)
|
|
89
|
+
expect(mode.owner.execute?).to eq(true)
|
|
90
|
+
expect(mode.owner.all?).to eq(false)
|
|
91
|
+
expect(mode.owner.to_i).to eq(1)
|
|
92
|
+
expect(mode.owner.symbolic).to eq('--x')
|
|
93
|
+
|
|
94
|
+
expect(mode.group.read?).to eq(false)
|
|
95
|
+
expect(mode.group.write?).to eq(false)
|
|
96
|
+
expect(mode.group.execute?).to eq(true)
|
|
97
|
+
expect(mode.group.all?).to eq(false)
|
|
98
|
+
expect(mode.group.to_i).to eq(1)
|
|
99
|
+
expect(mode.group.symbolic).to eq('--x')
|
|
100
|
+
|
|
101
|
+
expect(mode.other.read?).to eq(false)
|
|
102
|
+
expect(mode.other.write?).to eq(false)
|
|
103
|
+
expect(mode.other.execute?).to eq(true)
|
|
104
|
+
expect(mode.other.all?).to eq(false)
|
|
105
|
+
expect(mode.other.to_i).to eq(1)
|
|
106
|
+
expect(mode.other.symbolic).to eq('--x')
|
|
82
107
|
end
|
|
83
108
|
|
|
84
109
|
it 'changes mode numerically globally' do
|
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.22
|
|
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-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -173,8 +173,10 @@ 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/apt_spec.rb
|
|
176
177
|
- spec/functional/core/find_spec.rb
|
|
177
178
|
- spec/functional/core/path_spec.rb
|
|
179
|
+
- spec/functional/core/socket_spec.rb
|
|
178
180
|
- spec/functional/core/stat_spec.rb
|
|
179
181
|
- spec/functional/core/stream_spec.rb
|
|
180
182
|
- spec/functional/core/transfer_spec.rb
|