Commit 6cdaa84f authored by Sae-ngow Wasin's avatar Sae-ngow Wasin

Update changed request, add test and test result.

parent 11c87810
...@@ -552,7 +552,7 @@ func (s *CommitsService) RevertCommit(pid interface{}, sha string, opt *RevertCo ...@@ -552,7 +552,7 @@ func (s *CommitsService) RevertCommit(pid interface{}, sha string, opt *RevertCo
// //
// GitLab API docs: https://docs.gitlab.com/ee/api/commits.html#get-gpg-signature-of-a-commit // GitLab API docs: https://docs.gitlab.com/ee/api/commits.html#get-gpg-signature-of-a-commit
type GPGSubKey struct { type GPGSubKey struct {
KeyID sql.NullInt64 sql.NullInt64
} }
// GPGSignature represents a Gitlab commit's GPG Signature. // GPGSignature represents a Gitlab commit's GPG Signature.
...@@ -575,19 +575,19 @@ func (s *CommitsService) GetGPGSiganature(pid interface{}, sha string, options . ...@@ -575,19 +575,19 @@ func (s *CommitsService) GetGPGSiganature(pid interface{}, sha string, options .
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
u := fmt.Sprintf("projects/%s/repository/commits/%s/signature", pathEscape(project), sha)
url := fmt.Sprintf("projects/%s/repository/commits/%s/signature", pathEscape(project), sha) req, err := s.client.NewRequest("GET", u, nil, options)
req, err := s.client.NewRequest("GET", url, nil, options)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
var signature *GPGSignature sig := new(GPGSignature)
resp, err := s.client.Do(req, &signature) resp, err := s.client.Do(req, &sig)
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return signature, resp, err return sig, resp, err
} }
...@@ -174,3 +174,29 @@ func TestRevertCommit_WithOptions(t *testing.T) { ...@@ -174,3 +174,29 @@ func TestRevertCommit_WithOptions(t *testing.T) {
assert.Equal(t, want, commit) assert.Equal(t, want, commit)
} }
func TestGetGPGSignature(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/api/v4/projects/1/repository/commits/b0b3a907f41409829b307a28b82fdbd552ee5a27/signature", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
mustWriteHTTPResponse(t, w, "testdata/get_signature.json")
})
sig, resp, err := client.Commits.GetGPGSiganature("1", "b0b3a907f41409829b307a28b82fdbd552ee5a27", nil)
if err != nil {
t.Fatalf("Commits.GetGPGSignature returned error: %v, response: %v", err, resp)
}
want := &GPGSignature{
KeyID: 7977,
KeyPrimaryKeyID: "627C5F589F467F17",
KeyUserName: "Dmitriy Zaporozhets",
KeyUserEmail: "dmitriy.zaporozhets@gmail.com",
VerificationStatus: "verified",
KeySubkeyID: nil,
}
assert.Equal(t, want, sig)
}
{
"gpg_key_id": 7977,
"gpg_key_primary_keyid": "627C5F589F467F17",
"gpg_key_user_name": "Dmitriy Zaporozhets",
"gpg_key_user_email": "dmitriy.zaporozhets@gmail.com",
"verification_status": "verified",
"gpg_key_subkey_id": null
}
\ No newline at end of file
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