Skip to content

Commit f79d3bc

Browse files
author
vitalie
committed
PRD Hashicorp Vault Integration (#280)
1 parent 16cdde6 commit f79d3bc

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/travis/scheduler/serialize/worker/config/decrypt.rb

+6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ def apply
99
config[key] = process_env(config[key]) if config[key]
1010
end
1111

12+
force_vault_to_be_secure!(config)
13+
config[:vault] = decryptor.decrypt(config[:vault]) if config[:vault]
1214
config[:addons] = decryptor.decrypt(config[:addons]) if config[:addons]
1315
config
1416
end
1517

1618
private
1719

20+
def force_vault_to_be_secure!(config)
21+
config[:vault].delete(:token) if config.dig(:vault, :token).is_a?(String)
22+
end
23+
1824
def secure_env?
1925
!!options[:secure_env]
2026
end

spec/travis/scheduler/serialize/worker/config_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ def encrypt(string)
7171
let(:env) { [{ FOO: 'foo', BAR: 'bar' }, encrypt('BAZ=baz')] }
7272
it { should eql env: ['FOO=foo', 'BAR=bar', 'SECURE BAZ=baz'], global_env: ['FOO=foo', 'BAR=bar', 'SECURE BAZ=baz'] }
7373
end
74+
75+
describe 'decrypts vault secure token' do
76+
let(:config) { { vault: { token: { secure: encrypt('my_key') } } } }
77+
it { should eql vault: {token: 'my_key'} }
78+
end
79+
80+
describe 'clears vault unsecure token' do
81+
let(:config) { { vault: { token: 'my_key' } } }
82+
it { should eql vault: {} }
83+
end
7484
end
7585

7686
describe 'with secure env disabled' do

0 commit comments

Comments
 (0)