fix(TestRemoteDiscovery): extend the http error messages in the test.

Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
Camila Ayres 2025-08-07 22:15:41 +02:00 committed by backportbot[bot]
parent e10d5f3018
commit ad72e3fd2a

View File

@ -68,18 +68,36 @@ private slots:
QTest::addColumn<QString>("expectedErrorString");
QTest::addColumn<bool>("syncSucceeds");
QString itemErrorMessage = "Internal Server Fake Error";
const auto itemErrorMessage = "An unexpected error occurred. Please try syncing again or contact contact your server administrator if the issue continues.";
QTest::newRow("400") << 400 << itemErrorMessage << false;
QTest::newRow("401") << 401 << itemErrorMessage << false;
QTest::newRow("403") << 403 << itemErrorMessage << true;
QTest::newRow("404") << 404 << itemErrorMessage << true;
QTest::newRow("500") << 500 << itemErrorMessage << true;
QTest::newRow("503") << 503 << itemErrorMessage << true;
QTest::newRow("400") << 400 << QStringLiteral("We couldnt process your request. Please try syncing again later. If this keeps happening, contact your server administrator for help.") << false;
QTest::newRow("401") << 401 << QStringLiteral("You need to sign in to continue. If you have trouble with your credentials, please reach out to your server administrator.") << false;
QTest::newRow("403") << 403 << QStringLiteral("You dont have access to this resource. If you think this is a mistake, please contact your server administrator.") << true;
QTest::newRow("404") << 404 << QStringLiteral("We couldnt find what you were looking for. It might have been moved or deleted. If you need help, contact your server administrator.") << true;
QTest::newRow("407") << 407 << QStringLiteral("It seems you are using a proxy that required authentication. Please check your proxy settings and credentials. If you need help, contact your server administrator.") << true;
QTest::newRow("408") << 408 << QStringLiteral("The request is taking longer than usual. Please try syncing again. If it still doesnt work, reach out to your server administrator.") << true;
QTest::newRow("409") << 409 << QStringLiteral("Server files changed while you were working. Please try syncing again. Contact your server administrator if the issue persists.") << true;
QTest::newRow("410") << 410 << QStringLiteral("This folder or file isnt available anymore. If you need assistance, please contact your server administrator.") << true;
QTest::newRow("412") << 412 << QStringLiteral("The request could not be completed because some required conditions were not met. Please try syncing again later. If you need assistance, please contact your server administrator.") << true;
QTest::newRow("413") << 413 << QStringLiteral("The file is too big to upload. You might need to choose a smaller file or contact your server administrator for assistance.") << true;
QTest::newRow("414") << 414 << QStringLiteral("The address used to make the request is too long for the server to handle. Please try shortening the information youre sending or contact your server administrator for assistance.") << true;
QTest::newRow("415") << 415 << QStringLiteral("This file type isnt supported. Please contact your server administrator for assistance.") << true;
QTest::newRow("422") << 422 << QStringLiteral("The server couldnt process your request because some information was incorrect or incomplete. Please try syncing again later, or contact your server administrator for assistance.") << true;
QTest::newRow("423") << 423 << QStringLiteral("The resource you are trying to access is currently locked and cannot be modified. Please try changing it later, or contact your server administrator for assistance.") << true;
QTest::newRow("428") << 428 << QStringLiteral("This request could not be completed because it is missing some required conditions. Please try again later, or contact your server administrator for help.") << true;
QTest::newRow("429") << 429 << QStringLiteral("You made too many requests. Please wait and try again. If you keep seeing this, your server administrator can help.") << true;
QTest::newRow("500") << 500 << QStringLiteral("Something went wrong on the server. Please try syncing again later, or contact your server administrator if the issue persists.") << true;
QTest::newRow("502") << 502 << QStringLiteral("Were having trouble connecting to the server. Please try again soon. If the issue persists, your server administrator can help you.") << true;
QTest::newRow("503") << 503 << QStringLiteral("The server is busy right now. Please try syncing again in a few minutes or contact your server administrator if its urgent.") << true;
QTest::newRow("504") << 504 << QStringLiteral("Its taking too long to connect to the server. Please try again later. If you need help, contact your server administrator.") << true;
QTest::newRow("505") << 505 << QStringLiteral("The server does not support the version of the connection being used. Contact your server administrator for help.") << true;
QTest::newRow("507") << 507 << QStringLiteral("The server does not have enough space to complete your request. Please check how much quota your user has by contacting your server administrator.") << true;
QTest::newRow("511") << 511 << QStringLiteral("Your network needs extra authentication. Please check your connection. Contact your server administrator for help if the issue persists.") << true;
QTest::newRow("513") << 513 << QStringLiteral("You dont have permission to access this resource. If you believe this is an error, contact your server administrator to ask for assistance.") << true;
// 200 should be an error since propfind should return 207
QTest::newRow("200") << 200 << itemErrorMessage << false;
QTest::newRow("InvalidXML") << +InvalidXML << "Unknown error" << false;
QTest::newRow("Timeout") << +Timeout << "Operation canceled" << false;
QTest::newRow("InvalidXML") << +InvalidXML << itemErrorMessage << false;
QTest::newRow("Timeout") << +Timeout << QStringLiteral("The server took too long to respond. Check your connection and try syncing again. If it still doesnt work, reach out to your server administrator.") << false;
}
@ -104,7 +122,6 @@ private slots:
auto oldRemoteState = fakeFolder.currentRemoteState();
QString errorFolder = "dav/files/admin/B";
QString fatalErrorPrefix = "Server replied with an error while reading directory \"B\" : ";
fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *)
-> QNetworkReply *{
if (req.attribute(QNetworkRequest::CustomVerbAttribute).toString() == "PROPFIND" && req.url().path().endsWith(errorFolder)) {
@ -131,7 +148,7 @@ private slots:
QCOMPARE(oldRemoteState.children["B"], fakeFolder.currentRemoteState().children["B"]);
if (!syncSucceeds) {
QCOMPARE(errorSpy.size(), 1);
QCOMPARE(errorSpy[0][0].toString(), QString(fatalErrorPrefix + expectedErrorString));
QCOMPARE(errorSpy[0][0].toString(), expectedErrorString);
} else {
QCOMPARE(completeSpy.findItem("B")->_instruction, CSYNC_INSTRUCTION_IGNORE);
QVERIFY(completeSpy.findItem("B")->_errorString.contains(expectedErrorString));
@ -146,11 +163,10 @@ private slots:
// Check the same discovery error on the sync root
//
errorFolder = "dav/files/admin/";
fatalErrorPrefix = "Server replied with an error while reading directory \"\" : ";
errorSpy.clear();
QVERIFY(!fakeFolder.syncOnce());
QCOMPARE(errorSpy.size(), 1);
QCOMPARE(errorSpy[0][0].toString(), QString(fatalErrorPrefix + expectedErrorString));
QCOMPARE(errorSpy[0][0].toString(), expectedErrorString);
}
void testMissingData()