diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-08-08 16:52:35 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2021-08-22 16:09:02 +0200 |
| commit | e01ce46971b85f6b2b778dc4ae41956a668f5b53 (patch) | |
| tree | 8a9e395ae9c1057f4b211a1e79f3dfd08d3a989a /tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp | |
| parent | 3e465fd0d273c52c66b3aeb3dc4ae147c914bdd6 (diff) | |
| download | qxmpp-e01ce46971b85f6b2b778dc4ae41956a668f5b53.tar.gz | |
Add PubSubSubAuthorization form
Diffstat (limited to 'tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp')
| -rw-r--r-- | tests/qxmpppubsubforms/tst_qxmpppubsubforms.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
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 <QObject> + +class tst_QXmppPubSubForms : public QObject +{ + Q_OBJECT + +private slots: + void subAuthorization(); + +private: +}; + +void tst_QXmppPubSubForms::subAuthorization() +{ + QByteArray xml(R"( +<x xmlns="jabber:x:data" type="form"> +<field type="hidden" var="FORM_TYPE"> +<value>http://jabber.org/protocol/pubsub#subscribe_authorization</value> +</field> +<field type="boolean" var="pubsub#allow"><value>0</value></field> +<field type="text-single" var="pubsub#node"><value>princely_musings</value></field> +<field type="text-single" var="pubsub#subid"><value>123-abc</value></field> +<field type="jid-single" var="pubsub#subscriber_jid"><value>horatio@denmark.lit</value></field> +</x>)"); + + 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" |
