kanrisuru 0.8.17 → 0.8.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/lib/kanrisuru/core/apt.rb +4 -4
- data/lib/kanrisuru/core/find.rb +12 -5
- 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/find_spec.rb +169 -0
- 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/find_spec.rb +3 -0
- 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: 1681e03fd41949c6519e0606a6e7138fed6bb8a75302848ad446e2c44fab3252
|
4
|
+
data.tar.gz: 2215d0f12fba2b91a9412db908975c4a82b76ab2eff8f93e095fb6acb1735d88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4477883aef70e512d5b1e91cc65154cc1381075531d35063b1ef9fc3c409e0a094b586e7c9892e121321f4642714f607d7e9333d2f46590bdfdc0101afb5787
|
7
|
+
data.tar.gz: 6b1cb465511443feeb85d4cc115bde8cb91eef4c047a037b89bc4ab33e78a3a800694c917f9366cfd151d3f3e1565d3dee2f3a22f8ca20f0e5d0369b7606455e
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,21 @@
|
|
1
|
-
## Kanrisuru 0.8.
|
1
|
+
## Kanrisuru 0.8.21 (November 15, 2021)
|
2
|
+
* Fix bug with `Kanrisuru::Mode` class, lookup table had incorrect value for execute only symbolic to numeric field.
|
3
|
+
|
4
|
+
## Kanrisuru 0.8.20 (November 13, 2021)
|
5
|
+
* Unstub network requests for full rspec test-suite run
|
6
|
+
|
7
|
+
## Kanrisuru 0.8.19 (October 31, 2021)
|
8
|
+
* Add functional test cases for `ss` command.
|
9
|
+
* Enforce contraints on `family` parameter for `ss` command.
|
10
|
+
* 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.
|
11
|
+
* Replace `string_join_array` method calls in `apt`, `transfer`, `yum`, and `zypper` with `array_join_string`.
|
12
|
+
|
13
|
+
## Kanrisuru 0.8.18 (October 19, 2021)
|
14
|
+
* Add functional test cases for `find` commmand.
|
15
|
+
* Add `regex_type` option for `find` command.
|
16
|
+
* 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.
|
17
|
+
|
18
|
+
## Kanrisuru 0.8.17 (October 16, 2021)
|
2
19
|
* Add functional test cases for `transfer` module
|
3
20
|
* Update wget command to accept hash for `headers` opt.
|
4
21
|
|
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/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]
|
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,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,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
|
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
|
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.21
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -173,7 +173,9 @@ 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
|
179
181
|
- spec/functional/core/transfer_spec.rb
|