Commit eb77e106 authored by Alexis Reigel's avatar Alexis Reigel

add second gpg key for specs

parent 87c0fd34
...@@ -2,6 +2,6 @@ require_relative '../support/gpg_helpers' ...@@ -2,6 +2,6 @@ require_relative '../support/gpg_helpers'
FactoryGirl.define do FactoryGirl.define do
factory :gpg_key do factory :gpg_key do
key GpgHelpers.public_key key GpgHelpers::User1.public_key
end end
end end
...@@ -4,7 +4,7 @@ describe Gitlab::Gpg do ...@@ -4,7 +4,7 @@ describe Gitlab::Gpg do
describe '.fingerprints_from_key' do describe '.fingerprints_from_key' do
it 'returns the fingerprint' do it 'returns the fingerprint' do
expect( expect(
described_class.fingerprints_from_key(GpgHelpers.public_key) described_class.fingerprints_from_key(GpgHelpers::User1.public_key)
).to eq ['4F4840A503964251CF7D7F5DC728AF10972E97C0'] ).to eq ['4F4840A503964251CF7D7F5DC728AF10972E97C0']
end end
...@@ -19,7 +19,7 @@ describe Gitlab::Gpg do ...@@ -19,7 +19,7 @@ describe Gitlab::Gpg do
it 'stores the key in the keychain' do it 'stores the key in the keychain' do
expect(GPGME::Key.find(:public, '4F4840A503964251CF7D7F5DC728AF10972E97C0')).to eq [] expect(GPGME::Key.find(:public, '4F4840A503964251CF7D7F5DC728AF10972E97C0')).to eq []
Gitlab::Gpg.add_to_keychain(GpgHelpers.public_key) Gitlab::Gpg.add_to_keychain(GpgHelpers::User1.public_key)
expect(GPGME::Key.find(:public, '4F4840A503964251CF7D7F5DC728AF10972E97C0')).not_to eq [] expect(GPGME::Key.find(:public, '4F4840A503964251CF7D7F5DC728AF10972E97C0')).not_to eq []
end end
...@@ -27,7 +27,7 @@ describe Gitlab::Gpg do ...@@ -27,7 +27,7 @@ describe Gitlab::Gpg do
describe '.remove_from_keychain', :gpg do describe '.remove_from_keychain', :gpg do
it 'removes the key from the keychain' do it 'removes the key from the keychain' do
Gitlab::Gpg.add_to_keychain(GpgHelpers.public_key) Gitlab::Gpg.add_to_keychain(GpgHelpers::User1.public_key)
expect(GPGME::Key.find(:public, '4F4840A503964251CF7D7F5DC728AF10972E97C0')).not_to eq [] expect(GPGME::Key.find(:public, '4F4840A503964251CF7D7F5DC728AF10972E97C0')).not_to eq []
Gitlab::Gpg.remove_from_keychain('4F4840A503964251CF7D7F5DC728AF10972E97C0') Gitlab::Gpg.remove_from_keychain('4F4840A503964251CF7D7F5DC728AF10972E97C0')
......
...@@ -422,11 +422,11 @@ eos ...@@ -422,11 +422,11 @@ eos
context 'signed commit', :gpg do context 'signed commit', :gpg do
it 'returns a valid signature if the public key is known' do it 'returns a valid signature if the public key is known' do
GPGME::Key.import(GpgHelpers.public_key) GPGME::Key.import(GpgHelpers::User1.public_key)
raw_commit = double(:raw_commit, signature: [ raw_commit = double(:raw_commit, signature: [
GpgHelpers.signed_commit_signature, GpgHelpers::User1.signed_commit_signature,
GpgHelpers.signed_commit_base_data GpgHelpers::User1.signed_commit_base_data
]) ])
allow(raw_commit).to receive :save! allow(raw_commit).to receive :save!
...@@ -440,8 +440,8 @@ eos ...@@ -440,8 +440,8 @@ eos
it 'returns an invalid signature if the public commit is unknown', :gpg do it 'returns an invalid signature if the public commit is unknown', :gpg do
raw_commit = double(:raw_commit, signature: [ raw_commit = double(:raw_commit, signature: [
GpgHelpers.signed_commit_signature, GpgHelpers::User1.signed_commit_signature,
GpgHelpers.signed_commit_base_data GpgHelpers::User1.signed_commit_base_data
]) ])
allow(raw_commit).to receive :save! allow(raw_commit).to receive :save!
......
...@@ -16,7 +16,7 @@ describe GpgKey do ...@@ -16,7 +16,7 @@ describe GpgKey do
context 'callbacks', :gpg do context 'callbacks', :gpg do
describe 'extract_fingerprint' do describe 'extract_fingerprint' do
it 'extracts the fingerprint from the gpg key' do it 'extracts the fingerprint from the gpg key' do
gpg_key = described_class.new(key: GpgHelpers.public_key) gpg_key = described_class.new(key: GpgHelpers::User1.public_key)
gpg_key.valid? gpg_key.valid?
expect(gpg_key.fingerprint).to eq '4F4840A503964251CF7D7F5DC728AF10972E97C0' expect(gpg_key.fingerprint).to eq '4F4840A503964251CF7D7F5DC728AF10972E97C0'
end end
...@@ -24,7 +24,7 @@ describe GpgKey do ...@@ -24,7 +24,7 @@ describe GpgKey do
describe 'add_to_keychain' do describe 'add_to_keychain' do
it 'calls add_to_keychain after create' do it 'calls add_to_keychain after create' do
expect(Gitlab::Gpg).to receive(:add_to_keychain).with(GpgHelpers.public_key) expect(Gitlab::Gpg).to receive(:add_to_keychain).with(GpgHelpers::User1.public_key)
create :gpg_key create :gpg_key
end end
end end
......
module GpgHelpers module GpgHelpers
module User1
extend self extend self
def signed_commit_signature def signed_commit_signature
...@@ -219,4 +220,89 @@ module GpgHelpers ...@@ -219,4 +220,89 @@ module GpgHelpers
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
PUBLICKEY PUBLICKEY
end end
def key_id
'972E97C0'
end
end
module User2
extend self
def private_key
<<~KEY.strip
-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v1
lQHYBFiuqioBBADg46jkiATWMy9t1npxFWJ77xibPXdUo36LAZgZ6uGungSzcFL4
50bdEyMMGm5RJp6DCYkZlwQDlM//YEqwf0Cmq/AibC5m9bHr7hf5sMxl40ssJ4fj
dzT6odihO0vxD2ARSrtiwkESzFxjJ51mjOfdPvAGf0ucxzgeRfUlCrM3kwARAQAB
AAP8CJlDFnbywR9dWfqBxi19sFMOk/smCObNQanuTcx6CDcu4zHi0Yxx6BoNCQES
cDRCLX5HevnpZngzQB3qa7dga+yqxKzwO8v0P0hliL81B1ZVXUk9TWhBj3NS3m3v
+kf2XeTxuZFb9fj44/4HpfbQ2yazTs/Xa+/ZeMqFPCYSNEECAOtjIbwHdfjkpVWR
uiwphRkNimv5hdObufs63m9uqhpKPdPKmr2IXgahPZg5PooxqE0k9IXaX2pBsJUF
DyuL1dsCAPSVL+YAOviP8ecM1jvdKpkFDd67kR5C+7jEvOGl+c2aX3qLvKt62HPR
+DxvYE0Oy0xfoHT14zNSfqthmlhIPqkB/i4WyJaafQVv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Q6XxvDjQ7wdBCNBpwkzmTYIBuI0EWK6q
KgEEAN7mdR1U5xtmWfE6OXQoEBP4DlubIEtRPQGYs+yYDg+5cNK2Hta+Js8LzBwJ
0JhWTQhExid5lSJar+jlziu2F8tHiODySu6+iZDgTh3iHIjpHQwvFdhndcy7rtW5
JwWBstRHDV5FnXoA13c1zVW4VbuazS8IbSJ0HyJJkGhQtorxABEBAAGInwQYAQIA
CQUCWK6qKgIbDAAKCRC/nZJfkR79ZUIIBADVsEMK5U9gRS1lfBcfsJYN9fpnI5E6
tC2lrt6LngJbqEpfd9gek6K7jIeuiaMaUg1OOMdyWwmmf+qaImLOQH3/GXshFZX5
FWkOyFnebKY6V2kuIqAjn5GXqZm07hO0z0FjOIgQLbiH4iRosHKVljPiiB9vNcoX
wnG0c8xS7AlUMQ==
=Erp5
-----END PGP PUBLIC KEY BLOCK-----
KEY
end
def key_id
'911EFD65'
end
def signature
'6D494CA6FC90C0CAE0910E42BF9D925F911EFD65'
end
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