Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] Use msftconnecttest.com in QuoteInvalidQuoteUrlsShouldWork (#…
…7919) Context: 112c832 Context: https://bugzilla.xamarin.com/show_bug.cgi?id=14968 Context: xamarin/monodroid@5e923e3 Context: xamarin/monodroid@2e5f7bb For historical purposes… <https://bugzilla.xamarin.com/show_bug.cgi?id=14968> is (was?) a bug wherein accessing an "invalid" URL such as <http://example.com/?query&foo|bar> would result in a `URISyntaxException` at runtime: Exception of type 'Java.Net.URISyntaxException' was thrown. at Android.Runtime.JNIEnv.NewObject (IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) at Java.Net.URI..ctor (System.String uri) at Android.Runtime.AndroidEnvironment+_Proxy.IsBypassed (System.Uri host) at System.Net.ServicePointManager.FindServicePoint (System.Uri address, IWebProxy proxy) at System.Net.HttpWebRequest.GetServicePoint () at System.Net.HttpWebRequest.BeginGetResponse (System.AsyncCallback callback, System.Object state) at System.Net.HttpWebRequest.GetResponse () at Xamarin.Android.RuntimeTests.ProxyTest.QuoteInvalidQuoteUrlsShouldWork () at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) --- End of managed exception stack trace --- java.net.URISyntaxException: Illegal character in query at index 29: http://example.com/?query&foo|bar at libcore.net.UriCodec.validate(UriCodec.java:63) at java.net.URI.parseURI(URI.java:406) at java.net.URI.<init>(URI.java:204) at xamarin.android.nunitlite.TestSuiteInstrumentation.n_onStart(Native Method) at xamarin.android.nunitlite.TestSuiteInstrumentation.onStart(TestSuiteInstrumentation.java:39) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701) Index 29 is `|` (zero-based!). The "problem" here that using `|` within the query string is accepted under .NET & Mono, which resulted in a "breakage of expectations" for Xamarin.Android customers ("this URL works on .NET!"). The "fix" was to use [`Uri.AbsoluteUri`][5], which replaces `|` with `%7C`, hex-escaping the offending value and adding the `ProxyTest.QuoteInvalidQuoteUrlsShouldWork()` unit test. That background done, commit 112c832 updated `ProxyTest.QuoteInvalidQuoteUrlsShouldWork()` to hit <https://bing.com/?query&foo|bar> instead of <http://example.com/?query&foo|bar>, on the assumption that it would be "better" if we *didn't* use non-Microsoft URLs as part of our unit tests. The problem is that this didn't work (eep?! not sure how PR #7909 was green here!): System.Net.WebException : net_http_ssl_connection_failed ----> System.Net.Http.HttpRequestException : net_http_ssl_connection_failed ----> System.Security.Authentication.AuthenticationException : net_auth_SSPI ----> Interop+AndroidCrypto+SslException : Exception_WasThrown, Interop+AndroidCrypto+SslException Update `ProxyTest.QuoteInvalidQuoteUrlsShouldWork()` to instead hit <http://www.msftconnecttest.com/connecttest.txt?query&foo|bar>, which is a Microsoft-owned server -- no possible DOS'ing of <http://example.com> -- which *passes* for this particular test. [0]: https://developer.android.com/reference/java/net/URI#URI(java.lang.String) [1]: https://www.ietf.org/rfc/rfc2396.txt [2]: https://www.ietf.org/rfc/rfc3986.html#section-3.4 [3]: https://android.googlesource.com/platform/libcore/+/jb-mr2-release/luni/src/main/java/libcore/net/UriCodec.java#46 [4]: https://android.googlesource.com/platform/libcore/+/jb-mr2-release/luni/src/main/java/java/net/URI.java#349 [5]: https://learn.microsoft.com/en-us/dotnet/api/system.uri.absoluteuri?view=net-7.0
- Loading branch information