From 727d887d7bc8a17b88402ae63e0569084a24a84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Apr 2017 00:24:59 +0200 Subject: Fix wrong JID computing when sending iq ping or version in fixed mode fix #3259 --- src/bridge/bridge.cpp | 4 ++-- tests/end_to_end/__main__.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index f263c3f..69e8c35 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -1048,7 +1048,7 @@ void Bridge::send_iq_version_request(const std::string& nick, const std::string& { const auto resources = this->resources_in_server[hostname]; if (resources.begin() != resources.end()) - this->xmpp.send_iq_version_request(utils::tolower(nick) + "%" + utils::empty_if_fixed_server(hostname), + this->xmpp.send_iq_version_request(utils::tolower(nick) + utils::empty_if_fixed_server("%" + hostname), this->user_jid + "/" + *resources.begin()); } @@ -1061,7 +1061,7 @@ void Bridge::send_xmpp_ping_request(const std::string& nick, const std::string& // Forward to the first resource (arbitrary, based on the “order” of the std::set) only const auto resources = this->resources_in_server[hostname]; if (resources.begin() != resources.end()) - this->xmpp.send_ping_request(utils::tolower(nick) + "%" + utils::empty_if_fixed_server(hostname), + this->xmpp.send_ping_request(utils::tolower(nick) + utils::empty_if_fixed_server("%" + hostname), this->user_jid + "/" + *resources.begin(), utils::revstr(id)); } diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 8acfe14..bd25f55 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1255,6 +1255,31 @@ if __name__ == '__main__': "/iq[@from='#foo%{irc_server_one}/{nick_one}'][@type='result'][@to='{jid_one}/{resource_two}'][@id='third_ping']"), ]), + Scenario("self_ping_fixed_server", [ + handshake_sequence(), + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, + "/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"), + partial(expect_stanza, + ("/presence[@to='{jid_one}/{resource_one}'][@from='#foo@{biboumi_host}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']", + "/presence/muc_user:x/muc_user:status[@code='110']") + ), + partial(expect_stanza, "/message[@from='#foo@{biboumi_host}'][@type='groupchat']/subject[not(text())]"), + + # Send a ping to ourself + partial(send_stanza, + ""), + # We receive our own ping request, + partial(expect_stanza, + "/iq[@from='{lower_nick_one}@{biboumi_host}'][@type='get'][@to='{jid_one}/{resource_one}'][@id='gnip_tsrif']"), + # Respond to the request + partial(send_stanza, + ""), + partial(expect_stanza, + "/iq[@from='#foo@{biboumi_host}/{nick_one}'][@type='result'][@to='{jid_one}/{resource_one}'][@id='first_ping']"), + ], conf="fixed_server"), Scenario("simple_kick", [ handshake_sequence(), -- cgit v1.2.3