Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
866ef2bb
Commit
866ef2bb
authored
Sep 28, 2017
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more specs to cover subkeys scenarios
parent
b27549df
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
252 additions
and
0 deletions
+252
-0
spec/features/profiles/gpg_keys_spec.rb
spec/features/profiles/gpg_keys_spec.rb
+12
-0
spec/lib/gitlab/gpg/commit_spec.rb
spec/lib/gitlab/gpg/commit_spec.rb
+39
-0
spec/models/gpg_signature_spec.rb
spec/models/gpg_signature_spec.rb
+1
-0
spec/support/gpg_helpers.rb
spec/support/gpg_helpers.rb
+200
-0
No files found.
spec/features/profiles/gpg_keys_spec.rb
View file @
866ef2bb
...
@@ -20,6 +20,18 @@ feature 'Profile > GPG Keys' do
...
@@ -20,6 +20,18 @@ feature 'Profile > GPG Keys' do
expect
(
page
).
to
have_content
(
'bette.cartwright@example.net Unverified'
)
expect
(
page
).
to
have_content
(
'bette.cartwright@example.net Unverified'
)
expect
(
page
).
to
have_content
(
GpgHelpers
::
User2
.
fingerprint
)
expect
(
page
).
to
have_content
(
GpgHelpers
::
User2
.
fingerprint
)
end
end
scenario
'with multiple subkeys'
do
fill_in
(
'Key'
,
with:
GpgHelpers
::
User3
.
public_key
)
click_button
(
'Add key'
)
expect
(
page
).
to
have_content
(
'john.doe@example.com Unverified'
)
expect
(
page
).
to
have_content
(
GpgHelpers
::
User3
.
fingerprint
)
GpgHelpers
::
User3
.
subkey_fingerprints
.
each
do
|
fingerprint
|
expect
(
page
).
to
have_content
(
fingerprint
)
end
end
end
end
scenario
'User sees their key'
do
scenario
'User sees their key'
do
...
...
spec/lib/gitlab/gpg/commit_spec.rb
View file @
866ef2bb
...
@@ -63,6 +63,45 @@ describe Gitlab::Gpg::Commit do
...
@@ -63,6 +63,45 @@ describe Gitlab::Gpg::Commit do
it_behaves_like
'returns the cached signature on second call'
it_behaves_like
'returns the cached signature on second call'
end
end
context
'commit signed with a subkey'
do
let!
(
:commit
)
{
create
:commit
,
project:
project
,
sha:
commit_sha
,
committer_email:
GpgHelpers
::
User3
.
emails
.
first
}
let!
(
:user
)
{
create
(
:user
,
email:
GpgHelpers
::
User3
.
emails
.
first
)
}
let!
(
:gpg_key
)
do
create
:gpg_key
,
key:
GpgHelpers
::
User3
.
public_key
,
user:
user
end
let
(
:gpg_key_subkey
)
do
gpg_key
.
subkeys
.
find_by
(
fingerprint:
'0522DD29B98F167CD8421752E38FFCAF75ABD92A'
)
end
before
do
allow
(
Rugged
::
Commit
).
to
receive
(
:extract_signature
)
.
with
(
Rugged
::
Repository
,
commit_sha
)
.
and_return
(
[
GpgHelpers
::
User3
.
signed_commit_signature
,
GpgHelpers
::
User3
.
signed_commit_base_data
]
)
end
it
'returns a valid signature'
do
expect
(
described_class
.
new
(
commit
).
signature
).
to
have_attributes
(
commit_sha:
commit_sha
,
project:
project
,
gpg_key:
gpg_key_subkey
,
gpg_key_primary_keyid:
gpg_key_subkey
.
keyid
,
gpg_key_user_name:
GpgHelpers
::
User3
.
names
.
first
,
gpg_key_user_email:
GpgHelpers
::
User3
.
emails
.
first
,
verification_status:
'verified'
)
end
it_behaves_like
'returns the cached signature on second call'
end
context
'user email does not match the committer email, but is the same user'
do
context
'user email does not match the committer email, but is the same user'
do
let!
(
:commit
)
{
create
:commit
,
project:
project
,
sha:
commit_sha
,
committer_email:
GpgHelpers
::
User2
.
emails
.
first
}
let!
(
:commit
)
{
create
:commit
,
project:
project
,
sha:
commit_sha
,
committer_email:
GpgHelpers
::
User2
.
emails
.
first
}
...
...
spec/models/gpg_signature_spec.rb
View file @
866ef2bb
...
@@ -4,6 +4,7 @@ RSpec.describe GpgSignature do
...
@@ -4,6 +4,7 @@ RSpec.describe GpgSignature do
describe
'associations'
do
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:gpg_key
)
}
it
{
is_expected
.
to
belong_to
(
:gpg_key
)
}
it
{
is_expected
.
to
belong_to
(
:gpg_key_subkey
)
}
end
end
describe
'validation'
do
describe
'validation'
do
...
...
spec/support/gpg_helpers.rb
View file @
866ef2bb
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment