Skip to content

Commit

Permalink
Update Vault test utilities to use local 'VAULT_TOKEN' auth if not ru…
Browse files Browse the repository at this point in the history
…nning in CI
  • Loading branch information
Gavin Williams committed Jul 3, 2020
1 parent fca60fe commit c9ce004
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ class { 'elasticsearch':

c.before :context, :with_license do
Vault.address = ENV['VAULT_ADDR']
Vault.auth.approle ENV['VAULT_APPROLE_ROLE_ID'], ENV['VAULT_APPROLE_SECRET_ID']
if ENV['CI']
Vault.auth.approle(ENV['VAULT_APPROLE_ROLE_ID'], ENV['VAULT_APPROLE_SECRET_ID'])
else
Vault.auth.token(ENV['VAULT_TOKEN'])
end
licenses = Vault.with_retries(Vault::HTTPConnectionError) do
Vault.logical.read(ENV['VAULT_PATH'])
end.data
Expand Down
10 changes: 7 additions & 3 deletions spec/spec_utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ def pid_file
end

def vault_available?
%w[VAULT_ADDR VAULT_APPROLE_ROLE_ID VAULT_APPROLE_SECRET_ID VAULT_PATH].select do |var|
ENV[var].nil?
end.empty?
if ENV['CI']
%w[VAULT_ADDR VAULT_APPROLE_ROLE_ID VAULT_APPROLE_SECRET_ID VAULT_PATH].select do |var|
ENV[var].nil?
end.empty?
else
true
end
end

def http_retry(url)
Expand Down

0 comments on commit c9ce004

Please sign in to comment.