inspec 4.12.0 → 4.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,13 +13,15 @@ class PluginManagerCliOptions < Minitest::Test
13
13
 
14
14
  def test_list_args
15
15
  arg_config = cli_class.all_commands["list"].options
16
- assert_equal 1, arg_config.count, "The list command should have 1 option"
16
+ assert_equal 4, arg_config.count, "The list command should have 4 options"
17
17
 
18
- assert_includes arg_config.keys, :all, "The list command should have an --all option"
19
- assert_equal :boolean, arg_config[:all].type, "The --all option should be boolean"
20
- assert_equal :a, arg_config[:all].aliases.first, "The --all option should be aliased as -a"
21
- refute_nil arg_config[:all].description, "The --all option should have a description"
22
- refute arg_config[:all].required, "The --all option should not be required"
18
+ { u: :user, a: :all, c: :core, s: :system }.each do |abbrev, option|
19
+ assert_includes arg_config.keys, option, "The list command should have an --#{option} option"
20
+ assert_equal :boolean, arg_config[option].type, "The --#{option} option should be boolean"
21
+ assert_equal abbrev, arg_config[option].aliases.first, "The --#{option} option should be aliased as -#{abbrev}"
22
+ refute_nil arg_config[option].description, "The --#{option} option should have a description"
23
+ refute arg_config[option].required, "The --#{option} option should not be required"
24
+ end
23
25
 
24
26
  assert_equal 0, cli_class.instance_method(:list).arity, "The list command should take no arguments"
25
27
  end
@@ -40,25 +40,27 @@ module SourceReaders
40
40
  raise "Unable to parse #{metadata_source}: #{e.class} -- #{e.message}"
41
41
  end
42
42
 
43
+ def find_all(regexp)
44
+ @target.files.grep(regexp)
45
+ end
46
+
47
+ def load_all(regexp)
48
+ find_all(regexp)
49
+ .map { |path| file = @target.read(path); [path, file] if file }
50
+ .compact
51
+ .to_h
52
+ end
53
+
43
54
  def load_tests
44
- tests = @target.files.find_all do |path|
45
- path.start_with?("controls") && path.end_with?(".rb")
46
- end
47
- Hash[tests.map { |x| [x, @target.read(x)] }.delete_if { |_file, contents| contents.nil? }]
55
+ load_all(%r{^controls/.*\.rb$})
48
56
  end
49
57
 
50
58
  def load_libs
51
- tests = @target.files.find_all do |path|
52
- path.start_with?("libraries") && path.end_with?(".rb")
53
- end
54
- Hash[tests.map { |x| [x, @target.read(x)] }.delete_if { |_file, contents| contents.nil? }]
59
+ load_all(%r{^libraries/.*\.rb$})
55
60
  end
56
61
 
57
62
  def load_data_files
58
- files = @target.files.find_all do |path|
59
- path.start_with?("files" + File::SEPARATOR)
60
- end
61
- Hash[files.map { |x| [x, @target.read(x)] }.delete_if { |_file, contents| contents.nil? }]
63
+ load_all(%r{^files/})
62
64
  end
63
65
  end
64
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.0
4
+ version: 4.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-15 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train
@@ -589,6 +589,7 @@ files:
589
589
  - lib/inspec/resources/pip.rb
590
590
  - lib/inspec/resources/platform.rb
591
591
  - lib/inspec/resources/port.rb
592
+ - lib/inspec/resources/postfix_conf.rb
592
593
  - lib/inspec/resources/postgres.rb
593
594
  - lib/inspec/resources/postgres_conf.rb
594
595
  - lib/inspec/resources/postgres_hba_conf.rb