Skip to content

Commit c9ce004

Browse files
author
Gavin Williams
committed
Update Vault test utilities to use local 'VAULT_TOKEN' auth if not running in CI
1 parent fca60fe commit c9ce004

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

spec/spec_helper_acceptance.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ class { 'elasticsearch':
107107

108108
c.before :context, :with_license do
109109
Vault.address = ENV['VAULT_ADDR']
110-
Vault.auth.approle ENV['VAULT_APPROLE_ROLE_ID'], ENV['VAULT_APPROLE_SECRET_ID']
110+
if ENV['CI']
111+
Vault.auth.approle(ENV['VAULT_APPROLE_ROLE_ID'], ENV['VAULT_APPROLE_SECRET_ID'])
112+
else
113+
Vault.auth.token(ENV['VAULT_TOKEN'])
114+
end
111115
licenses = Vault.with_retries(Vault::HTTPConnectionError) do
112116
Vault.logical.read(ENV['VAULT_PATH'])
113117
end.data

spec/spec_utilities.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@ def pid_file
104104
end
105105

106106
def vault_available?
107-
%w[VAULT_ADDR VAULT_APPROLE_ROLE_ID VAULT_APPROLE_SECRET_ID VAULT_PATH].select do |var|
108-
ENV[var].nil?
109-
end.empty?
107+
if ENV['CI']
108+
%w[VAULT_ADDR VAULT_APPROLE_ROLE_ID VAULT_APPROLE_SECRET_ID VAULT_PATH].select do |var|
109+
ENV[var].nil?
110+
end.empty?
111+
else
112+
true
113+
end
110114
end
111115

112116
def http_retry(url)

0 commit comments

Comments
 (0)