diff options
Diffstat (limited to 'spec/lib/gitlab/x509/tag_spec.rb')
-rw-r--r-- | spec/lib/gitlab/x509/tag_spec.rb | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/spec/lib/gitlab/x509/tag_spec.rb b/spec/lib/gitlab/x509/tag_spec.rb index e20ef688db5..4368c3d7a4b 100644 --- a/spec/lib/gitlab/x509/tag_spec.rb +++ b/spec/lib/gitlab/x509/tag_spec.rb @@ -1,15 +1,24 @@ # frozen_string_literal: true require 'spec_helper' -RSpec.describe Gitlab::X509::Tag do - subject(:signature) { described_class.new(project.repository, tag).signature } - +RSpec.describe Gitlab::X509::Tag, feature_category: :source_code_management do describe '#signature' do - let_it_be(:project) { create(:project, :repository) } - let_it_be(:repository) { project.repository.raw } + let(:tag_id) { 'v1.1.1' } + let(:tag) { instance_double('Gitlab::Git::Tag') } + let_it_be(:user) { create(:user, email: X509Helpers::User1.tag_email) } + let_it_be(:project) { create(:project, path: X509Helpers::User1.path, creator: user) } + let(:signature) { described_class.new(project.repository, tag).signature } + + before do + allow(tag).to receive(:id).and_return(tag_id) + allow(tag).to receive(:has_signature?).and_return(true) + allow(tag).to receive(:user_email).and_return(user.email) + allow(tag).to receive(:date).and_return(X509Helpers::User1.signed_tag_time) + allow(Gitlab::Git::Tag).to receive(:extract_signature_lazily).with(project.repository, tag_id) + .and_return([X509Helpers::User1.signed_tag_signature, X509Helpers::User1.signed_tag_base_data]) + end describe 'signed tag' do - let(:tag) { project.repository.find_tag('v1.1.1') } let(:certificate_attributes) do { subject_key_identifier: X509Helpers::User1.tag_certificate_subject_key_identifier, @@ -32,11 +41,5 @@ RSpec.describe Gitlab::X509::Tag do it { expect(signature.x509_certificate).to have_attributes(certificate_attributes) } it { expect(signature.x509_certificate.x509_issuer).to have_attributes(issuer_attributes) } end - - describe 'unsigned tag' do - let(:tag) { project.repository.find_tag('v1.0.0') } - - it { expect(signature).to be_nil } - end end end |