2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::X509::Tag do
|
2021-10-27 15:23:28 +05:30
|
|
|
subject(:signature) { described_class.new(project.repository, tag).signature }
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
describe '#signature' do
|
|
|
|
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
describe 'signed tag' do
|
2020-05-24 23:13:21 +05:30
|
|
|
let(:tag) { project.repository.find_tag('v1.1.1') }
|
|
|
|
let(:certificate_attributes) do
|
|
|
|
{
|
|
|
|
subject_key_identifier: X509Helpers::User1.tag_certificate_subject_key_identifier,
|
|
|
|
subject: X509Helpers::User1.certificate_subject,
|
|
|
|
email: X509Helpers::User1.certificate_email,
|
|
|
|
serial_number: X509Helpers::User1.tag_certificate_serial
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:issuer_attributes) do
|
|
|
|
{
|
|
|
|
subject_key_identifier: X509Helpers::User1.tag_issuer_subject_key_identifier,
|
|
|
|
subject: X509Helpers::User1.tag_certificate_issuer,
|
|
|
|
crl_url: X509Helpers::User1.tag_certificate_crl
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(signature).not_to be_nil }
|
|
|
|
it { expect(signature.verification_status).to eq(:unverified) }
|
|
|
|
it { expect(signature.x509_certificate).to have_attributes(certificate_attributes) }
|
|
|
|
it { expect(signature.x509_certificate.x509_issuer).to have_attributes(issuer_attributes) }
|
|
|
|
end
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
describe 'unsigned tag' do
|
2020-05-24 23:13:21 +05:30
|
|
|
let(:tag) { project.repository.find_tag('v1.0.0') }
|
|
|
|
|
|
|
|
it { expect(signature).to be_nil }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|