Secrets test
This commit is contained in:
@@ -249,7 +249,7 @@ class CliAppTest < CliTestCase
|
|||||||
|
|
||||||
test "exec separate arguments" do
|
test "exec separate arguments" do
|
||||||
run_command("exec", "ruby", " -v").tap do |output|
|
run_command("exec", "ruby", " -v").tap do |output|
|
||||||
assert_match "docker run --rm --env-file .kamal/env/roles/app-web.env dhh/app:latest ruby -v", output
|
assert_match "docker run --rm dhh/app:latest ruby -v", output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,38 +1,10 @@
|
|||||||
require_relative "cli_test_case"
|
require_relative "cli_test_case"
|
||||||
|
|
||||||
class CliSecretsTest < CliTestCase
|
class CliSecretsTest < CliTestCase
|
||||||
test "login" do
|
|
||||||
assert_equal "LOGIN_TOKEN", run_command("login", "--adapter", "test")
|
|
||||||
end
|
|
||||||
|
|
||||||
test "login failed" do
|
|
||||||
assert_raises("Boom!") do
|
|
||||||
run_command("login", "--adapter", "test", "--adapter-options", "boom:true")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
test "fetch" do
|
test "fetch" do
|
||||||
assert_equal "oof", run_command("fetch", "foo", "--adapter", "test")
|
|
||||||
end
|
|
||||||
|
|
||||||
test "fetch failed" do
|
|
||||||
assert_raises("Boom!") do
|
|
||||||
run_command("fetch", "foo", "--adapter", "test", "--adapter-options", "boom:true")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
test "fetch_all" do
|
|
||||||
assert_equal \
|
assert_equal \
|
||||||
"\\{\\\"foo\\\":\\\"oof\\\",\\\"bar\\\":\\\"rab\\\",\\\"baz\\\":\\\"zab\\\"\\}",
|
"\\{\\\"foo\\\":\\\"oof\\\",\\\"bar\\\":\\\"rab\\\",\\\"baz\\\":\\\"zab\\\"\\}",
|
||||||
run_command("fetch_all", "foo", "bar", "baz", "--adapter", "test")
|
run_command("fetch", "foo", "bar", "baz", "--account", "myaccount", "--adapter", "test")
|
||||||
end
|
|
||||||
|
|
||||||
test "fetch_all failed" do
|
|
||||||
assert_raises("Boom!") do
|
|
||||||
assert_equal \
|
|
||||||
"\\{\\\"foo\\\":\\\"oof\\\",\\\"bar\\\":\\\"rab\\\",\\\"baz\\\":\\\"zab\\\"\\}",
|
|
||||||
run_command("fetch_all", "foo", "bar", "baz", "--adapter", "test", "--adapter-options", "boom:true")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "extract" do
|
test "extract" do
|
||||||
|
|||||||
@@ -64,19 +64,14 @@ class ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Kamal::Secrets::Adapters::Test
|
class Kamal::Secrets::Adapters::Test < Kamal::Secrets::Adapters::Base
|
||||||
def login(boom: false)
|
def login(account)
|
||||||
raise "Boom!" if boom
|
"MYSESSION"
|
||||||
"LOGIN_TOKEN"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch(name, boom: false)
|
def fetch_from_vault(secrets, account:, session:)
|
||||||
raise "Boom!" if boom
|
raise "No Session" unless session == "MYSESSION"
|
||||||
name.reverse
|
raise "Boom!" if ENV["BOOM"]
|
||||||
end
|
secrets.to_h { |name| [ name, name.reverse ] }
|
||||||
|
|
||||||
def fetch_all(*names, boom: false)
|
|
||||||
raise "Boom!" if boom
|
|
||||||
names.to_h { |name| [ name, name.reverse ] }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user