File indexing completed on 2025-02-02 04:51:24
0001 /* 0002 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "getbannersjobtest.h" 0008 #include "banner/getbannersjob.h" 0009 #include "restapimethod.h" 0010 #include <QTest> 0011 QTEST_GUILESS_MAIN(GetBannersJobTest) 0012 using namespace RocketChatRestApi; 0013 GetBannersJobTest::GetBannersJobTest(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 void GetBannersJobTest::shouldHaveDefaultValue() 0019 { 0020 GetBannersJob job; 0021 QVERIFY(!job.restApiMethod()); 0022 QVERIFY(!job.networkAccessManager()); 0023 QVERIFY(!job.start()); 0024 QVERIFY(job.requireHttpAuthentication()); 0025 QVERIFY(!job.restApiLogger()); 0026 QVERIFY(!job.hasQueryParameterSupport()); 0027 QVERIFY(!job.requireTwoFactorAuthentication()); 0028 } 0029 0030 void GetBannersJobTest::shouldGenerateRequest() 0031 { 0032 GetBannersJob job; 0033 RestApiMethod method; 0034 method.setServerUrl(QStringLiteral("http://www.kde.org")); 0035 job.setRestApiMethod(&method); 0036 QNetworkRequest request = job.request(); 0037 QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/banners?platform=web"))); 0038 } 0039 0040 void GetBannersJobTest::shouldNotStarting() 0041 { 0042 GetBannersJob job; 0043 0044 RestApiMethod method; 0045 method.setServerUrl(QStringLiteral("http://www.kde.org")); 0046 job.setRestApiMethod(&method); 0047 0048 QNetworkAccessManager mNetworkAccessManager; 0049 job.setNetworkAccessManager(&mNetworkAccessManager); 0050 QVERIFY(!job.canStart()); 0051 const QString auth = QStringLiteral("foo"); 0052 const QString userId = QStringLiteral("foo"); 0053 job.setAuthToken(auth); 0054 QVERIFY(!job.canStart()); 0055 job.setUserId(userId); 0056 0057 QVERIFY(job.canStart()); 0058 } 0059 0060 #include "moc_getbannersjobtest.cpp"