diff options
author | Balasankar "Balu" C <balasankar@gitlab.com> | 2019-02-08 09:36:47 +0300 |
---|---|---|
committer | Balasankar "Balu" C <balasankar@gitlab.com> | 2019-02-14 08:59:42 +0300 |
commit | e9c3c3bf31a3d16d111026abb2c5a9e8eb68afd1 (patch) | |
tree | c5db0ebe62323f69e90ac7a2d6d493d9fcceba0a /spec/requests/api | |
parent | 034d1d02b9dec544dd4d04c61ca4404775c57970 (diff) |
Add specs for commit's GPG signature API endpoint
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/commits_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index bc892523cf8..066f1d6862a 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -1457,4 +1457,42 @@ describe API::Commits do expect(response).to have_gitlab_http_status(404) end end + + describe 'GET /projects/:id/repository/commits/:sha/signature' do + let!(:project) { create(:project, :repository, :public) } + let(:project_id) { project.id } + let(:commit_id) { project.repository.commit.id } + let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}/signature" } + + context 'when commit does not exist' do + let(:commit_id) { 'unknown' } + + it_behaves_like '404 response' do + let(:request) { get api(route, current_user) } + let(:message) { '404 Commit Not Found' } + end + end + + context 'unsigned commit' do + it_behaves_like '404 response' do + let(:request) { get api(route, current_user) } + let(:message) { '404 GPG Signature Not Found'} + end + end + + context 'signed commit' do + let(:commit) { project.repository.commit(GpgHelpers::SIGNED_COMMIT_SHA) } + let(:commit_id) { commit.id } + + it 'returns correct JSON' do + get api(route, current_user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['gpg_key_id']).to eq(commit.signature.gpg_key_id) + expect(json_response['gpg_key_subkey_id']).to eq(commit.signature.gpg_key_subkey_id) + expect(json_response['gpg_key_primary_keyid']).to eq(commit.signature.gpg_key_primary_keyid) + expect(json_response['verification_status']).to eq(commit.signature.verification_status) + end + end + end end |