Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡ Allow warning messages to be configurable
When a Rails application that uses Vault::Rails runs its test suite using an in-memory cipher (a common use case), many hundreds of log messages warning about using an insecure cipher in a production-like environment can result. This increases the logging noise and reduces the value of logging during testing. Adding configuration methods to disable these in-memory warnings improves the signal to noise ratio when using this gem in a test environment.
- Loading branch information
Showing
3 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "spec_helper" | ||
|
||
describe Vault::Rails::Configurable do | ||
subject do | ||
Class.new.tap do |c| | ||
c.class.instance_eval do | ||
include Vault::Rails::Configurable | ||
end | ||
end | ||
end | ||
|
||
describe '.in_memory_warnings_enabled?' do | ||
context 'when unconfigured' do | ||
it 'returns true' do | ||
expect(subject.in_memory_warnings_enabled?).to eq true | ||
end | ||
end | ||
|
||
context 'when configured as on' do | ||
before do | ||
subject.configure do |vault| | ||
vault.in_memory_warnings_enabled = true | ||
end | ||
end | ||
|
||
it 'returns true' do | ||
expect(subject.in_memory_warnings_enabled?).to eq true | ||
end | ||
end | ||
|
||
context 'when configured as off' do | ||
before do | ||
subject.configure do |vault| | ||
vault.in_memory_warnings_enabled = false | ||
end | ||
end | ||
|
||
it 'returns false' do | ||
expect(subject.in_memory_warnings_enabled?).to eq false | ||
end | ||
end | ||
end | ||
end |