kanrisuru 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/kanrisuru.gemspec +7 -3
  4. data/lib/kanrisuru/command.rb +5 -1
  5. data/lib/kanrisuru/core/disk/commands/lsblk.rb +6 -11
  6. data/lib/kanrisuru/core/disk/constants.rb +9 -0
  7. data/lib/kanrisuru/core/disk/parser.rb +1 -0
  8. data/lib/kanrisuru/core/disk/parsers/lsblk_version.rb +21 -0
  9. data/lib/kanrisuru/core/disk.rb +1 -0
  10. data/lib/kanrisuru/core/dmi/commands/dmi.rb +1 -1
  11. data/lib/kanrisuru/core/file/commands/chmod.rb +1 -1
  12. data/lib/kanrisuru/core/file/commands/copy.rb +1 -3
  13. data/lib/kanrisuru/core/file/commands/mkdir.rb +11 -6
  14. data/lib/kanrisuru/core/file/commands/rm.rb +4 -1
  15. data/lib/kanrisuru/core/file/commands/touch.rb +2 -1
  16. data/lib/kanrisuru/core/system/commands/kill.rb +1 -1
  17. data/lib/kanrisuru/core/user/commands/create_user.rb +9 -17
  18. data/lib/kanrisuru/core/user/commands/delete_user.rb +1 -1
  19. data/lib/kanrisuru/core/user/commands/update_user.rb +14 -23
  20. data/lib/kanrisuru/result.rb +15 -0
  21. data/lib/kanrisuru/version.rb +1 -1
  22. data/spec/functional/core/archive_spec.rb +1 -1
  23. data/spec/functional/core/disk_spec.rb +77 -0
  24. data/spec/functional/core/dmi_spec.rb +78 -0
  25. data/spec/functional/core/file_spec.rb +284 -0
  26. data/spec/functional/core/group_spec.rb +62 -0
  27. data/spec/functional/core/system_spec.rb +135 -0
  28. data/spec/functional/core/user_spec.rb +97 -0
  29. data/spec/functional/result_spec.rb +91 -44
  30. data/spec/helper/stub_network.rb +6 -2
  31. data/spec/unit/command_spec.rb +2 -0
  32. data/spec/unit/core/ip_spec.rb +12 -0
  33. metadata +13 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e77a2eee0eb08495f947f9dc3b130a7c47cd713ab2f970dcc8fd17b7b52cd8b3
4
- data.tar.gz: 76d3ec684fe307aafce2f3be2c594f47a38c50f2b0bb394998c1c83c06d8a47b
3
+ metadata.gz: 7dcfedf8792427fccd9a7210d3f8dab6f95d2f1ba1b196ed90205c0d4a5b2c4f
4
+ data.tar.gz: 9e5d940a569f7b4c964aaf2a8869a07b4194a2aa9699dff9de780184403f65a2
5
5
  SHA512:
6
- metadata.gz: cdd8b0d400e2557525fca889bbd3ef8b8eef67774f0143ea925fa9c5ac091acabe2986de25d0f69a7005185425cf94edcd873b19cacbe56aa823c9c64fa607b3
7
- data.tar.gz: c1d802b26491e276ffbcdc3e3dd4e4272c9b48ab63a5e6b7283fb5e5f7b706ce64d5216728946aa3783f88396a0ec9a0582c045571cd78de050f42496479a392
6
+ metadata.gz: 8f90832958572df546c18e49f8354b3014dea58b780a4540bbd204196be96562652ea0768283912005aa025fc97a85d39ff9d96dd0c48f104f89bb10d086fb64
7
+ data.tar.gz: df414f1782efeb27eef49133c3af0c13e6966489adc19115403e3d78c69b6fe07aedaca8b21f78417bdd921860d455df9dbe7735823f2cdaeb427c55576e8a4d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## Kanrisuru 0.16.0 (December 14, 2021) ##
2
+ * Fix `append_array` for the `Kanrisuru::Command` class with negated check on Array type.
3
+ * Add `to_f` method for `Kanrisuru::Command` and `Kanrisuru::Result` with unit test cases.
4
+ * Refactor `lsblk_version` into seperate command namespace with it's own parser.
5
+ * Add functional test cases for several core modules.
6
+ * Add `return_value` option to `stub_command!` method for non-result return methods. These are few and far between, but need to be tested appropriately.
7
+ * Refactor several core modules with use of `command` calls for legibility.
8
+ * Fix several issues with `create_user`, `update_user`, and `delete_user`.
9
+
1
10
  ## Kanrisuru 0.15.0 (December 13, 2021) ##
2
11
  * Add opts for `ip` command.
3
12
  * Refactor `ip` object commands into smaller methods. Refactor `version` for consistent use and stub ability in funcitonal test cases.
data/kanrisuru.gemspec CHANGED
@@ -8,9 +8,12 @@ Gem::Specification.new do |gem|
8
8
  gem.author = 'Ryan Mammina'
9
9
  gem.email = 'ryan@avamia.com'
10
10
  gem.license = 'MIT'
11
- gem.summary = 'Manage remote servers over ssh with ruby.'
12
- gem.description = 'Kanrisuru helps manage remote servers with objected oriented ruby. Results come back as structured data, parsed, prepared and ready.'
13
11
  gem.homepage = 'https://github.com/avamia/kanrisuru'
12
+ gem.summary = 'Manage remote servers over ssh with ruby.'
13
+ gem.description = <<-EOF
14
+ Kanrisuru helps manage remote servers with objected oriented ruby.#{' '}
15
+ Results come back as structured data, parsed, prepared and ready.
16
+ EOF
14
17
 
15
18
  gem.required_ruby_version = '>= 2.5.0'
16
19
 
@@ -30,6 +33,7 @@ Gem::Specification.new do |gem|
30
33
 
31
34
  gem.metadata = {
32
35
  'source_code_uri' => 'https://github.com/avamia/kanrisuru/',
33
- 'changelog_uri' => 'https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md'
36
+ 'changelog_uri' => 'https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md',
37
+ 'rubygems_mfa_required' => 'true'
34
38
  }
35
39
  end
@@ -23,6 +23,10 @@ module Kanrisuru
23
23
  to_a.join.to_i
24
24
  end
25
25
 
26
+ def to_f
27
+ to_a.join.to_f
28
+ end
29
+
26
30
  def to_s
27
31
  to_a.join(' ')
28
32
  end
@@ -87,7 +91,7 @@ module Kanrisuru
87
91
  def append_array(value)
88
92
  return unless Kanrisuru::Util.present?(value)
89
93
 
90
- value = [value] if value.instance_of?(String)
94
+ value = [value] unless value.instance_of?(Array)
91
95
  append_value(value.join(' '))
92
96
  end
93
97
 
@@ -10,12 +10,12 @@ module Kanrisuru
10
10
 
11
11
  command = Kanrisuru::Command.new('lsblk')
12
12
 
13
- version = lsblk_version
13
+ version = lsblk_version.to_f
14
14
 
15
15
  ## lsblk after version 2.26 handles json parsing.
16
16
  ## TODO: parse nested children for earlier version of lsblk
17
- if version >= 2.27
18
- command.append_flag('--json') if version >= 2.27
17
+ if version >= LSBK_VERSION
18
+ command.append_flag('--json') if version >= LSBK_VERSION
19
19
  else
20
20
  command.append_flag('-i')
21
21
  command.append_flag('-P')
@@ -40,14 +40,9 @@ module Kanrisuru
40
40
  command = Kanrisuru::Command.new('lsblk --version')
41
41
  execute(command)
42
42
 
43
- version = 0.00
44
- regex = Regexp.new(/\d+(?:[,.]\d+)?/)
45
-
46
- raise 'lsblk command not found' if command.failure?
47
-
48
- version = command.to_s.scan(regex)[0].to_f unless regex.match(command.to_s).nil?
49
-
50
- version
43
+ Kanrisuru::Result.new(command) do |cmd|
44
+ Parser::LsblkVersion.parse(cmd)
45
+ end
51
46
  end
52
47
  end
53
48
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanrisuru
4
+ module Core
5
+ module Disk
6
+ LSBK_VERSION = 2.27
7
+ end
8
+ end
9
+ end
@@ -3,4 +3,5 @@
3
3
  require_relative 'parsers/blkid'
4
4
  require_relative 'parsers/df'
5
5
  require_relative 'parsers/du'
6
+ require_relative 'parsers/lsblk_version'
6
7
  require_relative 'parsers/lsblk'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanrisuru
4
+ module Core
5
+ module Disk
6
+ module Parser
7
+ class LsblkVersion
8
+ def self.parse(command)
9
+ version = 0.00
10
+ regex = Regexp.new(/\d+(?:[,.]\d+)?/)
11
+
12
+ raise 'lsblk command not found' if command.failure?
13
+
14
+ version = command.to_s.scan(regex)[0].to_f unless regex.match(command.to_s).nil?
15
+ version
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
 
5
+ require_relative 'disk/constants'
5
6
  require_relative 'disk/types'
6
7
  require_relative 'disk/parser'
7
8
  require_relative 'disk/commands'
@@ -20,7 +20,7 @@ module Kanrisuru
20
20
  return unless Kanrisuru::Util.present?(opts[:types])
21
21
 
22
22
  types = opts[:types]
23
- types = [types] if types.instance_of?(String)
23
+ types = [types] unless types.instance_of?(Array)
24
24
 
25
25
  types.each do |type|
26
26
  type = get_dmi_type(type)
@@ -7,7 +7,7 @@ module Kanrisuru
7
7
  recursive = opts[:recursive]
8
8
 
9
9
  command =
10
- if mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
10
+ if mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode)) && mode.length < 10
11
11
  Kanrisuru::Command.new("chmod #{mode} #{path}")
12
12
  elsif mode.instance_of?(Kanrisuru::Mode)
13
13
  Kanrisuru::Command.new("chmod #{mode.numeric} #{path}")
@@ -29,9 +29,7 @@ module Kanrisuru
29
29
  if opts[:preserve].instance_of?(TrueClass)
30
30
  command.append_flag('-p')
31
31
  elsif Kanrisuru::Util.present?(opts[:preserve])
32
- preserve =
33
- (opts[:preserve].join(',') if opts[:preserve].instance_of?(Array))
34
-
32
+ preserve = Kanrisuru::Util.array_join_string(opts[:preserve], ',')
35
33
  command << "--preserve=#{preserve}"
36
34
  end
37
35
 
@@ -8,16 +8,21 @@ module Kanrisuru
8
8
  group = opts[:group]
9
9
  recursive = opts[:recursive]
10
10
 
11
- command = Kanrisuru::Command.new("mkdir #{path}")
11
+ command = Kanrisuru::Command.new('mkdir')
12
+
13
+ command.append_array(path)
12
14
  command.append_flag('-p', opts[:silent])
13
15
 
14
16
  if Kanrisuru::Util.present?(opts[:mode])
15
17
  mode = opts[:mode]
16
- if mode.instance_of?(Kanrisuru::Mode)
17
- mode = mode.numeric
18
- elsif mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
19
- mode = Kanrisuru::Mode.new(mode).numeric
20
- end
18
+
19
+ mode = if mode.instance_of?(Kanrisuru::Mode)
20
+ mode.numeric
21
+ elsif mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
22
+ mode
23
+ else
24
+ Kanrisuru::Mode.new(mode).numeric
25
+ end
21
26
 
22
27
  command.append_arg('-m', mode)
23
28
  end
@@ -10,7 +10,10 @@ module Kanrisuru
10
10
  raise ArgumentError, "Can't delete root path" if path == '/' || realpath(path).path == '/'
11
11
  end
12
12
 
13
- command = Kanrisuru::Command.new("rm #{paths.join(' ')} --preserve-root")
13
+ command = Kanrisuru::Command.new('rm')
14
+ command.append_array(paths)
15
+
16
+ command.append_flag('--preserve-root')
14
17
  command.append_flag('-f', opts[:force])
15
18
  command.append_flag('-r', opts[:recursive])
16
19
 
@@ -7,7 +7,8 @@ module Kanrisuru
7
7
  date = opts[:date]
8
8
 
9
9
  paths = [paths] if paths.instance_of?(String)
10
- command = Kanrisuru::Command.new("touch #{paths.join(' ')}")
10
+ command = Kanrisuru::Command.new('touch')
11
+ command.append_array(paths)
11
12
 
12
13
  command.append_flag('-a', opts[:atime])
13
14
  command.append_flag('-m', opts[:mtime])
@@ -11,7 +11,7 @@ module Kanrisuru
11
11
 
12
12
  command = Kanrisuru::Command.new('kill')
13
13
  command << "-#{signal}"
14
- command << (pids.instance_of?(Array) ? pids.join(' ') : pids)
14
+ command.append_array(pids)
15
15
 
16
16
  execute_shell(command)
17
17
 
@@ -4,33 +4,25 @@ module Kanrisuru
4
4
  module Core
5
5
  module User
6
6
  def create_user(user, opts = {})
7
- uid = opts[:uid]
8
7
  group = opts[:group]
9
8
  groups = opts[:groups]
10
- home = opts[:home]
11
9
  shell = opts[:shell] || '/bin/false'
12
- createhome = opts[:createhome]
13
- system_opt = opts[:system]
14
- skeleton = opts[:skeleton]
15
- non_unique = opts[:non_unique]
16
- password = opts[:password]
17
- expires = opts[:expires] ## YYYY-MM-DD
18
10
 
19
11
  command = Kanrisuru::Command.new("useradd #{user}")
20
12
 
21
- if Kanrisuru::Util.present?(uid)
22
- command.append_arg('-u', uid)
23
- command.append_flag('-o', non_unique)
13
+ if Kanrisuru::Util.present?(opts[:uid])
14
+ command.append_arg('-u', opts[:uid])
15
+ command.append_flag('-o', opts[:non_unique])
24
16
  end
25
17
 
26
- command.append_flag('-r', system_opt)
18
+ command.append_flag('-r', opts[:system])
27
19
  command.append_arg('-s', shell)
28
- command.append_arg('-d', home)
20
+ command.append_arg('-d', opts[:home])
29
21
 
30
- case createhome
22
+ case opts[:createhome]
31
23
  when true
32
24
  command.append_flag('-m')
33
- command.append_arg('-k', skeleton)
25
+ command.append_arg('-k', opts[:skeleton])
34
26
  when false
35
27
  command.append_flag('-M')
36
28
  end
@@ -43,8 +35,8 @@ module Kanrisuru
43
35
 
44
36
  command.append_arg('-G', groups.join(',')) if Kanrisuru::Util.present?(groups)
45
37
 
46
- command.append_arg('-p', password)
47
- command.append_arg('-e', expires)
38
+ command.append_arg('-p', opts[:password])
39
+ command.append_arg('-e', opts[:expires]) ## YYYY-MM-DD
48
40
 
49
41
  execute_shell(command)
50
42
 
@@ -6,7 +6,7 @@ module Kanrisuru
6
6
  def delete_user(user, opts = {})
7
7
  force = opts[:force]
8
8
 
9
- return false unless get_uid(user)
9
+ return false if get_uid(user).failure?
10
10
 
11
11
  command = Kanrisuru::Command.new("userdel #{user}")
12
12
  command.append_flag('-f', force)
@@ -4,52 +4,43 @@ module Kanrisuru
4
4
  module Core
5
5
  module User
6
6
  def update_user(user, opts = {})
7
- uid = opts[:uid]
8
7
  group = opts[:group]
9
8
  groups = opts[:groups]
10
- append = opts[:append]
11
- home = opts[:home]
12
- move_home = opts[:move_home]
13
- shell = opts[:shell] || '/bin/false'
14
- non_unique = opts[:non_unique]
15
- password = opts[:password]
16
- expires = opts[:expires] ## YYYY-MM-DD
17
- locked = opts[:locked]
18
9
 
19
10
  command = Kanrisuru::Command.new("usermod #{user}")
20
11
 
21
- if Kanrisuru::Util.present?(home)
22
- command.append_arg('-d', home)
23
- command.append_flag('-m', move_home)
12
+ if Kanrisuru::Util.present?(opts[:home])
13
+ command.append_arg('-d', opts[:home])
14
+ command.append_flag('-m', opts[:move_home])
24
15
  end
25
16
 
26
- command.append_arg('-s', shell)
17
+ command.append_arg('-s', opts[:shell])
27
18
 
28
- if Kanrisuru::Util.present?(uid)
29
- command.append_arg('-u', uid)
30
- command.append_flag('-o', non_unique)
19
+ if Kanrisuru::Util.present?(opts[:uid])
20
+ command.append_arg('-u', opts[:uid])
21
+ command.append_flag('-o', opts[:non_unique])
31
22
  end
32
23
 
33
- command.append_arg('-g', group) if Kanrisuru::Util.present?(group) && group_exists?(group)
24
+ command.append_arg('-g', group) if Kanrisuru::Util.present?(group) && group?(group)
34
25
 
35
26
  if Kanrisuru::Util.present?(groups)
36
- command.append_arg('-G', groups.join(','))
37
- command.append_flag('-a', append)
27
+ command.append_arg('-G', Kanrisuru::Util.array_join_string(groups, ','))
28
+ command.append_flag('-a', opts[:append])
38
29
  end
39
30
 
40
- case locked
31
+ case opts[:locked]
41
32
  when true
42
33
  command.append_flag('-L')
43
34
  command.append_arg('-e', 1)
44
35
  when false
45
- command.append_arg('-U')
36
+ command.append_flag('-U')
46
37
  command.append_arg('-e', 99_999)
47
38
  else
48
39
  ## Ensure expires isn't added twice.
49
- command.append_arg('-e', expires)
40
+ command.append_arg('-e', opts[:expires]) ## YYYY-MM-DD
50
41
 
51
42
  ## Can't use password with lock / unlock flag.
52
- command.append_arg('-p', password)
43
+ command.append_arg('-p', opts[:password])
53
44
  end
54
45
 
55
46
  execute_shell(command)
@@ -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.15.0'
4
+ VERSION = '0.16.0'
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