Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b66e3726
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b66e3726
编写于
7月 06, 2017
作者:
A
Alexis Reigel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
also update gpg_signatures when gpg_key is null
上级
7f03282f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
16 deletion
+56
-16
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
+1
-1
spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
+55
-15
未找到文件。
lib/gitlab/gpg/invalid_gpg_signature_updater.rb
浏览文件 @
b66e3726
...
...
@@ -7,7 +7,7 @@ module Gitlab
def
run
GpgSignature
.
where
(
valid_signature:
false
)
.
where
(
'gpg_key_id IS NULL OR valid_signature = ?'
,
false
)
.
where
(
gpg_key_primary_keyid:
@gpg_key
.
primary_keyid
)
.
find_each
do
|
gpg_signature
|
Gitlab
::
Gpg
::
Commit
.
new
(
gpg_signature
.
commit
).
update_signature!
(
gpg_signature
)
...
...
spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
浏览文件 @
b66e3726
...
...
@@ -19,29 +19,60 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
create
:commit
,
git_commit:
raw_commit
,
project:
project
end
let!
(
:gpg_signature
)
do
create
:gpg_signature
,
project:
project
,
commit_sha:
commit_sha
,
gpg_key:
nil
,
gpg_key_primary_keyid:
GpgHelpers
::
User1
.
primary_keyid
,
valid_signature:
false
end
before
do
allow_any_instance_of
(
GpgSignature
).
to
receive
(
:commit
).
and_return
(
commit
)
end
context
'gpg signature did have an associated gpg key which was removed later'
do
let!
(
:user
)
{
create
:user
,
email:
GpgHelpers
::
User1
.
emails
.
first
}
let!
(
:valid_gpg_signature
)
do
create
:gpg_signature
,
project:
project
,
commit_sha:
commit_sha
,
gpg_key:
nil
,
gpg_key_primary_keyid:
GpgHelpers
::
User1
.
primary_keyid
,
valid_signature:
true
end
it
'assigns the gpg key to the signature when the missing gpg key is added'
do
# InvalidGpgSignatureUpdater is called by the after_create hook
gpg_key
=
create
:gpg_key
,
key:
GpgHelpers
::
User1
.
public_key
,
user:
user
expect
(
valid_gpg_signature
.
reload
.
gpg_key
).
to
eq
gpg_key
end
it
'does not assign the gpg key when an unrelated gpg key is added'
do
# InvalidGpgSignatureUpdater is called by the after_create hook
create
:gpg_key
,
key:
GpgHelpers
::
User2
.
public_key
,
user:
user
expect
(
valid_gpg_signature
.
reload
.
gpg_key
).
to
be_nil
end
end
context
'gpg signature did not have an associated gpg key'
do
let!
(
:user
)
{
create
:user
,
email:
GpgHelpers
::
User1
.
emails
.
first
}
let!
(
:invalid_gpg_signature
)
do
create
:gpg_signature
,
project:
project
,
commit_sha:
commit_sha
,
gpg_key:
nil
,
gpg_key_primary_keyid:
GpgHelpers
::
User1
.
primary_keyid
,
valid_signature:
false
end
it
'updates the signature to being valid when the missing gpg key is added'
do
# InvalidGpgSignatureUpdater is called by the after_create hook
create
:gpg_key
,
key:
GpgHelpers
::
User1
.
public_key
,
user:
user
expect
(
gpg_signature
.
reload
.
valid_signature
).
to
be_truthy
expect
(
invalid_
gpg_signature
.
reload
.
valid_signature
).
to
be_truthy
end
it
'keeps the signature at being invalid when an unrelated gpg key is added'
do
...
...
@@ -50,7 +81,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
key:
GpgHelpers
::
User2
.
public_key
,
user:
user
expect
(
gpg_signature
.
reload
.
valid_signature
).
to
be_falsey
expect
(
invalid_
gpg_signature
.
reload
.
valid_signature
).
to
be_falsey
end
end
...
...
@@ -61,17 +92,26 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
end
end
let!
(
:invalid_gpg_signature
)
do
create
:gpg_signature
,
project:
project
,
commit_sha:
commit_sha
,
gpg_key:
nil
,
gpg_key_primary_keyid:
GpgHelpers
::
User1
.
primary_keyid
,
valid_signature:
false
end
it
'updates the signature to being valid when the user updates the email address'
do
create
:gpg_key
,
key:
GpgHelpers
::
User1
.
public_key
,
user:
user
expect
(
gpg_signature
.
reload
.
valid_signature
).
to
be_falsey
expect
(
invalid_
gpg_signature
.
reload
.
valid_signature
).
to
be_falsey
# InvalidGpgSignatureUpdater is called by the after_update hook
user
.
update_attributes!
(
email:
GpgHelpers
::
User1
.
emails
.
first
)
expect
(
gpg_signature
.
reload
.
valid_signature
).
to
be_truthy
expect
(
invalid_
gpg_signature
.
reload
.
valid_signature
).
to
be_truthy
end
it
'keeps the signature at being invalid when the changed email address is still unrelated'
do
...
...
@@ -79,12 +119,12 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
key:
GpgHelpers
::
User1
.
public_key
,
user:
user
expect
(
gpg_signature
.
reload
.
valid_signature
).
to
be_falsey
expect
(
invalid_
gpg_signature
.
reload
.
valid_signature
).
to
be_falsey
# InvalidGpgSignatureUpdater is called by the after_update hook
user
.
update_attributes!
(
email:
'still.unrelated@example.com'
)
expect
(
gpg_signature
.
reload
.
valid_signature
).
to
be_falsey
expect
(
invalid_
gpg_signature
.
reload
.
valid_signature
).
to
be_falsey
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录