[libcalamares] Fix tests on FreeBSD

- https requests can fail if ca_nss isn't installed; ping something
  else then.
This commit is contained in:
Adriaan de Groot 2020-05-06 18:03:49 +02:00
parent 7277d52828
commit 401a34fcbd

View File

@ -47,8 +47,25 @@ NetworkTests::testPing()
using namespace CalamaresUtils::Network; using namespace CalamaresUtils::Network;
Logger::setupLogLevel( Logger::LOGVERBOSE ); Logger::setupLogLevel( Logger::LOGVERBOSE );
auto& nam = Manager::instance(); auto& nam = Manager::instance();
// On FreeBSD, the SSL handling depends on the presence of root keys
// (from the ca_nss port) which may not be available. So HTTPS requests
// may fail with SSLVerificationError; this breaks the tests even if
// the point is to just check whether ping() works.
//
// So fall back to pinging example.com if the normal ping fails.
auto canPing_www_kde_org auto canPing_www_kde_org
= nam.synchronousPing( QUrl( "https://www.kde.org" ), RequestOptions( RequestOptions::FollowRedirect ) ); = nam.synchronousPing( QUrl( "https://www.kde.org" ), RequestOptions( RequestOptions::FollowRedirect ) );
cDebug() << "Ping:" << canPing_www_kde_org; cDebug() << "Ping:" << canPing_www_kde_org;
QVERIFY( canPing_www_kde_org ); if ( canPing_www_kde_org.status == RequestStatus::HttpError )
{
cDebug() << Logger::SubEntry << "Some HTTP failure, try example.com instead.";
auto canPing_example_com
= nam.synchronousPing( QUrl( "http://example.com" ), RequestOptions( RequestOptions::FollowRedirect ) );
QVERIFY( canPing_example_com );
}
else
{
QVERIFY( canPing_www_kde_org );
}
} }