diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-05 21:09:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-05 21:09:16 +0300 |
commit | 2b2299ea5f8717ad59a47c1c40d951409dfeb35b (patch) | |
tree | 806b797004e307caf431cea03a6d3c913c1aaf4c /spec/views | |
parent | c4acd4624d61ef923453561a698c905c0ffa7b57 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/projects/commit/show.html.haml_spec.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb index 6d2237e773e..4cfff00d390 100644 --- a/spec/views/projects/commit/show.html.haml_spec.rb +++ b/spec/views/projects/commit/show.html.haml_spec.rb @@ -71,14 +71,12 @@ RSpec.describe 'projects/commit/show.html.haml', feature_category: :source_code_ let(:title) { badge_attributes['data-title'].value } let(:content) { badge_attributes['data-content'].value } - before do - render - end - context 'with GPG' do let(:commit) { project.commit(GpgHelpers::SIGNED_COMMIT_SHA) } it 'renders unverified badge' do + render + expect(title).to include('This commit was signed with an unverified signature.') expect(content).to include(commit.signature.gpg_key_primary_keyid) end @@ -88,15 +86,34 @@ RSpec.describe 'projects/commit/show.html.haml', feature_category: :source_code_ let(:commit) { project.commit('7b5160f9bb23a3d58a0accdbe89da13b96b1ece9') } it 'renders unverified badge' do + render + expect(title).to include('This commit was signed with an unverified signature.') expect(content).to match(/SSH key fingerprint:[\s\S].+#{commit.signature.key_fingerprint_sha256}/) end + + context 'when the commit has been signed by GitLab' do + it 'renders verified badge' do + allow_next_instance_of(Gitlab::Ssh::Commit) do |instance| + allow(instance).to receive(:signer).and_return(:SIGNER_SYSTEM) + end + + render + + expect(content).to match(/SSH key fingerprint:[\s\S].+#{commit.signature.key_fingerprint_sha256}/) + expect(title).to include( + 'This commit was created in the GitLab UI, and signed with a GitLab-verified signature.' + ) + end + end end context 'with X.509' do let(:commit) { project.commit('189a6c924013fc3fe40d6f1ec1dc20214183bc97') } it 'renders unverified badge' do + render + expect(title).to include('This commit was signed with an <strong>unverified</strong> signature.') expect(content).to include(commit.signature.x509_certificate.subject_key_identifier.tr(":", " ")) end |