@@ -250,28 +250,25 @@ public void CanInspectCertificateOnClone(string url, string hostname, Type certT
250
250
"SSH not supported" ) ;
251
251
252
252
bool wasCalled = false ;
253
+ bool checksHappy = false ;
253
254
254
-
255
- Repository . Clone ( url , scd . DirectoryPath , new CloneOptions
256
- {
257
- CertificateCheck = ( cert , valid , host ) =>
258
- {
255
+ var options = new CloneOptions {
256
+ CertificateCheck = ( cert , valid , host ) => {
259
257
wasCalled = true ;
260
258
261
259
Assert . Equal ( hostname , host ) ;
262
260
Assert . Equal ( certType , cert . GetType ( ) ) ;
263
261
264
- if ( certType == typeof ( CertificateX509 ) )
265
- {
262
+ if ( certType == typeof ( CertificateX509 ) ) {
266
263
Assert . True ( valid ) ;
267
264
var x509 = ( ( CertificateX509 ) cert ) . Certificate ;
268
265
// we get a string with the different fields instead of a structure, so...
269
266
Assert . True ( x509 . Subject . Contains ( "CN=github.com," ) ) ;
270
- return true ;
267
+ checksHappy = true ;
268
+ return false ;
271
269
}
272
270
273
- if ( certType == typeof ( CertificateSsh ) )
274
- {
271
+ if ( certType == typeof ( CertificateSsh ) ) {
275
272
var hostkey = ( CertificateSsh ) cert ;
276
273
Assert . True ( hostkey . HasMD5 ) ;
277
274
/*
@@ -283,15 +280,21 @@ public void CanInspectCertificateOnClone(string url, string hostname, Type certT
283
280
* though GitHub's hostkey won't change anytime soon.
284
281
*/
285
282
Assert . Equal ( "1627aca576282d36631b564debdfa648" ,
286
- BitConverter . ToString ( hostkey . HashMD5 ) . ToLower ( ) . Replace ( "-" , "" ) ) ;
287
- return true ;
283
+ BitConverter . ToString ( hostkey . HashMD5 ) . ToLower ( ) . Replace ( "-" , "" ) ) ;
284
+ checksHappy = true ;
285
+ return false ;
288
286
}
289
287
290
288
return false ;
291
289
} ,
292
- } ) ;
290
+ } ;
291
+
292
+ Assert . Throws < UserCancelledException > ( ( ) =>
293
+ Repository . Clone ( url , scd . DirectoryPath , options )
294
+ ) ;
293
295
294
296
Assert . True ( wasCalled ) ;
297
+ Assert . True ( checksHappy ) ;
295
298
}
296
299
297
300
[ Fact ]
0 commit comments