diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 21:10:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 21:10:03 +0300 |
commit | b6847c621ff246e6abceb90545d5a608318762d6 (patch) | |
tree | 460da2a6c2be2e4f5164c2bba1851b66260f850d /lib/api | |
parent | c08d9c22569d1c9e7c7737e183969593394133d9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/commits.rb | 8 | ||||
-rw-r--r-- | lib/api/entities/commit_signature.rb | 12 | ||||
-rw-r--r-- | lib/api/entities/gpg_commit_signature.rb | 12 | ||||
-rw-r--r-- | lib/api/entities/x509_certificate.rb | 15 | ||||
-rw-r--r-- | lib/api/entities/x509_issuer.rb | 12 | ||||
-rw-r--r-- | lib/api/entities/x509_signature.rb | 10 |
6 files changed, 60 insertions, 9 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index dfb0066ceb0..086a1b7c402 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -356,7 +356,7 @@ module API present paginate(commit_merge_requests), with: Entities::MergeRequestBasic end - desc "Get a commit's GPG signature" do + desc "Get a commit's signature" do success Entities::CommitSignature end params do @@ -365,11 +365,9 @@ module API get ':id/repository/commits/:sha/signature', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do commit = user_project.commit(params[:sha]) not_found! 'Commit' unless commit + not_found! 'Signature' unless commit.has_signature? - signature = commit.signature - not_found! 'GPG Signature' unless signature - - present signature, with: Entities::CommitSignature + present commit, with: Entities::CommitSignature end end end diff --git a/lib/api/entities/commit_signature.rb b/lib/api/entities/commit_signature.rb index 8e86d4c1aa6..b5232273521 100644 --- a/lib/api/entities/commit_signature.rb +++ b/lib/api/entities/commit_signature.rb @@ -3,10 +3,14 @@ module API module Entities class CommitSignature < Grape::Entity - expose :gpg_key_id - expose :gpg_key_primary_keyid, :gpg_key_user_name, :gpg_key_user_email - expose :verification_status - expose :gpg_key_subkey_id + expose :signature_type + expose :signature, merge: true do |commit, options| + if commit.signature.is_a?(GpgSignature) + ::API::Entities::GpgCommitSignature.represent commit.signature, options + elsif commit.signature.is_a?(X509CommitSignature) + ::API::Entities::X509Signature.represent commit.signature, options + end + end end end end diff --git a/lib/api/entities/gpg_commit_signature.rb b/lib/api/entities/gpg_commit_signature.rb new file mode 100644 index 00000000000..03466452b50 --- /dev/null +++ b/lib/api/entities/gpg_commit_signature.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + class GpgCommitSignature < Grape::Entity + expose :verification_status + expose :gpg_key_id + expose :gpg_key_primary_keyid, :gpg_key_user_name, :gpg_key_user_email + expose :gpg_key_subkey_id + end + end +end diff --git a/lib/api/entities/x509_certificate.rb b/lib/api/entities/x509_certificate.rb new file mode 100644 index 00000000000..aad11339148 --- /dev/null +++ b/lib/api/entities/x509_certificate.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module API + module Entities + class X509Certificate < Grape::Entity + expose :id + expose :subject + expose :subject_key_identifier + expose :email + expose :serial_number + expose :certificate_status + expose :x509_issuer, using: 'API::Entities::X509Issuer' + end + end +end diff --git a/lib/api/entities/x509_issuer.rb b/lib/api/entities/x509_issuer.rb new file mode 100644 index 00000000000..b480bc107bc --- /dev/null +++ b/lib/api/entities/x509_issuer.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + class X509Issuer < Grape::Entity + expose :id + expose :subject + expose :subject_key_identifier + expose :crl_url + end + end +end diff --git a/lib/api/entities/x509_signature.rb b/lib/api/entities/x509_signature.rb new file mode 100644 index 00000000000..909b630288c --- /dev/null +++ b/lib/api/entities/x509_signature.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module API + module Entities + class X509Signature < Grape::Entity + expose :verification_status + expose :x509_certificate, using: 'API::Entities::X509Certificate' + end + end +end |