chef-vault-testfixtures 0.5.0 → 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: 644e9c5bbb5372faf29af5d11bc7d7580d07fdca
4
- data.tar.gz: 42a949fc8bea10c3a4f3d6b63f2a4d811110a7ce
2
+ SHA256:
3
+ metadata.gz: fe6b242f307f5eb4fef04ef2e138a65f565dbfa216950bb68969b7b833244bca
4
+ data.tar.gz: 7c834ba28e09914bcaa0c24e12410eb86b0ba4c27bdc7d82a70bd1f541f03a9b
5
5
  SHA512:
6
- metadata.gz: 5e2eb02210c2483adb5a57e12f0ba1e879eb9fc1aa6f89fd2771e165081dae3b50adc2ac5244b81c848ac7244a5b085deb96a50a505e7384117410ac9015ff91
7
- data.tar.gz: 0d9d7006e1a92c22993a1b130e275f24521399de3ab84728403a2a12e000929c53a0a6bef3811f17ccbc98ecc27dddec89e19178eb89642cb78f5ac3d71b6fef
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,84 +1,21 @@
1
- # -*- encoding: utf-8 -*-
2
- # stub: chef-vault-testfixtures 0.4.2.20150505160823 ruby lib
1
+ $:.unshift(File.dirname(__FILE__) + "/lib")
2
+ require "chef-vault/test_fixtures_version"
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = "chef-vault-testfixtures"
6
- s.version = "0.4.2.20150505160823"
5
+ s.name = "chef-vault-testfixtures"
6
+ s.version = ChefVault::TestFixtures::VERSION
7
7
 
8
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
- s.require_paths = ["lib"]
10
- s.authors = ["James FitzGibbon"]
11
- s.date = "2015-05-05"
12
- s.description = "chef-vault-testfixtures provides an RSpec shared context that\nstubs access to chef-vault encrypted data bags using the same\nfallback mechanism as the `chef_vault_item` helper from the\n[chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)"
13
- s.email = ["james.i.fitzgibbon@nordstrom.com"]
14
- s.extra_rdoc_files = ["History.md", "Manifest.txt", "README.md"]
15
- s.files = [".rspec", ".rubocop.yml", ".yardopts", "Gemfile", "Guardfile", "History.md", "Manifest.txt", "README.md", "Rakefile", "chef-vault-testfixtures.gemspec", "lib/chef-vault/test_fixtures.rb", "lib/hoe/markdown.rb", "spec/lib/chef-vault/test_fixtures_spec.rb", "spec/spec_helper.rb"]
16
- s.homepage = "https://github.com/Nordstrom/chef-vault-testfixtures"
17
- s.licenses = ["apache2"]
18
- s.rdoc_options = ["--main", "README.md"]
19
- s.rubygems_version = "2.4.4"
20
- 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)"
8
+ s.require_paths = ["lib"]
9
+ s.authors = ["Thom May"]
10
+ s.email = ["thom@chef.io"]
11
+ s.homepage = "https://github.com/chef/chef-vault-testfixtures"
12
+ s.files = %w{LICENSE} + Dir.glob("*.gemspec") + `git ls-files`.split("\n").select { |f| f =~ %r{^(?:bin/|lib/)}i }
13
+ s.licenses = ["apache2"]
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)"
15
+ s.description = s.summary
16
+ s.required_ruby_version = ">= 2.5"
21
17
 
22
- if s.respond_to? :specification_version then
23
- s.specification_version = 4
24
-
25
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<rspec>, ["~> 3.1"])
27
- s.add_runtime_dependency(%q<chef-vault>, ["~> 2.5"])
28
- s.add_runtime_dependency(%q<hashie>, ["~> 2.1"])
29
- s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
30
- s.add_development_dependency(%q<chef>, ["~> 12.0"])
31
- s.add_development_dependency(%q<hoe>, ["~> 3.13"])
32
- s.add_development_dependency(%q<hoe-gemspec>, ["~> 1.0"])
33
- s.add_development_dependency(%q<rake>, ["~> 10.3"])
34
- s.add_development_dependency(%q<guard>, ["~> 2.12"])
35
- s.add_development_dependency(%q<guard-rspec>, ["~> 4.2"])
36
- s.add_development_dependency(%q<guard-rake>, ["~> 0.0"])
37
- s.add_development_dependency(%q<guard-rubocop>, ["~> 1.2"])
38
- s.add_development_dependency(%q<chefspec>, ["~> 4.2"])
39
- s.add_development_dependency(%q<berkshelf>, ["~> 3.2"])
40
- s.add_development_dependency(%q<rubocop>, ["~> 0.29"])
41
- s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
42
- s.add_development_dependency(%q<simplecov-console>, ["~> 0.2"])
43
- s.add_development_dependency(%q<yard>, ["~> 0.8"])
44
- else
45
- s.add_dependency(%q<rspec>, ["~> 3.1"])
46
- s.add_dependency(%q<chef-vault>, ["~> 2.5"])
47
- s.add_dependency(%q<hashie>, ["~> 2.1"])
48
- s.add_dependency(%q<rdoc>, ["~> 4.0"])
49
- s.add_dependency(%q<chef>, ["~> 12.0"])
50
- s.add_dependency(%q<hoe>, ["~> 3.13"])
51
- s.add_dependency(%q<hoe-gemspec>, ["~> 1.0"])
52
- s.add_dependency(%q<rake>, ["~> 10.3"])
53
- s.add_dependency(%q<guard>, ["~> 2.12"])
54
- s.add_dependency(%q<guard-rspec>, ["~> 4.2"])
55
- s.add_dependency(%q<guard-rake>, ["~> 0.0"])
56
- s.add_dependency(%q<guard-rubocop>, ["~> 1.2"])
57
- s.add_dependency(%q<chefspec>, ["~> 4.2"])
58
- s.add_dependency(%q<berkshelf>, ["~> 3.2"])
59
- s.add_dependency(%q<rubocop>, ["~> 0.29"])
60
- s.add_dependency(%q<simplecov>, ["~> 0.9"])
61
- s.add_dependency(%q<simplecov-console>, ["~> 0.2"])
62
- s.add_dependency(%q<yard>, ["~> 0.8"])
63
- end
64
- else
65
- s.add_dependency(%q<rspec>, ["~> 3.1"])
66
- s.add_dependency(%q<chef-vault>, ["~> 2.5"])
67
- s.add_dependency(%q<hashie>, ["~> 2.1"])
68
- s.add_dependency(%q<rdoc>, ["~> 4.0"])
69
- s.add_dependency(%q<chef>, ["~> 12.0"])
70
- s.add_dependency(%q<hoe>, ["~> 3.13"])
71
- s.add_dependency(%q<hoe-gemspec>, ["~> 1.0"])
72
- s.add_dependency(%q<rake>, ["~> 10.3"])
73
- s.add_dependency(%q<guard>, ["~> 2.12"])
74
- s.add_dependency(%q<guard-rspec>, ["~> 4.2"])
75
- s.add_dependency(%q<guard-rake>, ["~> 0.0"])
76
- s.add_dependency(%q<guard-rubocop>, ["~> 1.2"])
77
- s.add_dependency(%q<chefspec>, ["~> 4.2"])
78
- s.add_dependency(%q<berkshelf>, ["~> 3.2"])
79
- s.add_dependency(%q<rubocop>, ["~> 0.29"])
80
- s.add_dependency(%q<simplecov>, ["~> 0.9"])
81
- s.add_dependency(%q<simplecov-console>, ["~> 0.2"])
82
- s.add_dependency(%q<yard>, ["~> 0.8"])
83
- end
18
+ s.add_runtime_dependency "rspec", "~> 3.4"
19
+ s.add_runtime_dependency "chef-vault", ">= 3", "< 5" # validate 5 if we release that
20
+ s.add_runtime_dependency "hashie", "< 4.0", ">= 2.0"
84
21
  end
@@ -1,18 +1,17 @@
1
- require 'pathname'
2
- require 'json'
3
- require 'hashie/extensions/method_access'
1
+ require "pathname"
2
+ require "json"
3
+ require "hashie/extensions/method_access"
4
4
 
5
- require 'rspec'
6
- require 'rspec/core/shared_context'
7
- require 'chef-vault'
5
+ require "rspec"
6
+ require "rspec/core/shared_context"
7
+ require "chef-vault"
8
+
9
+ require "chef-vault/test_fixtures_version"
8
10
 
9
11
  # chef-vault helps manage encrypted data bags using a node's public key
10
12
  class ChefVault
11
13
  # dynamic RSpec contexts for cookbooks that use chef-vault
12
14
  class TestFixtures
13
- # the version of the gem
14
- VERSION = '0.5.0'
15
-
16
15
  # dynamically creates a memoized RSpec shared context
17
16
  # that when included into an example group will stub
18
17
  # ChefVault::Item for each of the defined vaults. The
@@ -41,10 +40,16 @@ class ChefVault
41
40
  # return [void]
42
41
  # @api private
43
42
  def find_vaults(stub_encrypted_data)
44
- dbdir = Pathname.new('test') + 'integration' + 'data_bags'
45
- dbdir.each_child do |vault|
46
- next unless vault.directory?
47
- stub_vault(stub_encrypted_data, vault)
43
+ dbdir = Pathname.new("test") + "integration" + "data_bags"
44
+ smokedir = Pathname.new("test") + "smoke" + "default" + "data_bags"
45
+ [ dbdir, smokedir ].each do |dir|
46
+ next unless dir.directory?
47
+
48
+ dir.each_child do |vault|
49
+ next unless vault.directory?
50
+
51
+ stub_vault(stub_encrypted_data, vault)
52
+ end
48
53
  end
49
54
  end
50
55
 
@@ -61,8 +66,10 @@ class ChefVault
61
66
  db = {}
62
67
  vault.each_child do |e|
63
68
  next unless e.file?
69
+
64
70
  m = e.basename.to_s.downcase.match(/(.+)\.json/i)
65
71
  next unless m
72
+
66
73
  content = JSON.parse(e.read)
67
74
  vaultname = vault.basename.to_s
68
75
  stub_vault_item(vaultname, m[1], content, db)
@@ -88,13 +95,22 @@ class ChefVault
88
95
 
89
96
  # stub vault lookup of each of the vault item keys
90
97
  content.each do |k, v|
91
- next if 'id' == k
98
+ next if "id" == k
99
+
92
100
  allow(vi).to receive(:[]).with(k).and_return(v)
93
101
  end
94
102
 
103
+ # stub hash conversion as a stopgap to other hash methods
104
+ allow(vi).to receive(:to_h).with(no_args).and_return(content)
105
+ allow(vi).to receive(:to_hash).with(no_args).and_return(content)
106
+
95
107
  # stub ChefVault and Chef::DataBag to return the doubles
96
108
  # via both symbol and string forms of the data bag name
97
109
  [vault, vault.to_sym].each do |dbname|
110
+ allow(ChefVault::Item).to(
111
+ receive(:vault?).with(dbname, item).and_return(true)
112
+ )
113
+
98
114
  allow(ChefVault::Item).to(
99
115
  receive(:load)
100
116
  .with(dbname, item)
@@ -121,17 +137,16 @@ class ChefVault
121
137
  def stub_vault_item_encrypted_data(vault, item, content)
122
138
  # stub data bag lookup of each of the vault item keys
123
139
  dbi = ChefVault::TestFixtureDataBagItem.new
124
- dbi['raw_data'] = content
140
+ dbi["raw_data"] = content
125
141
  content.each_key do |k|
126
- next if 'id' == k
127
- dbi[k] = { 'encrypted_data' => '...' }
142
+ next if "id" == k
143
+
144
+ dbi[k] = { "encrypted_data" => "..." }
128
145
  end
129
146
 
130
147
  [vault, vault.to_sym].each do |dbname|
131
148
  allow(Chef::DataBagItem).to(
132
- receive(:load)
133
- .with(dbname, item)
134
- .and_return(dbi)
149
+ receive(:load).with(dbname, item).and_return(dbi)
135
150
  )
136
151
  end
137
152
  end
@@ -0,0 +1,7 @@
1
+ class ChefVault
2
+ # dynamic RSpec contexts for cookbooks that use chef-vault
3
+ class TestFixtures
4
+ # the version of the gem
5
+ VERSION = "3.1.1".freeze
6
+ end
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: 0.5.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - James FitzGibbon
7
+ - Thom May
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-06 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
@@ -16,303 +16,87 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '3.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '3.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-vault
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2.5'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
33
+ version: '3'
34
+ - - "<"
39
35
  - !ruby/object:Gem::Version
40
- version: '2.5'
41
- - !ruby/object:Gem::Dependency
42
- name: hashie
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.1'
36
+ version: '5'
48
37
  type: :runtime
49
38
  prerelease: false
50
39
  version_requirements: !ruby/object:Gem::Requirement
51
40
  requirements:
52
- - - "~>"
41
+ - - ">="
53
42
  - !ruby/object:Gem::Version
54
- version: '2.1'
55
- - !ruby/object:Gem::Dependency
56
- name: rdoc
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
43
+ version: '3'
44
+ - - "<"
60
45
  - !ruby/object:Gem::Version
61
- version: '4.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '4.0'
69
- - !ruby/object:Gem::Dependency
70
- name: chef
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '12.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '12.0'
46
+ version: '5'
83
47
  - !ruby/object:Gem::Dependency
84
- name: hoe
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '3.13'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '3.13'
97
- - !ruby/object:Gem::Dependency
98
- name: hoe-gemspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1.0'
111
- - !ruby/object:Gem::Dependency
112
- name: rake
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '10.3'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '10.3'
125
- - !ruby/object:Gem::Dependency
126
- name: guard
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '2.12'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '2.12'
139
- - !ruby/object:Gem::Dependency
140
- name: guard-rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '4.2'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '4.2'
153
- - !ruby/object:Gem::Dependency
154
- name: guard-rake
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '0.0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '0.0'
167
- - !ruby/object:Gem::Dependency
168
- name: guard-rubocop
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '1.2'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '1.2'
181
- - !ruby/object:Gem::Dependency
182
- name: chefspec
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '4.2'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '4.2'
195
- - !ruby/object:Gem::Dependency
196
- name: berkshelf
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '3.2'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: '3.2'
209
- - !ruby/object:Gem::Dependency
210
- name: rubocop
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: '0.29'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: '0.29'
223
- - !ruby/object:Gem::Dependency
224
- name: simplecov
48
+ name: hashie
225
49
  requirement: !ruby/object:Gem::Requirement
226
50
  requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: '0.9'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
51
+ - - ">="
235
52
  - !ruby/object:Gem::Version
236
- version: '0.9'
237
- - !ruby/object:Gem::Dependency
238
- name: simplecov-console
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - "~>"
53
+ version: '2.0'
54
+ - - "<"
242
55
  - !ruby/object:Gem::Version
243
- version: '0.2'
244
- type: :development
56
+ version: '4.0'
57
+ type: :runtime
245
58
  prerelease: false
246
59
  version_requirements: !ruby/object:Gem::Requirement
247
60
  requirements:
248
- - - "~>"
249
- - !ruby/object:Gem::Version
250
- version: '0.2'
251
- - !ruby/object:Gem::Dependency
252
- name: yard
253
- requirement: !ruby/object:Gem::Requirement
254
- requirements:
255
- - - "~>"
61
+ - - ">="
256
62
  - !ruby/object:Gem::Version
257
- version: '0.8'
258
- type: :development
259
- prerelease: false
260
- version_requirements: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - "~>"
63
+ version: '2.0'
64
+ - - "<"
263
65
  - !ruby/object:Gem::Version
264
- version: '0.8'
265
- description: |-
266
- chef-vault-testfixtures provides an RSpec shared context that
267
- stubs access to chef-vault encrypted data bags using the same
268
- fallback mechanism as the `chef_vault_item` helper from the
269
- [chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)
66
+ version: '4.0'
67
+ description: chef-vault-testfixtures provides an RSpec shared context that stubs access
68
+ to chef-vault encrypted data bags using the same fallback mechanism as the `chef_vault_item`
69
+ helper from the [chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)
270
70
  email:
271
- - james.i.fitzgibbon@nordstrom.com
71
+ - thom@chef.io
272
72
  executables: []
273
73
  extensions: []
274
- extra_rdoc_files:
275
- - History.md
276
- - Manifest.txt
277
- - README.md
74
+ extra_rdoc_files: []
278
75
  files:
279
- - ".rspec"
280
- - ".rubocop.yml"
281
- - ".yardopts"
282
- - Gemfile
283
- - Guardfile
284
- - History.md
285
- - Manifest.txt
286
- - README.md
287
- - Rakefile
76
+ - LICENSE
288
77
  - chef-vault-testfixtures.gemspec
289
78
  - lib/chef-vault/test_fixtures.rb
290
- - lib/hoe/markdown.rb
291
- - spec/lib/chef-vault/test_fixtures_spec.rb
292
- - spec/spec_helper.rb
293
- homepage: https://github.com/Nordstrom/chef-vault-testfixtures
79
+ - lib/chef-vault/test_fixtures_version.rb
80
+ homepage: https://github.com/chef/chef-vault-testfixtures
294
81
  licenses:
295
82
  - apache2
296
83
  metadata: {}
297
84
  post_install_message:
298
- rdoc_options:
299
- - "--main"
300
- - README.md
85
+ rdoc_options: []
301
86
  require_paths:
302
87
  - lib
303
88
  required_ruby_version: !ruby/object:Gem::Requirement
304
89
  requirements:
305
90
  - - ">="
306
91
  - !ruby/object:Gem::Version
307
- version: '0'
92
+ version: '2.5'
308
93
  required_rubygems_version: !ruby/object:Gem::Requirement
309
94
  requirements:
310
95
  - - ">="
311
96
  - !ruby/object:Gem::Version
312
97
  version: '0'
313
98
  requirements: []
314
- rubyforge_project:
315
- rubygems_version: 2.4.4
99
+ rubygems_version: 3.0.3
316
100
  signing_key:
317
101
  specification_version: 4
318
102
  summary: chef-vault-testfixtures provides an RSpec shared context that stubs access
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
@@ -1,18 +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
16
-
17
- Metrics/CyclomaticComplexity:
18
- Max: 7
data/.yardopts DELETED
@@ -1,4 +0,0 @@
1
- -
2
- README.rdoc
3
- History.rdoc
4
- lib/**/*.rb
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org/'
2
-
3
- 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,42 +0,0 @@
1
- # Changelog for chef-vault-testfixtures
2
-
3
- ## 0.5.0
4
-
5
- * 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))
6
-
7
- ## 0.4.1
8
-
9
- * fix bug where only the last item for a given vault was stubbed
10
-
11
- ## 0.4.0
12
-
13
- * 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)
14
-
15
- ## 0.3.0
16
-
17
- * completely re-work to use JSON data bag files in test/integration for compatibility with the fallback mechanism in the chef-vault cookbook
18
-
19
- ## 0.2.0
20
-
21
- * 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
22
-
23
- ## 0.1.3
24
-
25
- * change chef runtime dependency from >= 11.14 to >= 11.0
26
- * clean up some test ordering problems related to not clearing the blacklist properly
27
-
28
- ## 0.1.2
29
-
30
- * allow access to the data bag via the symbol form as well as the string form
31
- * re-organize the README to make the summary extracted by Hoe smaller
32
- * add Travis-CI integration and badging
33
- * add Code Climate integration and badging
34
-
35
- ## 0.1.1
36
-
37
- * fix disconnect between docs and code for shared context method
38
- * remove Hoe test plugin so we don't double up on test runs
39
-
40
- ## 0.1.0
41
-
42
- * initial version
@@ -1,14 +0,0 @@
1
- .rspec
2
- .rubocop.yml
3
- .yardopts
4
- Gemfile
5
- Guardfile
6
- History.md
7
- Manifest.txt
8
- README.md
9
- Rakefile
10
- chef-vault-testfixtures.gemspec
11
- lib/chef-vault/test_fixtures.rb
12
- lib/hoe/markdown.rb
13
- spec/lib/chef-vault/test_fixtures_spec.rb
14
- spec/spec_helper.rb
data/README.md DELETED
@@ -1,201 +0,0 @@
1
- # chef-vault-testfixtures
2
-
3
- * home :: https://github.com/Nordstrom/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/Nordstrom/chef-vault-testfixtures.png?branch=master)](https://travis-ci.org/Nordstrom/chef-vault-testfixtures)
7
- * code climate :: [![Code Climate](https://codeclimate.com/github/Nordstrom/chef-vault-testfixtures/badges/gpa.svg)](https://codeclimate.com/github/Nordstrom/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/Nordstrom/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.converge(described_recipe) }
57
-
58
- it 'should converge' do
59
- expect(chef_run).to include_recipe(described_recipe)
60
- end
61
- end
62
-
63
- The recipe that the example tests:
64
-
65
- include_recipe 'chef-vault'
66
- item = chef_vault_item('foo', 'bar')
67
- file '/tmp/foo' do
68
- contents item['password']
69
- end
70
-
71
- The helper will call `ChefVault::Item.load`, which will be stubbed using
72
- the data bag from the test/integration/data_bags directory.
73
-
74
- ## VAULT PROBING
75
-
76
- Some recipes and helpers attempt to determine if a data bag is a vault
77
- by checking the raw data bag item to see if one of the values contains
78
- encrypted data, then checking for the existence of the `_keys` data bag
79
- 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
80
- of this:
81
-
82
- ```
83
- raw_hash = Chef::DataBagItem.load(data_bag_name, item)
84
- encrypted = raw_hash.detect do |key, value|
85
- if value.is_a?(Hash)
86
- value.has_key?("encrypted_data")
87
- end
88
- end
89
- if encrypted
90
- if Chef::DataBag.load(data_bag_name).key? "#{item}_keys"
91
- chef_vault_item(data_bag_name, item)
92
- else
93
- secret = Chef::EncryptedDataBagItem.load_secret
94
- Chef::EncryptedDataBagItem.new(raw_hash, secret)
95
- end
96
- else
97
- raw_hash
98
- end
99
- ```
100
-
101
- chef-vault-testfixtures also stubs `Chef::DataBag` so that for every JSON
102
- file in your test directory, it will think that there is a side-along
103
- item suffixed with `_keys`. This satisfies the probes that the chef-vault
104
- cookbook helper uses. To address the check for the `encrypted_data` key
105
- that the sensu cookbook uses, pass a true value to `rspec_shared_context`:
106
-
107
- ```
108
- RSpec.describe 'my_cookbook::default' do
109
- include ChefVault::TestFixtures.rspec_shared_context(true)
110
- end
111
- ```
112
-
113
- Now, when your recipe calls `Chef::DataBagItem.load`, it will
114
- get back a hash with the same keys as the JSON file, but values which are
115
- hashes of the form:
116
-
117
- ```
118
- {
119
- encrypted_data => '...'
120
- }
121
- ```
122
-
123
- This is not a valid data bag obviously, but it will satisfy the probe
124
- and cause code like that in the sensu cookbook to call `ChefVault::Item.load`,
125
- which is stubbed to return valid data.
126
-
127
- ## STUBBING UNENCRYPTED DATA BAGS
128
-
129
- This technique is not a part of this gem, but was brought to my attention
130
- in an issue. Credit to Dru Goradia for the approach. This will let you
131
- populate an unencrypted data bag from the same JSON files:
132
-
133
- In `spec/spec_helper.rb`:
134
-
135
- ```
136
- require 'chef-vault/test_fixtures'
137
- require 'json'
138
-
139
- def parse_data_bag (path)
140
- data_bags_path = File.expand_path(File.join(File.dirname(__FILE__), '../test/integration/data_bags'))
141
- return JSON.parse(File.read("#{data_bags_path}/#{path}"))
142
- end
143
- ```
144
-
145
- In your test:
146
-
147
- ```
148
- describe 'my_cookbook::default' do
149
- include ChefVault::TestFixtures.rspec_shared_context
150
-
151
- let(:chef_run) do
152
- ChefSpec::ServerRunner.new() do |node, server|
153
- server.create_data_bag('foo', {
154
- 'bar' => parse_data_bag('foo/bar.json')
155
- })
156
- end.converge(described_recipe)
157
- end
158
-
159
- it 'should converge' do
160
- expect(chef_run).to include_recipe(described_recipe)
161
- end
162
- end
163
- ```
164
-
165
- ## DEPENDENCIES
166
-
167
- It may seem strange that chef isn't a runtime dependency of this gem.
168
- This is due to idiosyncracies in the way that old versions of rubygems
169
- (such as those that ship with chef-client prior to 11.18.0) process
170
- dependencies.
171
-
172
- If we include chef as a dependency, even with a relaxed requirement
173
- like '>= 11.0', rubygems v1.8.x will still try to pull in chef-12.0.3,
174
- even if the --conservative switch is used. This in turn pulls in
175
- Ohai 8.1.x, which doesn't work under Ruby 1.9.3 (which is what chef-client
176
- 11 embeds).
177
-
178
- rubygems v2.x.x do not suffer from this problem. The net takeaway is that
179
- attempting to install this gem on a system that does not have chef installed
180
- will fail. I expect the instances of people trying to do this to be
181
- small.
182
-
183
- ## AUTHOR
184
-
185
- James FitzGibbon - james.i.fitzgibbon@nordstrom.com - @jf647
186
-
187
- ## LICENSE
188
-
189
- Copyright 2015 Nordstrom, Inc.
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.
data/Rakefile DELETED
@@ -1,89 +0,0 @@
1
- require 'chef-vault/test_fixtures'
2
-
3
- begin
4
- require 'hoe'
5
- require 'hoe/markdown'
6
- Hoe.plugin :gemspec
7
- Hoe.plugin :markdown
8
- Hoe.plugins.delete :test
9
- Hoe.spec 'chef-vault-testfixtures' do |s|
10
- s.version = ChefVault::TestFixtures::VERSION
11
- developer 'James FitzGibbon', 'james.i.fitzgibbon@nordstrom.com'
12
- license 'apache2'
13
- extra_deps << ['rspec', '~> 3.1']
14
- extra_deps << ['chef-vault', '~> 2.5']
15
- extra_deps << ['hashie', '~> 2.1']
16
- extra_dev_deps << ['chef', '~> 12.0']
17
- extra_dev_deps << ['hoe', '~> 3.13']
18
- extra_dev_deps << ['hoe-gemspec', '~> 1.0']
19
- extra_dev_deps << ['rake', '~> 10.3']
20
- extra_dev_deps << ['rspec', '~> 3.1']
21
- extra_dev_deps << ['guard', '~> 2.12']
22
- extra_dev_deps << ['guard-rspec', '~> 4.2']
23
- extra_dev_deps << ['guard-rake', '~> 0.0']
24
- extra_dev_deps << ['guard-rubocop', '~> 1.2']
25
- extra_dev_deps << ['chefspec', '~> 4.2']
26
- extra_dev_deps << ['berkshelf', '~> 3.2']
27
- extra_dev_deps << ['rubocop', '~> 0.29']
28
- extra_dev_deps << ['simplecov', '~> 0.9']
29
- extra_dev_deps << ['simplecov-console', '~> 0.2']
30
- extra_dev_deps << ['yard', '~> 0.8']
31
- end
32
- # re-generate our gemspec before packaging
33
- task package: 'gem:spec'
34
- rescue LoadError
35
- puts 'hoe not available; disabling tasks'
36
- end
37
-
38
- # Style Tests
39
- begin
40
- require 'rubocop/rake_task'
41
- RuboCop::RakeTask.new do |t|
42
- t.formatters = ['progress']
43
- t.options = ['-D']
44
- t.patterns = %w(
45
- bin/*
46
- lib/**/*.rb
47
- spec/**/*.rb
48
- ./Rakefile
49
- )
50
- end
51
- desc 'Run Style Tests'
52
- task style: [:rubocop]
53
- rescue LoadError
54
- puts 'rubocop not available; disabling tasks'
55
- end
56
-
57
- # Unit Tests
58
- begin
59
- require 'rspec/core/rake_task'
60
- RSpec::Core::RakeTask.new
61
-
62
- # Coverage
63
- desc 'Generate unit test coverage report'
64
- task :coverage do
65
- ENV['COVERAGE'] = 'true'
66
- Rake::Task[:test].invoke
67
- end
68
-
69
- # test is an alias for spec
70
- desc 'runs unit tests'
71
- task test: :spec
72
-
73
- # default is to test everything
74
- desc 'runs all tests'
75
- task default: :test
76
- rescue LoadError
77
- puts 'rspec not available; disabling tasks'
78
- end
79
-
80
- # Documentation
81
- begin
82
- require 'yard'
83
- require 'yard/rake/yardoc_task'
84
- YARD::Rake::YardocTask.new(:doc) do |t|
85
- t.stats_options = ['--list-undoc']
86
- end
87
- rescue LoadError
88
- puts 'yard not available; disabling tasks'
89
- end
@@ -1,12 +0,0 @@
1
- class Hoe
2
- module Markdown
3
- def initialize_markdown
4
- self.readme_file = readme_file.sub(/\.txt$/, '.md')
5
- self.history_file = history_file.sub(/\.txt$/, '.md')
6
- end
7
-
8
- def define_markdown_tasks
9
- # do nothing
10
- end
11
- end
12
- end
@@ -1,82 +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 allow and ignore an attempt to change a vault' do
48
- item = ChefVault::Item.load('bar', 'foo')
49
- item['foo'] = 'foo'
50
- end
51
-
52
- it 'should allow and ignore an attempt to set the clients' do
53
- item = ChefVault::Item.load('bar', 'foo')
54
- item.clients('*:*')
55
- end
56
-
57
- it 'should allow and ignore an attempt to save' do
58
- item = ChefVault::Item.load('bar', 'foo')
59
- item.save
60
- end
61
-
62
- it 'should stub the _keys data bag item' do
63
- db = Chef::DataBag.load('foo')
64
- expect(db.key?('bar_keys')).to be_truthy
65
- end
66
- end
67
- end
68
-
69
- RSpec.describe ChefVault::TestFixtures do
70
- describe 'with the encrypted_data stub' do
71
- ChefVault::TestFixtures.clear_context
72
- include ChefVault::TestFixtures.rspec_shared_context(true)
73
-
74
- it 'should present the foo/bar data bag item as encrypted' do
75
- dbi = Chef::DataBagItem.load('foo', 'bar')
76
- encrypted = dbi.detect do |_, v|\
77
- v.is_a?(Hash) && v.key?('encrypted_data')
78
- end
79
- expect(encrypted).to be_truthy
80
- end
81
- end
82
- 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