File indexing completed on 2025-02-02 04:51:34

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "userslistjobtest.h"
0008 #include "restapimethod.h"
0009 #include "ruqola_restapi_helper.h"
0010 #include "users/userslistjob.h"
0011 QTEST_GUILESS_MAIN(UsersListJobTest)
0012 using namespace RocketChatRestApi;
0013 UsersListJobTest::UsersListJobTest(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 void UsersListJobTest::shouldHaveDefaultValue()
0019 {
0020     UsersListJob job;
0021     verifyDefaultValue(&job);
0022     QVERIFY(job.requireHttpAuthentication());
0023     QVERIFY(!job.hasUserIdentifier());
0024     QVERIFY(job.hasQueryParameterSupport());
0025     QVERIFY(!job.requireTwoFactorAuthentication());
0026 }
0027 
0028 void UsersListJobTest::shouldGenerateRequest()
0029 {
0030     UsersListJob job;
0031     UsersListJob::UserInfo info;
0032     info.userIdentifier = QStringLiteral("foo1");
0033     info.userInfoType = UsersListJob::UserInfoType::UserId;
0034     job.setUserInfo(info);
0035     QNetworkRequest request = QNetworkRequest(QUrl());
0036     verifyAuthentication(&job, request);
0037     QEXPECT_FAIL("", "Problem with argument", Continue);
0038     QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.list?userId=foo1")));
0039 }
0040 
0041 void UsersListJobTest::shouldGenerateRequestUsername()
0042 {
0043     UsersListJob job;
0044     UsersListJob::UserInfo info;
0045     info.userIdentifier = QStringLiteral("foo1");
0046     info.userInfoType = UsersListJob::UserInfoType::UserName;
0047     job.setUserInfo(info);
0048     QNetworkRequest request = QNetworkRequest(QUrl());
0049     verifyAuthentication(&job, request);
0050     QEXPECT_FAIL("", "Problem with argument", Continue);
0051     QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.list?username=foo1")));
0052 }
0053 
0054 #include "moc_userslistjobtest.cpp"