chef-vault 4.2.5 → 4.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ RSpec.describe ChefVault::User do
2
+ let(:item) { double(ChefVault::Item) }
3
+ let(:user) { ChefVault::User.new("foo", "bar") }
4
+
5
+ before do
6
+ allow(ChefVault::Item).to receive(:load).with("foo", "bar") { item }
7
+ allow(item).to receive(:[]).with("id") { "bar" }
8
+ allow(item).to receive(:[]).with("password") { "baz" }
9
+ end
10
+
11
+ describe "#new" do
12
+ it "loads item" do
13
+ expect(ChefVault::Item).to receive(:load).with("foo", "bar")
14
+
15
+ ChefVault::User.new("foo", "bar")
16
+ end
17
+ end
18
+
19
+ describe "#[]" do
20
+ it "returns the value of the 'id' parameter" do
21
+ expect(user["id"]).to eq "bar"
22
+ end
23
+ end
24
+
25
+ describe "decrypt_password" do
26
+ it "echoes warning" do
27
+ expect(ChefVault::Log).to receive(:warn).with("This method is deprecated, please switch to item['value'] calls")
28
+ user.decrypt_password
29
+ end
30
+
31
+ it "returns items password" do
32
+ expect(item).to receive(:[]).with("password")
33
+ expect(user.decrypt_password).to eq "baz"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,65 @@
1
+ #
2
+ # Helper for configuring the Chef Zero server
3
+ # (inspired by ChefSpec)
4
+ #
5
+ def chef_zero
6
+ require "socket"
7
+ require "tmpdir"
8
+ require "fileutils"
9
+ require "chef_zero/server"
10
+ # Find a free TCP port
11
+ server = TCPServer.new("127.0.0.1", 0)
12
+ port = server.addr[1].to_i
13
+ server.close
14
+ # Define a Chef Zero Server
15
+ server = ChefZero::Server.new(port: port)
16
+ # Write the private key
17
+ tmp = Dir.mktmpdir
18
+ key = File.join(tmp, "client.pem")
19
+ File.write(key, ChefZero::PRIVATE_KEY)
20
+ # Configure the server
21
+ Chef::Config[:client_key] = key
22
+ Chef::Config[:client_name] = "chefvault"
23
+ Chef::Config[:node_name] = "chefvault"
24
+ Chef::Config[:chef_server_url] = server.url
25
+ # Exit handlers
26
+ at_exit { FileUtils.rm_rf(tmp) }
27
+ at_exit { server.stop if server.running? }
28
+ server
29
+ end
30
+
31
+ RSpec.describe ChefVault do
32
+ let(:vault) { ChefVault.new("foo") }
33
+
34
+ describe "#new" do
35
+ context "with only a vault parameter specified" do
36
+
37
+ it "assigns 'foo' to the vault accessor" do
38
+ expect(vault.vault).to eq "foo"
39
+ end
40
+ end
41
+ end
42
+
43
+ context "with a vault and config file parameter specified" do
44
+ before do
45
+ allow(IO).to receive(:read).with("config.rb").and_return("node_name 'myserver'")
46
+ end
47
+
48
+ let(:vault) { ChefVault.new("foo", "config.rb") }
49
+
50
+ it "assigns 'foo' to the vault accessor" do
51
+ expect(vault.vault).to eq "foo"
52
+ end
53
+
54
+ it "loads the Chef config values" do
55
+ expect(ChefVault).to receive(:load_config).with("config.rb")
56
+ vault
57
+ end
58
+ end
59
+
60
+ describe "#version" do
61
+ it "the version method equals VERSION" do
62
+ expect(vault.version).to eq(ChefVault::VERSION)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,92 @@
1
+ require_relative "../lib/chef-vault"
2
+ require "simplecov"
3
+ SimpleCov.start
4
+
5
+ # This file was generated by the `rspec --init` command. Conventionally, all
6
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
7
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
8
+ # file to always be loaded, without a need to explicitly require it in any files.
9
+ #
10
+ # Given that it is always loaded, you are encouraged to keep this file as
11
+ # light-weight as possible. Requiring heavyweight dependencies from this file
12
+ # will add to the boot time of your test suite on EVERY test run, even for an
13
+ # individual file that may not need all of that loaded. Instead, consider making
14
+ # a separate helper file that requires the additional dependencies and performs
15
+ # the additional setup, and require it from the spec files that actually need it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ mocks.allow_message_expectations_on_nil = true
44
+ end
45
+
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
56
+ # For more details, see:
57
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
58
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
59
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
60
+ config.disable_monkey_patching!
61
+
62
+ # This setting enables warnings. It's recommended, but in some cases may
63
+ # be too noisy due to issues in dependencies.
64
+ # config.warnings = true
65
+
66
+ # Many RSpec users commonly either run the entire suite or an individual
67
+ # file, and it's useful to allow more verbose output when running an
68
+ # individual spec file.
69
+ if config.files_to_run.one?
70
+ # Use the documentation formatter for detailed output,
71
+ # unless a formatter has already been configured
72
+ # (e.g. via a command-line flag).
73
+ config.default_formatter = "doc"
74
+ end
75
+
76
+ # Print the 10 slowest examples and example groups at the
77
+ # end of the spec run, to help surface which specs are running
78
+ # particularly slow.
79
+ config.profile_examples = 10
80
+
81
+ # Run specs in random order to surface order dependencies. If you find an
82
+ # order dependency and want to debug it, you can fix the order by providing
83
+ # the seed, which is printed after each run.
84
+ # --seed 1234
85
+ config.order = :random
86
+
87
+ # Seed global randomization in this process using the `--seed` CLI option.
88
+ # Setting this allows you to use `--seed` to deterministically reproduce
89
+ # test failures related to randomization by passing the same `--seed` value
90
+ # as the one that triggered the failure.
91
+ Kernel.srand config.seed
92
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.5
4
+ version: 4.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-17 00:00:00.000000000 Z
11
+ date: 2026-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: syslog
@@ -63,6 +63,15 @@ files:
63
63
  - lib/chef/knife/vault_rotate_keys.rb
64
64
  - lib/chef/knife/vault_show.rb
65
65
  - lib/chef/knife/vault_update.rb
66
+ - spec/chef-vault/actor_spec.rb
67
+ - spec/chef-vault/certificate_spec.rb
68
+ - spec/chef-vault/chef_api_spec.rb
69
+ - spec/chef-vault/item_keys_spec.rb
70
+ - spec/chef-vault/item_spec.rb
71
+ - spec/chef-vault/user_spec.rb
72
+ - spec/chef-vault_spec.rb
73
+ - spec/chef/helper_spec.rb
74
+ - spec/spec_helper.rb
66
75
  homepage: https://github.com/chef/chef-vault
67
76
  licenses:
68
77
  - Apache-2.0