chef-vault-testfixtures 0.2.0 → 0.3.0.20150417141427
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +1 -1
- data/History.md +4 -0
- data/Manifest.txt +0 -2
- data/README.md +24 -144
- data/Rakefile +0 -4
- data/chef-vault-testfixtures.gemspec +7 -19
- data/lib/chef-vault/test_fixtures.rb +36 -28
- data/spec/lib/chef-vault/test_fixtures_spec.rb +0 -41
- metadata +10 -64
- data/spec/support/chef-vault/test_fixtures/bar.rb +0 -11
- data/spec/support/chef-vault/test_fixtures/foo.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 061b4ef41c4e3bc41a4fa2e4ba49e09b79f83e9b
|
4
|
+
data.tar.gz: db49f7226f5d2684e3c0203853d86e0fa200e880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14b2a13313dc979b9053c3d079e9b48d00c1800709899aa052922eb3ec2ed9de886d91bea740291e4329d75f5a4a5ff423466eb719ee685ff4b5f159e3871a4a
|
7
|
+
data.tar.gz: 7a575c3ea9cfd60c8c3661e0c2f0d67843da3956b908ae55a22d59e8ebaf166223832f7b5a430bc29abbaee2a7ed03432619aa6b26dad8b5e50102e957b22eb8
|
data/Guardfile
CHANGED
@@ -9,7 +9,7 @@ guard :rubocop, all_on_start: true, cli: ['-D'] do
|
|
9
9
|
watch('Rakefile')
|
10
10
|
end
|
11
11
|
|
12
|
-
guard :rspec, all_on_start: true, cmd: 'bundle exec
|
12
|
+
guard :rspec, all_on_start: true, cmd: 'bundle exec rspec' do
|
13
13
|
watch(%r{^spec/(.+)_spec\.rb$})
|
14
14
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
15
15
|
watch(%r{^spec/spec_helper.*\.rb$}) { 'spec' }
|
data/History.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog for chef-vault-testfixtures
|
2
2
|
|
3
|
+
## 0.3.0
|
4
|
+
|
5
|
+
* completely re-work to use JSON data bag files in test/integration for compatibility with the fallback mechanism in the chef-vault cookbook
|
6
|
+
|
3
7
|
## 0.2.0
|
4
8
|
|
5
9
|
* 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
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -9,51 +9,40 @@
|
|
9
9
|
## DESCRIPTION
|
10
10
|
|
11
11
|
chef-vault-testfixtures provides an RSpec shared context that
|
12
|
-
|
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)
|
13
15
|
|
14
16
|
## USAGE
|
15
17
|
|
16
|
-
[chef-vault](https://github.com/Nordstrom/chef-vault) is a gem to manage
|
17
|
-
decrypt Chef encrypted data bags.
|
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.
|
18
20
|
|
19
21
|
When testing a cookbook that uses chef-vault, encryption is generally
|
20
|
-
out of scope, which results in a large number of stubs or mocks so that
|
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.
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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`.
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Since plugins can be whitelisted or blacklisted when the shared
|
33
|
-
context is created, this makes it easy to only include the appropriate
|
34
|
-
secrets in a given cookbook's tests.
|
35
|
-
|
36
|
-
Attempts to access secrets that would not be available to a node
|
37
|
-
during a real chef-client run will not be mocked, which will cause
|
38
|
-
the double to raise an 'unexpected message received' error.
|
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.
|
39
36
|
|
40
37
|
## USAGE
|
41
38
|
|
42
|
-
In the file `
|
39
|
+
In the file `test/integration/data_bags/foo/bar.json`:
|
43
40
|
|
44
|
-
|
45
|
-
class TestFixtures
|
46
|
-
class Foo
|
47
|
-
def bar
|
48
|
-
{ 'baz' => 2 }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
41
|
+
{ "password": "sekrit" }
|
53
42
|
|
54
43
|
In your cookbook Gemfile:
|
55
44
|
|
56
|
-
gem 'chef-vault-testfixtures', '~> 0.
|
45
|
+
gem 'chef-vault-testfixtures', '~> 0.3'
|
57
46
|
|
58
47
|
In your cookbook `spec/spec_helper.rb`:
|
59
48
|
|
@@ -73,123 +62,14 @@ In a cookbook example:
|
|
73
62
|
|
74
63
|
The recipe that the example tests:
|
75
64
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
require 'chef-vault'
|
80
|
-
item = ChefVault::Item.load('foo', 'bar')
|
65
|
+
include_recipe 'chef-vault'
|
66
|
+
item = chef_vault_item('foo', 'bar')
|
81
67
|
file '/tmp/foo' do
|
82
68
|
contents item['password']
|
83
69
|
end
|
84
70
|
|
85
|
-
The call
|
86
|
-
|
87
|
-
|
88
|
-
## PLUGINS
|
89
|
-
|
90
|
-
This gem uses [little-plugger](https://rubygems.org/gems/little-plugger)
|
91
|
-
to make adding vault fixtures easy. Each data bag needs a plugin
|
92
|
-
named using [little-pluggers's rules](https://github.com/TwP/little-plugger/blob/master/lib/little-plugger.rb#L13-24).
|
93
|
-
|
94
|
-
The plugin must define a class inside the naming hierarchy
|
95
|
-
`ChefVault::TestFixtures::`. The class name should be the filename
|
96
|
-
converted to CamelCase (e.g. `foo_bar.rb` = `FooBar`)
|
97
|
-
|
98
|
-
Inside of the plugin, define a class method for each vault item you
|
99
|
-
want to stub. The method must return a Hash, which contains the
|
100
|
-
vault data.
|
101
|
-
|
102
|
-
For example, if you wanted to stub the data bag item foo/bar, you would
|
103
|
-
create the class `ChefVault::TestFixtures::Foo` and inside define a class method `bar`.
|
104
|
-
|
105
|
-
### ALIASING VAULT ITEMS
|
106
|
-
|
107
|
-
If you want your vault to return the same data for two different
|
108
|
-
vault items, just alias the method:
|
109
|
-
|
110
|
-
class ChefVault
|
111
|
-
class TestFixtures
|
112
|
-
class MyApp
|
113
|
-
def test
|
114
|
-
{ 'baz' => 1 }
|
115
|
-
end
|
116
|
-
|
117
|
-
alias_method :prod, :test
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
Now you will get the same value for:
|
123
|
-
|
124
|
-
ChefVault::Item.load('my_app', 'test')['baz']
|
125
|
-
|
126
|
-
as you do from
|
127
|
-
|
128
|
-
ChefVault::Item.load('my_app', 'prod')['baz']
|
129
|
-
|
130
|
-
This can be useful when your vaults use `node.chef_environment`
|
131
|
-
(or a derivative thereof) for the item name.
|
132
|
-
|
133
|
-
## FINDING VAULTS
|
134
|
-
|
135
|
-
LittlePlugger loads any files in any installed gem that match
|
136
|
-
the pathspec `lib/chef-vault/test_fixtures/*.rb`. Plugin classes
|
137
|
-
that are loaded using 'require' are also available as vaults.
|
138
|
-
|
139
|
-
You can bundle one or more plugins as a gem that you can distribute
|
140
|
-
publicly or privately, or you can distribute them baked into your cookbook.
|
141
|
-
|
142
|
-
For example, in a cookbook create the file `spec/support/chef-vault/test_fixtures/foo.rb`
|
143
|
-
with the same contents as above. LittlePlugger will not find
|
144
|
-
this automatically because it's not part of an installed gem, but
|
145
|
-
by requiring it from your `spec/spec_helper.rb`:
|
146
|
-
|
147
|
-
require 'support/chef-vault/test_fixtures/foo'
|
148
|
-
|
149
|
-
It will be available when `ChefVault::TestFixtures.rspec_shared_context` is called.
|
150
|
-
|
151
|
-
Note that LittlePlugger excludes any plugins that have a class name
|
152
|
-
all in capitals (because it assumes those are constants). A plugin
|
153
|
-
for database secrets should be named `Db` instead of `DB`. However,
|
154
|
-
this is only of interest to plugin authors. When selecting the plugins
|
155
|
-
to load, the names are always lowercase symbols.
|
156
|
-
|
157
|
-
## LISTING VAULTS
|
158
|
-
|
159
|
-
To get a list of the stubbed vaults, call
|
160
|
-
|
161
|
-
ChefVault::TestFixtures.load_plugins
|
162
|
-
list = ChefVault::TestFixtures.plugins.keys
|
163
|
-
|
164
|
-
The return from `::plugins` is a hash of plugin names (as symbols)
|
165
|
-
to the class or module that provide them.
|
166
|
-
|
167
|
-
The plugin name is always a lowercase symbol.
|
168
|
-
|
169
|
-
## RESTRICTING WHICH VAULTS ARE USED
|
170
|
-
|
171
|
-
Thanks to Little Plugger, you can change what plugins (vaults) will
|
172
|
-
be loaded the first time that `#rspec_shared_context` is called.
|
173
|
-
|
174
|
-
To only load certain plugins, call
|
175
|
-
|
176
|
-
ChefVault::TestFixtures.plugin :pluginone, :plugintwo
|
177
|
-
|
178
|
-
before calling `ChefVault::TestFixtures.rspec_shared_context`.
|
179
|
-
|
180
|
-
To prevent certain plugins from being loaded, call
|
181
|
-
|
182
|
-
ChefVault::TestFixtures.disregard_plugin :pluginthree
|
183
|
-
|
184
|
-
before calling `ChefVault::TestFixtures.rspec_shared_context`.
|
185
|
-
|
186
|
-
Note that the context is memoized on first call, so calling `::plugin` or `::disregard_plugin` after calling `::rspec_shared_context` will not change what vaults are available.
|
187
|
-
|
188
|
-
## COMPANION COOKBOOK FOR TEST KITCHEN
|
189
|
-
|
190
|
-
A [companion cookbook](https://supermarket.chef.io/cookbooks/chef_vault_testfixtures)
|
191
|
-
is also available that uses the same data to populate vaults during
|
192
|
-
Test Kitchen integration runs.
|
71
|
+
The helper will call `ChefVault::Item.load`, which will be stubbed using
|
72
|
+
the data bag from the test/integration/data_bags directory.
|
193
73
|
|
194
74
|
## DEPENDENCIES
|
195
75
|
|
data/Rakefile
CHANGED
@@ -12,7 +12,6 @@ begin
|
|
12
12
|
license 'apache2'
|
13
13
|
extra_deps << ['rspec', '~> 3.1']
|
14
14
|
extra_deps << ['chef-vault', '~> 2.5']
|
15
|
-
extra_deps << ['little-plugger', '~> 1.1']
|
16
15
|
extra_dev_deps << ['chef', '~> 12.0']
|
17
16
|
extra_dev_deps << ['hoe', '~> 3.13']
|
18
17
|
extra_dev_deps << ['hoe-gemspec', '~> 1.0']
|
@@ -25,9 +24,6 @@ begin
|
|
25
24
|
extra_dev_deps << ['rubocop', '~> 0.29']
|
26
25
|
extra_dev_deps << ['simplecov', '~> 0.9']
|
27
26
|
extra_dev_deps << ['simplecov-console', '~> 0.2']
|
28
|
-
extra_dev_deps << ['pry-byebug', '~> 3.0']
|
29
|
-
extra_dev_deps << ['pry-rescue', '~> 1.3']
|
30
|
-
extra_dev_deps << ['pry-stack_explorer', '~> 0.4']
|
31
27
|
extra_dev_deps << ['yard', '~> 0.8']
|
32
28
|
end
|
33
29
|
# re-generate our gemspec before packaging
|
@@ -1,23 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: chef-vault-testfixtures 0.
|
2
|
+
# stub: chef-vault-testfixtures 0.3.0.20150417141427 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "chef-vault-testfixtures"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.3.0.20150417141427"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["James FitzGibbon"]
|
11
|
-
s.date = "2015-
|
12
|
-
s.description = "chef-vault-testfixtures provides an RSpec shared context that\
|
11
|
+
s.date = "2015-04-17"
|
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
13
|
s.email = ["james.i.fitzgibbon@nordstrom.com"]
|
14
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"
|
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
16
|
s.homepage = "https://github.com/Nordstrom/chef-vault-testfixtures"
|
17
17
|
s.licenses = ["apache2"]
|
18
18
|
s.rdoc_options = ["--main", "README.md"]
|
19
|
-
s.rubygems_version = "2.4.
|
20
|
-
s.summary = "chef-vault-testfixtures provides an RSpec shared context that
|
19
|
+
s.rubygems_version = "2.4.6"
|
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)"
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
23
23
|
s.specification_version = 4
|
@@ -25,7 +25,6 @@ Gem::Specification.new do |s|
|
|
25
25
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
26
|
s.add_runtime_dependency(%q<rspec>, ["~> 3.1"])
|
27
27
|
s.add_runtime_dependency(%q<chef-vault>, ["~> 2.5"])
|
28
|
-
s.add_runtime_dependency(%q<little-plugger>, ["~> 1.1"])
|
29
28
|
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
30
29
|
s.add_development_dependency(%q<chef>, ["~> 12.0"])
|
31
30
|
s.add_development_dependency(%q<hoe>, ["~> 3.13"])
|
@@ -38,14 +37,10 @@ Gem::Specification.new do |s|
|
|
38
37
|
s.add_development_dependency(%q<rubocop>, ["~> 0.29"])
|
39
38
|
s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
|
40
39
|
s.add_development_dependency(%q<simplecov-console>, ["~> 0.2"])
|
41
|
-
s.add_development_dependency(%q<pry-byebug>, ["~> 3.0"])
|
42
|
-
s.add_development_dependency(%q<pry-rescue>, ["~> 1.3"])
|
43
|
-
s.add_development_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
|
44
40
|
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
45
41
|
else
|
46
42
|
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
47
43
|
s.add_dependency(%q<chef-vault>, ["~> 2.5"])
|
48
|
-
s.add_dependency(%q<little-plugger>, ["~> 1.1"])
|
49
44
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
50
45
|
s.add_dependency(%q<chef>, ["~> 12.0"])
|
51
46
|
s.add_dependency(%q<hoe>, ["~> 3.13"])
|
@@ -58,15 +53,11 @@ Gem::Specification.new do |s|
|
|
58
53
|
s.add_dependency(%q<rubocop>, ["~> 0.29"])
|
59
54
|
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
60
55
|
s.add_dependency(%q<simplecov-console>, ["~> 0.2"])
|
61
|
-
s.add_dependency(%q<pry-byebug>, ["~> 3.0"])
|
62
|
-
s.add_dependency(%q<pry-rescue>, ["~> 1.3"])
|
63
|
-
s.add_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
|
64
56
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
65
57
|
end
|
66
58
|
else
|
67
59
|
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
68
60
|
s.add_dependency(%q<chef-vault>, ["~> 2.5"])
|
69
|
-
s.add_dependency(%q<little-plugger>, ["~> 1.1"])
|
70
61
|
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
71
62
|
s.add_dependency(%q<chef>, ["~> 12.0"])
|
72
63
|
s.add_dependency(%q<hoe>, ["~> 3.13"])
|
@@ -79,9 +70,6 @@ Gem::Specification.new do |s|
|
|
79
70
|
s.add_dependency(%q<rubocop>, ["~> 0.29"])
|
80
71
|
s.add_dependency(%q<simplecov>, ["~> 0.9"])
|
81
72
|
s.add_dependency(%q<simplecov-console>, ["~> 0.2"])
|
82
|
-
s.add_dependency(%q<pry-byebug>, ["~> 3.0"])
|
83
|
-
s.add_dependency(%q<pry-rescue>, ["~> 1.3"])
|
84
|
-
s.add_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
|
85
73
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
86
74
|
end
|
87
75
|
end
|
@@ -1,15 +1,14 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'json'
|
3
|
+
|
1
4
|
require 'rspec'
|
2
5
|
require 'rspec/core/shared_context'
|
3
6
|
require 'chef-vault'
|
4
|
-
require 'little-plugger'
|
5
7
|
|
6
8
|
class ChefVault
|
7
9
|
# dynamic RSpec contexts for cookbooks that use chef-vault
|
8
10
|
class TestFixtures
|
9
|
-
VERSION = '0.
|
10
|
-
|
11
|
-
extend LittlePlugger path: 'chef-vault/test_fixtures',
|
12
|
-
module: ChefVault::TestFixtures
|
11
|
+
VERSION = '0.3.0'
|
13
12
|
|
14
13
|
# dynamically creates a memoized RSpec shared context
|
15
14
|
# that when included into an example group will stub
|
@@ -20,36 +19,45 @@ class ChefVault
|
|
20
19
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
21
20
|
def rspec_shared_context
|
22
21
|
@context ||= begin
|
23
|
-
load_plugins
|
24
22
|
Module.new do
|
25
23
|
extend RSpec::Core::SharedContext
|
26
24
|
|
27
|
-
before
|
28
|
-
|
29
|
-
|
25
|
+
before { find_vaults }
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def find_vaults
|
30
|
+
dbdir = Pathname.new('test') + 'integration' + 'data_bags'
|
31
|
+
dbdir.each_child do |vault|
|
32
|
+
next unless vault.directory?
|
33
|
+
stub_vault(vault)
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
33
|
-
|
37
|
+
def stub_vault(vault)
|
38
|
+
vault.each_child do |e|
|
39
|
+
next unless e.file?
|
40
|
+
m = e.basename.to_s.downcase.match(/(.+)\.json/i)
|
41
|
+
stub_vault_item(vault.basename.to_s, m[1], e.read) if m
|
42
|
+
end
|
43
|
+
end
|
34
44
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
)
|
52
|
-
end
|
45
|
+
def stub_vault_item(vault, item, json)
|
46
|
+
content = JSON.parse(json)
|
47
|
+
vi = make_fakevault(vault, item)
|
48
|
+
# stub lookup of each of the vault item keys
|
49
|
+
content.each do |k, v|
|
50
|
+
next if 'id' == k
|
51
|
+
allow(vi).to receive(:[]).with(k).and_return(v)
|
52
|
+
end
|
53
|
+
# stub chef-vault to return the fake vault item, via
|
54
|
+
# both symbol and string forms of the data bag name
|
55
|
+
[vault, vault.to_sym].each do |dbname|
|
56
|
+
allow(ChefVault::Item).to(
|
57
|
+
receive(:load)
|
58
|
+
.with(dbname, item)
|
59
|
+
.and_return(vi)
|
60
|
+
)
|
53
61
|
end
|
54
62
|
end
|
55
63
|
|
@@ -1,22 +1,5 @@
|
|
1
1
|
require 'chef-vault/test_fixtures'
|
2
2
|
|
3
|
-
# sample plugins
|
4
|
-
require 'support/chef-vault/test_fixtures/foo.rb'
|
5
|
-
require 'support/chef-vault/test_fixtures/bar.rb'
|
6
|
-
|
7
|
-
# LittlePlugger doesn't expect to have its inclusion/exclusion
|
8
|
-
# lists reset in a single process, so we have to monkeypatch
|
9
|
-
# in some testing functionality
|
10
|
-
module LittlePlugger
|
11
|
-
module ClassMethods
|
12
|
-
def clear_plugins
|
13
|
-
@plugin_names = []
|
14
|
-
@disregard_plugin = []
|
15
|
-
@loaded = {}
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
3
|
# same with ChefVault::TestFixtures
|
21
4
|
class ChefVault
|
22
5
|
class TestFixtures
|
@@ -32,26 +15,14 @@ RSpec.describe ChefVault::TestFixtures do
|
|
32
15
|
include ChefVault::TestFixtures.rspec_shared_context
|
33
16
|
|
34
17
|
before do
|
35
|
-
ChefVault::TestFixtures.clear_plugins
|
36
18
|
ChefVault::TestFixtures.clear_context
|
37
19
|
end
|
38
20
|
|
39
21
|
after do
|
40
|
-
ChefVault::TestFixtures.clear_plugins
|
41
22
|
ChefVault::TestFixtures.clear_context
|
42
23
|
end
|
43
24
|
|
44
25
|
describe 'Generic functionality' do
|
45
|
-
it 'should be able to load plugins' do
|
46
|
-
expect(ChefVault::TestFixtures.plugins).to be_a(Hash)
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should load the expected vaults' do
|
50
|
-
expect(ChefVault::TestFixtures.plugins.keys).to(
|
51
|
-
contain_exactly(:foo, :bar)
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
26
|
it 'can create an RSpec shared context' do
|
56
27
|
sc = ChefVault::TestFixtures.rspec_shared_context
|
57
28
|
expect(sc).to be_a(Module)
|
@@ -63,18 +34,6 @@ RSpec.describe ChefVault::TestFixtures do
|
|
63
34
|
mod2 = ChefVault::TestFixtures.rspec_shared_context
|
64
35
|
expect(mod2).to be(mod1)
|
65
36
|
end
|
66
|
-
|
67
|
-
it 'allows for the plugin list to be make explicit' do
|
68
|
-
ChefVault::TestFixtures.plugin :foo
|
69
|
-
expect(ChefVault::TestFixtures.plugins).to include(:foo)
|
70
|
-
expect(ChefVault::TestFixtures.plugins).not_to include(:bar)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'allows for plugins to be blacklisted' do
|
74
|
-
ChefVault::TestFixtures.disregard_plugin :foo
|
75
|
-
expect(ChefVault::TestFixtures.plugins).not_to include(:foo)
|
76
|
-
expect(ChefVault::TestFixtures.plugins).to include(:bar)
|
77
|
-
end
|
78
37
|
end
|
79
38
|
|
80
39
|
describe 'Stub a Vault' do
|
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.
|
4
|
+
version: 0.3.0.20150417141427
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James FitzGibbon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.5'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: little-plugger
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.1'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.1'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rdoc
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,48 +206,6 @@ dependencies:
|
|
220
206
|
- - "~>"
|
221
207
|
- !ruby/object:Gem::Version
|
222
208
|
version: '0.2'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: pry-byebug
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - "~>"
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '3.0'
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - "~>"
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '3.0'
|
237
|
-
- !ruby/object:Gem::Dependency
|
238
|
-
name: pry-rescue
|
239
|
-
requirement: !ruby/object:Gem::Requirement
|
240
|
-
requirements:
|
241
|
-
- - "~>"
|
242
|
-
- !ruby/object:Gem::Version
|
243
|
-
version: '1.3'
|
244
|
-
type: :development
|
245
|
-
prerelease: false
|
246
|
-
version_requirements: !ruby/object:Gem::Requirement
|
247
|
-
requirements:
|
248
|
-
- - "~>"
|
249
|
-
- !ruby/object:Gem::Version
|
250
|
-
version: '1.3'
|
251
|
-
- !ruby/object:Gem::Dependency
|
252
|
-
name: pry-stack_explorer
|
253
|
-
requirement: !ruby/object:Gem::Requirement
|
254
|
-
requirements:
|
255
|
-
- - "~>"
|
256
|
-
- !ruby/object:Gem::Version
|
257
|
-
version: '0.4'
|
258
|
-
type: :development
|
259
|
-
prerelease: false
|
260
|
-
version_requirements: !ruby/object:Gem::Requirement
|
261
|
-
requirements:
|
262
|
-
- - "~>"
|
263
|
-
- !ruby/object:Gem::Version
|
264
|
-
version: '0.4'
|
265
209
|
- !ruby/object:Gem::Dependency
|
266
210
|
name: yard
|
267
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -278,7 +222,9 @@ dependencies:
|
|
278
222
|
version: '0.8'
|
279
223
|
description: |-
|
280
224
|
chef-vault-testfixtures provides an RSpec shared context that
|
281
|
-
|
225
|
+
stubs access to chef-vault encrypted data bags using the same
|
226
|
+
fallback mechanism as the `chef_vault_item` helper from the
|
227
|
+
[chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)
|
282
228
|
email:
|
283
229
|
- james.i.fitzgibbon@nordstrom.com
|
284
230
|
executables: []
|
@@ -302,8 +248,6 @@ files:
|
|
302
248
|
- lib/hoe/markdown.rb
|
303
249
|
- spec/lib/chef-vault/test_fixtures_spec.rb
|
304
250
|
- spec/spec_helper.rb
|
305
|
-
- spec/support/chef-vault/test_fixtures/bar.rb
|
306
|
-
- spec/support/chef-vault/test_fixtures/foo.rb
|
307
251
|
homepage: https://github.com/Nordstrom/chef-vault-testfixtures
|
308
252
|
licenses:
|
309
253
|
- apache2
|
@@ -326,9 +270,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
270
|
version: '0'
|
327
271
|
requirements: []
|
328
272
|
rubyforge_project:
|
329
|
-
rubygems_version: 2.4.
|
273
|
+
rubygems_version: 2.4.6
|
330
274
|
signing_key:
|
331
275
|
specification_version: 4
|
332
|
-
summary: chef-vault-testfixtures provides an RSpec shared context that
|
333
|
-
|
276
|
+
summary: chef-vault-testfixtures provides an RSpec shared context that stubs access
|
277
|
+
to chef-vault encrypted data bags using the same fallback mechanism as the `chef_vault_item`
|
278
|
+
helper from the [chef-vault cookbook](https://supermarket.chef.io/cookbooks/chef-vault)
|
334
279
|
test_files: []
|
280
|
+
has_rdoc:
|