inspec 0.21.1 → 0.21.2

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
  SHA1:
3
- metadata.gz: 1a6c7098d367a3d561834016a1bfdd60d23c1253
4
- data.tar.gz: da8753876169c48fbe087a1b16e92b13ab6185dd
3
+ metadata.gz: eb1998905015712a10ce6ed1acad4b930082e181
4
+ data.tar.gz: 360a2c3f273d67180ce48bd1d595dc21409bb20f
5
5
  SHA512:
6
- metadata.gz: b8adc2e483a203e77d2b0df1eb4d842570947474ca83e411967563e7f2e958d54f35733bda867586f28a472807e4dc5e851b81d0414e198788980d77a1241807
7
- data.tar.gz: ab9eb448c12955d4b2b633113616d90d44f3732b10f1c65e871b07df627fdf7892f3d6b2e67ead38164491c9d37a9f8338b57292a6370b4410387c41221c2149
6
+ metadata.gz: 50f86b7266afda06dc4109bf641129b3213d505f6ee198c807a657d38e32b5a909e044d55c0f1858c0b5332fe963d2df07153b387c0a06ed5b7e012346cd00c4
7
+ data.tar.gz: 891130c79cb1f3c38412c9dfabe3d646a07e23d4d1821c38067e1c3b1f568c9fcabe9945d297437ca223051566f547765c1d25b62900d19a3dc029ca09307509
data/CHANGELOG.md CHANGED
@@ -1,7 +1,19 @@
1
1
  # Change Log
2
2
 
3
- ## [0.21.1](https://github.com/chef/inspec/tree/0.21.1) (2016-05-10)
4
- [Full Changelog](https://github.com/chef/inspec/compare/v0.21.0...0.21.1)
3
+ ## [0.21.2](https://github.com/chef/inspec/tree/0.21.2) (2016-05-11)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.21.1...0.21.2)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Read SELinux labels for processes [\#726](https://github.com/chef/inspec/issues/726)
9
+ - Fix contain\_match, add none\_match [\#736](https://github.com/chef/inspec/pull/736) ([alexpop](https://github.com/alexpop))
10
+
11
+ **Fixed bugs:**
12
+
13
+ - Fix contain\\_match, add none\\_match [\#736](https://github.com/chef/inspec/pull/736) ([alexpop](https://github.com/alexpop))
14
+
15
+ ## [v0.21.1](https://github.com/chef/inspec/tree/v0.21.1) (2016-05-10)
16
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.21.0...v0.21.1)
5
17
 
6
18
  **Fixed bugs:**
7
19
 
data/docs/matchers.rst CHANGED
@@ -10,6 +10,7 @@ Inspec uses matchers to help compare resource values to expectations. The follow
10
10
  * `eq`
11
11
  * `include`
12
12
  * `match`
13
+ * Array matchers: `contain_match`, `all_match`, `none_match`, `contain_duplicates`
13
14
 
14
15
 
15
16
  be
@@ -135,3 +136,66 @@ Check if a string matches a regular expression.
135
136
  describe sshd_config do
136
137
  its('Ciphers') { should_not match /cbc/ }
137
138
  end
139
+
140
+
141
+ Array Matchers
142
+ =====================================================
143
+
144
+ The following matchers are designed to work with arrays:
145
+
146
+
147
+ contain_match
148
+ -----------------------------------------------------
149
+
150
+ Check if an array contains at least one item that matches the regex:
151
+
152
+ .. code-block:: ruby
153
+
154
+ describe ['lemon', 'ginger', 'grapes'] do
155
+ it { should contain_match /^gin/}
156
+ end
157
+ describe port(25) do
158
+ its('addresses') it { should_not contain_match /0\.0\.0\.0/}
159
+ end
160
+
161
+
162
+ all_match
163
+ -----------------------------------------------------
164
+
165
+ Check if all items of an array match the regex:
166
+
167
+ .. code-block:: ruby
168
+
169
+ describe ['grapefruit', 'grapes'] do
170
+ it { should all_match /^grape.+/}
171
+ end
172
+
173
+
174
+ none_match
175
+ -----------------------------------------------------
176
+
177
+ Check if all items of an array match the regex:
178
+
179
+ .. code-block:: ruby
180
+
181
+ describe ['ginger', 'grapefruit'] do
182
+ it { should none_match /^sugar$/}
183
+ end
184
+ describe port(25) do
185
+ its('addresses') it { should none_match /^0\.0\.0\.0$/ }
186
+ end
187
+
188
+
189
+ contain_duplicates
190
+ -----------------------------------------------------
191
+
192
+ Check if an array contains duplicate items:
193
+
194
+ .. code-block:: ruby
195
+
196
+ describe [80, 443, 80] do
197
+ it { should contain_duplicates }
198
+ end
199
+ describe ['ginger', 'grapefruit'] do
200
+ it { should_not contain_duplicates }
201
+ end
@@ -3,5 +3,5 @@
3
3
  # author: Christoph Hartmann
4
4
 
5
5
  module Inspec
6
- VERSION = '0.21.1'.freeze
6
+ VERSION = '0.21.2'.freeze
7
7
  end
@@ -74,26 +74,30 @@ RSpec::Matchers.define :contain_legacy_plus do
74
74
  end
75
75
  end
76
76
 
77
- # matcher to check that all entries match the regex
77
+ # verifies that all entries match the regex
78
78
  RSpec::Matchers.define :all_match do |regex|
79
79
  match do |arr|
80
- arr.all? { |element| element.match(regex) }
80
+ Array(arr).all? { |element| element.to_s.match(regex) }
81
+ end
82
+ end
83
+
84
+ # verifies that all entries don't match a regex
85
+ RSpec::Matchers.define :none_match do |regex|
86
+ match do |arr|
87
+ Array(arr).all? { |element| !element.to_s.match(regex) }
81
88
  end
82
89
  end
83
90
 
84
91
  # verifies that no entry in an array contains a value
85
92
  RSpec::Matchers.define :contain_match do |regex|
86
93
  match do |arr|
87
- arr.inject { |result, i|
88
- result = i.match(regex)
89
- result || i.match(/$/)
90
- }
94
+ Array(arr).one? { |element| element.to_s.match(regex) }
91
95
  end
92
96
  end
93
97
 
94
98
  RSpec::Matchers.define :contain_duplicates do
95
99
  match do |arr|
96
- dup = arr.select { |element| arr.count(element) > 1 }
100
+ dup = Array(arr).select { |element| arr.count(element) > 1 }
97
101
  !dup.uniq.empty?
98
102
  end
99
103
  end
@@ -1,9 +1,51 @@
1
1
  # encoding: utf-8
2
2
 
3
+ # 'all_match' matcher tests
3
4
  describe ['ananas', 'apples', 'oranges', 'air', 'alot'] do
4
- it { should all_match /[a]./}
5
+ it { should all_match /[a]./}
5
6
  end
7
+ describe ['ananas', 'apples', 'oranges', 'melons', 'air'] do
8
+ it { should_not all_match /[a]./}
9
+ end
10
+ describe [true, true, true] do
11
+ it { should all_match /^true$/}
12
+ end
13
+
14
+
15
+ # 'none_match' matcher tests
16
+ describe ['kiwi', 'avocado', 'grapefruit'] do
17
+ it { should none_match /xyz/}
18
+ end
19
+ describe ['kiwi', 'avocado', 'grapefruit'] do
20
+ it { should_not none_match /^avo/}
21
+ end
22
+ describe 999 do
23
+ it { should none_match /^666/}
24
+ end
25
+
6
26
 
7
- describe ['ananas', 'apples', 'oranges', 'air', 'melons'] do
8
- it { should_not all_match /[a]./}
27
+ # 'contain_match' matcher tests
28
+ describe ['lemon', 'ginger', 'grapes'] do
29
+ it { should contain_match /^gin/}
30
+ end
31
+ describe ['lemon', 'ginger', 'gra(pes'] do
32
+ it { should contain_match 'gra\(pe' }
33
+ end
34
+ describe ['lemon', 'ginger', 'grapes'] do
35
+ it { should_not contain_match /^chocolate/}
36
+ end
37
+ describe 'kiwi' do
38
+ it { should contain_match /^kiw/}
39
+ end
40
+
41
+
42
+ # 'contain_duplicates' matcher tests
43
+ describe ['onion', 'carrot', 'onion'] do
44
+ it { should contain_duplicates }
45
+ end
46
+ describe ['onion', 'carrot', 'brocoli'] do
47
+ it { should_not contain_duplicates }
48
+ end
49
+ describe [80, 443] do
50
+ it { should_not contain_duplicates }
9
51
  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: 0.21.1
4
+ version: 0.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: r-train