Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
678b59aa
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,发现更多精彩内容 >>
未验证
提交
678b59aa
编写于
10月 17, 2019
作者:
K
Kasper Timm Hansen
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'keep_symbolic_link_for_credentials'
上级
5defe266
6db6432d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
8 deletion
+41
-8
activesupport/CHANGELOG.md
activesupport/CHANGELOG.md
+4
-0
activesupport/lib/active_support/encrypted_file.rb
activesupport/lib/active_support/encrypted_file.rb
+2
-1
activesupport/test/encrypted_file_test.rb
activesupport/test/encrypted_file_test.rb
+35
-7
未找到文件。
activesupport/CHANGELOG.md
浏览文件 @
678b59aa
*
Support symbolic links for
`content_path`
in
`ActiveSupport::EncryptedFile`
.
*Takumi Shotoku*
*
Improve
`Range#===`
,
`Range#include?`
, and
`Range#cover?`
to work with beginless (startless)
*
Improve
`Range#===`
,
`Range#include?`
, and
`Range#cover?`
to work with beginless (startless)
and endless range targets.
and endless range targets.
...
...
activesupport/lib/active_support/encrypted_file.rb
浏览文件 @
678b59aa
...
@@ -30,7 +30,8 @@ def self.generate_key
...
@@ -30,7 +30,8 @@ def self.generate_key
attr_reader
:content_path
,
:key_path
,
:env_key
,
:raise_if_missing_key
attr_reader
:content_path
,
:key_path
,
:env_key
,
:raise_if_missing_key
def
initialize
(
content_path
:,
key_path
:,
env_key
:,
raise_if_missing_key
:)
def
initialize
(
content_path
:,
key_path
:,
env_key
:,
raise_if_missing_key
:)
@content_path
,
@key_path
=
Pathname
.
new
(
content_path
),
Pathname
.
new
(
key_path
)
@content_path
=
Pathname
.
new
(
content_path
).
yield_self
{
|
path
|
path
.
symlink?
?
path
.
realpath
:
path
}
@key_path
=
Pathname
.
new
(
key_path
)
@env_key
,
@raise_if_missing_key
=
env_key
,
raise_if_missing_key
@env_key
,
@raise_if_missing_key
=
env_key
,
raise_if_missing_key
end
end
...
...
activesupport/test/encrypted_file_test.rb
浏览文件 @
678b59aa
...
@@ -12,9 +12,7 @@ class EncryptedFileTest < ActiveSupport::TestCase
...
@@ -12,9 +12,7 @@ class EncryptedFileTest < ActiveSupport::TestCase
@key_path
=
File
.
join
(
Dir
.
tmpdir
,
"content.txt.key"
)
@key_path
=
File
.
join
(
Dir
.
tmpdir
,
"content.txt.key"
)
File
.
write
(
@key_path
,
ActiveSupport
::
EncryptedFile
.
generate_key
)
File
.
write
(
@key_path
,
ActiveSupport
::
EncryptedFile
.
generate_key
)
@encrypted_file
=
ActiveSupport
::
EncryptedFile
.
new
(
@encrypted_file
=
encrypted_file
(
@content_path
)
content_path:
@content_path
,
key_path:
@key_path
,
env_key:
"CONTENT_KEY"
,
raise_if_missing_key:
true
)
end
end
teardown
do
teardown
do
...
@@ -50,10 +48,40 @@ class EncryptedFileTest < ActiveSupport::TestCase
...
@@ -50,10 +48,40 @@ class EncryptedFileTest < ActiveSupport::TestCase
end
end
test
"raise MissingKeyError when key is missing"
do
test
"raise MissingKeyError when key is missing"
do
assert_raise
(
ActiveSupport
::
EncryptedFile
::
MissingKeyError
)
do
assert_raise
ActiveSupport
::
EncryptedFile
::
MissingKeyError
do
ActiveSupport
::
EncryptedFile
.
new
(
encrypted_file
(
@content_path
,
key_path:
""
,
env_key:
""
).
read
content_path:
@content_path
,
key_path:
""
,
env_key:
""
,
raise_if_missing_key:
true
).
read
end
end
end
end
test
"respects existing content_path symlink"
do
@encrypted_file
.
write
(
@content
)
symlink_path
=
File
.
join
(
Dir
.
tmpdir
,
"content_symlink.txt.enc"
)
File
.
symlink
(
@encrypted_file
.
content_path
,
symlink_path
)
encrypted_file
(
symlink_path
).
write
(
@content
)
assert
File
.
symlink?
(
symlink_path
)
assert_equal
@content
,
@encrypted_file
.
read
ensure
FileUtils
.
rm_rf
symlink_path
end
test
"creates new content_path symlink if it's dead"
do
symlink_path
=
File
.
join
(
Dir
.
tmpdir
,
"content_symlink.txt.enc"
)
File
.
symlink
(
@content_path
,
symlink_path
)
encrypted_file
(
symlink_path
).
write
(
@content
)
assert
File
.
exist?
(
@content_path
)
assert_equal
@content
,
@encrypted_file
.
read
ensure
FileUtils
.
rm_rf
symlink_path
end
private
def
encrypted_file
(
content_path
,
key_path:
@key_path
,
env_key:
"CONTENT_KEY"
)
ActiveSupport
::
EncryptedFile
.
new
(
content_path:
@content_path
,
key_path:
key_path
,
env_key:
env_key
,
raise_if_missing_key:
true
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录