kanrisuru 0.8.18 → 0.8.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e813c072c86f8c0b076a90d2b8136fb9bc64271df996c6c54c4e2bf6c7b5806
4
- data.tar.gz: a763991aa4979eb17c1c0e123d80c2057552b2caf9be24358b39659a292e241d
3
+ metadata.gz: 90fafd703817d1e16744262817dd0b5e5a51ea942f2853b154f4bd2746295fd7
4
+ data.tar.gz: 0e0b35e325d3237faacbb71f22873b1c661495af0d93830e7ad91babbb060b3c
5
5
  SHA512:
6
- metadata.gz: 52be23f3a72de4d6f9633e8b01470949035aec9be4123a87bbfc2e4a93120c463fa1470a69030ad696fbabb389ce60890b64925d129654f513a4baa392846ca8
7
- data.tar.gz: 749dfdd773a1256575ab262a73f56be48ec6caaef21e8499ea9fb42d9cb2ae79e569d3f8b9581aa153d9d7031eef88d46c64a9a68900d27e00cf85e28885d45d
6
+ metadata.gz: 76e116b83a5c119c0672b8ec5f1bac8f23307e1e06d3b393804df912f6110faf63527ca126ed4eb164d6ba58ef4ba92f3d1c3e15b252dc703058e39fc3ab4ba3
7
+ data.tar.gz: 8e80e6457fd848d4dee5a31e33881c91458402df16cc82845b6300afc2543fe583fe48aeb2914e4329de9d9a668b6afbc2dd533d56886bd6fe0656ede58e5c95
data/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
- ## Kanrisuru 0.8.17 (October 16 2021)
1
+ ## Kanrisuru 0.8.19 (October 31, 2021)
2
+ * Add functional test cases for `ss` command.
3
+ * Enforce contraints on `family` parameter for `ss` command.
4
+ * 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.
5
+ * Replace `string_join_array` method calls in `apt`, `transfer`, `yum`, and `zypper` with `array_join_string`.
6
+
7
+ ## Kanrisuru 0.8.18 (October 19, 2021)
8
+ * Add functional test cases for `find` commmand.
9
+ * Add `regex_type` option for `find` command.
10
+ * 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.
11
+
12
+ ## Kanrisuru 0.8.17 (October 16, 2021)
2
13
  * Add functional test cases for `transfer` module
3
14
  * Update wget command to accept hash for `headers` opt.
4
15
 
@@ -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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:packages], ' ')
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
- command.append_arg('-f', opts[:family])
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.string_join_array(opts[:restrict_file_names]))
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]
@@ -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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:repos], ' ')
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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:repos], ' ') if opts[:repos]
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.string_join_array(opts[:packages], ' ') if opts[:packages]
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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:packages], ' ')
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.string_join_array(opts[:packages], ' ')
786
+ packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
787
787
  command << packages
788
788
 
789
789
  execute_shell(command)
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.8.18'
4
+ VERSION = '0.8.19'
5
5
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ StubNetwork.stub!
6
+
7
+ RSpec.describe Kanrisuru::Core::Socket 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 ss command' do
17
+ expect_command(host.ss, 'ss -a -m')
18
+
19
+ expect_command(host.ss(
20
+ numeric: true,
21
+ tcp: true,
22
+ udp: true,
23
+ unix: true,
24
+ raw: true
25
+ ),
26
+ 'ss -a -m -n -t -u -x -w'
27
+ )
28
+
29
+ expect_command(host.ss(
30
+ family: 'inet'
31
+ ),
32
+ 'ss -a -m -f inet'
33
+ )
34
+
35
+ expect {
36
+ host.ss(family: 'inet5')
37
+ }.to raise_error(ArgumentError)
38
+
39
+ expect_command(host.ss(
40
+ state: 'established'
41
+ ),
42
+ 'ss -a -m state established'
43
+ )
44
+
45
+ expect_command(host.ss(
46
+ state: 'connected'
47
+ ),
48
+ 'ss -a -m state connected'
49
+ )
50
+
51
+ expect {
52
+ host.ss(state: 'test')
53
+ }.to raise_error(ArgumentError)
54
+
55
+ expect_command(host.ss(
56
+ expression: "'( dport = :ssh or sport = :ssh )'"
57
+ ),
58
+ "ss -a -m '( dport = :ssh or sport = :ssh )'"
59
+ )
60
+ end
61
+ 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.18
4
+ version: 0.8.19
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-10-19 00:00:00.000000000 Z
11
+ date: 2021-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -175,6 +175,7 @@ files:
175
175
  - lib/kanrisuru/version.rb
176
176
  - spec/functional/core/find_spec.rb
177
177
  - spec/functional/core/path_spec.rb
178
+ - spec/functional/core/socket_spec.rb
178
179
  - spec/functional/core/stat_spec.rb
179
180
  - spec/functional/core/stream_spec.rb
180
181
  - spec/functional/core/transfer_spec.rb