diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-06-15 10:28:28 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-27 15:42:53 +0200 |
commit | 34810acd6c3d4dd27f43f6f07e47b4e06bb95f82 (patch) | |
tree | 85e29ac5cb80247e5d8236453170100dd2047cd2 /spec/models | |
parent | 7b616d39efaa7cba933d17dfae010d393c18d057 (diff) | |
download | gitlab-ce-34810acd6c3d4dd27f43f6f07e47b4e06bb95f82.tar.gz |
move signature cache read to Gpg::Commit
as we write the cache in the gpg commit class already the read should
also happen there.
This also removes all logic from the main commit class, which just
proxies the call to the Gpg::Commit now.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/commit_spec.rb | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 4370c78e6fd..528b211c9d6 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -414,86 +414,4 @@ eos expect(described_class.valid_hash?('a' * 41)).to be false end end - - describe '#signature' do - it 'returns nil if the commit is not signed' do - expect(commit.signature).to be_nil - end - - context 'signed commit', :gpg do - context 'known public key' do - it 'returns a valid signature' do - create :gpg_key, key: GpgHelpers::User1.public_key - - raw_commit = double(:raw_commit, signature: [ - GpgHelpers::User1.signed_commit_signature, - GpgHelpers::User1.signed_commit_base_data - ], sha: '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33') - allow(raw_commit).to receive :save! - - commit = create :commit, - git_commit: raw_commit, - project: project - - expect(commit.signature.valid_signature?).to be_truthy - end - - it 'returns the cached validation result on second call', :gpg do - create :gpg_key, key: GpgHelpers::User1.public_key - - raw_commit = double(:raw_commit, signature: [ - GpgHelpers::User1.signed_commit_signature, - GpgHelpers::User1.signed_commit_base_data - ], sha: '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33') - allow(raw_commit).to receive :save! - - commit = create :commit, - git_commit: raw_commit, - project: project - - expect(Gitlab::Gpg::Commit).to receive(:new).and_call_original - expect(commit.signature.valid_signature?).to be_truthy - - # second call returns the cache - expect(Gitlab::Gpg::Commit).not_to receive(:new).and_call_original - expect(commit.signature.valid_signature?).to be_truthy - end - end - - context 'unknown public key' do - it 'returns an invalid signature if the public key is unknown', :gpg do - raw_commit = double(:raw_commit, signature: [ - GpgHelpers::User1.signed_commit_signature, - GpgHelpers::User1.signed_commit_base_data - ], sha: '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33') - allow(raw_commit).to receive :save! - - commit = create :commit, - git_commit: raw_commit, - project: project - - expect(commit.signature.valid_signature?).to be_falsey - end - - it 'returns the cached validation result on second call', :gpg do - raw_commit = double(:raw_commit, signature: [ - GpgHelpers::User1.signed_commit_signature, - GpgHelpers::User1.signed_commit_base_data - ], sha: '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33') - allow(raw_commit).to receive :save! - - commit = create :commit, - git_commit: raw_commit, - project: project - - expect(Gitlab::Gpg::Commit).to receive(:new).and_call_original - expect(commit.signature.valid_signature?).to be_falsey - - # second call returns the cache - expect(Gitlab::Gpg::Commit).not_to receive(:new).and_call_original - expect(commit.signature.valid_signature?).to be_falsey - end - end - end - end end |