Skip to content

Commit

Permalink
[tests] Adjust a few linker tests to cope with unreliable networks. (#…
Browse files Browse the repository at this point in the history
…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 #14943.
  • Loading branch information
rolfbjarne committed May 20, 2022
1 parent bd7d3d8 commit 0b16919
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/linker/ios/link all/LinkAllTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ public void TrustUsingOldPolicy ()
// caching means it will be called at least for the first run, but it might not
// be called again in subsequent requests (unless it expires)
Assert.That (test_policy.CheckCount, Is.GreaterThan (0), "policy checked");
} catch (WebException we) {
// The remote server returned an error: (502) Bad Gateway.
// The remote server returned an error: (503) Service Unavailable.
if (we.Message.Contains ("(502)") || we.Message.Contains ("(503)"))
Assert.Inconclusive (we.Message);
throw;
} finally {
ServicePointManager.CertificatePolicy = old;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/linker/ios/link sdk/CryptoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public void TrustUsingNewCallback ()
// caching means it will be called at least for the first run, but it might not
// be called again in subsequent requests (unless it expires)
Assert.That (trust_validation_callback, Is.GreaterThan (0), "validation done");
} catch (WebException we) {
// The remote server returned an error: (502) Bad Gateway.
// The remote server returned an error: (503) Service Unavailable.
if (we.Message.Contains ("(502)") || we.Message.Contains ("(503)"))
Assert.Inconclusive (we.Message);
throw;
}
finally {
ServicePointManager.ServerCertificateValidationCallback = null;
Expand Down
3 changes: 3 additions & 0 deletions tests/monotouch-test/System.Net.Http/NetworkResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ public static class NetworkResources
public static readonly string [] HttpsUrls = {
MicrosoftUrl,
XamarinUrl,
Httpbin.Url,
};

public static readonly string [] HttpUrls = {
MicrosoftHttpUrl,
XamarinHttpUrl,
Httpbin.HttpUrl,
};

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


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

0 comments on commit 0b16919

Please sign in to comment.