Allow ommitting AWS account while fetching secrets
This commit is contained in:
@@ -156,14 +156,45 @@ class AwsSecretsManagerAdapterTest < SecretAdapterTestCase
|
||||
assert_equal "AWS CLI is not installed", error.message
|
||||
end
|
||||
|
||||
test "fetch without account option omits --profile" do
|
||||
stub_ticks.with("aws --version 2> /dev/null")
|
||||
stub_ticks
|
||||
.with("aws secretsmanager batch-get-secret-value --secret-id-list secret/KEY1 secret/KEY2")
|
||||
.returns(<<~JSON)
|
||||
{
|
||||
"SecretValues": [
|
||||
{
|
||||
"ARN": "arn:aws:secretsmanager:us-east-1:aaaaaaaaaaaa:secret:secret",
|
||||
"Name": "secret",
|
||||
"VersionId": "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv",
|
||||
"SecretString": "{\\"KEY1\\":\\"VALUE1\\", \\"KEY2\\":\\"VALUE2\\"}",
|
||||
"VersionStages": [
|
||||
"AWSCURRENT"
|
||||
],
|
||||
"CreatedDate": "2024-01-01T00:00:00.000000"
|
||||
}
|
||||
],
|
||||
"Errors": []
|
||||
}
|
||||
JSON
|
||||
|
||||
json = JSON.parse(shellunescape(run_command("fetch", "--from", "secret", "KEY1", "KEY2", account: nil)))
|
||||
|
||||
expected_json = {
|
||||
"secret/KEY1"=>"VALUE1",
|
||||
"secret/KEY2"=>"VALUE2"
|
||||
}
|
||||
assert_equal expected_json, json
|
||||
end
|
||||
|
||||
private
|
||||
def run_command(*command)
|
||||
def run_command(*command, account: "default")
|
||||
stdouted do
|
||||
Kamal::Cli::Secrets.start \
|
||||
[ *command,
|
||||
"-c", "test/fixtures/deploy_with_accessories.yml",
|
||||
"--adapter", "aws_secrets_manager",
|
||||
"--account", "default" ]
|
||||
args = [ *command,
|
||||
"-c", "test/fixtures/deploy_with_accessories.yml",
|
||||
"--adapter", "aws_secrets_manager" ]
|
||||
args += [ "--account", account ] if account
|
||||
Kamal::Cli::Secrets.start(args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user