@@ -92,10 +92,17 @@ def copySshKey(tempPath: str, testKeyName: str) -> str:
9292 return Path (pubPath ).as_posix ()
9393
9494
95- def setUpForSshSigning (tempPath : str , repoWorkdir : str , testKeyName : str = "simple" ):
95+ def setUpForSshSigning (
96+ tempPath : str ,
97+ repoWorkdir : str ,
98+ testKeyName : str = "simple" ,
99+ principal : str = "CriquetteRockwell" ,
100+ ):
96101 pubKeyCopy = copySshKey (tempPath , testKeyName )
97- allowedSigners = f"{ tempPath } /allowedSigners"
98- writeFile (allowedSigners , "CriquetteRockwell " + readTextFile (pubKeyCopy ))
102+ pubKeyText = readTextFile (pubKeyCopy )
103+
104+ allowedSigners = f"{ tempPath } /allowed_signers"
105+ writeFile (allowedSigners , f"{ principal } { pubKeyText } " )
99106
100107 with RepoContext (repoWorkdir ) as repo :
101108 repo .config ["gpg.format" ] = "ssh"
@@ -269,17 +276,23 @@ def testVerifyGoodPgpSignatureWithMissingKey(tempDir, mainWindow, tempGpgHome):
269276
270277
271278@requiresGpg
272- def testVerifyGoodSshSignature (tempDir , mainWindow , tempGpgHome ):
279+ @pytest .mark .parametrize ("principal" , [
280+ # Principal names usually don't contain spaces, but the allowed_signers file
281+ # allows quoting the principal field (see ssh-keygen(1)).
282+ "criquette@example.com" ,
283+ '"Criquette Rockwell <criquette@example.com>"' ,
284+ ])
285+ def testVerifyGoodSshSignature (tempDir , mainWindow , tempGpgHome , principal ):
273286 wd = unpackRepo (tempDir )
274- _pubKey , allowedSigners = setUpForSshSigning (tempDir .name , wd )
287+ _pubKey , allowedSigners = setUpForSshSigning (tempDir .name , wd , principal = principal )
275288
276289 signedOid = makeSignedCommit (wd )
277290
278291 rw = mainWindow .openRepo (wd )
279292 rw .jump (NavLocator .inCommit (signedOid , "" ), check = True )
280293
281294 triggerContextMenuAction (rw .graphView .viewport (), "verify signature" )
282- acceptQMessageBox (rw , "good signature; key trusted.+CriquetteRockwell " )
295+ acceptQMessageBox (rw , "good signature; key trusted.+criquette " )
283296
284297 # Clear allowed signers, then verify the signature again
285298 writeFile (allowedSigners , "" )
0 commit comments