@@ -48,6 +48,26 @@ def resp_revert_commit(url, request):
4848 return response (200 , content , headers , None , 5 , request )
4949
5050
51+ @urlmatch (
52+ scheme = "http" ,
53+ netloc = "localhost" ,
54+ path = "/api/v4/projects/1/repository/commits/6b2257ea/signature" ,
55+ method = "get" ,
56+ )
57+ def resp_get_commit_gpg_signature (url , request ):
58+ """Mock for commit GPG signature GET response."""
59+ content = """{
60+ "gpg_key_id": 1,
61+ "gpg_key_primary_keyid": "8254AAB3FBD54AC9",
62+ "gpg_key_user_name": "John Doe",
63+ "gpg_key_user_email": "johndoe@example.com",
64+ "verification_status": "verified",
65+ "gpg_key_subkey_id": null
66+ }"""
67+ content = content .encode ("utf-8" )
68+ return response (200 , content , headers , None , 5 , request )
69+
70+
5171class TestCommit (TestProject ):
5272 """
5373 Base class for commit tests. Inherits from TestProject,
@@ -77,3 +97,10 @@ def test_revert_commit(self):
7797 revert_commit = commit .revert (branch = "master" )
7898 self .assertEqual (revert_commit ["short_id" ], "8b090c1b" )
7999 self .assertEqual (revert_commit ["title" ], 'Revert "Initial commit"' )
100+
101+ @with_httmock (resp_get_commit_gpg_signature )
102+ def test_get_commit_gpg_signature (self ):
103+ commit = self .project .commits .get ("6b2257ea" , lazy = True )
104+ signature = commit .signature ()
105+ self .assertEqual (signature ["gpg_key_primary_keyid" ], "8254AAB3FBD54AC9" )
106+ self .assertEqual (signature ["verification_status" ], "verified" )
0 commit comments