From 49ead66e9b4d5914dfd9c33e62b0311d4d8eb940 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Tue, 31 Mar 2020 21:45:44 +0200 Subject: QXmppStanza::Error: Add redirection URI from RFC6120 The error conditions and can contain an XMPP URI to redirect to as defined in RFC6120. --- tests/qxmppstanza/tst_qxmppstanza.cpp | 71 +++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/qxmppstanza/tst_qxmppstanza.cpp b/tests/qxmppstanza/tst_qxmppstanza.cpp index 05522d3d..45cc8997 100644 --- a/tests/qxmppstanza/tst_qxmppstanza.cpp +++ b/tests/qxmppstanza/tst_qxmppstanza.cpp @@ -86,19 +86,70 @@ void tst_QXmppStanza::testErrorCases_data() QTest::addColumn("type"); QTest::addColumn("condition"); QTest::addColumn("text"); + QTest::addColumn("redirectionUri"); -#define ROW(xml, type, condition, text) \ - QTest::newRow(QT_STRINGIFY(condition)) << QByteArrayLiteral(xml) << QXmppStanza::Error::type << QXmppStanza::Error::condition << text +#define ROW(name, xml, type, condition, text, redirect) \ + QTest::newRow(QT_STRINGIFY(name)) << QByteArrayLiteral(xml) << QXmppStanza::Error::type << QXmppStanza::Error::condition << text << redirect #define BASIC(xml, type, condition) \ - ROW(xml, type, condition, QString()) + ROW(condition, xml, type, condition, QString(), QString()) ROW( + empty-text, "" "" "", Modify, BadRequest, - ""); + QString(), + QString()); + ROW( + redirection-uri-gone, + "" + "" + "xmpp:romeo@afterlife.example.net" + "" + "", + Cancel, + Gone, + QString(), + "xmpp:romeo@afterlife.example.net"); + ROW( + redirection-uri-redirect, + "" + "" + "xmpp:rms@afterlife.example.net" + "" + "", + Cancel, + Redirect, + QString(), + "xmpp:rms@afterlife.example.net"); + ROW( + redirection-uri-empty, + "" + "" + "", + Cancel, + Redirect, + QString(), + QString()); + ROW( + policy-violation-text, + "" + "" + "The used words are not allowed on this server." + "", + Modify, + PolicyViolation, + "The used words are not allowed on this server.", + QString()); + + BASIC( + "" + "" + "", + Modify, + BadRequest); BASIC( "" "" @@ -159,14 +210,12 @@ void tst_QXmppStanza::testErrorCases_data() "", Auth, NotAuthorized); - ROW( + BASIC( "" "" - "The used words are not allowed on this server." "", Modify, - PolicyViolation, - "The used words are not allowed on this server."); + PolicyViolation); BASIC( "" "" @@ -221,6 +270,9 @@ void tst_QXmppStanza::testErrorCases_data() "", Modify, UndefinedCondition); + +#undef BASIC +#undef ROW } void tst_QXmppStanza::testErrorCases() @@ -229,6 +281,7 @@ void tst_QXmppStanza::testErrorCases() QFETCH(QXmppStanza::Error::Type, type); QFETCH(QXmppStanza::Error::Condition, condition); QFETCH(QString, text); + QFETCH(QString, redirectionUri); // parsing QXmppStanza::Error error; @@ -236,6 +289,7 @@ void tst_QXmppStanza::testErrorCases() QCOMPARE(error.type(), type); QCOMPARE(error.condition(), condition); QCOMPARE(error.text(), text); + QCOMPARE(error.redirectionUri(), redirectionUri); // check parsed error results in the same xml serializePacket(error, xml); @@ -244,6 +298,7 @@ void tst_QXmppStanza::testErrorCases() error.setType(type); error.setCondition(condition); error.setText(text); + error.setRedirectionUri(redirectionUri); serializePacket(error, xml); } -- cgit v1.2.3