From e01ce46971b85f6b2b778dc4ae41956a668f5b53 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Sat, 8 Aug 2020 16:52:35 +0200 Subject: Add PubSubSubAuthorization form --- tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp | 71 +++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp (limited to 'tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp') diff --git a/tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp b/tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp new file mode 100644 index 00000000..725059c3 --- /dev/null +++ b/tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2008-2020 The QXmpp developers + * + * Author: + * Linus Jahn + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) 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 + * Lesser General Public License for more details. + * + */ + +#include "QXmppDataFormBase.h" +#include "QXmppPubSubSubAuthorization.h" + +#include "util.h" +#include + +class tst_QXmppPubSubForms : public QObject +{ + Q_OBJECT + +private slots: + void subAuthorization(); + +private: +}; + +void tst_QXmppPubSubForms::subAuthorization() +{ + QByteArray xml(R"( + + +http://jabber.org/protocol/pubsub#subscribe_authorization + +0 +princely_musings +123-abc +horatio@denmark.lit +)"); + + QXmppDataForm form; + parsePacket(form, xml); + + auto subAuthForm = QXmppPubSubSubAuthorization::fromDataForm(form); + QVERIFY(subAuthForm.has_value()); + QCOMPARE(subAuthForm->subid(), QStringLiteral("123-abc")); + QCOMPARE(subAuthForm->node(), QStringLiteral("princely_musings")); + QCOMPARE(subAuthForm->subscriberJid(), QStringLiteral("horatio@denmark.lit")); + QVERIFY(subAuthForm->allowSubscription().has_value()); + QCOMPARE(subAuthForm->allowSubscription().value(), false); + + form = subAuthForm->toDataForm(); + QVERIFY(!form.isNull()); + xml = QString::fromUtf8(xml).remove(QChar('\n')).toUtf8(); + serializePacket(form, xml); +} + +QTEST_MAIN(tst_QXmppPubSubForms) +#include "tst_qxmpppubsubforms.moc" -- cgit v1.2.3