提交 bad1041b 编写于 作者: Y yuuji.yaginuma

Add test for reads environment credential file with environment variable key

上级 2e7e9fe1
# frozen_string_literal: true
require "isolation/abstract_unit"
require "env_helpers"
class Rails::CredentialsTest < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation
include ActiveSupport::Testing::Isolation, EnvHelpers
setup :build_app
teardown :teardown_app
......@@ -38,6 +39,21 @@ class Rails::CredentialsTest < ActiveSupport::TestCase
end
end
test "reads credentials using environment variable key" do
with_credentials do |content, key|
Dir.chdir(app_path) do
Dir.mkdir("config/credentials")
File.write("config/credentials/production.yml.enc", content)
end
switch_env("RAILS_MASTER_KEY", key) do
app("production")
assert_equal "revealed", Rails.application.credentials.mystery
end
end
end
private
def with_credentials
key = "2117e775dc2024d4f49ddf3aeb585919"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册