Skip to content

Commit 6deae11

Browse files
committed
fixup! Allow the caller to inspect the host's certificate
1 parent d080fdc commit 6deae11

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

LibGit2Sharp.Tests/CloneFixture.cs

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -244,35 +244,43 @@ public void CanInspectCertificateOnClone(string url, string hostname, Type certT
244244
{
245245
var scd = BuildSelfCleaningDirectory();
246246

247-
if (certType == typeof(CertificateSsh) && !GlobalSettings.Version.Features.HasFlag(BuiltInFeatures.Ssh))
248-
{
249-
throw new SkipException("SSH not supported");
250-
}
247+
InconclusiveIf(
248+
() =>
249+
certType == typeof (CertificateSsh) && !GlobalSettings.Version.Features.HasFlag(BuiltInFeatures.Ssh),
250+
"SSH not supported");
251+
252+
bool wasCalled = false;
253+
251254

252-
Assert.Throws<UserCancelledException>(() => {
253-
Repository.Clone(url, scd.DirectoryPath, new CloneOptions()
255+
Repository.Clone(url, scd.DirectoryPath, new CloneOptions
256+
{
257+
CertificateCheck = (cert, valid, host) =>
254258
{
255-
CertificateCheck = (cert, valid, host) =>
259+
Assert.Equal(hostname, host);
260+
Assert.Equal(certType, cert.GetType());
261+
262+
if (certType == typeof(CertificateX509))
256263
{
257-
Assert.Equal(hostname, host);
258-
Assert.Equal(certType, cert.GetType());
259-
if (certType == typeof(CertificateX509))
260-
{
261-
Assert.True(valid);
262-
var x509 = ((CertificateX509)cert).Certificate;
263-
// we get a string with the different fields instead of a structure, so...
264-
Assert.True(x509.Subject.Contains("CN=github.com,"));
265-
}
266-
else
267-
{
268-
var hostkey = (CertificateSsh)cert;
269-
Assert.True(hostkey.HasMD5);
270-
Assert.Equal("1627aca576282d36631b564debdfa648", BitConverter.ToString(hostkey.HashMD5));
271-
}
272-
return false;
273-
},
274-
});
264+
Assert.True(valid);
265+
var x509 = ((CertificateX509)cert).Certificate;
266+
// we get a string with the different fields instead of a structure, so...
267+
Assert.True(x509.Subject.Contains("CN=github.com,"));
268+
return true;
269+
}
270+
271+
if (certType == typeof(CertificateSsh))
272+
{
273+
var hostkey = (CertificateSsh)cert;
274+
Assert.True(hostkey.HasMD5);
275+
Assert.Equal("1627aca576282d36631b564debdfa648", BitConverter.ToString(hostkey.HashMD5));
276+
return true;
277+
}
278+
279+
return false;
280+
},
275281
});
282+
283+
Assert.True(wasCalled);
276284
}
277285

278286
[Fact]

0 commit comments

Comments
 (0)