aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/commands
diff options
context:
space:
mode:
authorYuji Yaginuma <yuuji.yaginuma@gmail.com>2018-02-08 19:49:50 +0900
committerGitHub <noreply@github.com>2018-02-08 19:49:50 +0900
commit5d75ef72e61f00bbf987aa5a73e9ca2a1e23d718 (patch)
tree9723c9838931817aefa7974d30e57e05c1ba5ca2 /railties/test/commands
parentcc523fba9baf09849aeb59db28dab04135839f34 (diff)
downloadrails-5d75ef72e61f00bbf987aa5a73e9ca2a1e23d718.tar.gz
rails-5d75ef72e61f00bbf987aa5a73e9ca2a1e23d718.tar.bz2
rails-5d75ef72e61f00bbf987aa5a73e9ca2a1e23d718.zip
Do not add master key when `RAILS_MASTER_KEY` env specified (#31922)
Fixes #31917
Diffstat (limited to 'railties/test/commands')
-rw-r--r--railties/test/commands/credentials_test.rb12
-rw-r--r--railties/test/commands/encrypted_test.rb12
2 files changed, 24 insertions, 0 deletions
diff --git a/railties/test/commands/credentials_test.rb b/railties/test/commands/credentials_test.rb
index 7c464b3fde..663ee73bcd 100644
--- a/railties/test/commands/credentials_test.rb
+++ b/railties/test/commands/credentials_test.rb
@@ -43,6 +43,18 @@ class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase
assert_match(/api_key: abc/, run_show_command)
end
+ test "edit command does not add master key when `RAILS_MASTER_KEY` env specified" do
+ Dir.chdir(app_path) do
+ key = IO.binread("config/master.key").strip
+ FileUtils.rm("config/master.key")
+
+ switch_env("RAILS_MASTER_KEY", key) do
+ run_edit_command
+ assert_not File.exist?("config/master.key")
+ end
+ end
+ end
+
test "show credentials" do
assert_match(/access_key_id: 123/, run_show_command)
end
diff --git a/railties/test/commands/encrypted_test.rb b/railties/test/commands/encrypted_test.rb
index 6647dcc902..9fc73d5f18 100644
--- a/railties/test/commands/encrypted_test.rb
+++ b/railties/test/commands/encrypted_test.rb
@@ -33,6 +33,18 @@ class Rails::Command::EncryptedCommandTest < ActiveSupport::TestCase
end
end
+ test "edit command does not add master key when `RAILS_MASTER_KEY` env specified" do
+ Dir.chdir(app_path) do
+ key = IO.binread("config/master.key").strip
+ FileUtils.rm("config/master.key")
+
+ switch_env("RAILS_MASTER_KEY", key) do
+ run_edit_command("config/tokens.yml.enc")
+ assert_not File.exist?("config/master.key")
+ end
+ end
+ end
+
test "edit encrypts file with custom key" do
run_edit_command("config/tokens.yml.enc", key: "config/tokens.key")