Commit efe4067e authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-signed-commits-spec' into 'master'

Speed up "show GPG badge" feature specs

See merge request gitlab-org/gitlab-ce!23359
parents 7f477f7b 87d1e865
# frozen_string_literal: true
require 'spec_helper'
describe 'GPG signed commits', :js do
set(:ref) { :'2d1096e3a0ecf1d2baf6dee036cc80775d4940ba' }
let(:project) { create(:project, :repository) }
describe 'GPG signed commits' do
let(:project) { create(:project, :public, :repository) }
it 'changes from unverified to verified when the user changes his email to match the gpg key' do
user = create :user, email: 'unrelated.user@example.org'
project.add_maintainer(user)
ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
user = create(:user, email: 'unrelated.user@example.org')
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user
end
sign_in(user)
visit project_commits_path(project, ref)
visit project_commit_path(project, ref)
within '#commits-list' do
expect(page).to have_content 'Unverified'
expect(page).not_to have_content 'Verified'
end
expect(page).to have_link 'Unverified'
expect(page).not_to have_link 'Verified'
# user changes his email which makes the gpg key verified
perform_enqueued_jobs do
......@@ -27,41 +24,33 @@ describe 'GPG signed commits', :js do
user.update!(email: GpgHelpers::User1.emails.first)
end
visit project_commits_path(project, ref)
visit project_commit_path(project, ref)
within '#commits-list' do
expect(page).to have_content 'Unverified'
expect(page).to have_content 'Verified'
end
expect(page).not_to have_link 'Unverified'
expect(page).to have_link 'Verified'
end
it 'changes from unverified to verified when the user adds the missing gpg key' do
user = create :user, email: GpgHelpers::User1.emails.first
project.add_maintainer(user)
ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
user = create(:user, email: GpgHelpers::User1.emails.first)
sign_in(user)
visit project_commit_path(project, ref)
visit project_commits_path(project, ref)
within '#commits-list' do
expect(page).to have_content 'Unverified'
expect(page).not_to have_content 'Verified'
end
expect(page).to have_link 'Unverified'
expect(page).not_to have_link 'Verified'
# user adds the gpg key which makes the signature valid
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user
end
visit project_commits_path(project, ref)
visit project_commit_path(project, ref)
within '#commits-list' do
expect(page).to have_content 'Unverified'
expect(page).to have_content 'Verified'
end
expect(page).not_to have_link 'Unverified'
expect(page).to have_link 'Verified'
end
context 'shows popover badges' do
context 'shows popover badges', :js do
let(:user_1) do
create :user, email: GpgHelpers::User1.emails.first, username: 'nannie.bernhard', name: 'Nannie Bernhard'
end
......@@ -85,19 +74,10 @@ describe 'GPG signed commits', :js do
end
end
before do
user = create :user
project.add_maintainer(user)
sign_in(user)
end
it 'unverified signature' do
visit project_commits_path(project, ref)
visit project_commit_path(project, GpgHelpers::SIGNED_COMMIT_SHA)
within(find('.commit', text: 'signed commit by bette cartwright')) do
click_on 'Unverified'
end
click_on 'Unverified'
within '.popover' do
expect(page).to have_content 'This commit was signed with an unverified signature.'
......@@ -108,11 +88,9 @@ describe 'GPG signed commits', :js do
it 'unverified signature: user email does not match the committer email, but is the same user' do
user_2_key
visit project_commits_path(project, ref)
visit project_commit_path(project, GpgHelpers::DIFFERING_EMAIL_SHA)
within(find('.commit', text: 'signed and authored commit by bette cartwright, different email')) do
click_on 'Unverified'
end
click_on 'Unverified'
within '.popover' do
expect(page).to have_content 'This commit was signed with a verified signature, but the committer email is not verified to belong to the same user.'
......@@ -125,11 +103,9 @@ describe 'GPG signed commits', :js do
it 'unverified signature: user email does not match the committer email' do
user_2_key
visit project_commits_path(project, ref)
visit project_commit_path(project, GpgHelpers::SIGNED_COMMIT_SHA)
within(find('.commit', text: 'signed commit by bette cartwright')) do
click_on 'Unverified'
end
click_on 'Unverified'
within '.popover' do
expect(page).to have_content "This commit was signed with a different user's verified signature."
......@@ -142,11 +118,9 @@ describe 'GPG signed commits', :js do
it 'verified and the gpg user has a gitlab profile' do
user_1_key
visit project_commits_path(project, ref)
visit project_commit_path(project, GpgHelpers::SIGNED_AND_AUTHORED_SHA)
within(find('.commit', text: 'signed and authored commit by nannie bernhard')) do
click_on 'Verified'
end
click_on 'Verified'
within '.popover' do
expect(page).to have_content 'This commit was signed with a verified signature and the committer email is verified to belong to the same user.'
......@@ -159,20 +133,16 @@ describe 'GPG signed commits', :js do
it "verified and the gpg user's profile doesn't exist anymore" do
user_1_key
visit project_commits_path(project, ref)
visit project_commit_path(project, GpgHelpers::SIGNED_AND_AUTHORED_SHA)
# wait for the signature to get generated
within(find('.commit', text: 'signed and authored commit by nannie bernhard')) do
expect(page).to have_content 'Verified'
end
expect(page).to have_link 'Verified'
user_1.destroy!
refresh
within(find('.commit', text: 'signed and authored commit by nannie bernhard')) do
click_on 'Verified'
end
click_on 'Verified'
within '.popover' do
expect(page).to have_content 'This commit was signed with a verified signature and the committer email is verified to belong to the same user.'
......
# frozen_string_literal: true
module GpgHelpers
SIGNED_COMMIT_SHA = '8a852d50dda17cc8fd1408d2fd0c5b0f24c76ca4'.freeze
SIGNED_COMMIT_SHA = '8a852d50dda17cc8fd1408d2fd0c5b0f24c76ca4'
SIGNED_AND_AUTHORED_SHA = '3c1d9a0266cb0c62d926f4a6c649beed561846f5'
DIFFERING_EMAIL_SHA = 'a17a9f66543673edf0a3d1c6b93bdda3fe600f32'
module User1
extend self
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment