Commit b62c1620 authored by Alexis Reigel's avatar Alexis Reigel

drop backwards compatibility for valid_signature

parent aa98c36e
......@@ -20,14 +20,6 @@ class GpgSignature < ActiveRecord::Base
validates :project_id, presence: true
validates :gpg_key_primary_keyid, presence: true
# backwards compatibility: legacy records that weren't migrated to use the
# new `#verification_status` have `#valid_signature` set instead
def verified?
return valid_signature if verification_status.nil?
super
end
def gpg_key_primary_keyid
super&.upcase
end
......
......@@ -6,15 +6,9 @@ module Gitlab
end
def run
# `OR valid_signature` is for backwards compatibility: legacy records
# that weren't migrated to use the new `#verification_status` have
# `#valid_signature` set instead
GpgSignature
.select(:id, :commit_sha, :project_id)
.where('gpg_key_id IS NULL OR valid_signature = ? OR verification_status <> ?',
false,
GpgSignature.verification_statuses[:verified]
)
.where('gpg_key_id IS NULL OR verification_status <> ?', GpgSignature.verification_statuses[:verified])
.where(gpg_key_primary_keyid: @gpg_key.primary_keyid)
.find_each { |sig| sig.gpg_commit.update_signature!(sig) }
end
......
......@@ -25,34 +25,4 @@ RSpec.describe GpgSignature do
gpg_signature.commit
end
end
describe '#verified?' do
it 'returns true when `verification_status` is not set, but `valid_signature` is true' do
signature = create :gpg_signature, valid_signature: true, verification_status: nil
expect(signature.verified?).to be true
expect(signature.reload.verified?).to be true
end
it 'returns true when `verification_status` is set to :verified' do
signature = create :gpg_signature, verification_status: :verified
expect(signature.verified?).to be true
expect(signature.reload.verified?).to be true
end
it 'returns false when `verification_status` is set to :unknown_key' do
signature = create :gpg_signature, verification_status: :unknown_key
expect(signature.verified?).to be false
expect(signature.reload.verified?).to be false
end
it 'returns false when `verification_status` is not set, but `valid_signature` is false' do
signature = create :gpg_signature, valid_signature: false, verification_status: nil
expect(signature.verified?).to be false
expect(signature.reload.verified?).to be false
end
end
end
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