Add test adapter and interpolate secrets in integration tests
This commit is contained in:
@@ -20,7 +20,7 @@ class Kamal::Cli::Secrets < Kamal::Cli::Base
|
|||||||
|
|
||||||
raise "Could not find secret #{name}" if value.nil?
|
raise "Could not find secret #{name}" if value.nil?
|
||||||
|
|
||||||
puts JSON.parse(secrets).fetch(name)
|
puts value
|
||||||
rescue => e
|
rescue => e
|
||||||
handle_error(e)
|
handle_error(e)
|
||||||
end
|
end
|
||||||
|
|||||||
10
lib/kamal/secrets/adapters/test.rb
Normal file
10
lib/kamal/secrets/adapters/test.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class Kamal::Secrets::Adapters::Test < Kamal::Secrets::Adapters::Base
|
||||||
|
private
|
||||||
|
def login(account)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_from_vault(secrets, account:, session:)
|
||||||
|
secrets.to_h { |secret| [ secret, secret.reverse ] }
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
SECRET_TOKEN='1234 with "中文"'
|
SECRET_TOKEN='1234 with "中文"'
|
||||||
SECRET_TAG='TAGME'
|
SECRET_TAG='TAGME'
|
||||||
|
SECRETS=$(kamal secrets fetch --adapter test --account test INTERPOLATED_SECRET1 INTERPOLATED_SECRET2)
|
||||||
|
INTERPOLATED_SECRET1=$(kamal secrets extract INTERPOLATED_SECRET1 ${SECRETS})
|
||||||
|
INTERPOLATED_SECRET2=$(kamal secrets extract INTERPOLATED_SECRET2 ${SECRETS})
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ env:
|
|||||||
HOST_TOKEN: "${HOST_TOKEN}"
|
HOST_TOKEN: "${HOST_TOKEN}"
|
||||||
secret:
|
secret:
|
||||||
- SECRET_TOKEN
|
- SECRET_TOKEN
|
||||||
|
- INTERPOLATED_SECRET1
|
||||||
|
- INTERPOLATED_SECRET2
|
||||||
tags:
|
tags:
|
||||||
tag1:
|
tag1:
|
||||||
CLEAR_TAG: tagged
|
CLEAR_TAG: tagged
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class MainTest < IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def assert_envs(version:)
|
def assert_envs(version:)
|
||||||
assert_env :CLEAR_TOKEN, "4321", version: version, vm: :vm1
|
assert_env :CLEAR_TOKEN, "4321", version: version, vm: :vm1
|
||||||
assert_env :HOST_TOKEN, "abcd", version: version, vm: :vm1
|
assert_env :HOST_TOKEN, "abcd", version: version, vm: :vm1
|
||||||
assert_env :SECRET_TOKEN, "1234 with \"中文\"", version: version, vm: :vm1
|
assert_env :SECRET_TOKEN, "1234 with \"中文\"", version: version, vm: :vm1
|
||||||
@@ -110,6 +110,8 @@ class MainTest < IntegrationTest
|
|||||||
assert_no_env :SECRET_TAG, version: version, vm: :vm1
|
assert_no_env :SECRET_TAG, version: version, vm: :vm1
|
||||||
assert_env :CLEAR_TAG, "tagged", version: version, vm: :vm2
|
assert_env :CLEAR_TAG, "tagged", version: version, vm: :vm2
|
||||||
assert_env :SECRET_TAG, "TAGME", version: version, vm: :vm2
|
assert_env :SECRET_TAG, "TAGME", version: version, vm: :vm2
|
||||||
|
assert_env :INTERPOLATED_SECRET1, "1TERCES_DETALOPRETNI", version: version, vm: :vm2
|
||||||
|
assert_env :INTERPOLATED_SECRET2, "2TERCES_DETALOPRETNI", version: version, vm: :vm2
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_env(key, value, vm:, version:)
|
def assert_env(key, value, vm:, version:)
|
||||||
|
|||||||
Reference in New Issue
Block a user