Skip to content

Commit a12c181

Browse files
author
Jonathan Peppers
committed
Cleaned up tests
1 parent e05338f commit a12c181

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Xamarin.SSLPinning.iOS/HttpsTest.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
using System.Net.Http;
2-
using System.Threading.Tasks;
1+
using System;
2+
using System.Net.Http;
33
using NUnit.Framework;
44

55
namespace Xamarin.SSLPinning.iOS
66
{
77
[TestFixture]
88
public class HttpsTest
99
{
10-
private const int Timeout = 3000;
10+
[Test]
11+
public void GoodCert()
12+
{
13+
var httpClient = new HttpClient(new NSUrlSessionHandler());
14+
var response = httpClient.GetAsync("https://httpbin.org/get").Result;
15+
response.EnsureSuccessStatusCode();
16+
}
1117

12-
[Test, Timeout(Timeout)]
13-
public async Task Get()
18+
[Test, ExpectedException(typeof(AggregateException))]
19+
public void BadCert()
1420
{
1521
var httpClient = new HttpClient(new NSUrlSessionHandler());
16-
var response = await httpClient.GetAsync("https://httpbin.org/get");
22+
var response = httpClient.GetAsync("https://www.google.com").Result;
1723
response.EnsureSuccessStatusCode();
1824
}
1925
}

Xamarin.SSLPinning.iOS/Xamarin/NSUrlSessionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public override void DidReceiveChallenge(NSUrlSession session, NSUrlSessionTask
381381
}
382382
else
383383
{
384-
completionHandler(NSUrlSessionAuthChallengeDisposition.RejectProtectionSpace, null);
384+
completionHandler(NSUrlSessionAuthChallengeDisposition.CancelAuthenticationChallenge, null);
385385
}
386386
}
387387
}

0 commit comments

Comments
 (0)