Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
dc09b995
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc09b995
编写于
2月 08, 2018
作者:
Y
Yuji Yaginuma
提交者:
yuuji.yaginuma
2月 08, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not add master key when `RAILS_MASTER_KEY` env specified (#31922)
Fixes #31917
上级
d2e3a288
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
2 deletion
+27
-2
railties/lib/rails/commands/credentials/credentials_command.rb
...ies/lib/rails/commands/credentials/credentials_command.rb
+1
-1
railties/lib/rails/commands/encrypted/encrypted_command.rb
railties/lib/rails/commands/encrypted/encrypted_command.rb
+2
-1
railties/test/commands/credentials_test.rb
railties/test/commands/credentials_test.rb
+12
-0
railties/test/commands/encrypted_test.rb
railties/test/commands/encrypted_test.rb
+12
-0
未找到文件。
railties/lib/rails/commands/credentials/credentials_command.rb
浏览文件 @
dc09b995
...
...
@@ -20,7 +20,7 @@ def edit
require_application_and_environment!
ensure_editor_available
(
command:
"bin/rails credentials:edit"
)
||
(
return
)
ensure_master_key_has_been_added
ensure_master_key_has_been_added
if
Rails
.
application
.
credentials
.
key
.
nil?
ensure_credentials_have_been_added
catch_editing_exceptions
do
...
...
railties/lib/rails/commands/encrypted/encrypted_command.rb
浏览文件 @
dc09b995
...
...
@@ -21,9 +21,10 @@ def help
def
edit
(
file_path
)
require_application_and_environment!
encrypted
=
Rails
.
application
.
encrypted
(
file_path
,
key_path:
options
[
:key
])
ensure_editor_available
(
command:
"bin/rails encrypted:edit"
)
||
(
return
)
ensure_encryption_key_has_been_added
(
options
[
:key
])
ensure_encryption_key_has_been_added
(
options
[
:key
])
if
encrypted
.
key
.
nil?
ensure_encrypted_file_has_been_added
(
file_path
,
options
[
:key
])
catch_editing_exceptions
do
...
...
railties/test/commands/credentials_test.rb
浏览文件 @
dc09b995
...
...
@@ -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
...
...
railties/test/commands/encrypted_test.rb
浏览文件 @
dc09b995
...
...
@@ -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"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录