summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-11-27 10:08:19 +0000
committerRémy Coutable <remy@rymai.me>2018-11-27 10:08:19 +0000
commitefe4067e2dcef209f1a4cf72daaf2a329b09f515 (patch)
treed866bcdcaf9b1bc0c94e3ef2f093aa5d43475007
parent7f477f7bb781683584b69b01d5258f0827c00d60 (diff)
parent87d1e865f57fbaa73f44ac196ec712ce2224e7e7 (diff)
downloadgitlab-ce-efe4067e2dcef209f1a4cf72daaf2a329b09f515.tar.gz
Merge branch 'rs-signed-commits-spec' into 'master'
Speed up "show GPG badge" feature specs See merge request gitlab-org/gitlab-ce!23359
-rw-r--r--spec/features/signed_commits_spec.rb94
-rw-r--r--spec/support/helpers/gpg_helpers.rb6
2 files changed, 37 insertions, 63 deletions
diff --git a/spec/features/signed_commits_spec.rb b/spec/features/signed_commits_spec.rb
index ef0e55a1468..e2b3444272e 100644
--- a/spec/features/signed_commits_spec.rb
+++ b/spec/features/signed_commits_spec.rb
@@ -1,25 +1,22 @@
+# 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.'
diff --git a/spec/support/helpers/gpg_helpers.rb b/spec/support/helpers/gpg_helpers.rb
index 3f7279a50e0..8d1637228d0 100644
--- a/spec/support/helpers/gpg_helpers.rb
+++ b/spec/support/helpers/gpg_helpers.rb
@@ -1,5 +1,9 @@
+# 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