File indexing completed on 2024-05-19 05:03:15

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "serverinfojobtest.h"
0008 #include "restapimethod.h"
0009 #include "ruqola_restapi_helper.h"
0010 #include "serverinfojob.h"
0011 QTEST_GUILESS_MAIN(ServerInfoJobTest)
0012 using namespace RocketChatRestApi;
0013 ServerInfoJobTest::ServerInfoJobTest(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 void ServerInfoJobTest::shouldHaveDefaultValue()
0019 {
0020     ServerInfoJob job;
0021     verifyDefaultValue(&job);
0022     QVERIFY(!job.requireHttpAuthentication());
0023     QVERIFY(!job.hasQueryParameterSupport());
0024     QVERIFY(job.useDeprecatedVersion());
0025 }
0026 
0027 void ServerInfoJobTest::shouldGenerateRequest()
0028 {
0029     {
0030         ServerInfoJob job;
0031         RestApiMethod method;
0032         method.setServerUrl(QStringLiteral("http://www.kde.org"));
0033         job.setRestApiMethod(&method);
0034         const QNetworkRequest request = job.request();
0035         QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/info")));
0036         QCOMPARE(request.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool(), true);
0037         QCOMPARE(request.attribute(QNetworkRequest::Http2AllowedAttribute).toBool(), true);
0038     }
0039     {
0040         ServerInfoJob job;
0041         job.setUseDeprecatedVersion(false);
0042         RestApiMethod method;
0043         method.setServerUrl(QStringLiteral("http://www.kde.org"));
0044         job.setRestApiMethod(&method);
0045         const QNetworkRequest request = job.request();
0046         QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/info")));
0047         QCOMPARE(request.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool(), true);
0048         QCOMPARE(request.attribute(QNetworkRequest::Http2AllowedAttribute).toBool(), true);
0049     }
0050 }
0051 
0052 #include "moc_serverinfojobtest.cpp"