Skip to content

Commit 0ee174c

Browse files
authored
[tests] Switch to httpbin.org (#7556)
Context: 234cf2c Commit 234cf2c updated the `AndroidHandlerTestBase.Redirect_Without_Protocol_Works()` and `AndroidHandlerTestBase.Redirect_POST_With_Content_Works()` tests to use <httpbingo.org> to test HTTP redirect behavior. Recently, <httpbingo.org> started returning HTTP-403 for our redirection test, whereas we expected it to send HTTP-302: % curl -D - 'https://httpbingo.org/redirect-to?url=https://github.com/xamarin/xamarin-android' HTTP/2 403 access-control-allow-credentials: true access-control-allow-origin: * content-type: text/plain; charset=utf-8 x-content-type-options: nosniff date: Wed, 16 Nov 2022 15:38:02 GMT content-length: 51 server: Fly/5f2bf728 (2022-11-11) via: 2 fly.io fly-request-id: 01GJ0HE398V7F0BKFHY0D2N8YE-iad Forbidden redirect URL. Be careful with this link. This caused the `Redirect_Without_Protocol_Works()` and `Redirect_POST_With_Content_Works()` unit tests to start failing: System.Net.Http.HttpRequestException : Response status code does not indicate success: 403 (Forbidden). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode () at Xamarin.Android.NetTests.AndroidHandlerTestBase.Redirect_POST_With_Content_Works () Update the tests to *stop* using <httpbingo.org> and instead use <httpbin.org>. This allows our tests to work as expected: % curl -D - 'https://httpbin.org/redirect-to?url=https://github.com/xamarin/xamarin-android' HTTP/2 302 date: Wed, 16 Nov 2022 15:38:28 GMT content-type: text/html; charset=utf-8 content-length: 0 location: https://github.com/xamarin/xamarin-android server: gunicorn/19.9.0 access-control-allow-origin: * access-control-allow-credentials: true
1 parent acfc1ef commit 0ee174c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public void Property_Timeout_Works()
246246
[Test]
247247
public void Redirect_Without_Protocol_Works()
248248
{
249-
var requestURI = new Uri ("https://httpbingo.org/redirect-to?url=https://github.com/xamarin/xamarin-android");
249+
var requestURI = new Uri ("https://httpbin.org/redirect-to?url=https://github.com/xamarin/xamarin-android");
250250
var redirectedURI = new Uri ("https://github.com/xamarin/xamarin-android");
251251
using (var c = new HttpClient (CreateHandler ())) {
252252
var tr = ConnectIgnoreFailure (() => c.GetAsync (requestURI), out bool connectionFailed);
@@ -265,7 +265,7 @@ public void Redirect_Without_Protocol_Works()
265265
[Test]
266266
public void Redirect_POST_With_Content_Works ()
267267
{
268-
var requestURI = new Uri ("https://httpbingo.org/redirect-to?url=https://github.com/xamarin/xamarin-android");
268+
var requestURI = new Uri ("https://httpbin.org/redirect-to?url=https://github.com/xamarin/xamarin-android");
269269
var redirectedURI = new Uri ("https://github.com/xamarin/xamarin-android");
270270
using (var c = new HttpClient (CreateHandler ())) {
271271
var request = new HttpRequestMessage (HttpMethod.Post, requestURI);

0 commit comments

Comments
 (0)