diff --git a/src/rocketchatrestapi-qt5/autotests/archivechanneljobtest.cpp b/src/rocketchatrestapi-qt5/autotests/archivechanneljobtest.cpp index bbc47a47..c1f133a0 100644 --- a/src/rocketchatrestapi-qt5/autotests/archivechanneljobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/archivechanneljobtest.cpp @@ -1,88 +1,89 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "archivechanneljobtest.h" #include "channels/archivechanneljob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ArchiveChannelJobTest) using namespace RocketChatRestApi; ArchiveChannelJobTest::ArchiveChannelJobTest(QObject *parent) : QObject(parent) { } void ArchiveChannelJobTest::shouldHaveDefaultValue() { ArchiveChannelJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ArchiveChannelJobTest::shouldGenerateRequest() { ArchiveChannelJob job; job.setArchive(true); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.archive"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); job.setArchive(false); request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.unarchive"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ArchiveChannelJobTest::shouldGenerateJson() { ArchiveChannelJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\"}").arg(roomId).toLatin1()); } void ArchiveChannelJobTest::shouldNotStarting() { ArchiveChannelJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/archivegroupsjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/archivegroupsjobtest.cpp index 4c4ccd9a..3ef6824f 100644 --- a/src/rocketchatrestapi-qt5/autotests/archivegroupsjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/archivegroupsjobtest.cpp @@ -1,88 +1,89 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "archivegroupsjobtest.h" #include "groups/archivegroupsjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ArchiveGroupsJobTest) using namespace RocketChatRestApi; ArchiveGroupsJobTest::ArchiveGroupsJobTest(QObject *parent) : QObject(parent) { } void ArchiveGroupsJobTest::shouldHaveDefaultValue() { ArchiveGroupsJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ArchiveGroupsJobTest::shouldGenerateRequest() { ArchiveGroupsJob job; job.setArchive(true); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.archive"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); job.setArchive(false); request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.unarchive"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ArchiveGroupsJobTest::shouldGenerateJson() { ArchiveGroupsJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\"}").arg(roomId).toLatin1()); } void ArchiveGroupsJobTest::shouldNotStarting() { ArchiveGroupsJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/changechannelannouncementjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changechannelannouncementjobtest.cpp index 8d825027..47252ebd 100644 --- a/src/rocketchatrestapi-qt5/autotests/changechannelannouncementjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changechannelannouncementjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changechannelannouncementjobtest.h" #include "channels/changechannelannouncementjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeChannelAnnouncementJobTest) using namespace RocketChatRestApi; ChangeChannelAnnouncementJobTest::ChangeChannelAnnouncementJobTest(QObject *parent) : QObject(parent) { } void ChangeChannelAnnouncementJobTest::shouldHaveDefaultValue() { ChangeChannelAnnouncementJob job; verifyDefaultValue(&job); QVERIFY(job.announcement().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeChannelAnnouncementJobTest::shouldGenerateRequest() { ChangeChannelAnnouncementJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setAnnouncement"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeChannelAnnouncementJobTest::shouldGenerateJson() { ChangeChannelAnnouncementJob job; const QString roomId = QStringLiteral("foo1"); const QString announcement = QStringLiteral("topic1"); job.setRoomId(roomId); job.setAnnouncement(announcement); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"announcement\":\"%1\",\"roomId\":\"%2\"}").arg(announcement, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/changechanneldescriptionjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changechanneldescriptionjobtest.cpp index e5829a9d..9ad240aa 100644 --- a/src/rocketchatrestapi-qt5/autotests/changechanneldescriptionjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changechanneldescriptionjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changechanneldescriptionjobtest.h" #include "channels/changechanneldescriptionjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeChannelDescriptionJobTest) using namespace RocketChatRestApi; ChangeChannelDescriptionJobTest::ChangeChannelDescriptionJobTest(QObject *parent) : QObject(parent) { } void ChangeChannelDescriptionJobTest::shouldHaveDefaultValue() { ChangeChannelDescriptionJob job; verifyDefaultValue(&job); QVERIFY(job.description().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeChannelDescriptionJobTest::shouldGenerateRequest() { ChangeChannelDescriptionJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setDescription"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeChannelDescriptionJobTest::shouldGenerateJson() { ChangeChannelDescriptionJob job; const QString roomId = QStringLiteral("foo1"); const QString description = QStringLiteral("topic1"); job.setRoomId(roomId); job.setDescription(description); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"description\":\"%1\",\"roomId\":\"%2\"}").arg(description, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/changechannelnamejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changechannelnamejobtest.cpp index ccab9094..13901815 100644 --- a/src/rocketchatrestapi-qt5/autotests/changechannelnamejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changechannelnamejobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changechannelnamejobtest.h" #include "channels/changechannelnamejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeChannelNameJobTest) using namespace RocketChatRestApi; ChangeChannelNameJobTest::ChangeChannelNameJobTest(QObject *parent) : QObject(parent) { } void ChangeChannelNameJobTest::shouldHaveDefaultValue() { ChangeChannelNameJob job; verifyDefaultValue(&job); QVERIFY(job.name().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeChannelNameJobTest::shouldGenerateRequest() { ChangeChannelNameJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.rename"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeChannelNameJobTest::shouldGenerateJson() { ChangeChannelNameJob job; const QString roomId = QStringLiteral("foo1"); const QString name = QStringLiteral("topic1"); job.setRoomId(roomId); job.setName(name); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"name\":\"%1\",\"roomId\":\"%2\"}").arg(name, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/changechannelreadonlyjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changechannelreadonlyjobtest.cpp index ce154210..18914b9c 100644 --- a/src/rocketchatrestapi-qt5/autotests/changechannelreadonlyjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changechannelreadonlyjobtest.cpp @@ -1,62 +1,63 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changechannelreadonlyjobtest.h" #include "channels/changechannelreadonlyjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeChannelReadonlyJobTest) using namespace RocketChatRestApi; ChangeChannelReadonlyJobTest::ChangeChannelReadonlyJobTest(QObject *parent) : QObject(parent) { } void ChangeChannelReadonlyJobTest::shouldHaveDefaultValue() { ChangeChannelReadonlyJob job; verifyDefaultValue(&job); QVERIFY(!job.readOnly()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeChannelReadonlyJobTest::shouldGenerateRequest() { ChangeChannelReadonlyJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setReadOnly"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeChannelReadonlyJobTest::shouldGenerateJson() { ChangeChannelReadonlyJob job; const QString roomId = QStringLiteral("foo1"); bool readOnly = true; job.setRoomId(roomId); job.setReadOnly(readOnly); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"readOnly\":true,\"roomId\":\"%1\"}").arg(roomId).toLatin1()); readOnly = false; job.setReadOnly(readOnly); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"readOnly\":false,\"roomId\":\"%1\"}").arg(roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/changechanneltopicjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changechanneltopicjobtest.cpp index 07db5c07..7c1753ac 100644 --- a/src/rocketchatrestapi-qt5/autotests/changechanneltopicjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changechanneltopicjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changechanneltopicjobtest.h" #include "channels/changechanneltopicjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeChannelTopicJobTest) using namespace RocketChatRestApi; ChangeChannelTopicJobTest::ChangeChannelTopicJobTest(QObject *parent) : QObject(parent) { } void ChangeChannelTopicJobTest::shouldHaveDefaultValue() { ChangeChannelTopicJob job; verifyDefaultValue(&job); QVERIFY(job.topic().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeChannelTopicJobTest::shouldGenerateRequest() { ChangeChannelTopicJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setTopic"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeChannelTopicJobTest::shouldGenerateJson() { ChangeChannelTopicJob job; const QString roomId = QStringLiteral("foo1"); const QString topic = QStringLiteral("topic1"); job.setRoomId(roomId); job.setTopic(topic); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"topic\":\"%2\"}").arg(roomId, topic).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/changegroupsannouncementjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changegroupsannouncementjobtest.cpp index 8a08e570..8b44ece1 100644 --- a/src/rocketchatrestapi-qt5/autotests/changegroupsannouncementjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changegroupsannouncementjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changegroupsannouncementjobtest.h" #include "groups/changegroupsannouncementjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeGroupsAnnouncementJobTest) using namespace RocketChatRestApi; ChangeGroupsAnnouncementJobTest::ChangeGroupsAnnouncementJobTest(QObject *parent) : QObject(parent) { } void ChangeGroupsAnnouncementJobTest::shouldHaveDefaultValue() { ChangeGroupsAnnouncementJob job; verifyDefaultValue(&job); QVERIFY(job.announcement().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeGroupsAnnouncementJobTest::shouldGenerateRequest() { ChangeGroupsAnnouncementJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setAnnouncement"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeGroupsAnnouncementJobTest::shouldGenerateJson() { ChangeGroupsAnnouncementJob job; const QString roomId = QStringLiteral("foo1"); const QString announcement = QStringLiteral("topic1"); job.setRoomId(roomId); job.setAnnouncement(announcement); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"announcement\":\"%1\",\"roomId\":\"%2\"}").arg(announcement, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/changegroupsdescriptionjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changegroupsdescriptionjobtest.cpp index 58c70abc..dbfc70a6 100644 --- a/src/rocketchatrestapi-qt5/autotests/changegroupsdescriptionjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changegroupsdescriptionjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changegroupsdescriptionjobtest.h" #include "groups/changegroupsdescriptionjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeGroupsDescriptionJobTest) using namespace RocketChatRestApi; ChangeGroupsDescriptionJobTest::ChangeGroupsDescriptionJobTest(QObject *parent) : QObject(parent) { } void ChangeGroupsDescriptionJobTest::shouldHaveDefaultValue() { ChangeGroupsDescriptionJob job; verifyDefaultValue(&job); QVERIFY(job.description().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeGroupsDescriptionJobTest::shouldGenerateRequest() { ChangeGroupsDescriptionJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setDescription"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeGroupsDescriptionJobTest::shouldGenerateJson() { ChangeGroupsDescriptionJob job; const QString roomId = QStringLiteral("foo1"); const QString description = QStringLiteral("topic1"); job.setRoomId(roomId); job.setDescription(description); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"description\":\"%1\",\"roomId\":\"%2\"}").arg(description, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/changegroupsnamejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changegroupsnamejobtest.cpp index d550c422..8e8fe536 100644 --- a/src/rocketchatrestapi-qt5/autotests/changegroupsnamejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changegroupsnamejobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changegroupsnamejobtest.h" #include "groups/changegroupsnamejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeGroupsNameJobTest) using namespace RocketChatRestApi; ChangeGroupsNameJobTest::ChangeGroupsNameJobTest(QObject *parent) : QObject(parent) { } void ChangeGroupsNameJobTest::shouldHaveDefaultValue() { ChangeGroupsNameJob job; verifyDefaultValue(&job); QVERIFY(job.name().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeGroupsNameJobTest::shouldGenerateRequest() { ChangeGroupsNameJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.rename"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeGroupsNameJobTest::shouldGenerateJson() { ChangeGroupsNameJob job; const QString roomId = QStringLiteral("foo1"); const QString name = QStringLiteral("topic1"); job.setRoomId(roomId); job.setName(name); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"name\":\"%1\",\"roomId\":\"%2\"}").arg(name, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/changegroupstopicjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/changegroupstopicjobtest.cpp index b53ee850..4892406d 100644 --- a/src/rocketchatrestapi-qt5/autotests/changegroupstopicjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/changegroupstopicjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "changegroupstopicjobtest.h" #include "groups/changegroupstopicjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChangeGroupsTopicJobTest) using namespace RocketChatRestApi; ChangeGroupsTopicJobTest::ChangeGroupsTopicJobTest(QObject *parent) : QObject(parent) { } void ChangeGroupsTopicJobTest::shouldHaveDefaultValue() { ChangeGroupsTopicJob job; verifyDefaultValue(&job); QVERIFY(job.topic().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChangeGroupsTopicJobTest::shouldGenerateRequest() { ChangeGroupsTopicJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setTopic"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChangeGroupsTopicJobTest::shouldGenerateJson() { ChangeGroupsTopicJob job; const QString roomId = QStringLiteral("foo1"); const QString topic = QStringLiteral("topic1"); job.setRoomId(roomId); job.setTopic(topic); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"topic\":\"%2\"}").arg(roomId, topic).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/channeladdmoderatorjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channeladdmoderatorjobtest.cpp index a5928012..cda24c5f 100644 --- a/src/rocketchatrestapi-qt5/autotests/channeladdmoderatorjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channeladdmoderatorjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channeladdmoderatorjobtest.h" #include "channels/channeladdmoderatorjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChannelAddModeratorJobTest) using namespace RocketChatRestApi; ChannelAddModeratorJobTest::ChannelAddModeratorJobTest(QObject *parent) : QObject(parent) { } void ChannelAddModeratorJobTest::shouldHaveDefaultValue() { ChannelAddModeratorJob job; verifyDefaultValue(&job); QVERIFY(job.addModeratorUserId().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelAddModeratorJobTest::shouldGenerateRequest() { ChannelAddModeratorJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.addModerator"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChannelAddModeratorJobTest::shouldGenerateJson() { ChannelAddModeratorJob job; const QString roomId = QStringLiteral("foo1"); const QString addUsedId = QStringLiteral("topic1"); job.setRoomId(roomId); job.setAddModeratorUserId(addUsedId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%2\",\"userId\":\"%1\"}").arg(addUsedId, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/channeladdownerjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channeladdownerjobtest.cpp index b5ea4217..e60b1d7c 100644 --- a/src/rocketchatrestapi-qt5/autotests/channeladdownerjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channeladdownerjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channeladdownerjobtest.h" #include "channels/channeladdownerjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChannelAddOwnerJobTest) using namespace RocketChatRestApi; ChannelAddOwnerJobTest::ChannelAddOwnerJobTest(QObject *parent) : QObject(parent) { } void ChannelAddOwnerJobTest::shouldHaveDefaultValue() { ChannelAddOwnerJob job; verifyDefaultValue(&job); QVERIFY(job.addownerUserId().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelAddOwnerJobTest::shouldGenerateRequest() { ChannelAddOwnerJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.addOwner"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChannelAddOwnerJobTest::shouldGenerateJson() { ChannelAddOwnerJob job; const QString roomId = QStringLiteral("foo1"); const QString addUsedId = QStringLiteral("topic1"); job.setRoomId(roomId); job.setAddownerUserId(addUsedId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%2\",\"userId\":\"%1\"}").arg(addUsedId, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/channelclosejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelclosejobtest.cpp index e41f5cc2..a16d495d 100644 --- a/src/rocketchatrestapi-qt5/autotests/channelclosejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channelclosejobtest.cpp @@ -1,97 +1,98 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channelclosejobtest.h" #include "channels/channelclosejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChannelCloseJobTest) using namespace RocketChatRestApi; ChannelCloseJobTest::ChannelCloseJobTest(QObject *parent) : QObject(parent) { } void ChannelCloseJobTest::shouldHaveDefaultValue() { ChannelCloseJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QCOMPARE(job.channelType(), ChannelCloseJob::ChannelType::Unknown); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelCloseJobTest::shouldGenerateRequest() { ChannelCloseJob job; job.setChannelType(ChannelCloseJob::Channel); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.close"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); job.setChannelType(ChannelCloseJob::Direct); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.close"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); job.setChannelType(ChannelCloseJob::Groups); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.close"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChannelCloseJobTest::shouldGenerateJson() { ChannelCloseJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\"}") .arg(roomId).toLatin1()); } void ChannelCloseJobTest::shouldNotStarting() { ChannelCloseJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); job.setChannelType(ChannelCloseJob::ChannelType::Channel); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/channelfilesjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelfilesjobtest.cpp index 16b63658..2a4f7629 100644 --- a/src/rocketchatrestapi-qt5/autotests/channelfilesjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channelfilesjobtest.cpp @@ -1,84 +1,85 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channelfilesjobtest.h" #include "channels/channelfilesjob.h" #include "ruqola_restapi_helper.h" #include QTEST_GUILESS_MAIN(ChannelFilesJobTest) using namespace RocketChatRestApi; ChannelFilesJobTest::ChannelFilesJobTest(QObject *parent) : QObject(parent) { } void ChannelFilesJobTest::shouldHaveDefaultValue() { ChannelFilesJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QCOMPARE(job.channelType(), ChannelFilesJob::ChannelType::Unknown); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelFilesJobTest::shouldGenerateRequest() { ChannelFilesJob job; job.setChannelType(ChannelFilesJob::Channel); job.setRoomId(QStringLiteral("foo")); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.files?roomId=foo"))); job.setChannelType(ChannelFilesJob::Direct); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.files?roomId=foo"))); job.setChannelType(ChannelFilesJob::Groups); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.files?roomId=foo"))); } void ChannelFilesJobTest::shouldNotStarting() { ChannelFilesJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); job.setChannelType(ChannelFilesJob::ChannelType::Channel); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/channelgetallusermentionsjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelgetallusermentionsjobtest.cpp index eacab67c..3434bd9c 100644 --- a/src/rocketchatrestapi-qt5/autotests/channelgetallusermentionsjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channelgetallusermentionsjobtest.cpp @@ -1,81 +1,82 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channelgetallusermentionsjobtest.h" #include "channels/channelgetallusermentionsjob.h" #include "restapimethod.h" #include "ruqola_restapi_helper.h" #include QTEST_GUILESS_MAIN(ChannelGetAllUserMentionsJobTest) using namespace RocketChatRestApi; ChannelGetAllUserMentionsJobTest::ChannelGetAllUserMentionsJobTest(QObject *parent) : QObject(parent) { } void ChannelGetAllUserMentionsJobTest::shouldHaveDefaultValue() { ChannelGetAllUserMentionsJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelGetAllUserMentionsJobTest::shouldGenerateRequest() { ChannelGetAllUserMentionsJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QString roomId = QStringLiteral("avat"); job.setRoomId(roomId); QNetworkRequest request = job.request(); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.getAllUserMentionsByChannel?roomId=avat"))); delete method; } void ChannelGetAllUserMentionsJobTest::shouldNotStarting() { ChannelGetAllUserMentionsJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/channelhistoryjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelhistoryjobtest.cpp index 4132d0ce..69aa7320 100644 --- a/src/rocketchatrestapi-qt5/autotests/channelhistoryjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channelhistoryjobtest.cpp @@ -1,98 +1,99 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channelhistoryjobtest.h" #include "channels/channelhistoryjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChannelHistoryJobTest) using namespace RocketChatRestApi; ChannelHistoryJobTest::ChannelHistoryJobTest(QObject *parent) : QObject(parent) { } void ChannelHistoryJobTest::shouldHaveDefaultValue() { ChannelHistoryJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QCOMPARE(job.channelType(), ChannelHistoryJob::ChannelType::Unknown); QCOMPARE(job.count(), -1); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelHistoryJobTest::shouldGenerateRequest() { ChannelHistoryJob job; job.setChannelType(ChannelHistoryJob::Channel); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.history"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); job.setChannelType(ChannelHistoryJob::Direct); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.history"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); job.setChannelType(ChannelHistoryJob::Groups); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.history"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChannelHistoryJobTest::shouldGenerateJson() { ChannelHistoryJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\"}") .arg(roomId).toLatin1()); } void ChannelHistoryJobTest::shouldNotStarting() { ChannelHistoryJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); job.setChannelType(ChannelHistoryJob::ChannelType::Channel); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.cpp index a2df5221..0ec7a190 100644 --- a/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channelinfojobtest.cpp @@ -1,72 +1,73 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channelinfojobtest.h" #include "channels/channelinfojob.h" #include "ruqola_restapi_helper.h" #include QTEST_GUILESS_MAIN(ChannelInfoJobTest) using namespace RocketChatRestApi; ChannelInfoJobTest::ChannelInfoJobTest(QObject *parent) : QObject(parent) { } void ChannelInfoJobTest::shouldHaveDefaultValue() { ChannelInfoJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelInfoJobTest::shouldGenerateRequest() { ChannelInfoJob job; job.setRoomId(QStringLiteral("foo")); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.info?roomId=foo"))); } void ChannelInfoJobTest::shouldNotStarting() { ChannelInfoJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/channelinvitejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelinvitejobtest.cpp index 970e7b97..2b016033 100644 --- a/src/rocketchatrestapi-qt5/autotests/channelinvitejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channelinvitejobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channelinvitejobtest.h" #include "channels/channelinvitejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChannelInviteJobTest) using namespace RocketChatRestApi; ChannelInviteJobTest::ChannelInviteJobTest(QObject *parent) : QObject(parent) { } void ChannelInviteJobTest::shouldHaveDefaultValue() { ChannelInviteJob job; verifyDefaultValue(&job); QVERIFY(job.inviteUserId().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelInviteJobTest::shouldGenerateRequest() { ChannelInviteJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.invite"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChannelInviteJobTest::shouldGenerateJson() { ChannelInviteJob job; const QString roomId = QStringLiteral("foo1"); const QString userId = QStringLiteral("topic1"); job.setRoomId(roomId); job.setInviteUserId(userId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%2\",\"userId\":\"%1\"}").arg(userId, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/channeljoinjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channeljoinjobtest.cpp index 5515604d..cc1ca8ca 100644 --- a/src/rocketchatrestapi-qt5/autotests/channeljoinjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channeljoinjobtest.cpp @@ -1,88 +1,89 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channeljoinjobtest.h" #include "channels/channeljoinjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChannelJoinJobTest) using namespace RocketChatRestApi; ChannelJoinJobTest::ChannelJoinJobTest(QObject *parent) : QObject(parent) { } void ChannelJoinJobTest::shouldHaveDefaultValue() { ChannelJoinJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelJoinJobTest::shouldGenerateRequest() { ChannelJoinJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.join"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChannelJoinJobTest::shouldGenerateJson() { ChannelJoinJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); const QString joinCode = QStringLiteral("bli"); job.setJoinCode(joinCode); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"joinCode\":\"%2\",\"roomId\":\"%1\"}").arg(roomId, joinCode).toLatin1()); } void ChannelJoinJobTest::shouldNotStarting() { ChannelJoinJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); //Join code is optional const QString joinCode = QStringLiteral("fd1"); job.setJoinCode(joinCode); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/channelkickjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelkickjobtest.cpp index 4cdf7d05..d8562697 100644 --- a/src/rocketchatrestapi-qt5/autotests/channelkickjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channelkickjobtest.cpp @@ -1,88 +1,89 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channelkickjobtest.h" #include "channels/channelkickjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChannelKickJobTest) using namespace RocketChatRestApi; ChannelKickJobTest::ChannelKickJobTest(QObject *parent) : QObject(parent) { } void ChannelKickJobTest::shouldHaveDefaultValue() { ChannelKickJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QVERIFY(job.kickUserId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelKickJobTest::shouldGenerateRequest() { ChannelKickJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.kick"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChannelKickJobTest::shouldGenerateJson() { ChannelKickJob job; const QString channelname = QStringLiteral("foo1"); job.setRoomId(channelname); const QString userkick = QStringLiteral("bla"); job.setKickUserId(userkick); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"userId\":\"%2\"}").arg(channelname, userkick).toLatin1()); } void ChannelKickJobTest::shouldNotStarting() { ChannelKickJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); const QString kickuser = QStringLiteral("bla"); job.setKickUserId(kickuser); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/channellistjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channellistjobtest.cpp index 28bdc66c..61c54f11 100644 --- a/src/rocketchatrestapi-qt5/autotests/channellistjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channellistjobtest.cpp @@ -1,63 +1,64 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channellistjobtest.h" #include "channellistjob.h" #include #include QTEST_GUILESS_MAIN(ChannelListJobTest) using namespace RocketChatRestApi; ChannelListJobTest::ChannelListJobTest(QObject *parent) : QObject(parent) { } void ChannelListJobTest::shouldHaveDefaultValue() { ChannelListJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.authToken().isEmpty()); QVERIFY(job.userId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelListJobTest::shouldGenerateRequest() { ChannelListJob job; RestApiMethod *method = new RestApiMethod; const QString authToken = QStringLiteral("foo"); const QString userId = QStringLiteral("user"); job.setUserId(userId); job.setAuthToken(authToken); method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.list"))); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-Auth-Token")), authToken.toLocal8Bit()); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-User-Id")), userId.toLocal8Bit()); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/channelremoveownerjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/channelremoveownerjobtest.cpp index 83b65078..e1d3ba08 100644 --- a/src/rocketchatrestapi-qt5/autotests/channelremoveownerjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/channelremoveownerjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "channelremoveownerjobtest.h" #include "channels/channelremoveownerjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ChannelRemoveOwnerJobTest) using namespace RocketChatRestApi; ChannelRemoveOwnerJobTest::ChannelRemoveOwnerJobTest(QObject *parent) : QObject(parent) { } void ChannelRemoveOwnerJobTest::shouldHaveDefaultValue() { ChannelRemoveOwnerJob job; verifyDefaultValue(&job); QVERIFY(job.removeUserId().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ChannelRemoveOwnerJobTest::shouldGenerateRequest() { ChannelRemoveOwnerJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.removeOwner"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ChannelRemoveOwnerJobTest::shouldGenerateJson() { ChannelRemoveOwnerJob job; const QString roomId = QStringLiteral("foo1"); const QString removeUserId = QStringLiteral("topic1"); job.setRoomId(roomId); job.setRemoveUserId(removeUserId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%2\",\"userId\":\"%1\"}").arg(removeUserId, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/createchanneljobtest.cpp b/src/rocketchatrestapi-qt5/autotests/createchanneljobtest.cpp index 3fc16919..8fef0bc6 100644 --- a/src/rocketchatrestapi-qt5/autotests/createchanneljobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/createchanneljobtest.cpp @@ -1,96 +1,97 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "createchanneljobtest.h" #include "channels/createchanneljob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(CreateChannelJobTest) using namespace RocketChatRestApi; CreateChannelJobTest::CreateChannelJobTest(QObject *parent) : QObject(parent) { } void CreateChannelJobTest::shouldHaveDefaultValue() { CreateChannelJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(!job.readOnly()); QVERIFY(job.channelName().isEmpty()); QVERIFY(job.members().isEmpty()); QVERIFY(job.password().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void CreateChannelJobTest::shouldGenerateRequest() { CreateChannelJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.create"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void CreateChannelJobTest::shouldGenerateJson() { CreateChannelJob job; const QString channelname = QStringLiteral("foo1"); job.setChannelName(channelname); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"name\":\"%1\"}").arg(channelname).toLatin1()); bool readOnly = false; job.setReadOnly(readOnly); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"name\":\"%1\"}").arg(channelname).toLatin1()); readOnly = true; job.setReadOnly(readOnly); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"name\":\"%1\",\"readOnly\":true}").arg(channelname).toLatin1()); const QStringList members = {QStringLiteral("foo"), QStringLiteral("bla")}; job.setMembers(members); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"members\":[\"foo\",\"bla\"],\"name\":\"%1\",\"readOnly\":true}").arg(channelname).toLatin1()); } void CreateChannelJobTest::shouldNotStarting() { CreateChannelJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setChannelName(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/createdmjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/createdmjobtest.cpp index cbdbaf54..bad63bd8 100644 --- a/src/rocketchatrestapi-qt5/autotests/createdmjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/createdmjobtest.cpp @@ -1,81 +1,82 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "createdmjobtest.h" #include "directmessage/createdmjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(CreateDmJobTest) using namespace RocketChatRestApi; CreateDmJobTest::CreateDmJobTest(QObject *parent) : QObject(parent) { } void CreateDmJobTest::shouldHaveDefaultValue() { CreateDmJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.userName().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void CreateDmJobTest::shouldGenerateRequest() { CreateDmJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.create"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void CreateDmJobTest::shouldGenerateJson() { CreateDmJob job; const QString channelname = QStringLiteral("foo1"); job.setUserName(channelname); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"username\":\"%1\"}").arg(channelname).toLatin1()); } void CreateDmJobTest::shouldNotStarting() { CreateDmJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString username = QStringLiteral("foo1"); job.setUserName(username); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/creategroupsjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/creategroupsjobtest.cpp index 1e09b21d..2210ad23 100644 --- a/src/rocketchatrestapi-qt5/autotests/creategroupsjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/creategroupsjobtest.cpp @@ -1,95 +1,96 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "creategroupsjobtest.h" #include "groups/creategroupsjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(CreateGroupsJobTest) using namespace RocketChatRestApi; CreateGroupsJobTest::CreateGroupsJobTest(QObject *parent) : QObject(parent) { } void CreateGroupsJobTest::shouldHaveDefaultValue() { CreateGroupsJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(!job.readOnly()); QVERIFY(job.channelName().isEmpty()); QVERIFY(job.members().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void CreateGroupsJobTest::shouldGenerateRequest() { CreateGroupsJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.create"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void CreateGroupsJobTest::shouldGenerateJson() { CreateGroupsJob job; const QString channelname = QStringLiteral("foo1"); job.setChannelName(channelname); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"name\":\"%1\"}").arg(channelname).toLatin1()); bool readOnly = false; job.setReadOnly(readOnly); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"name\":\"%1\"}").arg(channelname).toLatin1()); readOnly = true; job.setReadOnly(readOnly); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"name\":\"%1\",\"readOnly\":true}").arg(channelname).toLatin1()); const QStringList members = {QStringLiteral("foo"), QStringLiteral("bla")}; job.setMembers(members); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"members\":[\"foo\",\"bla\"],\"name\":\"%1\",\"readOnly\":true}").arg(channelname).toLatin1()); } void CreateGroupsJobTest::shouldNotStarting() { CreateGroupsJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setChannelName(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/deletemessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/deletemessagejobtest.cpp index 286d2866..5494c6db 100644 --- a/src/rocketchatrestapi-qt5/autotests/deletemessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/deletemessagejobtest.cpp @@ -1,87 +1,88 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "deletemessagejobtest.h" #include "chat/deletemessagejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(DeleteMessageJobTest) using namespace RocketChatRestApi; DeleteMessageJobTest::DeleteMessageJobTest(QObject *parent) : QObject(parent) { } void DeleteMessageJobTest::shouldHaveDefaultValue() { DeleteMessageJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QVERIFY(job.messageId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void DeleteMessageJobTest::shouldGenerateRequest() { DeleteMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.delete"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void DeleteMessageJobTest::shouldGenerateJson() { DeleteMessageJob job; const QString roomId = QStringLiteral("foo1"); const QString text = QStringLiteral("topic1"); job.setRoomId(roomId); job.setMessageId(text); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"msgId\":\"%2\",\"roomId\":\"%1\"}").arg(roomId, text).toLatin1()); } void DeleteMessageJobTest::shouldNotStarting() { DeleteMessageJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); const QString text = QStringLiteral("topic1"); job.setMessageId(text); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/downloadfilejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/downloadfilejobtest.cpp index 06184843..1faf1f7a 100644 --- a/src/rocketchatrestapi-qt5/autotests/downloadfilejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/downloadfilejobtest.cpp @@ -1,33 +1,35 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "downloadfilejobtest.h" #include "downloadfilejob.h" #include QTEST_GUILESS_MAIN(DownloadFileJobTest) using namespace RocketChatRestApi; DownloadFileJobTest::DownloadFileJobTest(QObject *parent) : QObject(parent) { } void DownloadFileJobTest::shouldHaveDefaultValue() { + //TODO + //QVERIFY(!job.hasQueryParameterSupport()); } diff --git a/src/rocketchatrestapi-qt5/autotests/facebookauthjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/facebookauthjobtest.cpp index 7908e044..a7eebd0a 100644 --- a/src/rocketchatrestapi-qt5/autotests/facebookauthjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/facebookauthjobtest.cpp @@ -1,102 +1,103 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "facebookauthjobtest.h" #include "authentication/facebookauthjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(FacebookAuthJobTest) using namespace RocketChatRestApi; FacebookAuthJobTest::FacebookAuthJobTest(QObject *parent) : QObject(parent) { } void FacebookAuthJobTest::shouldHaveDefaultValue() { FacebookAuthJob job; verifyDefaultValue(&job); QVERIFY(!job.requireHttpAuthentication()); QVERIFY(job.secret().isEmpty()); QVERIFY(job.accessToken().isEmpty()); QCOMPARE(job.expireTokenInSeconds(), -1); + QVERIFY(!job.hasQueryParameterSupport()); } void FacebookAuthJobTest::shouldGenerateRequest() { FacebookAuthJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/login"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); delete method; } void FacebookAuthJobTest::shouldGenerateJson() { FacebookAuthJob job; const QString secret = QStringLiteral("secret:"); job.setSecret(secret); const QString accessToken = QStringLiteral("accessToken"); job.setAccessToken(accessToken); const int expireToken = 300; job.setExpireTokenInSeconds(expireToken); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"accessToken\":\"%1\",\"expiresIn\":300,\"secret\":\"%2\",\"serviceName\":\"facebook\"}") .arg(accessToken, secret).toLatin1()); } void FacebookAuthJobTest::shouldNotStarting() { FacebookAuthJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString secret = QStringLiteral("secret:"); job.setSecret(secret); QVERIFY(!job.canStart()); const QString accessToken = QStringLiteral("accessToken"); job.setAccessToken(accessToken); QVERIFY(!job.canStart()); const int expireToken = 300; job.setExpireTokenInSeconds(expireToken); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/fetchmykeysjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/fetchmykeysjobtest.cpp index 1d316039..82dfff89 100644 --- a/src/rocketchatrestapi-qt5/autotests/fetchmykeysjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/fetchmykeysjobtest.cpp @@ -1,51 +1,52 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "fetchmykeysjobtest.h" #include "e2e/fetchmykeysjob.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(FetchMyKeysJobTest) using namespace RocketChatRestApi; FetchMyKeysJobTest::FetchMyKeysJobTest(QObject *parent) : QObject(parent) { } void FetchMyKeysJobTest::shouldHaveDefaultValue() { FetchMyKeysJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void FetchMyKeysJobTest::shouldGenerateRequest() { FetchMyKeysJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/e2e.fetchMyKeys"))); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/forgotpasswordjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/forgotpasswordjobtest.cpp index 2d8a0f1a..285eb170 100644 --- a/src/rocketchatrestapi-qt5/autotests/forgotpasswordjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/forgotpasswordjobtest.cpp @@ -1,62 +1,63 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "forgotpasswordjobtest.h" #include "users/forgotpasswordjob.h" #include "restapimethod.h" #include #include QTEST_GUILESS_MAIN(ForgotPasswordJobTest) using namespace RocketChatRestApi; ForgotPasswordJobTest::ForgotPasswordJobTest(QObject *parent) : QObject(parent) { } void ForgotPasswordJobTest::shouldHaveDefaultValue() { ForgotPasswordJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(!job.requireHttpAuthentication()); QVERIFY(job.email().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void ForgotPasswordJobTest::shouldGenerateRequest() { ForgotPasswordJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); job.setEmail(QStringLiteral("foo")); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.forgotPassword"))); delete method; } void ForgotPasswordJobTest::shouldGenerateJson() { ForgotPasswordJob job; const QString email = QStringLiteral("foo"); job.setEmail(email); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"email\":\"%1\"}").arg(email).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/getavatarjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/getavatarjobtest.cpp index 227f131a..f1b43c03 100644 --- a/src/rocketchatrestapi-qt5/autotests/getavatarjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/getavatarjobtest.cpp @@ -1,54 +1,55 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "getavatarjobtest.h" #include "users/getavatarjob.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(GetAvatarJobTest) using namespace RocketChatRestApi; GetAvatarJobTest::GetAvatarJobTest(QObject *parent) : QObject(parent) { } void GetAvatarJobTest::shouldHaveDefaultValue() { GetAvatarJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(!job.requireHttpAuthentication()); QVERIFY(job.avatarUserId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void GetAvatarJobTest::shouldGenerateRequest() { GetAvatarJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QString avatarUserId = QStringLiteral("avat"); job.setAvatarUserId(avatarUserId); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.getAvatar?userId=avat"))); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/getchannelrolesjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/getchannelrolesjobtest.cpp index 74fae951..4ee0baf8 100644 --- a/src/rocketchatrestapi-qt5/autotests/getchannelrolesjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/getchannelrolesjobtest.cpp @@ -1,54 +1,55 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "getchannelrolesjobtest.h" #include "channels/getchannelrolesjob.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(GetChannelRolesJobTest) using namespace RocketChatRestApi; GetChannelRolesJobTest::GetChannelRolesJobTest(QObject *parent) : QObject(parent) { } void GetChannelRolesJobTest::shouldHaveDefaultValue() { GetChannelRolesJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void GetChannelRolesJobTest::shouldGenerateRequest() { GetChannelRolesJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QString roomId = QStringLiteral("avat"); job.setRoomId(roomId); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.roles?roomId=avat"))); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/getgrouprolesjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/getgrouprolesjobtest.cpp index 9635aeef..2fd1800b 100644 --- a/src/rocketchatrestapi-qt5/autotests/getgrouprolesjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/getgrouprolesjobtest.cpp @@ -1,54 +1,55 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "getgrouprolesjobtest.h" #include "groups/getgrouprolesjob.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(GetGroupRolesJobTest) using namespace RocketChatRestApi; GetGroupRolesJobTest::GetGroupRolesJobTest(QObject *parent) : QObject(parent) { } void GetGroupRolesJobTest::shouldHaveDefaultValue() { GetGroupRolesJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void GetGroupRolesJobTest::shouldGenerateRequest() { GetGroupRolesJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QString roomId = QStringLiteral("avat"); job.setRoomId(roomId); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.roles?roomId=avat"))); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/getmessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/getmessagejobtest.cpp index 9af663dc..629dc2fd 100644 --- a/src/rocketchatrestapi-qt5/autotests/getmessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/getmessagejobtest.cpp @@ -1,48 +1,49 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "getmessagejobtest.h" #include "chat/getmessagejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(GetMessageJobTest) using namespace RocketChatRestApi; GetMessageJobTest::GetMessageJobTest(QObject *parent) : QObject(parent) { } void GetMessageJobTest::shouldHaveDefaultValue() { GetMessageJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.getMessageId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void GetMessageJobTest::shouldGenerateRequest() { GetMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); job.setMessageId(QStringLiteral("foo")); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.getMessage?msgId=foo"))); } diff --git a/src/rocketchatrestapi-qt5/autotests/getpresencejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/getpresencejobtest.cpp index a59e42ec..0c1085f1 100644 --- a/src/rocketchatrestapi-qt5/autotests/getpresencejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/getpresencejobtest.cpp @@ -1,54 +1,55 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "getpresencejobtest.h" #include "users/getpresencejob.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(GetPresenceJobTest) using namespace RocketChatRestApi; GetPresenceJobTest::GetPresenceJobTest(QObject *parent) : QObject(parent) { } void GetPresenceJobTest::shouldHaveDefaultValue() { GetPresenceJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.presenceUserId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void GetPresenceJobTest::shouldGenerateRequest() { GetPresenceJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QString avatarUserId = QStringLiteral("avat"); job.setPresenceUserId(avatarUserId); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.getPresence?userId=avat"))); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/getroomsjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/getroomsjobtest.cpp index 565b5965..72d0f831 100644 --- a/src/rocketchatrestapi-qt5/autotests/getroomsjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/getroomsjobtest.cpp @@ -1,51 +1,52 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "getroomsjobtest.h" #include "rooms/getroomsjob.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(GetRoomsJobTest) using namespace RocketChatRestApi; GetRoomsJobTest::GetRoomsJobTest(QObject *parent) : QObject(parent) { } void GetRoomsJobTest::shouldHaveDefaultValue() { GetRoomsJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void GetRoomsJobTest::shouldGenerateRequest() { GetRoomsJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.get"))); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/getusernamesuggestionjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/getusernamesuggestionjobtest.cpp index 1852f763..5ddad646 100644 --- a/src/rocketchatrestapi-qt5/autotests/getusernamesuggestionjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/getusernamesuggestionjobtest.cpp @@ -1,51 +1,52 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "getusernamesuggestionjobtest.h" #include "users/getusernamesuggestionjob.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(GetUsernameSuggestionJobTest) using namespace RocketChatRestApi; GetUsernameSuggestionJobTest::GetUsernameSuggestionJobTest(QObject *parent) : QObject(parent) { } void GetUsernameSuggestionJobTest::shouldHaveDefaultValue() { GetUsernameSuggestionJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void GetUsernameSuggestionJobTest::shouldGenerateRequest() { GetUsernameSuggestionJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.getUsernameSuggestion"))); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/googleauthjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/googleauthjobtest.cpp index 79b52492..d4111411 100644 --- a/src/rocketchatrestapi-qt5/autotests/googleauthjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/googleauthjobtest.cpp @@ -1,102 +1,103 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "googleauthjobtest.h" #include "authentication/googleauthjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(GoogleAuthJobTest) using namespace RocketChatRestApi; GoogleAuthJobTest::GoogleAuthJobTest(QObject *parent) : QObject(parent) { } void GoogleAuthJobTest::shouldHaveDefaultValue() { GoogleAuthJob job; verifyDefaultValue(&job); QVERIFY(!job.requireHttpAuthentication()); QVERIFY(job.idToken().isEmpty()); QVERIFY(job.accessToken().isEmpty()); QCOMPARE(job.expireTokenInSeconds(), -1); + QVERIFY(!job.hasQueryParameterSupport()); } void GoogleAuthJobTest::shouldGenerateRequest() { GoogleAuthJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/login"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); delete method; } void GoogleAuthJobTest::shouldGenerateJson() { GoogleAuthJob job; const QString secret = QStringLiteral("secret:"); job.setIdToken(secret); const QString accessToken = QStringLiteral("accessToken"); job.setAccessToken(accessToken); const int expireToken = 300; job.setExpireTokenInSeconds(expireToken); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"accessToken\":\"%1\",\"expiresIn\":300,\"idToken\":\"%2\",\"serviceName\":\"google\"}") .arg(accessToken, secret).toLatin1()); } void GoogleAuthJobTest::shouldNotStarting() { GoogleAuthJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString secret = QStringLiteral("secret:"); job.setIdToken(secret); QVERIFY(!job.canStart()); const QString accessToken = QStringLiteral("accessToken"); job.setAccessToken(accessToken); QVERIFY(!job.canStart()); const int expireToken = 300; job.setExpireTokenInSeconds(expireToken); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/groupaddmoderatorjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/groupaddmoderatorjobtest.cpp index 8a8108d8..9a1a8fa9 100644 --- a/src/rocketchatrestapi-qt5/autotests/groupaddmoderatorjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/groupaddmoderatorjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "groupaddmoderatorjobtest.h" #include "groups/groupaddmoderatorjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(GroupAddModeratorJobTest) using namespace RocketChatRestApi; GroupAddModeratorJobTest::GroupAddModeratorJobTest(QObject *parent) : QObject(parent) { } void GroupAddModeratorJobTest::shouldHaveDefaultValue() { GroupAddModeratorJob job; verifyDefaultValue(&job); QVERIFY(job.addModeratorUserId().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void GroupAddModeratorJobTest::shouldGenerateRequest() { GroupAddModeratorJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.addModerator"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void GroupAddModeratorJobTest::shouldGenerateJson() { GroupAddModeratorJob job; const QString roomId = QStringLiteral("foo1"); const QString addUsedId = QStringLiteral("topic1"); job.setRoomId(roomId); job.setAddModeratorUserId(addUsedId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%2\",\"userId\":\"%1\"}").arg(addUsedId, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/groupaddownerjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/groupaddownerjobtest.cpp index a43a9bdf..2c6eadec 100644 --- a/src/rocketchatrestapi-qt5/autotests/groupaddownerjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/groupaddownerjobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "groupaddownerjobtest.h" #include "groups/groupaddownerjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(GroupAddOwnerJobTest) using namespace RocketChatRestApi; GroupAddOwnerJobTest::GroupAddOwnerJobTest(QObject *parent) : QObject(parent) { } void GroupAddOwnerJobTest::shouldHaveDefaultValue() { GroupAddOwnerJob job; verifyDefaultValue(&job); QVERIFY(job.addownerUserId().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void GroupAddOwnerJobTest::shouldGenerateRequest() { GroupAddOwnerJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.addOwner"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void GroupAddOwnerJobTest::shouldGenerateJson() { GroupAddOwnerJob job; const QString roomId = QStringLiteral("foo1"); const QString addUsedId = QStringLiteral("topic1"); job.setRoomId(roomId); job.setAddownerUserId(addUsedId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%2\",\"userId\":\"%1\"}").arg(addUsedId, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/groupsinfojobtest.cpp b/src/rocketchatrestapi-qt5/autotests/groupsinfojobtest.cpp index 0fddd0ac..5ccdd146 100644 --- a/src/rocketchatrestapi-qt5/autotests/groupsinfojobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/groupsinfojobtest.cpp @@ -1,72 +1,73 @@ /* Copyright (c) 2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "groupsinfojobtest.h" #include "groups/groupsinfojob.h" #include "ruqola_restapi_helper.h" #include QTEST_GUILESS_MAIN(GroupsInfoJobTest) using namespace RocketChatRestApi; GroupsInfoJobTest::GroupsInfoJobTest(QObject *parent) : QObject(parent) { } void GroupsInfoJobTest::shouldHaveDefaultValue() { GroupsInfoJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void GroupsInfoJobTest::shouldGenerateRequest() { GroupsInfoJob job; job.setRoomId(QStringLiteral("foo")); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.info?roomId=foo"))); } void GroupsInfoJobTest::shouldNotStarting() { GroupsInfoJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/groupsinvitejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/groupsinvitejobtest.cpp index 75a691b0..1f11c09d 100644 --- a/src/rocketchatrestapi-qt5/autotests/groupsinvitejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/groupsinvitejobtest.cpp @@ -1,58 +1,59 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "groupsinvitejobtest.h" #include "groups/groupsinvitejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(GroupsInviteJobTest) using namespace RocketChatRestApi; GroupsInviteJobTest::GroupsInviteJobTest(QObject *parent) : QObject(parent) { } void GroupsInviteJobTest::shouldHaveDefaultValue() { GroupsInviteJob job; verifyDefaultValue(&job); QVERIFY(job.inviteUserId().isEmpty()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void GroupsInviteJobTest::shouldGenerateRequest() { GroupsInviteJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.invite"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void GroupsInviteJobTest::shouldGenerateJson() { GroupsInviteJob job; const QString roomId = QStringLiteral("foo1"); const QString userId = QStringLiteral("topic1"); job.setRoomId(roomId); job.setInviteUserId(userId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%2\",\"userId\":\"%1\"}").arg(userId, roomId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/groupskickjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/groupskickjobtest.cpp index 19f99b4a..1e4df658 100644 --- a/src/rocketchatrestapi-qt5/autotests/groupskickjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/groupskickjobtest.cpp @@ -1,88 +1,89 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "groupskickjobtest.h" #include "groups/groupskickjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(GroupsKickJobTest) using namespace RocketChatRestApi; GroupsKickJobTest::GroupsKickJobTest(QObject *parent) : QObject(parent) { } void GroupsKickJobTest::shouldHaveDefaultValue() { GroupsKickJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QVERIFY(job.kickUserId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void GroupsKickJobTest::shouldGenerateRequest() { GroupsKickJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.kick"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void GroupsKickJobTest::shouldGenerateJson() { GroupsKickJob job; const QString channelname = QStringLiteral("foo1"); job.setRoomId(channelname); const QString userkick = QStringLiteral("bla"); job.setKickUserId(userkick); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"userId\":\"%2\"}").arg(channelname, userkick).toLatin1()); } void GroupsKickJobTest::shouldNotStarting() { GroupsKickJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); const QString kickuser = QStringLiteral("bla"); job.setKickUserId(kickuser); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/ignoreuserjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/ignoreuserjobtest.cpp index e31ab5a6..4c9b21d2 100644 --- a/src/rocketchatrestapi-qt5/autotests/ignoreuserjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/ignoreuserjobtest.cpp @@ -1,53 +1,54 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "ignoreuserjobtest.h" #include "chat/ignoreuserjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(IgnoreUserJobTest) using namespace RocketChatRestApi; IgnoreUserJobTest::IgnoreUserJobTest(QObject *parent) : QObject(parent) { } void IgnoreUserJobTest::shouldHaveDefaultValue() { IgnoreUserJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.ignoreUserId().isEmpty()); QVERIFY(job.ignore()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void IgnoreUserJobTest::shouldGenerateRequest() { IgnoreUserJob job; QNetworkRequest request = QNetworkRequest(QUrl()); job.setRoomId(QStringLiteral("foo")); job.setIgnoreUserId(QStringLiteral("bla")); verifyAuthentication(&job, request); //TODO verify //TODO add ignore == false QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.ignoreUser?rid=foo&userId=bla&ignore=true"))); } diff --git a/src/rocketchatrestapi-qt5/autotests/leavechanneljobtest.cpp b/src/rocketchatrestapi-qt5/autotests/leavechanneljobtest.cpp index 783dbaeb..a1e72f79 100644 --- a/src/rocketchatrestapi-qt5/autotests/leavechanneljobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/leavechanneljobtest.cpp @@ -1,81 +1,82 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "leavechanneljobtest.h" #include "channels/leavechanneljob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(LeaveChannelJobTest) using namespace RocketChatRestApi; LeaveChannelJobTest::LeaveChannelJobTest(QObject *parent) : QObject(parent) { } void LeaveChannelJobTest::shouldHaveDefaultValue() { LeaveChannelJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void LeaveChannelJobTest::shouldGenerateRequest() { LeaveChannelJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.leave"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void LeaveChannelJobTest::shouldGenerateJson() { LeaveChannelJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\"}").arg(roomId).toLatin1()); } void LeaveChannelJobTest::shouldNotStarting() { LeaveChannelJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/leavegroupsjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/leavegroupsjobtest.cpp index 3803bc48..487328c7 100644 --- a/src/rocketchatrestapi-qt5/autotests/leavegroupsjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/leavegroupsjobtest.cpp @@ -1,81 +1,82 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "leavegroupsjobtest.h" #include "groups/leavegroupsjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(LeaveGroupsJobTest) using namespace RocketChatRestApi; LeaveGroupsJobTest::LeaveGroupsJobTest(QObject *parent) : QObject(parent) { } void LeaveGroupsJobTest::shouldHaveDefaultValue() { LeaveGroupsJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void LeaveGroupsJobTest::shouldGenerateRequest() { LeaveGroupsJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.leave"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void LeaveGroupsJobTest::shouldGenerateJson() { LeaveGroupsJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\"}").arg(roomId).toLatin1()); } void LeaveGroupsJobTest::shouldNotStarting() { LeaveGroupsJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/listcommandsjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/listcommandsjobtest.cpp index f6de3577..5ea55cf6 100644 --- a/src/rocketchatrestapi-qt5/autotests/listcommandsjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/listcommandsjobtest.cpp @@ -1,46 +1,47 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "listcommandsjobtest.h" #include "commands/listcommandsjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ListCommandsJobTest) using namespace RocketChatRestApi; ListCommandsJobTest::ListCommandsJobTest(QObject *parent) : QObject(parent) { } void ListCommandsJobTest::shouldHaveDefaultValue() { ListCommandsJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); + QVERIFY(!job.hasQueryParameterSupport()); } void ListCommandsJobTest::shouldGenerateRequest() { ListCommandsJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/commands.list"))); } diff --git a/src/rocketchatrestapi-qt5/autotests/listpermissionsjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/listpermissionsjobtest.cpp index 5220f8bc..88cbd397 100644 --- a/src/rocketchatrestapi-qt5/autotests/listpermissionsjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/listpermissionsjobtest.cpp @@ -1,46 +1,47 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "listpermissionsjobtest.h" #include "permissions/listpermissionsjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ListPermissionsJobTest) using namespace RocketChatRestApi; ListPermissionsJobTest::ListPermissionsJobTest(QObject *parent) : QObject(parent) { } void ListPermissionsJobTest::shouldHaveDefaultValue() { ListPermissionsJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); + QVERIFY(!job.hasQueryParameterSupport()); } void ListPermissionsJobTest::shouldGenerateRequest() { ListPermissionsJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/permissions.list"))); } diff --git a/src/rocketchatrestapi-qt5/autotests/loademojicustomjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/loademojicustomjobtest.cpp index d8d2ec32..ee23feb2 100644 --- a/src/rocketchatrestapi-qt5/autotests/loademojicustomjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/loademojicustomjobtest.cpp @@ -1,59 +1,60 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "loademojicustomjobtest.h" #include "emoji/loademojicustomjob.h" #include #include QTEST_GUILESS_MAIN(LoadEmojiCustomJobTest) using namespace RocketChatRestApi; LoadEmojiCustomJobTest::LoadEmojiCustomJobTest(QObject *parent) : QObject(parent) { } void LoadEmojiCustomJobTest::shouldHaveDefaultValue() { LoadEmojiCustomJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.authToken().isEmpty()); QVERIFY(job.userId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void LoadEmojiCustomJobTest::shouldGenerateRequest() { LoadEmojiCustomJob job; const QString authToken = QStringLiteral("foo"); const QString userId = QStringLiteral("user"); job.setUserId(userId); job.setAuthToken(authToken); RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/emoji-custom"))); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-Auth-Token")), authToken.toLocal8Bit()); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-User-Id")), userId.toLocal8Bit()); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/loginjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/loginjobtest.cpp index 9e5ae063..f6d5ce7d 100644 --- a/src/rocketchatrestapi-qt5/autotests/loginjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/loginjobtest.cpp @@ -1,30 +1,31 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "loginjobtest.h" #include "authentication/loginjob.h" #include QTEST_GUILESS_MAIN(LoginJobTest) //TODO implement it! using namespace RocketChatRestApi; LoginJobTest::LoginJobTest(QObject *parent) : QObject(parent) { + //QVERIFY(!job.hasQueryParameterSupport()); } diff --git a/src/rocketchatrestapi-qt5/autotests/logoutjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/logoutjobtest.cpp index 0045c7ac..b67373f2 100644 --- a/src/rocketchatrestapi-qt5/autotests/logoutjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/logoutjobtest.cpp @@ -1,59 +1,60 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "logoutjobtest.h" #include "authentication/logoutjob.h" #include #include QTEST_GUILESS_MAIN(LogoutJobTest) using namespace RocketChatRestApi; LogoutJobTest::LogoutJobTest(QObject *parent) : QObject(parent) { } void LogoutJobTest::shouldHaveDefaultValue() { LogoutJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.authToken().isEmpty()); QVERIFY(job.userId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void LogoutJobTest::shouldGenerateRequest() { LogoutJob job; const QString authToken = QStringLiteral("foo"); const QString userId = QStringLiteral("user"); job.setUserId(userId); job.setAuthToken(authToken); RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/logout"))); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-Auth-Token")), authToken.toLocal8Bit()); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-User-Id")), userId.toLocal8Bit()); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/markroomasreadjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/markroomasreadjobtest.cpp index 25a5884a..3fb96b68 100644 --- a/src/rocketchatrestapi-qt5/autotests/markroomasreadjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/markroomasreadjobtest.cpp @@ -1,81 +1,82 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "markroomasreadjobtest.h" #include "subscriptions/markroomasreadjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(MarkRoomAsReadJobTest) using namespace RocketChatRestApi; MarkRoomAsReadJobTest::MarkRoomAsReadJobTest(QObject *parent) : QObject(parent) { } void MarkRoomAsReadJobTest::shouldHaveDefaultValue() { MarkRoomAsReadJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void MarkRoomAsReadJobTest::shouldGenerateRequest() { MarkRoomAsReadJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/subscriptions.read"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void MarkRoomAsReadJobTest::shouldGenerateJson() { MarkRoomAsReadJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"rid\":\"%1\"}").arg(roomId).toLatin1()); } void MarkRoomAsReadJobTest::shouldNotStarting() { MarkRoomAsReadJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/markroomasunreadjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/markroomasunreadjobtest.cpp index 229b17e6..c019e354 100644 --- a/src/rocketchatrestapi-qt5/autotests/markroomasunreadjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/markroomasunreadjobtest.cpp @@ -1,87 +1,88 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "markroomasunreadjobtest.h" #include "subscriptions/markroomasunreadjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(MarkRoomAsUnReadJobTest) using namespace RocketChatRestApi; MarkRoomAsUnReadJobTest::MarkRoomAsUnReadJobTest(QObject *parent) : QObject(parent) { } void MarkRoomAsUnReadJobTest::shouldHaveDefaultValue() { MarkRoomAsUnReadJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.objectId().isEmpty()); QCOMPARE(job.unReadObject(), MarkRoomAsUnReadJob::Unknown); + QVERIFY(!job.hasQueryParameterSupport()); } void MarkRoomAsUnReadJobTest::shouldGenerateRequest() { MarkRoomAsUnReadJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/subscriptions.unread"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void MarkRoomAsUnReadJobTest::shouldGenerateJson() { MarkRoomAsUnReadJob job; const QString roomId = QStringLiteral("foo1"); job.setObjectId(roomId); job.setUnReadObject(MarkRoomAsUnReadJob::Room); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\"}").arg(roomId).toLatin1()); job.setUnReadObject(MarkRoomAsUnReadJob::FromMessage); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"firstUnreadMessage\":{\"_id\":\"foo1\"}}").arg(roomId).toLatin1()); } void MarkRoomAsUnReadJobTest::shouldNotStarting() { MarkRoomAsUnReadJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setObjectId(roomId); QVERIFY(!job.canStart()); job.setUnReadObject(MarkRoomAsUnReadJob::FromMessage); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/owninfojobtest.cpp b/src/rocketchatrestapi-qt5/autotests/owninfojobtest.cpp index 114a47cc..af01241a 100644 --- a/src/rocketchatrestapi-qt5/autotests/owninfojobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/owninfojobtest.cpp @@ -1,46 +1,47 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "owninfojobtest.h" #include "misc/owninfojob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(OwnInfoJobTest) using namespace RocketChatRestApi; OwnInfoJobTest::OwnInfoJobTest(QObject *parent) : QObject(parent) { } void OwnInfoJobTest::shouldHaveDefaultValue() { OwnInfoJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); + QVERIFY(!job.hasQueryParameterSupport()); } void OwnInfoJobTest::shouldGenerateRequest() { OwnInfoJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/me"))); } diff --git a/src/rocketchatrestapi-qt5/autotests/pinmessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/pinmessagejobtest.cpp index 9cbf41df..61be0fe3 100644 --- a/src/rocketchatrestapi-qt5/autotests/pinmessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/pinmessagejobtest.cpp @@ -1,93 +1,94 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "pinmessagejobtest.h" #include "ruqola_restapi_helper.h" #include "chat/pinmessagejob.h" #include #include #include #include QTEST_GUILESS_MAIN(PinMessageJobTest) using namespace RocketChatRestApi; PinMessageJobTest::PinMessageJobTest(QObject *parent) : QObject(parent) { } void PinMessageJobTest::shouldHaveDefaultValue() { PinMessageJob job; verifyDefaultValue(&job); QVERIFY(job.messageId().isEmpty()); QVERIFY(job.pinMessage()); + QVERIFY(!job.hasQueryParameterSupport()); } void PinMessageJobTest::shouldHaveMessageId() { PinMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QVERIFY(!job.canStart()); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); job.setMessageId(QStringLiteral("bla")); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } void PinMessageJobTest::shouldGeneratePinMessageRequest() { PinMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.pinMessage"))); } void PinMessageJobTest::shouldGenerateUnPinMessageRequest() { PinMessageJob job; job.setPinMessage(false); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.unPinMessage"))); } void PinMessageJobTest::shouldGenerateJson() { PinMessageJob job; const QString messageId = QStringLiteral("foo1"); job.setMessageId(messageId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"messageId\":\"%1\"}").arg(messageId).toLatin1()); job.setPinMessage(false); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"messageId\":\"%1\"}").arg(messageId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/postmessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/postmessagejobtest.cpp index 7952b4ad..207ceec5 100644 --- a/src/rocketchatrestapi-qt5/autotests/postmessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/postmessagejobtest.cpp @@ -1,87 +1,88 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "postmessagejobtest.h" #include "chat/postmessagejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(PostMessageJobTest) using namespace RocketChatRestApi; PostMessageJobTest::PostMessageJobTest(QObject *parent) : QObject(parent) { } void PostMessageJobTest::shouldHaveDefaultValue() { PostMessageJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QVERIFY(job.text().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void PostMessageJobTest::shouldGenerateRequest() { PostMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.postMessage"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void PostMessageJobTest::shouldGenerateJson() { PostMessageJob job; const QString roomId = QStringLiteral("foo1"); const QString text = QStringLiteral("topic1"); job.setRoomId(roomId); job.setText(text); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"text\":\"%2\"}").arg(roomId, text).toLatin1()); } void PostMessageJobTest::shouldNotStarting() { PostMessageJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); const QString text = QStringLiteral("topic1"); job.setText(text); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/privateinfojobtest.cpp b/src/rocketchatrestapi-qt5/autotests/privateinfojobtest.cpp index 16499ba6..6deaddcf 100644 --- a/src/rocketchatrestapi-qt5/autotests/privateinfojobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/privateinfojobtest.cpp @@ -1,59 +1,60 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "privateinfojobtest.h" #include "settings/privateinfojob.h" #include #include QTEST_GUILESS_MAIN(PrivateInfoJobTest) using namespace RocketChatRestApi; PrivateInfoJobTest::PrivateInfoJobTest(QObject *parent) : QObject(parent) { } void PrivateInfoJobTest::shouldHaveDefaultValue() { PrivateInfoJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.authToken().isEmpty()); QVERIFY(job.userId().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void PrivateInfoJobTest::shouldGenerateRequest() { PrivateInfoJob job; const QString authToken = QStringLiteral("foo"); const QString userId = QStringLiteral("user"); job.setUserId(userId); job.setAuthToken(authToken); RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/settings"))); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-Auth-Token")), authToken.toLocal8Bit()); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-User-Id")), userId.toLocal8Bit()); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/reactonmessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/reactonmessagejobtest.cpp index 9da89d32..9c0da65c 100644 --- a/src/rocketchatrestapi-qt5/autotests/reactonmessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/reactonmessagejobtest.cpp @@ -1,90 +1,91 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "reactonmessagejobtest.h" #include "chat/reactonmessagejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ReactOnMessageJobTest) using namespace RocketChatRestApi; ReactOnMessageJobTest::ReactOnMessageJobTest(QObject *parent) : QObject(parent) { } void ReactOnMessageJobTest::shouldHaveDefaultValue() { ReactOnMessageJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.messageId().isEmpty()); QVERIFY(job.emoji().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ReactOnMessageJobTest::shouldGenerateRequest() { ReactOnMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.react"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ReactOnMessageJobTest::shouldGenerateJson() { ReactOnMessageJob job; const QString messageid = QStringLiteral("foo1"); const QString emoji = QStringLiteral("topic1"); job.setMessageId(messageid); job.setEmoji(emoji); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"emoji\":\"%1\",\"messageId\":\"%2\",\"shouldReact\":true}").arg(emoji, messageid).toLatin1()); job.setShouldReact(false); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"emoji\":\"%1\",\"messageId\":\"%2\",\"shouldReact\":false}").arg(emoji, messageid).toLatin1()); } void ReactOnMessageJobTest::shouldNotStarting() { ReactOnMessageJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString messageId = QStringLiteral("foo1"); job.setMessageId(messageId); QVERIFY(!job.canStart()); const QString emoji = QStringLiteral("topic1"); job.setEmoji(emoji); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/reportmessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/reportmessagejobtest.cpp index de6eb74b..02f73f25 100644 --- a/src/rocketchatrestapi-qt5/autotests/reportmessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/reportmessagejobtest.cpp @@ -1,86 +1,87 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "reportmessagejobtest.h" #include "ruqola_restapi_helper.h" #include "chat/reportmessagejob.h" #include #include #include #include QTEST_GUILESS_MAIN(ReportMessageJobTest) using namespace RocketChatRestApi; ReportMessageJobTest::ReportMessageJobTest(QObject *parent) : QObject(parent) { } void ReportMessageJobTest::shouldHaveDefaultValue() { ReportMessageJob job; verifyDefaultValue(&job); QVERIFY(job.messageId().isEmpty()); QVERIFY(job.reportMessage().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ReportMessageJobTest::shouldHaveMessageId() { ReportMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QVERIFY(!job.canStart()); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); job.setReportMessage(QStringLiteral("bla")); QVERIFY(!job.canStart()); job.setMessageId(QStringLiteral("bla")); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } void ReportMessageJobTest::shouldGenerateJobRequest() { ReportMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.reportMessage"))); } void ReportMessageJobTest::shouldGenerateJson() { ReportMessageJob job; const QString messageId = QStringLiteral("foo1"); job.setMessageId(messageId); const QString reportMessage = QStringLiteral("foo2"); job.setReportMessage(reportMessage); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"description\":\"%2\",\"messageId\":\"%1\"}").arg(messageId, reportMessage).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/resetavatarjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/resetavatarjobtest.cpp index 1cc790ee..c66db573 100644 --- a/src/rocketchatrestapi-qt5/autotests/resetavatarjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/resetavatarjobtest.cpp @@ -1,81 +1,82 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "resetavatarjobtest.h" #include "users/resetavatarjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(ResetAvatarJobTest) using namespace RocketChatRestApi; ResetAvatarJobTest::ResetAvatarJobTest(QObject *parent) : QObject(parent) { } void ResetAvatarJobTest::shouldHaveDefaultValue() { ResetAvatarJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.avatarUserId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void ResetAvatarJobTest::shouldGenerateRequest() { ResetAvatarJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.resetAvatar"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void ResetAvatarJobTest::shouldGenerateJson() { ResetAvatarJob job; const QString avatarid = QStringLiteral("foo1"); job.setAvatarUserId(avatarid); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"userId\":\"%1\"}").arg(avatarid).toLatin1()); } void ResetAvatarJobTest::shouldNotStarting() { ResetAvatarJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString avatarid = QStringLiteral("foo1"); job.setAvatarUserId(avatarid); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/roomfavoritejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/roomfavoritejobtest.cpp index d5734ffe..fc6e8732 100644 --- a/src/rocketchatrestapi-qt5/autotests/roomfavoritejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/roomfavoritejobtest.cpp @@ -1,81 +1,82 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "roomfavoritejobtest.h" #include "rooms/roomfavoritejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(RoomFavoriteJobTest) using namespace RocketChatRestApi; RoomFavoriteJobTest::RoomFavoriteJobTest(QObject *parent) : QObject(parent) { } void RoomFavoriteJobTest::shouldHaveDefaultValue() { RoomFavoriteJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void RoomFavoriteJobTest::shouldGenerateRequest() { RoomFavoriteJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.favorite"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void RoomFavoriteJobTest::shouldGenerateJson() { RoomFavoriteJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"favorite\":true,\"roomId\":\"%1\"}").arg(roomId).toLatin1()); } void RoomFavoriteJobTest::shouldNotStarting() { RoomFavoriteJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/roomleavejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/roomleavejobtest.cpp index e7eb60f9..b31ba89a 100644 --- a/src/rocketchatrestapi-qt5/autotests/roomleavejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/roomleavejobtest.cpp @@ -1,81 +1,82 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "roomleavejobtest.h" #include "rooms/roomleavejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(RoomLeaveJobTest) using namespace RocketChatRestApi; RoomLeaveJobTest::RoomLeaveJobTest(QObject *parent) : QObject(parent) { } void RoomLeaveJobTest::shouldHaveDefaultValue() { RoomLeaveJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void RoomLeaveJobTest::shouldGenerateRequest() { RoomLeaveJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.leave"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void RoomLeaveJobTest::shouldGenerateJson() { RoomLeaveJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\"}").arg(roomId).toLatin1()); } void RoomLeaveJobTest::shouldNotStarting() { RoomLeaveJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/savenotificationjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/savenotificationjobtest.cpp index 11e31d7d..501ac68e 100644 --- a/src/rocketchatrestapi-qt5/autotests/savenotificationjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/savenotificationjobtest.cpp @@ -1,138 +1,139 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "savenotificationjobtest.h" #include "rooms/savenotificationjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(SaveNotificationJobTest) using namespace RocketChatRestApi; SaveNotificationJobTest::SaveNotificationJobTest(QObject *parent) : QObject(parent) { } void SaveNotificationJobTest::shouldHaveDefaultValue() { SaveNotificationJob job; verifyDefaultValue(&job); QVERIFY(job.roomId().isEmpty()); QVERIFY(!job.disableNotifications()); QVERIFY(!job.muteGroupMentions()); QVERIFY(!job.hideUnreadStatus()); QVERIFY(job.emailNotifications().isEmpty()); QVERIFY(job.audioNotifications().isEmpty()); QVERIFY(job.mobilePushNotifications().isEmpty()); QVERIFY(job.audioNotificationValue().isEmpty()); QCOMPARE(job.desktopNotificationDuration(), 0); QVERIFY(job.unreadAlert().isEmpty()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void SaveNotificationJobTest::shouldGenerateRequest() { SaveNotificationJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.saveNotification"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void SaveNotificationJobTest::shouldGenerateJson() { SaveNotificationJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"notifications\":{},\"roomId\":\"%1\"}").arg(roomId).toLatin1()); //Add settings const QString audioNotification = QStringLiteral("all"); job.setAudioNotifications(audioNotification); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"notifications\":{\"audioNotifications\":\"%2\"},\"roomId\":\"%1\"}") .arg(roomId, audioNotification).toLatin1()); const bool hideUnread = true; job.setHideUnreadStatus(hideUnread); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"notifications\":{\"audioNotifications\":\"%2\",\"hideUnreadStatus\":\"1\"},\"roomId\":\"%1\"}") .arg(roomId, audioNotification).toLatin1()); const QString mobilePushNotifications = QStringLiteral("all"); job.setMobilePushNotifications(mobilePushNotifications); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"notifications\":{\"audioNotifications\":\"%2\"," "\"hideUnreadStatus\":\"1\"," "\"mobilePushNotifications\":\"%3\"},\"roomId\":\"%1\"}") .arg(roomId, audioNotification, mobilePushNotifications).toLatin1()); const bool disableNotifications = true; job.setDisableNotifications(disableNotifications); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"notifications\":{\"audioNotifications\":\"%2\"," "\"disableNotifications\":\"1\"," "\"hideUnreadStatus\":\"1\"," "\"mobilePushNotifications\":\"%3\"},\"roomId\":\"%1\"}") .arg(roomId, audioNotification, mobilePushNotifications).toLatin1()); const bool muteMentionGroups = true; job.setMuteGroupMentions(muteMentionGroups); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"notifications\":{\"audioNotifications\":\"%2\"," "\"disableNotifications\":\"1\"," "\"hideUnreadStatus\":\"1\"," "\"mobilePushNotifications\":\"%3\"," "\"muteGroupMentions\":\"1\"},\"roomId\":\"%1\"}") .arg(roomId, audioNotification, mobilePushNotifications).toLatin1()); //TODO add more settings } void SaveNotificationJobTest::shouldNotStarting() { SaveNotificationJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); //We need to change a settings job.setAudioNotificationValue(QStringLiteral("foo")); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/searchmessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/searchmessagejobtest.cpp index 9dd2628a..0533a389 100644 --- a/src/rocketchatrestapi-qt5/autotests/searchmessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/searchmessagejobtest.cpp @@ -1,62 +1,63 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "searchmessagejobtest.h" #include "chat/searchmessagejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(searchMessageJobTest) using namespace RocketChatRestApi; searchMessageJobTest::searchMessageJobTest(QObject *parent) : QObject(parent) { } void searchMessageJobTest::shouldHaveDefaultValue() { SearchMessageJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.searchText().isEmpty()); QVERIFY(job.roomId().isEmpty()); QCOMPARE(job.count(), -1); + QVERIFY(!job.hasQueryParameterSupport()); } void searchMessageJobTest::shouldGenerateRequest() { SearchMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); job.setRoomId(QStringLiteral("foo")); job.setSearchText(QStringLiteral("bla")); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.search?roomId=foo&searchText=bla"))); } void searchMessageJobTest::shouldGenerateRequestWithLimit() { SearchMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); job.setRoomId(QStringLiteral("foo")); job.setSearchText(QStringLiteral("bla")); job.setCount(5); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.search?roomId=foo&searchText=bla&count=5"))); } diff --git a/src/rocketchatrestapi-qt5/autotests/serverinfojobtest.cpp b/src/rocketchatrestapi-qt5/autotests/serverinfojobtest.cpp index e1cf8bc1..2e4ed837 100644 --- a/src/rocketchatrestapi-qt5/autotests/serverinfojobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/serverinfojobtest.cpp @@ -1,52 +1,53 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "serverinfojobtest.h" #include "serverinfojob.h" #include "restapimethod.h" #include "ruqola_restapi_helper.h" #include QTEST_GUILESS_MAIN(ServerInfoJobTest) using namespace RocketChatRestApi; ServerInfoJobTest::ServerInfoJobTest(QObject *parent) : QObject(parent) { } void ServerInfoJobTest::shouldHaveDefaultValue() { ServerInfoJob job; verifyDefaultValue(&job); QVERIFY(!job.requireHttpAuthentication()); + QVERIFY(!job.hasQueryParameterSupport()); } void ServerInfoJobTest::shouldGenerateRequest() { ServerInfoJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/info"))); QCOMPARE(request.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool(), true); QCOMPARE(request.attribute(QNetworkRequest::HTTP2AllowedAttribute).toBool(), true); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/setavatarjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/setavatarjobtest.cpp index 2d4c77ee..ea3852e6 100644 --- a/src/rocketchatrestapi-qt5/autotests/setavatarjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/setavatarjobtest.cpp @@ -1,82 +1,83 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "setavatarjobtest.h" #include "users/setavatarjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(SetAvatarJobTest) using namespace RocketChatRestApi; SetAvatarJobTest::SetAvatarJobTest(QObject *parent) : QObject(parent) { } void SetAvatarJobTest::shouldHaveDefaultValue() { SetAvatarJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.avatarUrl().isEmpty()); QVERIFY(job.avatarUserId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void SetAvatarJobTest::shouldGenerateRequest() { SetAvatarJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.setAvatar"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void SetAvatarJobTest::shouldGenerateJson() { SetAvatarJob job; const QString roomId = QStringLiteral("foo1"); job.setAvatarUrl(roomId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"avatarUrl\":\"%1\"}").arg(roomId).toLatin1()); } void SetAvatarJobTest::shouldNotStarting() { SetAvatarJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setAvatarUrl(roomId); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/setchanneltypejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/setchanneltypejobtest.cpp index 5c35dd46..173f40af 100644 --- a/src/rocketchatrestapi-qt5/autotests/setchanneltypejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/setchanneltypejobtest.cpp @@ -1,88 +1,89 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "setchanneltypejobtest.h" #include "channels/setchanneltypejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(SetChannelTypeJobTest) using namespace RocketChatRestApi; SetChannelTypeJobTest::SetChannelTypeJobTest(QObject *parent) : QObject(parent) { } void SetChannelTypeJobTest::shouldHaveDefaultValue() { SetChannelTypeJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QCOMPARE(job.type(), SetChannelTypeJob::Unknown); + QVERIFY(!job.hasQueryParameterSupport()); } void SetChannelTypeJobTest::shouldGenerateRequest() { SetChannelTypeJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setType"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void SetChannelTypeJobTest::shouldGenerateJson() { SetChannelTypeJob job; const QString channelname = QStringLiteral("foo1"); job.setRoomId(channelname); job.setType(SetChannelTypeJob::Private); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"type\":\"c\"}").arg(channelname).toLatin1()); job.setType(SetChannelTypeJob::Public); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"type\":\"p\"}").arg(channelname).toLatin1()); } void SetChannelTypeJobTest::shouldNotStarting() { SetChannelTypeJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); job.setType(SetChannelTypeJob::Private); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/setgrouptypejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/setgrouptypejobtest.cpp index 2e9237f7..53f2fa6f 100644 --- a/src/rocketchatrestapi-qt5/autotests/setgrouptypejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/setgrouptypejobtest.cpp @@ -1,88 +1,89 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "setgrouptypejobtest.h" #include "groups/setgrouptypejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(SetGroupTypeJobTest) using namespace RocketChatRestApi; SetGroupTypeJobTest::SetGroupTypeJobTest(QObject *parent) : QObject(parent) { } void SetGroupTypeJobTest::shouldHaveDefaultValue() { SetGroupTypeJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QCOMPARE(job.type(), SetGroupTypeJob::Unknown); + QVERIFY(!job.hasQueryParameterSupport()); } void SetGroupTypeJobTest::shouldGenerateRequest() { SetGroupTypeJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setType"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void SetGroupTypeJobTest::shouldGenerateJson() { SetGroupTypeJob job; const QString channelname = QStringLiteral("foo1"); job.setRoomId(channelname); job.setType(SetGroupTypeJob::Private); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"type\":\"c\"}").arg(channelname).toLatin1()); job.setType(SetGroupTypeJob::Public); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"roomId\":\"%1\",\"type\":\"p\"}").arg(channelname).toLatin1()); } void SetGroupTypeJobTest::shouldNotStarting() { SetGroupTypeJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); job.setType(SetGroupTypeJob::Private); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/setjoincodechanneljobtest.cpp b/src/rocketchatrestapi-qt5/autotests/setjoincodechanneljobtest.cpp index 391eff60..461d74f1 100644 --- a/src/rocketchatrestapi-qt5/autotests/setjoincodechanneljobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/setjoincodechanneljobtest.cpp @@ -1,87 +1,88 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "setjoincodechanneljobtest.h" #include "channels/setjoincodechanneljob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(SetJoinCodeChannelJobTest) using namespace RocketChatRestApi; SetJoinCodeChannelJobTest::SetJoinCodeChannelJobTest(QObject *parent) : QObject(parent) { } void SetJoinCodeChannelJobTest::shouldHaveDefaultValue() { SetJoinCodeChannelJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void SetJoinCodeChannelJobTest::shouldGenerateRequest() { SetJoinCodeChannelJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setJoinCode"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void SetJoinCodeChannelJobTest::shouldGenerateJson() { SetJoinCodeChannelJob job; const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); const QString joinCode = QStringLiteral("bli"); job.setJoinCode(joinCode); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"joinCode\":\"%2\",\"roomId\":\"%1\"}").arg(roomId, joinCode).toLatin1()); } void SetJoinCodeChannelJobTest::shouldNotStarting() { SetJoinCodeChannelJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); const QString joinCode = QStringLiteral("fd1"); job.setJoinCode(joinCode); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/settingsoauthjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/settingsoauthjobtest.cpp index abe90dbe..0e2bd470 100644 --- a/src/rocketchatrestapi-qt5/autotests/settingsoauthjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/settingsoauthjobtest.cpp @@ -1,46 +1,47 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "settingsoauthjobtest.h" #include "misc/settingsoauthjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(SettingsOauthJobTest) using namespace RocketChatRestApi; SettingsOauthJobTest::SettingsOauthJobTest(QObject *parent) : QObject(parent) { } void SettingsOauthJobTest::shouldHaveDefaultValue() { SettingsOauthJob job; verifyDefaultValue(&job); QVERIFY(!job.requireHttpAuthentication()); + QVERIFY(!job.hasQueryParameterSupport()); } void SettingsOauthJobTest::shouldGenerateRequest() { SettingsOauthJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/settings.oauth"))); } diff --git a/src/rocketchatrestapi-qt5/autotests/setuserpublicandprivatekeysjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/setuserpublicandprivatekeysjobtest.cpp index 1d392623..10269b9f 100644 --- a/src/rocketchatrestapi-qt5/autotests/setuserpublicandprivatekeysjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/setuserpublicandprivatekeysjobtest.cpp @@ -1,88 +1,89 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "setuserpublicandprivatekeysjobtest.h" #include "e2e/setuserpublicandprivatekeysjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(SetUserPublicAndPrivateKeysJobTest) using namespace RocketChatRestApi; SetUserPublicAndPrivateKeysJobTest::SetUserPublicAndPrivateKeysJobTest(QObject *parent) : QObject(parent) { } void SetUserPublicAndPrivateKeysJobTest::shouldHaveDefaultValue() { SetUserPublicAndPrivateKeysJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.rsaPrivateKey().isEmpty()); QVERIFY(job.rsaPublicKey().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void SetUserPublicAndPrivateKeysJobTest::shouldGenerateRequest() { SetUserPublicAndPrivateKeysJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/e2e.setUserPublicAndPivateKeys"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void SetUserPublicAndPrivateKeysJobTest::shouldGenerateJson() { SetUserPublicAndPrivateKeysJob job; const QString rsapublic = QStringLiteral("foo1"); job.setRsaPublicKey(rsapublic); const QString rsaprivate = QStringLiteral("private"); job.setRsaPrivateKey(rsaprivate); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"private_key\":\"%2\",\"public_key\":\"%1\"}").arg(rsapublic, rsaprivate).toLatin1()); } void SetUserPublicAndPrivateKeysJobTest::shouldNotStarting() { SetUserPublicAndPrivateKeysJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString rsaprivate = QStringLiteral("foo1"); job.setRsaPrivateKey(rsaprivate); QVERIFY(!job.canStart()); const QString rsapublic = QStringLiteral("bla"); job.setRsaPublicKey(rsapublic); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/spotlightjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/spotlightjobtest.cpp index d747ac33..f6eacf31 100644 --- a/src/rocketchatrestapi-qt5/autotests/spotlightjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/spotlightjobtest.cpp @@ -1,54 +1,55 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "spotlightjobtest.h" #include "spotlightjob.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(SpotlightJobTest) using namespace RocketChatRestApi; SpotlightJobTest::SpotlightJobTest(QObject *parent) : QObject(parent) { } void SpotlightJobTest::shouldHaveDefaultValue() { SpotlightJob job; QVERIFY(!job.restApiMethod()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.start()); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.searchPattern().isEmpty()); QVERIFY(!job.restApiLogger()); + QVERIFY(!job.hasQueryParameterSupport()); } void SpotlightJobTest::shouldGenerateRequest() { SpotlightJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QString avatarUserId = QStringLiteral("avat"); job.setSearchPattern(avatarUserId); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/spotlight?query=avat"))); delete method; } diff --git a/src/rocketchatrestapi-qt5/autotests/starmessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/starmessagejobtest.cpp index 6d92a743..48a9a8a9 100644 --- a/src/rocketchatrestapi-qt5/autotests/starmessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/starmessagejobtest.cpp @@ -1,116 +1,117 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "starmessagejobtest.h" #include "chat/starmessagejob.h" #include #include #include QTEST_GUILESS_MAIN(StarMessageJobTest) using namespace RocketChatRestApi; StarMessageJobTest::StarMessageJobTest(QObject *parent) : QObject(parent) { } void StarMessageJobTest::shouldHaveDefaultValue() { StarMessageJob job; QVERIFY(job.requireHttpAuthentication()); QVERIFY(!job.networkAccessManager()); QVERIFY(!job.restApiMethod()); QVERIFY(!job.start()); QVERIFY(job.authToken().isEmpty()); QVERIFY(job.userId().isEmpty()); QVERIFY(job.messageId().isEmpty()); QVERIFY(!job.restApiLogger()); QVERIFY(job.starMessage()); + QVERIFY(!job.hasQueryParameterSupport()); } void StarMessageJobTest::shouldHaveMessageId() { StarMessageJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QVERIFY(!job.canStart()); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); job.setMessageId(QStringLiteral("bla")); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } void StarMessageJobTest::shouldGenerateStarMessageRequest() { StarMessageJob job; RestApiMethod *method = new RestApiMethod; const QString authToken = QStringLiteral("foo"); const QString userId = QStringLiteral("user"); job.setUserId(userId); job.setAuthToken(authToken); method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QString messageId = QStringLiteral("foo"); job.setMessageId(messageId); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.starMessage"))); QCOMPARE(request.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool(), true); QCOMPARE(request.attribute(QNetworkRequest::HTTP2AllowedAttribute).toBool(), true); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-Auth-Token")), authToken.toLocal8Bit()); QCOMPARE(request.rawHeader(QByteArrayLiteral("X-User-Id")), userId.toLocal8Bit()); delete method; } void StarMessageJobTest::shouldGenerateUnStarMessageRequest() { StarMessageJob job; job.setStarMessage(false); RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QString messageId = QStringLiteral("foo"); job.setMessageId(messageId); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.unStarMessage"))); QCOMPARE(request.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool(), true); QCOMPARE(request.attribute(QNetworkRequest::HTTP2AllowedAttribute).toBool(), true); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); delete method; } void StarMessageJobTest::shouldGenerateJson() { StarMessageJob job; const QString messageId = QStringLiteral("foo1"); job.setMessageId(messageId); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"messageId\":\"%1\"}").arg(messageId).toLatin1()); } diff --git a/src/rocketchatrestapi-qt5/autotests/twitterauthjobtest.cpp b/src/rocketchatrestapi-qt5/autotests/twitterauthjobtest.cpp index ce710a3f..88059fc9 100644 --- a/src/rocketchatrestapi-qt5/autotests/twitterauthjobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/twitterauthjobtest.cpp @@ -1,117 +1,118 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "twitterauthjobtest.h" #include "authentication/twitterauthjob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(TwitterAuthJobTest) using namespace RocketChatRestApi; TwitterAuthJobTest::TwitterAuthJobTest(QObject *parent) : QObject(parent) { } void TwitterAuthJobTest::shouldHaveDefaultValue() { TwitterAuthJob job; verifyDefaultValue(&job); QVERIFY(!job.requireHttpAuthentication()); QVERIFY(job.secret().isEmpty()); QVERIFY(job.accessToken().isEmpty()); QCOMPARE(job.expireTokenInSeconds(), -1); + QVERIFY(!job.hasQueryParameterSupport()); } void TwitterAuthJobTest::shouldGenerateRequest() { TwitterAuthJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); const QNetworkRequest request = job.request(); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/login"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); delete method; } void TwitterAuthJobTest::shouldGenerateJson() { TwitterAuthJob job; const QString secret = QStringLiteral("secret:"); job.setSecret(secret); const QString accessToken = QStringLiteral("accessToken"); job.setAccessToken(accessToken); const QString appId = QStringLiteral("appid"); job.setAppId(appId); const QString appSecret = QStringLiteral("appSecret"); job.setAppSecret(appSecret); const int expireToken = 300; job.setExpireTokenInSeconds(expireToken); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"accessToken\":\"%1\",\"accessTokenSecret\":\"%2\",\"appId\":\"%3\",\"appSecret\":\"%4\",\"expiresIn\":300,\"serviceName\":\"twitter\"}") .arg(accessToken, secret, appId).arg(appSecret).toLatin1()); } void TwitterAuthJobTest::shouldNotStarting() { TwitterAuthJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString secret = QStringLiteral("secret:"); job.setSecret(secret); QVERIFY(!job.canStart()); const QString accessToken = QStringLiteral("accessToken"); job.setAccessToken(accessToken); QVERIFY(!job.canStart()); const int expireToken = 300; job.setExpireTokenInSeconds(expireToken); QVERIFY(!job.canStart()); const QString appId = QStringLiteral("appid"); job.setAppId(appId); QVERIFY(!job.canStart()); const QString appSecret = QStringLiteral("appSecret"); job.setAppSecret(appSecret); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/updatemessagejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/updatemessagejobtest.cpp index e5eb4d9f..1ada3a60 100644 --- a/src/rocketchatrestapi-qt5/autotests/updatemessagejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/updatemessagejobtest.cpp @@ -1,96 +1,97 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "updatemessagejobtest.h" #include "chat/updatemessagejob.h" #include "ruqola_restapi_helper.h" #include #include QTEST_GUILESS_MAIN(UpdateMessageJobTest) using namespace RocketChatRestApi; UpdateMessageJobTest::UpdateMessageJobTest(QObject *parent) : QObject(parent) { } void UpdateMessageJobTest::shouldHaveDefaultValue() { UpdateMessageJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.roomId().isEmpty()); QVERIFY(job.messageId().isEmpty()); QVERIFY(job.updatedText().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void UpdateMessageJobTest::shouldGenerateRequest() { UpdateMessageJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.update"))); QCOMPARE(request.header(QNetworkRequest::ContentTypeHeader).toString(), QStringLiteral("application/json")); } void UpdateMessageJobTest::shouldGenerateJson() { UpdateMessageJob job; const QString roomId = QStringLiteral("foo1"); const QString messageId = QStringLiteral("topic1"); const QString updatedText = QStringLiteral("topic1"); job.setRoomId(roomId); job.setMessageId(messageId); job.setUpdatedText(updatedText); QCOMPARE(job.json().toJson(QJsonDocument::Compact), QStringLiteral("{\"msgId\":\"%2\",\"roomId\":\"%1\",\"text\":\"%3\"}") .arg(roomId, messageId, updatedText).toLatin1()); } void UpdateMessageJobTest::shouldNotStarting() { UpdateMessageJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); const QString roomId = QStringLiteral("foo1"); job.setRoomId(roomId); QVERIFY(!job.canStart()); const QString text = QStringLiteral("topic1"); job.setMessageId(text); QVERIFY(job.canStart()); QVERIFY(job.updatedText().isEmpty()); QVERIFY(job.canStart()); job.setUpdatedText(QStringLiteral("too")); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/uploadfilejobtest.cpp b/src/rocketchatrestapi-qt5/autotests/uploadfilejobtest.cpp index 8ec4f573..83db72df 100644 --- a/src/rocketchatrestapi-qt5/autotests/uploadfilejobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/uploadfilejobtest.cpp @@ -1,73 +1,74 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "uploadfilejobtest.h" #include "uploadfilejob.h" #include "restapimethod.h" #include "ruqola_restapi_helper.h" #include QTEST_GUILESS_MAIN(UploadFileJobTest) using namespace RocketChatRestApi; UploadFileJobTest::UploadFileJobTest(QObject *parent) : QObject(parent) { } void UploadFileJobTest::shouldHaveDefaultValue() { UploadFileJob job; verifyDefaultValue(&job); QVERIFY(job.description().isEmpty()); QVERIFY(job.messageText().isEmpty()); QVERIFY(job.roomId().isEmpty()); QVERIFY(!job.filenameUrl().isValid()); QVERIFY(job.authToken().isEmpty()); QVERIFY(job.userId().isEmpty()); + QVERIFY(!job.hasQueryParameterSupport()); } void UploadFileJobTest::shouldGenerateRequest() { UploadFileJob job; QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.upload"))); } void UploadFileJobTest::shouldStart() { UploadFileJob job; RestApiMethod *method = new RestApiMethod; method->setServerUrl(QStringLiteral("http://www.kde.org")); job.setRestApiMethod(method); QVERIFY(!job.canStart()); QNetworkAccessManager *mNetworkAccessManager = new QNetworkAccessManager; job.setNetworkAccessManager(mNetworkAccessManager); QVERIFY(!job.canStart()); const QString auth = QStringLiteral("foo"); const QString userId = QStringLiteral("foo"); job.setAuthToken(auth); QVERIFY(!job.canStart()); job.setUserId(userId); QVERIFY(!job.canStart()); job.setRoomId(QStringLiteral("bla")); QVERIFY(job.canStart()); delete method; delete mNetworkAccessManager; } diff --git a/src/rocketchatrestapi-qt5/autotests/usersinfojobtest.cpp b/src/rocketchatrestapi-qt5/autotests/usersinfojobtest.cpp index b8340761..bc5509d7 100644 --- a/src/rocketchatrestapi-qt5/autotests/usersinfojobtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/usersinfojobtest.cpp @@ -1,62 +1,63 @@ /* Copyright (c) 2018-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "usersinfojobtest.h" #include "users/usersinfojob.h" #include "ruqola_restapi_helper.h" #include #include #include QTEST_GUILESS_MAIN(UsersInfoJobTest) using namespace RocketChatRestApi; UsersInfoJobTest::UsersInfoJobTest(QObject *parent) : QObject(parent) { } void UsersInfoJobTest::shouldHaveDefaultValue() { UsersInfoJob job; verifyDefaultValue(&job); QVERIFY(job.requireHttpAuthentication()); QVERIFY(job.identifier().isEmpty()); QVERIFY(!job.useUserName()); + QVERIFY(!job.hasQueryParameterSupport()); } void UsersInfoJobTest::shouldGenerateRequest() { UsersInfoJob job; const QString roomId = QStringLiteral("foo1"); job.setIdentifier(roomId); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.info?userId=foo1"))); } void UsersInfoJobTest::shouldGenerateRequestUsername() { UsersInfoJob job; const QString roomId = QStringLiteral("foo1"); job.setIdentifier(roomId); job.setUseUserName(true); QNetworkRequest request = QNetworkRequest(QUrl()); verifyAuthentication(&job, request); QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.info?username=foo1"))); }