From d5ebe48d93b266e0d681e8d533ed39bf5dd4f09d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Jan 2021 22:15:32 +0100 Subject: [PATCH] Use httpbin for error status with body test too Although httpbin doesn't return any body for the other 4xx statuses, it does make an exception for this one, so we can use it for testing instead of the even less reliable httpstat.us which regularly returns 503 server error instead of the expected 418. This probably also makes the workaround for Ubuntu 14.04 unnecessary, so remove it. --- tests/net/webrequest.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tests/net/webrequest.cpp b/tests/net/webrequest.cpp index 225d0e8473..70fcfea5c8 100644 --- a/tests/net/webrequest.cpp +++ b/tests/net/webrequest.cpp @@ -247,24 +247,14 @@ TEST_CASE_METHOD(RequestFixture, if ( !InitBaseURL() ) return; - // We can't use the same httpbin.org server that we use for the other tests - // for this one because it doesn't return anything in the body when - // returning an error status code, so use another one. - CreateAbs("https://httpstat.us/418"); + Create("/status/418"); Run(wxWebRequest::State_Failed, 0); - // For some reason, this test doesn't work with libcurl included in Ubuntu - // 14.04, so skip it. - const int status = request.GetResponse().GetStatus(); - if ( status == 0 ) - { - WARN("Status code not returned."); - } - else - { - CHECK( status == 418 ); - CHECK( request.GetResponse().AsString() == "418 I'm a teapot" ); - } + CHECK( request.GetResponse().GetStatus() == 418 ); + + const wxString& response = request.GetResponse().AsString(); + INFO( "Response: " << response); + CHECK( response.Contains("teapot") ); } TEST_CASE_METHOD(RequestFixture,