chef-vault-testfixtures 3.0.1 → 3.1.1

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
- SHA1:
3
- metadata.gz: 5b67a15bc44d54b66d412102daff5375dce2631b
4
- data.tar.gz: 16857caafe5649a560f9efa01a359112133f41ea
2
+ SHA256:
3
+ metadata.gz: fe6b242f307f5eb4fef04ef2e138a65f565dbfa216950bb68969b7b833244bca
4
+ data.tar.gz: 7c834ba28e09914bcaa0c24e12410eb86b0ba4c27bdc7d82a70bd1f541f03a9b
5
5
  SHA512:
6
- metadata.gz: e15b9677e03bdbee6681eb40ed372924d5691d51960f4a8c6f7143e3c2a0891899e6ce267f7e6ca9b9acfc30dd95d712f00b2921c721e1b520437cd327b33bc6
7
- data.tar.gz: 96aa23c40db52eff0a6ecb3d74c6ced80c3f047ed7e8cf2c902fc72ced2c368b1362d604d402feb1ab3870dc55b27bd670e580ae751d817bf2b0425fd32f8eb7
6
+ metadata.gz: 3e423424fea8424e839016492fff5c1a3dd8c8fafd4f69785c1ebd19197bcff0a4b3c4d78cc3110354c69e717838f81933a7819f434f0ab1cafc830a8601858e
7
+ data.tar.gz: c7b3dbc4279422c0bbbb2ba15fdf0f80d5e510242d8c69577235164bd920310b88dd60c62df912a7869ed1f3bd75086c5edd2c55b2fd8cf5022940e272cdb84b
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  $:.unshift(File.dirname(__FILE__) + "/lib")
3
2
  require "chef-vault/test_fixtures_version"
4
3
 
@@ -9,28 +8,14 @@ Gem::Specification.new do |s|
9
8
  s.require_paths = ["lib"]
10
9
  s.authors = ["Thom May"]
11
10
  s.email = ["thom@chef.io"]
12
- s.extra_rdoc_files = ["History.md", "README.md"]
13
11
  s.homepage = "https://github.com/chef/chef-vault-testfixtures"
14
- s.files = `git ls-files`.split("\n")
12
+ s.files = %w{LICENSE} + Dir.glob("*.gemspec") + `git ls-files`.split("\n").select { |f| f =~ %r{^(?:bin/|lib/)}i }
15
13
  s.licenses = ["apache2"]
16
- s.rdoc_options = ["--main", "README.md"]
17
14
  s.summary = "chef-vault-testfixtures provides an RSpec shared context that stubs access to chef-vault encrypted data bags using the same fallback mechanism as the `chef_vault_item` helper from the [chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)"
18
15
  s.description = s.summary
19
- s.required_ruby_version = ">= 2.2.0"
16
+ s.required_ruby_version = ">= 2.5"
20
17
 
21
18
  s.add_runtime_dependency "rspec", "~> 3.4"
22
- s.add_runtime_dependency "chef-vault", "~> 3"
19
+ s.add_runtime_dependency "chef-vault", ">= 3", "< 5" # validate 5 if we release that
23
20
  s.add_runtime_dependency "hashie", "< 4.0", ">= 2.0"
24
- s.add_development_dependency "rdoc"
25
- s.add_development_dependency "chef", ">= 12.9"
26
- s.add_development_dependency "rake", "~> 11.0"
27
- s.add_development_dependency "guard"
28
- s.add_development_dependency "guard-rspec"
29
- s.add_development_dependency "guard-rake"
30
- s.add_development_dependency "guard-rubocop"
31
- s.add_development_dependency "chefspec"
32
- s.add_development_dependency "berkshelf"
33
- s.add_development_dependency "simplecov"
34
- s.add_development_dependency "simplecov-console"
35
- s.add_development_dependency "yard"
36
21
  end
@@ -44,8 +44,10 @@ class ChefVault
44
44
  smokedir = Pathname.new("test") + "smoke" + "default" + "data_bags"
45
45
  [ dbdir, smokedir ].each do |dir|
46
46
  next unless dir.directory?
47
+
47
48
  dir.each_child do |vault|
48
49
  next unless vault.directory?
50
+
49
51
  stub_vault(stub_encrypted_data, vault)
50
52
  end
51
53
  end
@@ -64,8 +66,10 @@ class ChefVault
64
66
  db = {}
65
67
  vault.each_child do |e|
66
68
  next unless e.file?
69
+
67
70
  m = e.basename.to_s.downcase.match(/(.+)\.json/i)
68
71
  next unless m
72
+
69
73
  content = JSON.parse(e.read)
70
74
  vaultname = vault.basename.to_s
71
75
  stub_vault_item(vaultname, m[1], content, db)
@@ -92,6 +96,7 @@ class ChefVault
92
96
  # stub vault lookup of each of the vault item keys
93
97
  content.each do |k, v|
94
98
  next if "id" == k
99
+
95
100
  allow(vi).to receive(:[]).with(k).and_return(v)
96
101
  end
97
102
 
@@ -135,6 +140,7 @@ class ChefVault
135
140
  dbi["raw_data"] = content
136
141
  content.each_key do |k|
137
142
  next if "id" == k
143
+
138
144
  dbi[k] = { "encrypted_data" => "..." }
139
145
  end
140
146
 
@@ -2,6 +2,6 @@ class ChefVault
2
2
  # dynamic RSpec contexts for cookbooks that use chef-vault
3
3
  class TestFixtures
4
4
  # the version of the gem
5
- VERSION = "3.0.1"
5
+ VERSION = "3.1.1".freeze
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-vault-testfixtures
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-04 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -28,204 +28,42 @@ dependencies:
28
28
  name: chef-vault
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '5'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '3'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '5'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: hashie
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "<"
46
- - !ruby/object:Gem::Version
47
- version: '4.0'
48
51
  - - ">="
49
52
  - !ruby/object:Gem::Version
50
53
  version: '2.0'
51
- type: :runtime
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
54
  - - "<"
56
55
  - !ruby/object:Gem::Version
57
56
  version: '4.0'
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '2.0'
61
- - !ruby/object:Gem::Dependency
62
- name: rdoc
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: chef
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '12.9'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '12.9'
89
- - !ruby/object:Gem::Dependency
90
- name: rake
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '11.0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '11.0'
103
- - !ruby/object:Gem::Dependency
104
- name: guard
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
- - !ruby/object:Gem::Dependency
118
- name: guard-rspec
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: '0'
131
- - !ruby/object:Gem::Dependency
132
- name: guard-rake
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '0'
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
- - !ruby/object:Gem::Dependency
146
- name: guard-rubocop
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- version: '0'
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: '0'
159
- - !ruby/object:Gem::Dependency
160
- name: chefspec
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - ">="
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- version: '0'
173
- - !ruby/object:Gem::Dependency
174
- name: berkshelf
175
- requirement: !ruby/object:Gem::Requirement
176
- requirements:
177
- - - ">="
178
- - !ruby/object:Gem::Version
179
- version: '0'
180
- type: :development
181
- prerelease: false
182
- version_requirements: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - ">="
185
- - !ruby/object:Gem::Version
186
- version: '0'
187
- - !ruby/object:Gem::Dependency
188
- name: simplecov
189
- requirement: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - ">="
192
- - !ruby/object:Gem::Version
193
- version: '0'
194
- type: :development
195
- prerelease: false
196
- version_requirements: !ruby/object:Gem::Requirement
197
- requirements:
198
- - - ">="
199
- - !ruby/object:Gem::Version
200
- version: '0'
201
- - !ruby/object:Gem::Dependency
202
- name: simplecov-console
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- version: '0'
208
- type: :development
57
+ type: :runtime
209
58
  prerelease: false
210
59
  version_requirements: !ruby/object:Gem::Requirement
211
60
  requirements:
212
61
  - - ">="
213
62
  - !ruby/object:Gem::Version
214
- version: '0'
215
- - !ruby/object:Gem::Dependency
216
- name: yard
217
- requirement: !ruby/object:Gem::Requirement
218
- requirements:
219
- - - ">="
220
- - !ruby/object:Gem::Version
221
- version: '0'
222
- type: :development
223
- prerelease: false
224
- version_requirements: !ruby/object:Gem::Requirement
225
- requirements:
226
- - - ">="
63
+ version: '2.0'
64
+ - - "<"
227
65
  - !ruby/object:Gem::Version
228
- version: '0'
66
+ version: '4.0'
229
67
  description: chef-vault-testfixtures provides an RSpec shared context that stubs access
230
68
  to chef-vault encrypted data bags using the same fallback mechanism as the `chef_vault_item`
231
69
  helper from the [chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)
@@ -233,59 +71,32 @@ email:
233
71
  - thom@chef.io
234
72
  executables: []
235
73
  extensions: []
236
- extra_rdoc_files:
237
- - History.md
238
- - README.md
74
+ extra_rdoc_files: []
239
75
  files:
240
- - ".gitignore"
241
- - ".rspec"
242
- - ".rubocop.yml"
243
- - ".travis.yml"
244
- - ".yardopts"
245
- - Berksfile
246
- - Berksfile.lock
247
- - Gemfile
248
- - Guardfile
249
- - History.md
250
- - README.md
251
- - Rakefile
252
- - TODO.md
76
+ - LICENSE
253
77
  - chef-vault-testfixtures.gemspec
254
78
  - lib/chef-vault/test_fixtures.rb
255
79
  - lib/chef-vault/test_fixtures_version.rb
256
- - spec/lib/chef-vault/test_fixtures_spec.rb
257
- - spec/recipes/test1_default_spec.rb
258
- - spec/spec_helper.rb
259
- - test/fixtures/cookbooks/test1/metadata.rb
260
- - test/fixtures/cookbooks/test1/recipes/default.rb
261
- - test/integration/data_bags/bar/foo.json
262
- - test/integration/data_bags/bar/gzonk.json
263
- - test/integration/data_bags/baz/wibble.json
264
- - test/integration/data_bags/foo/bar.json
265
- - test/smoke/default/data_bags/canteloupe/foo.json
266
80
  homepage: https://github.com/chef/chef-vault-testfixtures
267
81
  licenses:
268
82
  - apache2
269
83
  metadata: {}
270
84
  post_install_message:
271
- rdoc_options:
272
- - "--main"
273
- - README.md
85
+ rdoc_options: []
274
86
  require_paths:
275
87
  - lib
276
88
  required_ruby_version: !ruby/object:Gem::Requirement
277
89
  requirements:
278
90
  - - ">="
279
91
  - !ruby/object:Gem::Version
280
- version: 2.2.0
92
+ version: '2.5'
281
93
  required_rubygems_version: !ruby/object:Gem::Requirement
282
94
  requirements:
283
95
  - - ">="
284
96
  - !ruby/object:Gem::Version
285
97
  version: '0'
286
98
  requirements: []
287
- rubyforge_project:
288
- rubygems_version: 2.6.11
99
+ rubygems_version: 3.0.3
289
100
  signing_key:
290
101
  specification_version: 4
291
102
  summary: chef-vault-testfixtures provides an RSpec shared context that stubs access
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- doc/*
2
- coverage/*
3
- pkg/*
4
- .yardoc/*
5
- Gemfile.lock
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
@@ -1,15 +0,0 @@
1
- AllCops:
2
- Exclude:
3
- - '**/Gemfile'
4
- - '**/*.gemspec'
5
- - 'pkg/**/*'
6
-
7
- Style/RegexpLiteral:
8
- Exclude:
9
- - '**/Guardfile'
10
-
11
- Style/Documentation:
12
- Exclude:
13
- - 'spec/**/*.rb'
14
- - lib/chef-vault/test_fixtures/version.rb
15
- - lib/hoe/markdown.rb
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.3
4
- - 2.4.1
5
- install: bundle install --binstubs
6
- env: TRAVIS_BUILD=true
data/.yardopts DELETED
@@ -1,4 +0,0 @@
1
- -
2
- README.rdoc
3
- History.rdoc
4
- lib/**/*.rb
data/Berksfile DELETED
@@ -1,3 +0,0 @@
1
- source "https://supermarket.chef.io"
2
-
3
- cookbook "test1", path: "test/fixtures/cookbooks/test1"
@@ -1,6 +0,0 @@
1
- DEPENDENCIES
2
- test1
3
- path: test/fixtures/cookbooks/test1
4
-
5
- GRAPH
6
- test1 (0.0.0)
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org/'
2
-
3
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git"
4
-
5
- gemspec
data/Guardfile DELETED
@@ -1,17 +0,0 @@
1
- # prevent dropping into pry when nothing is happening
2
- interactor :off
3
-
4
- guard :rubocop, all_on_start: true, cli: ["-D"] do
5
- watch(%r{bin/.+$})
6
- watch(%r{.+\.rb$})
7
- watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
8
- watch("Gemfile")
9
- watch("Rakefile")
10
- end
11
-
12
- guard :rspec, all_on_start: true, cmd: "bundle exec rspec" do
13
- watch(%r{^spec/recipes/.+_spec\.rb$})
14
- watch(%r{^spec/(.+)_spec\.rb$})
15
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
16
- watch(%r{^spec/spec_helper.*\.rb$}) { "spec" }
17
- end
data/History.md DELETED
@@ -1,47 +0,0 @@
1
- # Changelog for chef-vault-testfixtures
2
-
3
- ## 0.5.1
4
-
5
- * Bump hashie dependency for compatibility with latest chefdk (Thanks to
6
- dougireton and dwmarshall)
7
-
8
- ## 0.5.0
9
-
10
- * breaking change: by default, only stub calls to `ChefVault::Item.load(bag, item)` and `Chef::DataBag.load(bag).key?(item_keys)`. This allows people who are using the JSON files in test/integration/data_bags to stub unencrypted data bag to do so. See the README for details of how to continue to stub `ChefVault::DataBagItem.load(bag, item)` and return a fake hash. Reported by [Dru Goradia](https://github.com/dgoradia-atlas))
11
-
12
- ## 0.4.1
13
-
14
- * fix bug where only the last item for a given vault was stubbed
15
-
16
- ## 0.4.0
17
-
18
- * add stubs for Chef::DataBagItem.load and Chef::DataBag.load for compatibility with code that probes the data bag to determine if it is a vault (e.g. chef-vault cookbook ~> 1.3)
19
-
20
- ## 0.3.0
21
-
22
- * completely re-work to use JSON data bag files in test/integration for compatibility with the fallback mechanism in the chef-vault cookbook
23
-
24
- ## 0.2.0
25
-
26
- * move chef dependency out of runtime and into development - rubygems 1.8.x (which chef-client shipped with prior to 11.8.0) has major problems now that Chef v11 and v12 are both available
27
-
28
- ## 0.1.3
29
-
30
- * change chef runtime dependency from >= 11.14 to >= 11.0
31
- * clean up some test ordering problems related to not clearing the blacklist properly
32
-
33
- ## 0.1.2
34
-
35
- * allow access to the data bag via the symbol form as well as the string form
36
- * re-organize the README to make the summary extracted by Hoe smaller
37
- * add Travis-CI integration and badging
38
- * add Code Climate integration and badging
39
-
40
- ## 0.1.1
41
-
42
- * fix disconnect between docs and code for shared context method
43
- * remove Hoe test plugin so we don't double up on test runs
44
-
45
- ## 0.1.0
46
-
47
- * initial version
data/README.md DELETED
@@ -1,203 +0,0 @@
1
- # chef-vault-testfixtures
2
-
3
- * home :: https://github.com/chef/chef-vault-testfixtures
4
- * license :: [Apache2](http://www.apache.org/licenses/LICENSE-2.0)
5
- * gem version :: [![Gem Version](https://badge.fury.io/rb/chef-vault-testfixtures.png)](http://badge.fury.io/rb/chef-vault-testfixtures)
6
- * build status :: [![Build Status](https://travis-ci.org/chef/chef-vault-testfixtures.png?branch=master)](https://travis-ci.org/chef/chef-vault-testfixtures)
7
- * code climate :: [![Code Climate](https://codeclimate.com/github/chef/chef-vault-testfixtures/badges/gpa.svg)](https://codeclimate.com/github/chef/chef-vault-testfixtures)
8
-
9
- ## DESCRIPTION
10
-
11
- chef-vault-testfixtures provides an RSpec shared context that
12
- stubs access to chef-vault encrypted data bags using the same
13
- fallback mechanism as the `chef_vault_item` helper from the
14
- [chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)
15
-
16
- ## USAGE
17
-
18
- [chef-vault](https://github.com/chef/chef-vault) is a gem to manage
19
- distribution and control of keys to decrypt Chef encrypted data bags.
20
-
21
- When testing a cookbook that uses chef-vault, encryption is generally
22
- out of scope, which results in a large number of stubs or mocks so that
23
- you can get back fixture data without performing decryption.
24
-
25
- Chef created the [chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)
26
- to make integration testing easier. If you use the `chef_vault_item`
27
- helper provided by that cookbook, then failing to load the vault
28
- causes the helper to fall back to a normal JSON data bag in the
29
- directory `test/integration/data_bags`.
30
-
31
- This gem makes the unit test side of cookbook testing with ChefSpec
32
- easier by dynamically stubbing attempts to access vault data to
33
- use the same JSON data bags as the helper. This allows you to provide
34
- one source of stubbing data that works for both unit and integration
35
- test.
36
-
37
- ## USAGE
38
-
39
- In the file `test/integration/data_bags/foo/bar.json`:
40
-
41
- { "password": "sekrit" }
42
-
43
- In your cookbook Gemfile:
44
-
45
- gem 'chef-vault-testfixtures', '~> 0.3'
46
-
47
- In your cookbook `spec/spec_helper.rb`:
48
-
49
- require 'chef-vault/test_fixtures'
50
-
51
- In a cookbook example:
52
-
53
- RSpec.describe 'my_cookbook::default' do
54
- include ChefVault::TestFixtures.rspec_shared_context
55
-
56
- let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '16.04')
57
- .converge(described_recipe) }
58
-
59
- it 'should converge' do
60
- expect(chef_run).to include_recipe(described_recipe)
61
- end
62
- end
63
-
64
- The recipe that the example tests:
65
-
66
- include_recipe 'chef-vault'
67
- item = chef_vault_item('foo', 'bar')
68
- file '/tmp/foo' do
69
- contents item['password']
70
- end
71
-
72
- The helper will call `ChefVault::Item.load`, which will be stubbed using
73
- the data bag from the test/integration/data_bags directory.
74
-
75
- ## VAULT PROBING
76
-
77
- Some recipes and helpers attempt to determine if a data bag is a vault
78
- by checking the raw data bag item to see if one of the values contains
79
- encrypted data, then checking for the existence of the `_keys` data bag
80
- item to go along with the normal item. The [sensu cookbook](https://github.com/sensu/sensu-chef/blob/35ee3aa6fa4ad578cdf751fe6822e3d2b3890d94/libraries/sensu_helpers.rb#L39-55) is a good example
81
- of this:
82
-
83
- ```
84
- raw_hash = Chef::DataBagItem.load(data_bag_name, item)
85
- encrypted = raw_hash.detect do |key, value|
86
- if value.is_a?(Hash)
87
- value.has_key?("encrypted_data")
88
- end
89
- end
90
- if encrypted
91
- if Chef::DataBag.load(data_bag_name).key? "#{item}_keys"
92
- chef_vault_item(data_bag_name, item)
93
- else
94
- secret = Chef::EncryptedDataBagItem.load_secret
95
- Chef::EncryptedDataBagItem.new(raw_hash, secret)
96
- end
97
- else
98
- raw_hash
99
- end
100
- ```
101
-
102
- chef-vault-testfixtures also stubs `Chef::DataBag` so that for every JSON
103
- file in your test directory, it will think that there is a side-along
104
- item suffixed with `_keys`. This satisfies the probes that the chef-vault
105
- cookbook helper uses. To address the check for the `encrypted_data` key
106
- that the sensu cookbook uses, pass a true value to `rspec_shared_context`:
107
-
108
- ```
109
- RSpec.describe 'my_cookbook::default' do
110
- include ChefVault::TestFixtures.rspec_shared_context(true)
111
- end
112
- ```
113
-
114
- Now, when your recipe calls `Chef::DataBagItem.load`, it will
115
- get back a hash with the same keys as the JSON file, but values which are
116
- hashes of the form:
117
-
118
- ```
119
- {
120
- encrypted_data => '...'
121
- }
122
- ```
123
-
124
- This is not a valid data bag obviously, but it will satisfy the probe
125
- and cause code like that in the sensu cookbook to call `ChefVault::Item.load`,
126
- which is stubbed to return valid data.
127
-
128
- ## STUBBING UNENCRYPTED DATA BAGS
129
-
130
- This technique is not a part of this gem, but was brought to my attention
131
- in an issue. Credit to Dru Goradia for the approach. This will let you
132
- populate an unencrypted data bag from the same JSON files:
133
-
134
- In `spec/spec_helper.rb`:
135
-
136
- ```
137
- require 'chef-vault/test_fixtures'
138
- require 'json'
139
-
140
- def parse_data_bag (path)
141
- data_bags_path = File.expand_path(File.join(File.dirname(__FILE__), '../test/integration/data_bags'))
142
- return JSON.parse(File.read("#{data_bags_path}/#{path}"))
143
- end
144
- ```
145
-
146
- In your test:
147
-
148
- ```
149
- describe 'my_cookbook::default' do
150
- include ChefVault::TestFixtures.rspec_shared_context
151
-
152
- let(:chef_run) do
153
- ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node, server|
154
- server.create_data_bag('foo', {
155
- 'bar' => parse_data_bag('foo/bar.json')
156
- })
157
- end.converge(described_recipe)
158
- end
159
-
160
- it 'should converge' do
161
- expect(chef_run).to include_recipe(described_recipe)
162
- end
163
- end
164
- ```
165
-
166
- ## DEPENDENCIES
167
-
168
- It may seem strange that chef isn't a runtime dependency of this gem.
169
- This is due to idiosyncracies in the way that old versions of rubygems
170
- (such as those that ship with chef-client prior to 11.18.0) process
171
- dependencies.
172
-
173
- If we include chef as a dependency, even with a relaxed requirement
174
- like '>= 11.0', rubygems v1.8.x will still try to pull in chef-12.0.3,
175
- even if the --conservative switch is used. This in turn pulls in
176
- Ohai 8.1.x, which doesn't work under Ruby 1.9.3 (which is what chef-client
177
- 11 embeds).
178
-
179
- rubygems v2.x.x do not suffer from this problem. The net takeaway is that
180
- attempting to install this gem on a system that does not have chef installed
181
- will fail. I expect the instances of people trying to do this to be
182
- small.
183
-
184
- ## AUTHOR
185
-
186
- James FitzGibbon - james.i.fitzgibbon@nordstrom.com - @jf647
187
-
188
- ## LICENSE
189
-
190
- Copyright 2015 Nordstrom, Inc.
191
- Copyright 2016 Chef Software, Inc.
192
-
193
- Licensed under the Apache License, Version 2.0 (the "License");
194
- you may not use this file except in compliance with the License.
195
- You may obtain a copy of the License at
196
-
197
- http://www.apache.org/licenses/LICENSE-2.0
198
-
199
- Unless required by applicable law or agreed to in writing, software
200
- distributed under the License is distributed on an "AS IS" BASIS,
201
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
- See the License for the specific language governing permissions and
203
- limitations under the License.
data/Rakefile DELETED
@@ -1,56 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "chef-vault/test_fixtures"
3
-
4
- # Style Tests
5
- begin
6
- require "chefstyle"
7
- require "rubocop/rake_task"
8
- RuboCop::RakeTask.new do |t|
9
- t.formatters = ["progress"]
10
- t.options = ["-D"]
11
- t.patterns = %w{
12
- bin/*
13
- lib/**/*.rb
14
- spec/**/*.rb
15
- ./Rakefile
16
- }
17
- end
18
- desc "Run Style Tests"
19
- task style: [:rubocop]
20
- rescue LoadError
21
- puts "rubocop not available; disabling tasks"
22
- end
23
-
24
- # Unit Tests
25
- begin
26
- require "rspec/core/rake_task"
27
- RSpec::Core::RakeTask.new
28
-
29
- # Coverage
30
- desc "Generate unit test coverage report"
31
- task :coverage do
32
- ENV["COVERAGE"] = "true"
33
- Rake::Task[:test].invoke
34
- end
35
-
36
- # test is an alias for spec
37
- desc "runs unit tests"
38
- task test: :spec
39
-
40
- # default is to test everything
41
- desc "runs all tests"
42
- task default: :test
43
- rescue LoadError
44
- puts "rspec not available; disabling tasks"
45
- end
46
-
47
- # Documentation
48
- begin
49
- require "yard"
50
- require "yard/rake/yardoc_task"
51
- YARD::Rake::YardocTask.new(:doc) do |t|
52
- t.stats_options = ["--list-undoc"]
53
- end
54
- rescue LoadError
55
- puts "yard not available; disabling tasks"
56
- end
data/TODO.md DELETED
@@ -1,6 +0,0 @@
1
- # TODO for chef-vault-testfixtures
2
-
3
- * make directory to load vaults from configurable
4
- * provide mechanism for limiting which vaults are loaded
5
- * provide mechanism to clear singleton
6
- * eventually, integrate into the chef-vault gem
@@ -1,87 +0,0 @@
1
- require "chef-vault/test_fixtures"
2
-
3
- RSpec.describe ChefVault::TestFixtures do
4
- describe "without the encrypted_data stub" do
5
- ChefVault::TestFixtures.clear_context
6
- include ChefVault::TestFixtures.rspec_shared_context(false)
7
-
8
- it "can create an RSpec shared context" do
9
- sc = ChefVault::TestFixtures.rspec_shared_context
10
- expect(sc).to be_a(Module)
11
- expect(sc).to be_a(RSpec::Core::SharedContext)
12
- end
13
-
14
- it "should only create one shared context" do
15
- mod1 = ChefVault::TestFixtures.rspec_shared_context
16
- mod2 = ChefVault::TestFixtures.rspec_shared_context
17
- expect(mod2).to be(mod1)
18
- end
19
-
20
- it "should stub the foo/bar vault item" do
21
- baz = ChefVault::Item.load("foo", "bar")["baz"]
22
- expect(baz).to eq(2)
23
- end
24
-
25
- it "should allow access to foo/bar via a symbol instead of a string" do
26
- baz = ChefVault::Item.load(:foo, "bar")["baz"]
27
- expect(baz).to eq(2)
28
- end
29
-
30
- it "should stub the bar/foo vault item" do
31
- baz = ChefVault::Item.load("bar", "foo")["baz"]
32
- expect(baz).to eq(1)
33
- end
34
-
35
- it "should allow access to the bar/gzonk vault item" do
36
- item1 = ChefVault::Item.load("bar", "foo")
37
- item2 = ChefVault::Item.load("bar", "gzonk")
38
- expect(item1["baz"]).to eq(item2["baz"])
39
- end
40
-
41
- it "should allow access to the bar/gzonk vault item via a symbol" do
42
- item1 = ChefVault::Item.load(:bar, "foo")
43
- item2 = ChefVault::Item.load(:bar, "gzonk")
44
- expect(item1["baz"]).to eq(item2["baz"])
45
- end
46
-
47
- it "should check both smoke and integration for a vault" do
48
- item = ChefVault::Item.load("canteloupe", "foo")
49
- item["cat"] == "cat"
50
- end
51
-
52
- it "should allow and ignore an attempt to change a vault" do
53
- item = ChefVault::Item.load("bar", "foo")
54
- item["foo"] = "foo"
55
- end
56
-
57
- it "should allow and ignore an attempt to set the clients" do
58
- item = ChefVault::Item.load("bar", "foo")
59
- item.clients("*:*")
60
- end
61
-
62
- it "should allow and ignore an attempt to save" do
63
- item = ChefVault::Item.load("bar", "foo")
64
- item.save
65
- end
66
-
67
- it "should stub the _keys data bag item" do
68
- db = Chef::DataBag.load("foo")
69
- expect(db.key?("bar_keys")).to be_truthy
70
- end
71
- end
72
- end
73
-
74
- RSpec.describe ChefVault::TestFixtures do
75
- describe "with the encrypted_data stub" do
76
- ChefVault::TestFixtures.clear_context
77
- include ChefVault::TestFixtures.rspec_shared_context(true)
78
-
79
- it "should present the foo/bar data bag item as encrypted" do
80
- dbi = Chef::DataBagItem.load("foo", "bar")
81
- encrypted = dbi.detect do |_, v|\
82
- v.is_a?(Hash) && v.key?("encrypted_data")
83
- end
84
- expect(encrypted).to be_truthy
85
- end
86
- end
87
- end
@@ -1,35 +0,0 @@
1
- require "chefspec"
2
- require "chefspec/berkshelf"
3
- require "chef-vault/test_fixtures"
4
-
5
- def parse_data_bag(path)
6
- data_bags_path = File.expand_path(
7
- File.join(File.dirname(__FILE__), "../../test/integration/data_bags")
8
- )
9
- JSON.parse(File.read("#{data_bags_path}/#{path}"))
10
- end
11
-
12
- RSpec.describe "test1::default" do
13
- ChefVault::TestFixtures.clear_context
14
- include ChefVault::TestFixtures.rspec_shared_context(false)
15
-
16
- let(:chef_run) do
17
- ChefSpec::ServerRunner.new(platform: "ubuntu", version: "16.04") do |_, server|
18
- server.create_data_bag(
19
- "baz", "wibble" => parse_data_bag("baz/wibble.json")
20
- )
21
- end.converge(described_recipe)
22
- end
23
-
24
- it "should converge" do
25
- expect(chef_run).to include_recipe(described_recipe)
26
- end
27
-
28
- it "should have the right value for the unencrypted data bag item" do
29
- expect(chef_run.node.run_state["dbi_wibble"]["wibble"]).to eq(3)
30
- end
31
-
32
- it "should have the right value for the encrypted data bag item" do
33
- expect(chef_run.node.run_state["foo"]["baz"]).to eq(4)
34
- end
35
- end
@@ -1,34 +0,0 @@
1
- if ENV["COVERAGE"]
2
- require "simplecov"
3
- require "simplecov-console"
4
- SimpleCov.formatters = [
5
- SimpleCov::Formatter::HTMLFormatter,
6
- SimpleCov::Formatter::Console,
7
- ]
8
- SimpleCov.start
9
- end
10
-
11
- RSpec.configure do |config|
12
- config.expect_with :rspec do |expectations|
13
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
14
- end
15
-
16
- config.mock_with :rspec do |mocks|
17
- mocks.verify_partial_doubles = true
18
- end
19
-
20
- config.disable_monkey_patching!
21
- config.order = :random
22
- Kernel.srand config.seed
23
- end
24
-
25
- # a helper to clear the context between examples
26
- class ChefVault
27
- class TestFixtures
28
- class << self
29
- def clear_context
30
- @context = nil
31
- end
32
- end
33
- end
34
- end
@@ -1,2 +0,0 @@
1
- name "test1"
2
- version "0.0.0"
@@ -1,9 +0,0 @@
1
- node.run_state["dbi_wibble"] = data_bag_item("baz", "wibble")
2
-
3
- vault_item = ChefVault::Item.load("foo", "bar")
4
- unless vault_item.to_h.empty?
5
- node.run_state["foo"] = {}
6
- vault_item.to_h.each do |key, val|
7
- node.run_state["foo"][key] = val * 2
8
- end
9
- end
@@ -1,3 +0,0 @@
1
- {
2
- "baz": 1
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "baz": 1
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "wibble": 3
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "baz": 2
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "cat": "cat"
3
- }