Skip to content

Commit 1e4db42

Browse files
rolfbjarnevs-mobiletools-engineering-service2
authored andcommitted
[tests] Adjust a few linker tests to cope with unreliable networks. (dotnet#15018)
* Handle 502 and 503 errors in the TrustUsingOldPolicy and TrustUsingNewCallback tests. Fixes: [FAIL] TrustUsingOldPolicy : System.Net.WebException : The remote server returned an error: (503) Service Unavailable. [FAIL] TrustUsingNewCallback : System.Net.WebException : The remote server returned an error: (503) Service Unavailable. * Add more http and https urls to try (and don't use microsoft.com). Hopefully fixes: [FAIL] WebClient_SSL_Leak : At least one url should work This is a follow-up to dotnet#14943.
1 parent c723314 commit 1e4db42

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

tests/linker/ios/link all/LinkAllTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ public void TrustUsingOldPolicy ()
232232
// caching means it will be called at least for the first run, but it might not
233233
// be called again in subsequent requests (unless it expires)
234234
Assert.That (test_policy.CheckCount, Is.GreaterThan (0), "policy checked");
235+
} catch (WebException we) {
236+
// The remote server returned an error: (502) Bad Gateway.
237+
// The remote server returned an error: (503) Service Unavailable.
238+
if (we.Message.Contains ("(502)") || we.Message.Contains ("(503)"))
239+
Assert.Inconclusive (we.Message);
240+
throw;
235241
} finally {
236242
ServicePointManager.CertificatePolicy = old;
237243
}

tests/linker/ios/link sdk/CryptoTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ public void TrustUsingNewCallback ()
6868
// caching means it will be called at least for the first run, but it might not
6969
// be called again in subsequent requests (unless it expires)
7070
Assert.That (trust_validation_callback, Is.GreaterThan (0), "validation done");
71+
} catch (WebException we) {
72+
// The remote server returned an error: (502) Bad Gateway.
73+
// The remote server returned an error: (503) Service Unavailable.
74+
if (we.Message.Contains ("(502)") || we.Message.Contains ("(503)"))
75+
Assert.Inconclusive (we.Message);
76+
throw;
7177
}
7278
finally {
7379
ServicePointManager.ServerCertificateValidationCallback = null;

tests/monotouch-test/System.Net.Http/NetworkResources.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ public static class NetworkResources
1818
public static readonly string [] HttpsUrls = {
1919
MicrosoftUrl,
2020
XamarinUrl,
21+
Httpbin.Url,
2122
};
2223

2324
public static readonly string [] HttpUrls = {
2425
MicrosoftHttpUrl,
2526
XamarinHttpUrl,
27+
Httpbin.HttpUrl,
2628
};
2729

2830
// Robots urls, useful when we want to get a small file
@@ -51,6 +53,7 @@ public static class Httpbin {
5153
public static readonly string PostUrl = "https://httpbin.org/post";
5254
public static readonly string PutUrl = "https://httpbin.org/put";
5355
public static readonly string CookiesUrl = $"https://httpbin.org/cookies";
56+
public static readonly string HttpUrl = "http://httpbin.org";
5457

5558

5659
public static string GetAbsoluteRedirectUrl (int count) => $"https://httpbin.org/absolute-redirect/{count}";

0 commit comments

Comments
 (0)