From fc22e06317c8f4df984ab29e6457b7c7e0adafd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 11 Mar 2020 00:32:18 +0100 Subject: Fix a type stable-id -> stanza-id, and add a test case to be exhaustive --- src/xmpp/biboumi_component.cpp | 6 +++--- tests/end_to_end/scenarios/stable_id.py | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index f2e3753..6fda98f 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -294,15 +294,15 @@ void BiboumiComponent::handle_message(const Stanza& stanza) if (origin_id) nodes_to_reflect.push_back(*origin_id); const auto own_address = std::to_string(iid) + '@' + this->served_hostname; - for (const XmlNode* stable_id: stanza.get_children("stable-id", STABLE_ID_NS)) + for (const XmlNode* stanza_id: stanza.get_children("stanza-id", STABLE_ID_NS)) { // Stanza ID generating entities, which encounter a // element where the 'by' attribute matches // the 'by' attribute they would otherwise set, MUST // delete that element even if they are not adding their // own stanza ID. - if (stable_id->get_tag("by") != own_address) - nodes_to_reflect.push_back(*stable_id); + if (stanza_id->get_tag("by") != own_address) + nodes_to_reflect.push_back(*stanza_id); } bridge->send_channel_message(iid, body->get_inner(), id, std::move(nodes_to_reflect)); } diff --git a/tests/end_to_end/scenarios/stable_id.py b/tests/end_to_end/scenarios/stable_id.py index 90b5866..9f3181b 100644 --- a/tests/end_to_end/scenarios/stable_id.py +++ b/tests/end_to_end/scenarios/stable_id.py @@ -8,19 +8,25 @@ scenario = ( scenarios.simple_channel_join.scenario, send_stanza(""" - - + + + coucou"""), # Entities, which are routing stanzas, SHOULD NOT strip any elements # qualified by the 'urn:xmpp:sid:0' namespace from message stanzas # unless the preceding rule applied to those elements. - expect_stanza("/message/stable_id:origin-id[@id='client-origin-id']", + expect_stanza("/message/stable_id:origin-id[@id='client-origin-id-should-be-kept']", # Stanza ID generating entities, which encounter a # element where the 'by' attribute matches the 'by' attribute they # would otherwise set, MUST delete that element even if they are not # adding their own stanza ID. "/message/stable_id:stanza-id[@id][@by='#foo%{irc_server_one}']", - "!/message/stable_id:stanza-id[@id='client-stanza-id']", + "!/message/stable_id:stanza-id[@id='client-stanza-id-should-be-removed']", + # Entities, which are routing stanzas, SHOULD NOT strip + # any elements qualified by the 'urn:xmpp:sid:0' + # namespace from message stanzas unless the preceding + # rule applied to those elements. + "/message/stable_id:stanza-id[@id='client-stanza-id-should-be-kept'][@by='someother@jid']", ), ) -- cgit v1.2.3