kanrisuru 0.13.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +5 -5
  4. data/kanrisuru.gemspec +7 -3
  5. data/lib/kanrisuru/command.rb +15 -1
  6. data/lib/kanrisuru/core/apt/commands/autoclean.rb +13 -0
  7. data/lib/kanrisuru/core/apt/commands/autoremove.rb +15 -0
  8. data/lib/kanrisuru/core/apt/commands/clean.rb +13 -0
  9. data/lib/kanrisuru/core/apt/commands/full_upgrade.rb +14 -0
  10. data/lib/kanrisuru/core/apt/commands/install.rb +22 -0
  11. data/lib/kanrisuru/core/apt/commands/list.rb +21 -0
  12. data/lib/kanrisuru/core/apt/commands/purge.rb +18 -0
  13. data/lib/kanrisuru/core/apt/commands/remove.rb +18 -0
  14. data/lib/kanrisuru/core/apt/commands/search.rb +18 -0
  15. data/lib/kanrisuru/core/apt/commands/show.rb +21 -0
  16. data/lib/kanrisuru/core/apt/commands/update.rb +14 -0
  17. data/lib/kanrisuru/core/apt/commands/upgrade.rb +14 -0
  18. data/lib/kanrisuru/core/apt/commands.rb +14 -0
  19. data/lib/kanrisuru/core/apt/parser.rb +6 -0
  20. data/lib/kanrisuru/core/apt/parsers/base.rb +51 -0
  21. data/lib/kanrisuru/core/apt/parsers/list.rb +28 -0
  22. data/lib/kanrisuru/core/apt/parsers/search.rb +32 -0
  23. data/lib/kanrisuru/core/apt/parsers/show.rb +90 -0
  24. data/lib/kanrisuru/core/apt/types.rb +36 -0
  25. data/lib/kanrisuru/core/apt.rb +4 -284
  26. data/lib/kanrisuru/core/archive/commands/tar.rb +126 -0
  27. data/lib/kanrisuru/core/archive/commands.rb +3 -0
  28. data/lib/kanrisuru/core/archive/types.rb +9 -0
  29. data/lib/kanrisuru/core/archive.rb +3 -121
  30. data/lib/kanrisuru/core/disk/commands/blkid.rb +35 -0
  31. data/lib/kanrisuru/core/disk/commands/df.rb +26 -0
  32. data/lib/kanrisuru/core/disk/commands/du.rb +24 -0
  33. data/lib/kanrisuru/core/disk/commands/lsblk.rb +49 -0
  34. data/lib/kanrisuru/core/disk/commands.rb +6 -0
  35. data/lib/kanrisuru/core/disk/constants.rb +9 -0
  36. data/lib/kanrisuru/core/disk/parser.rb +7 -0
  37. data/lib/kanrisuru/core/disk/parsers/blkid.rb +72 -0
  38. data/lib/kanrisuru/core/disk/parsers/df.rb +33 -0
  39. data/lib/kanrisuru/core/disk/parsers/du.rb +25 -0
  40. data/lib/kanrisuru/core/disk/parsers/lsblk.rb +96 -0
  41. data/lib/kanrisuru/core/disk/parsers/lsblk_version.rb +21 -0
  42. data/lib/kanrisuru/core/disk/types.rb +21 -0
  43. data/lib/kanrisuru/core/disk.rb +6 -290
  44. data/lib/kanrisuru/core/dmi/commands/dmi.rb +42 -0
  45. data/lib/kanrisuru/core/dmi/commands.rb +3 -0
  46. data/lib/kanrisuru/core/dmi/parser.rb +3 -0
  47. data/lib/kanrisuru/core/dmi/parsers/dmi.rb +149 -0
  48. data/lib/kanrisuru/core/dmi/types.rb +361 -0
  49. data/lib/kanrisuru/core/dmi.rb +4 -522
  50. data/lib/kanrisuru/core/file/commands/chmod.rb +29 -0
  51. data/lib/kanrisuru/core/file/commands/chown.rb +35 -0
  52. data/lib/kanrisuru/core/file/commands/copy.rb +54 -0
  53. data/lib/kanrisuru/core/file/commands/link.rb +25 -0
  54. data/lib/kanrisuru/core/file/commands/mkdir.rb +42 -0
  55. data/lib/kanrisuru/core/file/commands/move.rb +48 -0
  56. data/lib/kanrisuru/core/file/commands/rm.rb +41 -0
  57. data/lib/kanrisuru/core/file/commands/symlink.rb +46 -0
  58. data/lib/kanrisuru/core/file/commands/touch.rb +34 -0
  59. data/lib/kanrisuru/core/file/commands/unlink.rb +13 -0
  60. data/lib/kanrisuru/core/file/commands/wc.rb +16 -0
  61. data/lib/kanrisuru/core/file/commands.rb +29 -0
  62. data/lib/kanrisuru/core/file/parser.rb +3 -0
  63. data/lib/kanrisuru/core/file/parsers/wc.rb +16 -0
  64. data/lib/kanrisuru/core/file/types.rb +9 -0
  65. data/lib/kanrisuru/core/file.rb +4 -312
  66. data/lib/kanrisuru/core/find/commands/find.rb +97 -0
  67. data/lib/kanrisuru/core/find/commands.rb +3 -0
  68. data/lib/kanrisuru/core/find/constants.rb +9 -0
  69. data/lib/kanrisuru/core/find/parser.rb +3 -0
  70. data/lib/kanrisuru/core/find/parsers/find.rb +18 -0
  71. data/lib/kanrisuru/core/find/types.rb +9 -0
  72. data/lib/kanrisuru/core/find.rb +5 -97
  73. data/lib/kanrisuru/core/group/commands/create_group.rb +21 -0
  74. data/lib/kanrisuru/core/group/commands/delete_group.rb +16 -0
  75. data/lib/kanrisuru/core/group/commands/get_gid.rb +17 -0
  76. data/lib/kanrisuru/core/group/commands/get_group.rb +29 -0
  77. data/lib/kanrisuru/core/group/commands/is_group.rb +14 -0
  78. data/lib/kanrisuru/core/group/commands/update_group.rb +23 -0
  79. data/lib/kanrisuru/core/group/commands.rb +8 -0
  80. data/lib/kanrisuru/core/group/parser.rb +4 -0
  81. data/lib/kanrisuru/core/group/parsers/gid.rb +15 -0
  82. data/lib/kanrisuru/core/group/parsers/group.rb +15 -0
  83. data/lib/kanrisuru/core/group/types.rb +10 -0
  84. data/lib/kanrisuru/core/group.rb +4 -81
  85. data/lib/kanrisuru/core/ip/commands/address.rb +86 -0
  86. data/lib/kanrisuru/core/ip/commands/address_label.rb +54 -0
  87. data/lib/kanrisuru/core/ip/commands/link.rb +116 -0
  88. data/lib/kanrisuru/core/ip/commands/link_set_opts.rb +61 -0
  89. data/lib/kanrisuru/core/ip/commands/link_type_opts.rb +313 -0
  90. data/lib/kanrisuru/core/ip/commands/maddress.rb +42 -0
  91. data/lib/kanrisuru/core/ip/commands/neighbour.rb +72 -0
  92. data/lib/kanrisuru/core/ip/commands/route.rb +152 -0
  93. data/lib/kanrisuru/core/ip/commands/rule.rb +57 -0
  94. data/lib/kanrisuru/core/ip/commands.rb +26 -0
  95. data/lib/kanrisuru/core/ip/constants.rb +25 -0
  96. data/lib/kanrisuru/core/ip/parser.rb +11 -0
  97. data/lib/kanrisuru/core/ip/parsers/address.rb +104 -0
  98. data/lib/kanrisuru/core/ip/parsers/address_label.rb +27 -0
  99. data/lib/kanrisuru/core/ip/parsers/base.rb +166 -0
  100. data/lib/kanrisuru/core/ip/parsers/link.rb +86 -0
  101. data/lib/kanrisuru/core/ip/parsers/maddress.rb +85 -0
  102. data/lib/kanrisuru/core/ip/parsers/neighbour.rb +89 -0
  103. data/lib/kanrisuru/core/ip/parsers/route.rb +76 -0
  104. data/lib/kanrisuru/core/ip/parsers/rule.rb +60 -0
  105. data/lib/kanrisuru/core/ip/parsers/version.rb +15 -0
  106. data/lib/kanrisuru/core/ip/types.rb +46 -0
  107. data/lib/kanrisuru/core/ip.rb +15 -1002
  108. data/lib/kanrisuru/core/mount/commands/mount.rb +65 -0
  109. data/lib/kanrisuru/core/mount/commands/umount.rb +35 -0
  110. data/lib/kanrisuru/core/mount/commands.rb +49 -0
  111. data/lib/kanrisuru/core/mount.rb +2 -125
  112. data/lib/kanrisuru/core/path/commands/ls.rb +26 -0
  113. data/lib/kanrisuru/core/path/commands/pwd.rb +16 -0
  114. data/lib/kanrisuru/core/path/commands/readlink.rb +22 -0
  115. data/lib/kanrisuru/core/path/commands/realpath.rb +18 -0
  116. data/lib/kanrisuru/core/path/commands/which.rb +19 -0
  117. data/lib/kanrisuru/core/path/commands/whoami.rb +16 -0
  118. data/lib/kanrisuru/core/path/commands.rb +8 -0
  119. data/lib/kanrisuru/core/path/parser.rb +4 -0
  120. data/lib/kanrisuru/core/path/parsers/ls.rb +53 -0
  121. data/lib/kanrisuru/core/path/parsers/which.rb +18 -0
  122. data/lib/kanrisuru/core/path/types.rb +12 -0
  123. data/lib/kanrisuru/core/path.rb +4 -121
  124. data/lib/kanrisuru/core/socket/commands/ss.rb +44 -0
  125. data/lib/kanrisuru/core/socket/commands.rb +3 -0
  126. data/lib/kanrisuru/core/socket/constants.rb +29 -0
  127. data/lib/kanrisuru/core/socket/parser.rb +3 -0
  128. data/lib/kanrisuru/core/socket/parsers/ss.rb +109 -0
  129. data/lib/kanrisuru/core/socket/types.rb +18 -0
  130. data/lib/kanrisuru/core/socket.rb +5 -164
  131. data/lib/kanrisuru/core/stat/commands/stat.rb +62 -0
  132. data/lib/kanrisuru/core/stat/commands.rb +3 -0
  133. data/lib/kanrisuru/core/stat/parser.rb +3 -0
  134. data/lib/kanrisuru/core/stat/parsers/stat.rb +34 -0
  135. data/lib/kanrisuru/core/stat/types.rb +14 -0
  136. data/lib/kanrisuru/core/stat.rb +4 -81
  137. data/lib/kanrisuru/core/stream/commands/cat.rb +25 -0
  138. data/lib/kanrisuru/core/stream/commands/echo.rb +20 -0
  139. data/lib/kanrisuru/core/stream/commands/head.rb +18 -0
  140. data/lib/kanrisuru/core/stream/commands/read_file_chunk.rb +21 -0
  141. data/lib/kanrisuru/core/stream/commands/sed.rb +23 -0
  142. data/lib/kanrisuru/core/stream/commands/tail.rb +18 -0
  143. data/lib/kanrisuru/core/stream/commands.rb +27 -0
  144. data/lib/kanrisuru/core/stream/parser.rb +4 -0
  145. data/lib/kanrisuru/core/stream/parsers/echo.rb +17 -0
  146. data/lib/kanrisuru/core/stream/parsers/sed.rb +17 -0
  147. data/lib/kanrisuru/core/stream.rb +3 -104
  148. data/lib/kanrisuru/core/system/commands/cpu_info.rb +32 -0
  149. data/lib/kanrisuru/core/system/commands/free.rb +25 -0
  150. data/lib/kanrisuru/core/system/commands/kernel_statistics.rb +21 -0
  151. data/lib/kanrisuru/core/system/commands/kill.rb +22 -0
  152. data/lib/kanrisuru/core/system/commands/last.rb +31 -0
  153. data/lib/kanrisuru/core/system/commands/load_average.rb +16 -0
  154. data/lib/kanrisuru/core/system/commands/load_env.rb +16 -0
  155. data/lib/kanrisuru/core/system/commands/lscpu.rb +17 -0
  156. data/lib/kanrisuru/core/system/commands/lsof.rb +16 -0
  157. data/lib/kanrisuru/core/system/commands/poweroff.rb +42 -0
  158. data/lib/kanrisuru/core/system/commands/ps.rb +35 -0
  159. data/lib/kanrisuru/core/system/commands/reboot.rb +42 -0
  160. data/lib/kanrisuru/core/system/commands/uptime.rb +18 -0
  161. data/lib/kanrisuru/core/system/commands/w.rb +24 -0
  162. data/lib/kanrisuru/core/system/commands.rb +34 -0
  163. data/lib/kanrisuru/core/system/parser.rb +11 -0
  164. data/lib/kanrisuru/core/system/parsers/kernel_statistics.rb +56 -0
  165. data/lib/kanrisuru/core/system/parsers/last.rb +64 -0
  166. data/lib/kanrisuru/core/system/parsers/load_average.rb +15 -0
  167. data/lib/kanrisuru/core/system/parsers/load_env.rb +24 -0
  168. data/lib/kanrisuru/core/system/parsers/lscpu.rb +90 -0
  169. data/lib/kanrisuru/core/system/parsers/lsof.rb +62 -0
  170. data/lib/kanrisuru/core/system/parsers/ps.rb +71 -0
  171. data/lib/kanrisuru/core/system/parsers/uptime.rb +38 -0
  172. data/lib/kanrisuru/core/system/parsers/w.rb +30 -0
  173. data/lib/kanrisuru/core/system/types.rb +108 -0
  174. data/lib/kanrisuru/core/system.rb +4 -687
  175. data/lib/kanrisuru/core/transfer/commands/download.rb +26 -0
  176. data/lib/kanrisuru/core/transfer/commands/upload.rb +23 -0
  177. data/lib/kanrisuru/core/transfer/commands/wget.rb +168 -0
  178. data/lib/kanrisuru/core/transfer/commands.rb +5 -0
  179. data/lib/kanrisuru/core/transfer/constants.rb +10 -0
  180. data/lib/kanrisuru/core/transfer.rb +3 -199
  181. data/lib/kanrisuru/core/user/commands/create_user.rb +49 -0
  182. data/lib/kanrisuru/core/user/commands/delete_user.rb +20 -0
  183. data/lib/kanrisuru/core/user/commands/get_uid.rb +15 -0
  184. data/lib/kanrisuru/core/user/commands/get_user.rb +48 -0
  185. data/lib/kanrisuru/core/user/commands/is_user.rb +14 -0
  186. data/lib/kanrisuru/core/user/commands/update_user.rb +54 -0
  187. data/lib/kanrisuru/core/user/commands.rb +8 -0
  188. data/lib/kanrisuru/core/user/parser.rb +4 -0
  189. data/lib/kanrisuru/core/user/parsers/getent.rb +17 -0
  190. data/lib/kanrisuru/core/user/parsers/groups.rb +17 -0
  191. data/lib/kanrisuru/core/user/types.rb +11 -0
  192. data/lib/kanrisuru/core/user.rb +4 -182
  193. data/lib/kanrisuru/core/yum/commands/autoremove.rb +14 -0
  194. data/lib/kanrisuru/core/yum/commands/clean.rb +23 -0
  195. data/lib/kanrisuru/core/yum/commands/erase.rb +20 -0
  196. data/lib/kanrisuru/core/yum/commands/info.rb +21 -0
  197. data/lib/kanrisuru/core/yum/commands/install.rb +18 -0
  198. data/lib/kanrisuru/core/yum/commands/list.rb +30 -0
  199. data/lib/kanrisuru/core/yum/commands/localinstall.rb +22 -0
  200. data/lib/kanrisuru/core/yum/commands/remove.rb +20 -0
  201. data/lib/kanrisuru/core/yum/commands/repolist.rb +20 -0
  202. data/lib/kanrisuru/core/yum/commands/search.rb +21 -0
  203. data/lib/kanrisuru/core/yum/commands/update.rb +14 -0
  204. data/lib/kanrisuru/core/yum/commands/upgrade.rb +14 -0
  205. data/lib/kanrisuru/core/yum/commands.rb +39 -0
  206. data/lib/kanrisuru/core/yum/parser.rb +7 -0
  207. data/lib/kanrisuru/core/yum/parsers/base.rb +31 -0
  208. data/lib/kanrisuru/core/yum/parsers/info.rb +69 -0
  209. data/lib/kanrisuru/core/yum/parsers/list.rb +24 -0
  210. data/lib/kanrisuru/core/yum/parsers/repolist.rb +60 -0
  211. data/lib/kanrisuru/core/yum/parsers/search.rb +30 -0
  212. data/lib/kanrisuru/core/yum/types.rb +41 -0
  213. data/lib/kanrisuru/core/yum.rb +4 -347
  214. data/lib/kanrisuru/core/zypper/commands/add_lock.rb +22 -0
  215. data/lib/kanrisuru/core/zypper/commands/add_repo.rb +38 -0
  216. data/lib/kanrisuru/core/zypper/commands/add_service.rb +26 -0
  217. data/lib/kanrisuru/core/zypper/commands/clean_cache.rb +22 -0
  218. data/lib/kanrisuru/core/zypper/commands/clean_locks.rb +17 -0
  219. data/lib/kanrisuru/core/zypper/commands/dist_upgrade.rb +25 -0
  220. data/lib/kanrisuru/core/zypper/commands/info.rb +25 -0
  221. data/lib/kanrisuru/core/zypper/commands/install.rb +39 -0
  222. data/lib/kanrisuru/core/zypper/commands/install_new_recommends.rb +23 -0
  223. data/lib/kanrisuru/core/zypper/commands/list_locks.rb +22 -0
  224. data/lib/kanrisuru/core/zypper/commands/list_patches.rb +34 -0
  225. data/lib/kanrisuru/core/zypper/commands/list_repos.rb +21 -0
  226. data/lib/kanrisuru/core/zypper/commands/list_services.rb +21 -0
  227. data/lib/kanrisuru/core/zypper/commands/list_updates.rb +30 -0
  228. data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +48 -0
  229. data/lib/kanrisuru/core/zypper/commands/modify_service.rb +40 -0
  230. data/lib/kanrisuru/core/zypper/commands/patch.rb +40 -0
  231. data/lib/kanrisuru/core/zypper/commands/patch_check.rb +29 -0
  232. data/lib/kanrisuru/core/zypper/commands/purge_kernels.rb +18 -0
  233. data/lib/kanrisuru/core/zypper/commands/refresh_repos.rb +24 -0
  234. data/lib/kanrisuru/core/zypper/commands/refresh_services.rb +21 -0
  235. data/lib/kanrisuru/core/zypper/commands/remove.rb +26 -0
  236. data/lib/kanrisuru/core/zypper/commands/remove_lock.rb +22 -0
  237. data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +32 -0
  238. data/lib/kanrisuru/core/zypper/commands/remove_service.rb +21 -0
  239. data/lib/kanrisuru/core/zypper/commands/rename_repo.rb +20 -0
  240. data/lib/kanrisuru/core/zypper/commands/search.rb +52 -0
  241. data/lib/kanrisuru/core/zypper/commands/source_install.rb +22 -0
  242. data/lib/kanrisuru/core/zypper/commands/update.rb +27 -0
  243. data/lib/kanrisuru/core/zypper/commands/verify.rb +23 -0
  244. data/lib/kanrisuru/core/zypper/commands.rb +109 -0
  245. data/lib/kanrisuru/core/zypper/constants.rb +19 -0
  246. data/lib/kanrisuru/core/zypper/parser.rb +11 -0
  247. data/lib/kanrisuru/core/zypper/parsers/base.rb +18 -0
  248. data/lib/kanrisuru/core/zypper/parsers/info.rb +77 -0
  249. data/lib/kanrisuru/core/zypper/parsers/list_locks.rb +36 -0
  250. data/lib/kanrisuru/core/zypper/parsers/list_patches.rb +40 -0
  251. data/lib/kanrisuru/core/zypper/parsers/list_repos.rb +37 -0
  252. data/lib/kanrisuru/core/zypper/parsers/list_services.rb +36 -0
  253. data/lib/kanrisuru/core/zypper/parsers/list_updates.rb +32 -0
  254. data/lib/kanrisuru/core/zypper/parsers/patch_check.rb +34 -0
  255. data/lib/kanrisuru/core/zypper/parsers/search.rb +37 -0
  256. data/lib/kanrisuru/core/zypper/types.rb +88 -0
  257. data/lib/kanrisuru/core/zypper.rb +5 -998
  258. data/lib/kanrisuru/os_package.rb +2 -0
  259. data/lib/kanrisuru/result.rb +15 -0
  260. data/lib/kanrisuru/version.rb +1 -1
  261. data/spec/functional/core/archive_spec.rb +1 -1
  262. data/spec/functional/core/disk_spec.rb +77 -0
  263. data/spec/functional/core/dmi_spec.rb +78 -0
  264. data/spec/functional/core/file_spec.rb +284 -0
  265. data/spec/functional/core/group_spec.rb +62 -0
  266. data/spec/functional/core/ip/ip_address_label_spec.rb +81 -0
  267. data/spec/functional/core/ip/ip_address_spec.rb +95 -0
  268. data/spec/functional/core/ip/ip_link_spec.rb +814 -0
  269. data/spec/functional/core/ip/ip_maddress_spec.rb +78 -0
  270. data/spec/functional/core/ip/ip_neighbour_spec.rb +119 -0
  271. data/spec/functional/core/ip/ip_route_spec.rb +174 -0
  272. data/spec/functional/core/ip/ip_rule_spec.rb +75 -0
  273. data/spec/functional/core/ip/ip_spec.rb +27 -0
  274. data/spec/functional/core/system_spec.rb +135 -0
  275. data/spec/functional/core/user_spec.rb +97 -0
  276. data/spec/functional/result_spec.rb +91 -44
  277. data/spec/helper/stub_network.rb +6 -2
  278. data/spec/support/shared_examples/integration/core/transfer.rb +1 -1
  279. data/spec/unit/command_spec.rb +2 -0
  280. data/spec/unit/core/ip_spec.rb +12 -0
  281. data/spec/unit/util_spec.rb +16 -0
  282. metadata +253 -4
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'set'
4
+
3
5
  require_relative 'os_package/collection'
4
6
  require_relative 'os_package/define'
5
7
  require_relative 'os_package/include'
@@ -39,6 +39,21 @@ module Kanrisuru
39
39
  @data.instance_of?(Array) ? @data : [@data]
40
40
  end
41
41
 
42
+ def to_f
43
+ case @data
44
+ when Numeric
45
+ @data
46
+ when String
47
+ @data.to_f
48
+ when Array
49
+ @data.map(&:to_f)
50
+ when NilClass
51
+ nil
52
+ else
53
+ raise NoMethodError, "(undefined method `to_f' for Kanrisuru::Result)"
54
+ end
55
+ end
56
+
42
57
  def to_i
43
58
  case @data
44
59
  when Integer
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.13.0'
4
+ VERSION = '0.16.1'
5
5
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  RSpec.describe Kanrisuru::Core::Archive do
6
6
  before(:all) do
7
7
  StubNetwork.stub!
8
- StubNetwork.stub_command!(:realpath) do |_args|
8
+ StubNetwork.stub_command!(:realpath) do
9
9
  Kanrisuru::Core::Path::FilePath.new(directory)
10
10
  end
11
11
  end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Disk 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 blkid command' do
23
+ expect_command(host.blkid, 'blkid -o export')
24
+ expect_command(host.blkid(device: '/dev/vda1'), 'blkid -pio export /dev/vda1')
25
+ expect_command(host.blkid(label: 'UEFI'), 'blkid -L UEFI')
26
+ expect_command(host.blkid(uuid: '26F2-56F9'), 'blkid -U 26F2-56F9')
27
+ expect_command(host.blkid(label: 'UEFI', uuid: '26F2-56F9'), 'blkid -L UEFI -U 26F2-56F9')
28
+ end
29
+
30
+ it 'prepares df command' do
31
+ expect_command(host.df, "df -PT | awk '{print $1, $2, $3, $5, $6, $7}'")
32
+ expect_command(host.df(inodes: true, path: '/dev/vda1'),
33
+ "df -PT -i /dev/vda1 | awk '{print $1, $2, $3, $5, $6, $7}'")
34
+ end
35
+
36
+ it 'prepares du command' do
37
+ expect_command(host.du, "du | awk '{print \\$1, \\$2}'")
38
+ expect_command(host.du(summarize: true, path: '/etc'), "du -s /etc | awk '{print \\$1, \\$2}'")
39
+ end
40
+
41
+ context 'with json support' do
42
+ before(:all) do
43
+ StubNetwork.stub_command!(:lsblk_version) do
44
+ Kanrisuru::Core::Disk::LSBK_VERSION
45
+ end
46
+ end
47
+
48
+ after(:all) do
49
+ StubNetwork.unstub_command!(:lsblk_version)
50
+ end
51
+
52
+ it 'prepares lsblk command' do
53
+ expect_command(host.lsblk, 'lsblk --json -o NAME,FSTYPE,MAJ:MIN,MOUNTPOINT,SIZE,UUID,RO,RM,OWNER,GROUP,MODE,TYPE')
54
+ expect_command(host.lsblk(all: true, paths: true, nodeps: true),
55
+ 'lsblk --json -a -p -d -o NAME,FSTYPE,MAJ:MIN,MOUNTPOINT,SIZE,UUID,RO,RM,OWNER,GROUP,MODE,TYPE')
56
+ end
57
+ end
58
+
59
+ context 'without json support' do
60
+ before(:all) do
61
+ StubNetwork.stub_command!(:lsblk_version) do
62
+ Kanrisuru::Core::Disk::LSBK_VERSION - 0.1
63
+ end
64
+ end
65
+
66
+ after(:all) do
67
+ StubNetwork.unstub_command!(:lsblk_version)
68
+ end
69
+
70
+ it 'prepares lsblk command' do
71
+ expect_command(host.lsblk,
72
+ 'lsblk -i -P --noheadings -o NAME,FSTYPE,MAJ:MIN,MOUNTPOINT,SIZE,UUID,RO,RM,OWNER,GROUP,MODE,TYPE')
73
+ expect_command(host.lsblk(all: true, paths: true, nodeps: true),
74
+ 'lsblk -i -P --noheadings -a -p -d -o NAME,FSTYPE,MAJ:MIN,MOUNTPOINT,SIZE,UUID,RO,RM,OWNER,GROUP,MODE,TYPE')
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Dmi 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 dmi command' do
23
+ expect_command(host.dmi, 'dmidecode')
24
+ expect_command(host.dmi(types: 'BIOS'), 'dmidecode --type 0')
25
+ expect_command(host.dmi(types: 1), 'dmidecode --type 1')
26
+
27
+ expect do
28
+ host.dmi(types: 'hello')
29
+ end.to raise_error(ArgumentError)
30
+
31
+ expect_command(host.dmi(types: [
32
+ 'BIOS',
33
+ 'System',
34
+ 'Baseboard',
35
+ 'Chassis',
36
+ 'Processor',
37
+ 'Memory Controller',
38
+ 'Memory Module',
39
+ 'Cache',
40
+ 'Port Connector',
41
+ 'System Slots',
42
+ 'On Board Devices',
43
+ 'OEM Strings',
44
+ 'System Configuration Options',
45
+ 'BIOS Language',
46
+ 'Group Associations',
47
+ 'System Event Log',
48
+ 'Physical Memory Array',
49
+ 'Memory Device',
50
+ '32-bit Memory Error',
51
+ 'Memory Array Mapped Address',
52
+ 'Memory Device Mapped Address',
53
+ 'Built-in Pointing Device',
54
+ 'Portable Battery',
55
+ 'System Reset',
56
+ 'Hardware Security',
57
+ 'System Power Controls',
58
+ 'Voltage Probe',
59
+ 'Cooling Device',
60
+ 'Temperature Probe',
61
+ 'Electrical Current Probe',
62
+ 'Out-of-band Remote Access',
63
+ 'Boot Integrity Services',
64
+ 'System Boot',
65
+ '64-bit Memory Error',
66
+ 'Management Device',
67
+ 'Management Device Component',
68
+ 'Management Device Threshold Data',
69
+ 'Memory Channel',
70
+ 'IPMI Device',
71
+ 'System Power Supply',
72
+ 'Additional Information',
73
+ 'Onboard Devices Extended Information',
74
+ 'Management Controller Host Interface',
75
+ 'TPM Device'
76
+ ]), 'dmidecode --type 0 --type 1 --type 2 --type 3 --type 4 --type 5 --type 6 --type 7 --type 8 --type 9 --type 10 --type 11 --type 12 --type 13 --type 14 --type 15 --type 16 --type 17 --type 18 --type 19 --type 20 --type 21 --type 22 --type 23 --type 24 --type 25 --type 26 --type 27 --type 28 --type 29 --type 30 --type 31 --type 32 --type 33 --type 34 --type 35 --type 36 --type 37 --type 38 --type 39 --type 40 --type 41 --type 42 --type 43')
77
+ end
78
+ end
@@ -0,0 +1,284 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::File 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 chmod command' do
23
+ expect_command(host.chmod('/home/ubuntu/file1.txt', '-rwxrwxrwx'), 'chmod 777 /home/ubuntu/file1.txt')
24
+ expect_command(host.chmod('/home/ubuntu/dir', 'drwxrwxrwx', recursive: true), 'chmod 777 /home/ubuntu/dir -R')
25
+ expect_command(host.chmod('/home/ubuntu/dir', '600', recursive: true), 'chmod 600 /home/ubuntu/dir -R')
26
+ expect_command(host.chmod('/home/ubuntu/file2.conf', Kanrisuru::Mode.new('-rwxr--r--')),
27
+ 'chmod 744 /home/ubuntu/file2.conf')
28
+ expect_command(host.chmod('/home/ubuntu/file2.conf', 'g+x'), 'chmod g+x /home/ubuntu/file2.conf')
29
+ end
30
+
31
+ context 'with user and group stubs' do
32
+ before(:all) do
33
+ StubNetwork.stub_command!(:get_uid) do
34
+ 1000
35
+ end
36
+
37
+ StubNetwork.stub_command!(:get_gid) do
38
+ 1000
39
+ end
40
+ end
41
+
42
+ after(:all) do
43
+ StubNetwork.unstub_command!(:get_uid)
44
+ StubNetwork.unstub_command!(:get_gid)
45
+ end
46
+
47
+ it 'prepares chown command' do
48
+ expect_command(host.chown('/home/ubuntu/file1.text', owner: 'ubuntu', group: 'ubuntu'),
49
+ 'chown 1000:1000 /home/ubuntu/file1.text')
50
+ expect_command(host.chown('/home/ubuntu/file1.text', owner: 'ubuntu'), 'chown 1000 /home/ubuntu/file1.text')
51
+ expect_command(host.chown('/home/ubuntu/file1.text', group: 'ubuntu'), 'chown :1000 /home/ubuntu/file1.text')
52
+ expect(host.chown('/home/ubuntu/file1.txt')).to be_falsey
53
+ expect_command(host.chown('/home/ubuntu/dir', owner: 1000, group: 1000, recursive: true),
54
+ 'chown 1000:1000 -R /home/ubuntu/dir')
55
+ end
56
+ end
57
+
58
+ it 'prepares copy command' do
59
+ expect_command(host.copy('~/fileA', '~/fileB'), 'cp ~/fileA ~/fileB')
60
+ expect_command(host.copy('~/fileA', '~/fileB'), 'cp ~/fileA ~/fileB')
61
+ expect_command(host.copy('~/dir1', '~/dir2', {
62
+ recursive: true,
63
+ one_file_system: true,
64
+ update: true,
65
+ no_clobber: true,
66
+ strip_trailing_slashes: true
67
+ }), 'cp -R -x -u -n --strip-trailing-slashes ~/dir1 ~/dir2')
68
+
69
+ expect_command(host.copy('~/file1', '~/file1.copy', {
70
+ backup: true
71
+ }), 'cp -b ~/file1 ~/file1.copy')
72
+
73
+ expect_command(host.copy('~/file1', '~/file1.copy', {
74
+ backup: 'simple'
75
+ }), 'cp --backup=simple ~/file1 ~/file1.copy')
76
+
77
+ expect do
78
+ host.cp('~/file1', '~/file1.copy', { backup: 'forever' })
79
+ end.to raise_error(ArgumentError)
80
+
81
+ expect_command(host.cp('~/file1', '~/file2', { preserve: true }), 'cp -p ~/file1 ~/file2')
82
+ expect_command(host.cp('~/file1', '~/file2', { preserve: 'mode' }), 'cp --preserve=mode ~/file1 ~/file2')
83
+ expect_command(host.cp('~/file1', '~/file2', { preserve: %w[timestamps links] }),
84
+ 'cp --preserve=timestamps,links ~/file1 ~/file2')
85
+ expect_command(host.copy('~/fileA', '~/fileB', { no_target_directory: true }), 'cp -T ~/fileA ~/fileB')
86
+ expect_command(host.copy('~/fileA', '~/dirB', { target_directory: true }), 'cp -t ~/dirB ~/fileA')
87
+ end
88
+
89
+ context 'with dir stubs' do
90
+ before(:all) do
91
+ StubNetwork.stub_command!(:dir?, { return_value: true })
92
+ end
93
+
94
+ after(:all) do
95
+ StubNetwork.unstub_command!(:dir?)
96
+ end
97
+
98
+ it 'prepares link command' do
99
+ expect(host.ln('/home/ubuntu/dir', '/home/ubuntu/file1')).to be_falsey
100
+ end
101
+ end
102
+
103
+ context 'with dir stubs false' do
104
+ before(:all) do
105
+ StubNetwork.stub_command!(:dir?, { return_value: false })
106
+ end
107
+
108
+ after(:all) do
109
+ StubNetwork.unstub_command!(:dir?)
110
+ end
111
+
112
+ it 'prepares link command' do
113
+ expect_command(host.link('/home/ubuntu/file1', '/home/ubuntu/dir/file1'),
114
+ 'ln /home/ubuntu/file1 /home/ubuntu/dir/file1')
115
+
116
+ expect_command(host.ln('/home/ubuntu/file1', '/home/ubuntu/dir/file1', { force: true }),
117
+ 'ln /home/ubuntu/file1 /home/ubuntu/dir/file1 -f')
118
+ end
119
+ end
120
+
121
+ it 'prepares mkdir command' do
122
+ expect_command(host.mkdir('/home/ubuntu/dir1'), 'mkdir /home/ubuntu/dir1')
123
+ expect_command(host.mkdir(['~/dir1', '~/dir2', '~/dir3'], { silent: true }), 'mkdir ~/dir1 ~/dir2 ~/dir3 -p')
124
+ expect_command(host.mkdir('dir', { mode: '644' }), 'mkdir dir -m 644')
125
+ expect_command(host.mkdir(['dir2', '/etc/ddir'], { mode: Kanrisuru::Mode.new('dr--r--r--') }),
126
+ 'mkdir dir2 /etc/ddir -m 444')
127
+ expect_command(host.mkdir(['dir2', '/etc/ddir'], { mode: 'o+w' }), 'mkdir dir2 /etc/ddir -m o+w')
128
+ end
129
+
130
+ it 'prepares move command' do
131
+ expect_command(host.mv('~/fileA', '~/fileB'), 'mv ~/fileA ~/fileB')
132
+ expect_command(host.move('~/fileA', '~/fileB', { force: true }), 'mv -f ~/fileA ~/fileB')
133
+ expect_command(host.mv('~/fileA', '~/fileB', { no_clobber: true }), 'mv -n ~/fileA ~/fileB')
134
+ expect_command(host.mv('~/fileA', '~/fileB', { strip_trailing_slashes: true, force: true }),
135
+ 'mv --strip-trailing-slashes -f ~/fileA ~/fileB')
136
+ expect_command(host.mv('~/fileA', '~/fileB', { backup: true }), 'mv -b ~/fileA ~/fileB')
137
+ expect_command(host.mv('~/fileA', '~/fileB', { backup: 'numbered' }), 'mv --backup=numbered ~/fileA ~/fileB')
138
+
139
+ expect do
140
+ host.mv('~/fileA', '~/fileB', { backup: 'null' })
141
+ end.to raise_error(ArgumentError)
142
+
143
+ expect_command(host.mv('~/fileA', '~/fileB', { no_target_directory: true }), 'mv -T ~/fileA ~/fileB')
144
+ expect_command(host.mv(['~/fileA', '~/fileB'], '~/dir1', { target_directory: true }),
145
+ 'mv -t ~/dir1 ~/fileA ~/fileB')
146
+ expect_command(host.mv(['~/fileA', '~/fileB'], '~/dir1'), 'mv ~/fileA ~/fileB ~/dir1')
147
+ end
148
+
149
+ context 'with realpath non root' do
150
+ before(:all) do
151
+ StubNetwork.stub_command!(:realpath) do
152
+ Kanrisuru::Core::Path::FilePath.new('/home/ubuntu/fileA')
153
+ end
154
+ end
155
+
156
+ after(:all) do
157
+ StubNetwork.unstub_command!(:realpath)
158
+ end
159
+
160
+ it 'prepares rm command' do
161
+ expect_command(host.rm('~/fileA'), 'rm ~/fileA --preserve-root')
162
+ expect_command(host.rm('~/fileA', { force: true }), 'rm ~/fileA --preserve-root -f')
163
+ expect_command(host.rm('~/dirA', { force: true, recursive: true }), 'rm ~/dirA --preserve-root -f -r')
164
+ expect_command(host.rm(['~/dirA', '~/dirB'], { force: true, recursive: true }),
165
+ 'rm ~/dirA ~/dirB --preserve-root -f -r')
166
+ end
167
+
168
+ it 'prepares rmdir command' do
169
+ expect_command(host.rmdir('~/dir1'), 'rmdir ~/dir1')
170
+ expect_command(host.rmdir(['~/dir1', '~/dir2'], { silent: true, parents: true }),
171
+ 'rmdir ~/dir1 ~/dir2 --ignore-fail-on-non-empty --parents')
172
+ end
173
+ end
174
+
175
+ context 'with realpath root' do
176
+ before(:all) do
177
+ StubNetwork.stub_command!(:realpath) do
178
+ Kanrisuru::Core::Path::FilePath.new('/')
179
+ end
180
+ end
181
+
182
+ after(:all) do
183
+ StubNetwork.unstub_command!(:realpath)
184
+ end
185
+
186
+ it 'prepares rm command' do
187
+ expect do
188
+ host.rm('/', { force: true, recursive: true })
189
+ end.to raise_error(ArgumentError)
190
+
191
+ expect do
192
+ host.rm('/etc/..', { force: true, recursive: true })
193
+ end.to raise_error(ArgumentError)
194
+ end
195
+
196
+ it 'prepares rmdir command' do
197
+ expect do
198
+ host.rmdir('/etc/..', { silent: true })
199
+ end.to raise_error(ArgumentError)
200
+ end
201
+ end
202
+
203
+ context 'with stub' do
204
+ before(:all) do
205
+ StubNetwork.stub_command!(:realpath) do |cmd|
206
+ result = cmd[0].gsub('~', '/home/ubuntu')
207
+ Kanrisuru::Core::Path::FilePath.new(result)
208
+ end
209
+
210
+ StubNetwork.stub_command!(:inode?, { return_value: true })
211
+ StubNetwork.stub_command!(:symlink?, { return_value: false })
212
+ end
213
+
214
+ after(:all) do
215
+ StubNetwork.unstub_command!(:realpath)
216
+ StubNetwork.unstub_command!(:inode?)
217
+ StubNetwork.unstub_command!(:symlink?)
218
+ end
219
+
220
+ it 'prepares symlink command' do
221
+ StubNetwork.stub_command!(:dir?, { return_value: false })
222
+ expect_command(host.ln_s('~/fileA', '/etc/fileA'), 'ln -s /home/ubuntu/fileA /etc/fileA')
223
+ expect_command(host.ln_s('~/fileA', '/etc/fileA', { force: true }), 'ln -s /home/ubuntu/fileA /etc/fileA -f')
224
+ StubNetwork.unstub_command!(:dir?)
225
+
226
+ StubNetwork.stub_command!(:dir?, { return_value: true })
227
+ expect_command(host.symlink('~/fileA', '~/dirA', { force: true }),
228
+ 'ln -s /home/ubuntu/fileA /home/ubuntu/dirA -f')
229
+ StubNetwork.unstub_command!(:dir?)
230
+ end
231
+ end
232
+
233
+ context 'with broken stub' do
234
+ it 'prepares symlink command' do
235
+ StubNetwork.stub_command!(:inode?, { return_value: true })
236
+ StubNetwork.stub_command!(:realpath) do |_cmd|
237
+ Kanrisuru::Core::Path::FilePath.new('/')
238
+ end
239
+
240
+ expect do
241
+ host.symlink('/', '~/fileB')
242
+ end.to raise_error(ArgumentError)
243
+
244
+ expect do
245
+ host.symlink('/var/..', '~/fileB')
246
+ end.to raise_error(ArgumentError)
247
+
248
+ StubNetwork.unstub_command!(:inode?)
249
+ StubNetwork.unstub_command!(:realpath)
250
+
251
+ StubNetwork.stub_command!(:inode?, { return_value: false })
252
+ StubNetwork.stub_command!(:realpath) do |_cmd|
253
+ Kanrisuru::Core::Path::FilePath.new('')
254
+ end
255
+
256
+ expect do
257
+ host.symlink('', '~/fileB')
258
+ end.to raise_error(ArgumentError)
259
+
260
+ expect do
261
+ host.symlink('/home', '~/fileB')
262
+ end.to raise_error(ArgumentError)
263
+
264
+ StubNetwork.unstub_command!(:inode?)
265
+ StubNetwork.unstub_command!(:realpath)
266
+ end
267
+ end
268
+
269
+ it 'prepares touch command' do
270
+ expect_command(host.touch('file.conf'), 'touch file.conf')
271
+ expect_command(host.touch(['file1.conf', 'file2.conf']), 'touch file1.conf file2.conf')
272
+ expect_command(host.touch('file.conf', { atime: true, mtime: true, nofiles: true }), 'touch file.conf -a -m -c')
273
+ expect_command(host.touch('file.conf', { date: '2021-12-31' }), 'touch file.conf -d 2021-12-31')
274
+ expect_command(host.touch('file.conf', { reference: '~/otherfile.conf' }), 'touch file.conf -r ~/otherfile.conf')
275
+ end
276
+
277
+ it 'prepares unlink command' do
278
+ expect_command(host.unlink('/home/ubuntu/file1'), 'unlink /home/ubuntu/file1')
279
+ end
280
+
281
+ it 'prepares wc command' do
282
+ expect_command(host.wc('/var/log/syslog'), 'wc /var/log/syslog')
283
+ end
284
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::Group 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 create_group command' do
23
+ expect_command(host.create_group('admin'), 'groupadd admin')
24
+ expect_command(host.create_group('admin', { gid: 9000 }), 'groupadd admin -g 9000')
25
+ end
26
+
27
+ it 'prepares delete_group command' do
28
+ StubNetwork.stub_command!(:group?, { return_value: true })
29
+ expect_command(host.delete_group('admin'), 'groupdel admin')
30
+ StubNetwork.unstub_command!(:group?)
31
+ StubNetwork.stub_command!(:group?, { return_value: false })
32
+ expect(host.delete_group('admin')).to be_falsey
33
+ StubNetwork.unstub_command!(:group?)
34
+ end
35
+
36
+ it 'prepares get_gid command' do
37
+ expect_command(host.get_gid('ubuntu'), 'getent group ubuntu')
38
+ end
39
+
40
+ it 'prepares get_group command' do
41
+ expect_command(host.get_group('ubuntu'), 'getent group ubuntu | cut -d: -f4')
42
+ end
43
+
44
+ it 'prepares group? command' do
45
+ StubNetwork.stub_command!(:get_gid) do
46
+ 1000
47
+ end
48
+ expect(host).to be_group('ubuntu')
49
+ StubNetwork.unstub_command!(:get_gid)
50
+
51
+ StubNetwork.stub_command!(:get_gid, { status: 1 })
52
+ expect(host).not_to be_group('ubuntu')
53
+ StubNetwork.unstub_command!(:get_gid)
54
+ end
55
+
56
+ it 'prepares update_group command' do
57
+ expect_command(host.update_group('www-data', { gid: 34, new_name: 'web' }), 'groupmod www-data -g 34 -n web')
58
+ expect(host.update_group('www-data')).to be_nil
59
+ expect(host.update_group('www-data', { gid: 0, new_name: '' })).to be_nil
60
+ expect(host.update_group('www-data', { gid: '', new_name: 'test' })).to be_nil
61
+ end
62
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Core::IP 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
+ %w[addrlabel addrl].each do |object_variant|
23
+ context "with ip #{object_variant}" do
24
+ context 'with json support' do
25
+ before(:all) do
26
+ StubNetwork.stub_command!(:ip_version) do
27
+ Kanrisuru::Core::IP::IPROUTE2_JSON_VERSION
28
+ end
29
+ end
30
+
31
+ after(:all) do
32
+ StubNetwork.unstub_command!(:ip_version)
33
+ end
34
+
35
+ %w[show list].each do |action_variant|
36
+ it "prepares #{action_variant} command" do
37
+ expect_command(host.ip(object_variant, action_variant), 'ip -json addrlabel list')
38
+ end
39
+ end
40
+ end
41
+
42
+ context 'without json support' do
43
+ before(:all) do
44
+ StubNetwork.stub_command!(:ip_version) do
45
+ Kanrisuru::Core::IP::IPROUTE2_JSON_VERSION - 10
46
+ end
47
+ end
48
+
49
+ after(:all) do
50
+ StubNetwork.unstub_command!(:ip_version)
51
+ end
52
+
53
+ %w[show list].each do |action_variant|
54
+ it "prepares #{action_variant} command" do
55
+ expect_command(host.ip(object_variant, action_variant), 'ip addrlabel list')
56
+ end
57
+ end
58
+ end
59
+
60
+ it 'prepares flush command' do
61
+ expect_command(host.ip(object_variant, 'flush'), 'ip addrlabel flush')
62
+ end
63
+
64
+ it 'prepares add command' do
65
+ expect_command(host.ip(object_variant, 'add', {
66
+ prefix: '0.0.0.0/96',
67
+ dev: 'eno2',
68
+ label: 'eno2'
69
+ }), 'ip addrlabel add prefix 0.0.0.0/96 dev eno2 label eno2')
70
+ end
71
+
72
+ it 'prepares del command' do
73
+ expect_command(host.ip(object_variant, 'del', {
74
+ prefix: '0.0.0.0/96',
75
+ dev: 'eno2',
76
+ label: 'eno2'
77
+ }), 'ip addrlabel del prefix 0.0.0.0/96 dev eno2 label eno2')
78
+ end
79
+ end
80
+ end
81
+ end