From fe4ceb72d09968a16105c4c0864705f474d9a863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 24 Aug 2017 23:53:29 +0200 Subject: Add an e2e test to demonstrate bug #3291 --- tests/end_to_end/__main__.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index c6607d0..5317540 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1480,6 +1480,24 @@ if __name__ == '__main__': ("/message/subject",), ]), + # demonstrate bug https://lab.louiz.org/louiz/biboumi/issues/3291 + # First user joins an other channel + partial(send_stanza, + ""), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, "/message[@type='groupchat']/subject"), + + # Second user joins + partial(send_stanza, + ""), + partial(expect_unordered, [ + ("/presence/muc_user:x/muc_user:item[@affiliation='none'][@role='participant']",), + ("/presence/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",), + ("/presence/muc_user:x/muc_user:status[@code='110']",), + ("/message/subject",), + ]), + # Moderator kicks participant partial(send_stanza, "reported"), @@ -1495,6 +1513,14 @@ if __name__ == '__main__': ), ("/iq[@id='kick1'][@type='result']",), ]), + + # Bug 3291, suite. We must not receive any presence from #foo, here + partial(send_stanza, "QUIT bye bye"), + partial(expect_unordered, + [("/presence[@from='#bar%{irc_server_one}/{nick_two}'][@to='{jid_one}/{resource_one}']",), + ("/presence[@from='#bar%{irc_server_one}/{nick_two}'][@to='{jid_two}/{resource_one}']",), + ("/message",), + ("/message",)]) ]), Scenario("mode_change", [ -- cgit v1.2.3 From 25243f53c2479e2fda0f1a05d1589c8214b70b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 27 Aug 2017 14:32:29 +0200 Subject: =?UTF-8?q?In=20fixed=20mode,=20server=20messages=20come=20from=20?= =?UTF-8?q?biboumi=E2=80=99s=20hostname=20directly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of irc.example.com@biboumi, because that’s actually user named “irc.example.com”, in that case. And that fixes the raw messages in fixed mode. fix #3286 --- tests/end_to_end/__main__.py | 77 ++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 25 deletions(-) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 5317540..f590c1c 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -403,10 +403,14 @@ def handshake_sequence(): partial(send_stanza, "")) -def connection_begin_sequence(irc_host, jid, expected_irc_presence=False): +def connection_begin_sequence(irc_host, jid, expected_irc_presence=False, fixed_irc_server=False): jid = jid.format_map(common_replacements) - xpath = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[text()='%s']" - xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" + if fixed_irc_server: + xpath = "/message[@to='" + jid + "'][@from='biboumi.localhost']/body[text()='%s']" + xpath_re = "/message[@to='" + jid + "'][@from='biboumi.localhost']/body[re:test(text(), '%s')]" + else: + xpath = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[text()='%s']" + xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" result = ( partial(expect_stanza, xpath % ('Connecting to %s:6697 (encrypted)' % irc_host)), @@ -440,10 +444,14 @@ def connection_begin_sequence(irc_host, jid, expected_irc_presence=False): return result -def connection_tls_begin_sequence(irc_host, jid): +def connection_tls_begin_sequence(irc_host, jid, fixed_irc_server): jid = jid.format_map(common_replacements) - xpath = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[text()='%s']" - xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" + if fixed_irc_server: + xpath = "/message[@to='" + jid + "'][@from='biboumi.localhost']/body[text()='%s']" + xpath_re = "/message[@to='" + jid + "'][@from='biboumi.localhost']/body[re:test(text(), '%s')]" + else: + xpath = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[text()='%s']" + xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" irc_host = 'irc.localhost' return ( partial(expect_stanza, @@ -463,10 +471,14 @@ def connection_tls_begin_sequence(irc_host, jid): xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), ) -def connection_end_sequence(irc_host, jid): +def connection_end_sequence(irc_host, jid, fixed_irc_server=False): jid = jid.format_map(common_replacements) - xpath = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[text()='%s']" - xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" + if fixed_irc_server: + xpath = "/message[@to='" + jid + "'][@from='biboumi.localhost']/body[text()='%s']" + xpath_re = "/message[@to='" + jid + "'][@from='biboumi.localhost']/body[re:test(text(), '%s')]" + else: + xpath = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[text()='%s']" + xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" irc_host = 'irc.localhost' return ( partial(expect_stanza, @@ -493,23 +505,26 @@ def connection_end_sequence(irc_host, jid): xpath_re % r'^User mode for \w+ is \[\+Z?i\]$'), ) -def connection_middle_sequence(irc_host, jid): - xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" +def connection_middle_sequence(irc_host, jid, fixed_irc_server=False): + if fixed_irc_server: + xpath_re = "/message[@to='" + jid + "'][@from='biboumi.localhost']/body[re:test(text(), '%s')]" + else: + xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" irc_host = 'irc.localhost' return ( partial(expect_stanza, xpath_re % (r'^%s: \*\*\* You are exempt from flood limits$' % irc_host)), ) -def connection_sequence(irc_host, jid, expected_irc_presence=False): - return connection_begin_sequence(irc_host, jid, expected_irc_presence) +\ - connection_middle_sequence(irc_host, jid) +\ - connection_end_sequence(irc_host, jid) +def connection_sequence(irc_host, jid, expected_irc_presence=False, fixed_irc_server=False): + return connection_begin_sequence(irc_host, jid, expected_irc_presence, fixed_irc_server=fixed_irc_server) +\ + connection_middle_sequence(irc_host, jid, fixed_irc_server=fixed_irc_server) +\ + connection_end_sequence(irc_host, jid, fixed_irc_server=fixed_irc_server) -def connection_tls_sequence(irc_host, jid): - return connection_tls_begin_sequence(irc_host, jid) + \ - connection_middle_sequence(irc_host, jid) +\ - connection_end_sequence(irc_host, jid) +def connection_tls_sequence(irc_host, jid, fixed_irc_server=False): + return connection_tls_begin_sequence(irc_host, jid, fixed_irc_server) + \ + connection_middle_sequence(irc_host, jid, fixed_irc_server) +\ + connection_end_sequence(irc_host, jid, fixed_irc_server) def extract_attribute(xpath, name, stanza): @@ -824,7 +839,7 @@ if __name__ == '__main__': handshake_sequence(), partial(send_stanza, ""), - connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', fixed_irc_server=True), partial(expect_stanza, "/message/body[text()='Mode #zgeg [+nt] by {irc_host_one}']"), partial(expect_stanza, @@ -1437,7 +1452,7 @@ if __name__ == '__main__': handshake_sequence(), partial(send_stanza, ""), - connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', fixed_irc_server=True), partial(expect_stanza, "/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"), partial(expect_stanza, @@ -1933,7 +1948,7 @@ if __name__ == '__main__': partial(send_stanza, ""), - connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', fixed_irc_server=True), partial(expect_stanza, "/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"), partial(expect_stanza, @@ -2011,7 +2026,7 @@ if __name__ == '__main__': # First user join partial(send_stanza, ""), - connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', fixed_irc_server=True), partial(expect_stanza, "/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"), partial(expect_stanza, @@ -2402,6 +2417,18 @@ if __name__ == '__main__': partial(send_stanza, "WHOIS {nick_one}"), partial(expect_stanza, "/message[@from='{irc_server_one}'][@type='chat']/body[text()='irc.localhost: {nick_one} ~{nick_one} localhost * {nick_one}']"), ]), + Scenario("raw_message_fixed_irc_server", + [ + handshake_sequence(), + partial(send_stanza, ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', fixed_irc_server=True), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence"), + partial(expect_stanza, "/message"), + + partial(send_stanza, "WHOIS {nick_one}"), + partial(expect_stanza, "/message[@from='{biboumi_host}'][@type='chat']/body[text()='irc.localhost: {nick_one} ~{nick_one} localhost * {nick_one}']"), + ], conf='fixed_server'), Scenario("self_disco_info", [ handshake_sequence(), @@ -2752,7 +2779,7 @@ if __name__ == '__main__': partial(send_stanza, ""), - connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', fixed_irc_server=True), partial(expect_stanza, "/message"), partial(expect_stanza, "/presence"), partial(expect_stanza, "/message"), @@ -2827,7 +2854,7 @@ if __name__ == '__main__': ""), # We must receive the IRC server presence, in the connection sequence - connection_sequence("irc.localhost", '{jid_one}/{resource_one}', True), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', expected_irc_presence=True), partial(expect_stanza, "/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"), partial(expect_stanza, -- cgit v1.2.3 From fcaffb9e778ad5962e69dc23c1fc91eb59a27945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 27 Aug 2017 22:30:44 +0200 Subject: Add support for the "history" node on MUC join Supports the "seconds", "maxstanzas", "since" and "maxchars" (but only =0) attributes. fix #3270 --- tests/end_to_end/__main__.py | 118 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index f590c1c..859904f 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1942,6 +1942,124 @@ if __name__ == '__main__': partial(expect_stanza, "/iq[@type='result'][@id='id8'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), ]), + + + Scenario("join_history_limits", + [ + 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%{irc_server_one}/{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%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), + + # Send two channel messages + partial(send_stanza, "coucou"), + partial(expect_stanza, + ("/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou']", + "/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]",) + ), + + partial(send_stanza, "coucou 2"), + # Record the current time + partial(expect_stanza, "/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou 2']", + after = partial(save_current_timestamp_plus_delta, "first_timestamp", datetime.timedelta(seconds=1))), + + # Wait two seconds before sending two new messages + partial(sleep_for, 2), + partial(send_stanza, "coucou 3"), + partial(send_stanza, "coucou 4"), + partial(expect_stanza, "/message[@type='groupchat']/body[text()='coucou 3']"), + partial(expect_stanza, "/message[@type='groupchat']/body[text()='coucou 4']", + after = partial(save_current_timestamp_plus_delta, "second_timestamp", datetime.timedelta(seconds=1))), + + # join the virtual channel, to stay connected to the server even after leaving #foo + partial(send_stanza, + ""), + partial(expect_stanza, "/presence/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, "/message/subject"), + + # Leave #foo + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable']"), + + # Rejoin #foo, with some history limit + partial(send_stanza, + ""), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, "/message/subject"), + + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable']"), + + # Rejoin #foo, with some history limit + partial(send_stanza, + ""), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 2']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 3']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 4']"), + partial(expect_stanza, "/message/subject"), + + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable']"), + + + # Rejoin #foo, with some history limit + partial(send_stanza, + ""), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 3']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 4']"), + partial(expect_stanza, "/message/subject"), + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable']"), + + # Rejoin #foo, with some history limit + partial(send_stanza, + ""), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 3']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 4']"), + partial(expect_stanza, "/message/subject"), + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable']"), + + # Rejoin #foo, with some history limit + partial(send_stanza, + ""), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou']"), partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 2']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 3']"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='coucou 4']"), + partial(expect_stanza, "/message/subject"), + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable']"), + + ]), + + Scenario("mam_on_fixed_server", [ handshake_sequence(), -- cgit v1.2.3 From dabc48b79b6189c99c246ae01af27fa170fd86a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 30 Aug 2017 16:14:35 +0200 Subject: Mark messages from the IRC server as private and no-copy fix #3284 --- tests/end_to_end/__main__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 859904f..93474ac 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -413,7 +413,11 @@ def connection_begin_sequence(irc_host, jid, expected_irc_presence=False, fixed_ xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" result = ( partial(expect_stanza, - xpath % ('Connecting to %s:6697 (encrypted)' % irc_host)), + (xpath % ('Connecting to %s:6697 (encrypted)' % irc_host), + "/message/hints:no-copy", + "/message/carbon:private" + ) + ), partial(expect_stanza, xpath % 'Connection failed: Connection refused'), partial(expect_stanza, @@ -455,7 +459,11 @@ def connection_tls_begin_sequence(irc_host, jid, fixed_irc_server): irc_host = 'irc.localhost' return ( partial(expect_stanza, - xpath % ('Connecting to %s:7778 (encrypted)' % irc_host)), + (xpath % ('Connecting to %s:7778 (encrypted)' % irc_host), + "/message/hints:no-copy", + "/message/carbon:private", + ) + ), partial(expect_stanza, xpath % 'Connected to IRC server (encrypted).'), # These five messages can be receive in any order -- cgit v1.2.3 From bfcf29451787d10c747ad79cb3fd177ac86e9cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 9 Sep 2017 17:09:17 +0200 Subject: Add the persistent_by_default configuration option fix #3293 --- tests/end_to_end/__main__.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 93474ac..dfb6ef7 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -377,7 +377,15 @@ port=8811 fixed_irc_server=irc.localhost admin=admin@example.com identd_port=1113 -"""} +""", + +'persistent_by_default': +"""hostname=biboumi.localhost +password=coucou +db_name=e2e_test.sqlite +port=8811 +persistent_by_default=true +""",} common_replacements = { 'irc_server_one': 'irc.localhost@biboumi.localhost', @@ -2650,6 +2658,7 @@ if __name__ == '__main__': "/iq/commands:command/dataform:x[@type='form']/dataform:instructions[text()='Edit the form, to configure your global settings for the component.']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='max_history_length']/dataform:value[text()='20']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='record_history']/dataform:value[text()='true']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='persistent']/dataform:value[text()='false']", "/iq/commands:command/commands:actions/commands:next", ), after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) @@ -2671,6 +2680,20 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), ]), + Scenario("global_configure_persistent_by_default", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='configure'][@sessionid][@status='executing']", + "/iq/commands:command/dataform:x[@type='form']/dataform:title[text()='Configure some global default settings.']", + "/iq/commands:command/dataform:x[@type='form']/dataform:instructions[text()='Edit the form, to configure your global settings for the component.']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='max_history_length']/dataform:value[text()='20']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='record_history']/dataform:value[text()='true']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='persistent']/dataform:value[text()='true']", + "/iq/commands:command/commands:actions/commands:next", + ), + ), + ],conf='persistent_by_default'), Scenario("irc_server_configure", [ handshake_sequence(), -- cgit v1.2.3 From cb6b50dc0109ee3a201a4012b63f3914cc5ea6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 7 Nov 2017 23:05:05 +0100 Subject: Change how we count the number of connected resources to a server --- tests/end_to_end/__main__.py | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index dfb6ef7..d10820d 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -623,8 +623,6 @@ if __name__ == '__main__': partial(send_stanza, "QUIT bye bye"), partial(expect_stanza, ("/presence[@from='#foo%{irc_server_one}/{nick_one}'][@type='unavailable']/muc_user:x/muc_user:status[@code='110']", "/presence[@from='#foo%{irc_server_one}/{nick_one}'][@type='unavailable']/muc_user:x/muc_user:status[@code='110']",)), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), ]), Scenario("multiple_channels_join", [ @@ -678,8 +676,6 @@ if __name__ == '__main__': connection_end_sequence("irc.localhost", '{jid_one}/{resource_one}'), partial(send_stanza, ""), partial(expect_stanza, "/presence[@type='unavailable'][@from='%{irc_server_one}/{nick_one}']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), ]), Scenario("not_connected_error", [ @@ -724,8 +720,6 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/presence[@type='unavailable'][@from='%{irc_server_one}/{nick_two}']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), ]), Scenario("channel_join_with_two_users", [ @@ -1030,7 +1024,6 @@ if __name__ == '__main__': partial(send_stanza, "localhostDisconnected by e2e"), partial(expect_unordered, [("/presence[@type='unavailable'][@to='{jid_one}/{resource_one}'][@from='#bon%{irc_server_two}/{nick_three}']",), ("/iq[@type='result']/commands:command[@node='disconnect-from-irc-server'][@status='completed']/commands:note[@type='info'][text()='{jid_one} was disconnected from 1 IRC server.']",), - ("/message[@to='{jid_one}/{resource_one}']/body[text()='ERROR: Disconnected by e2e']",), ]), @@ -1048,7 +1041,6 @@ if __name__ == '__main__': partial(send_stanza, "irc.localhostDisconnected by e2e"), partial(expect_unordered, [("/presence[@type='unavailable'][@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']",), ("/iq[@type='result']/commands:command[@node='disconnect-from-irc-server'][@status='completed']/commands:note[@type='info'][text()='{jid_one}/{resource_one} was disconnected from 1 IRC server.']",), - ("/message[@to='{jid_one}/{resource_one}']/body[text()='ERROR: Disconnected by e2e']",), ]), ]), Scenario("multisessionnick", @@ -1203,8 +1195,6 @@ if __name__ == '__main__': # Second user leaves the channel partial(send_stanza, ""), partial(expect_stanza, "/presence[@type='unavailable'][@from='#foo%{irc_server_one}/{nick_two}']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), ]), Scenario("channel_join_with_different_nick", [ @@ -2646,8 +2636,6 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/presence[@type='unavailable'][@from='%{irc_server_one}/{nick_two}']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), ]), Scenario("global_configure", [ @@ -3015,8 +3003,6 @@ if __name__ == '__main__': # Leave the channel, and thus the IRC server partial(send_stanza, ""), partial(expect_stanza, "/presence[@type='unavailable'][@from='#foo%{irc_server_one}/{nick_one}']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), - partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), partial(expect_stanza, "/presence[@from='{irc_server_one}'][@to='{jid_one}'][@type='unavailable']"), ]) ) -- cgit v1.2.3 From b82d662082f95e5cab8b486fe26b2e263d4a66cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 7 Nov 2017 23:16:42 +0100 Subject: Add an e2e test to demonstrate #3304 --- tests/end_to_end/__main__.py | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index d10820d..e024fc5 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2975,6 +2975,60 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(send_stanza, ""), ]), + Scenario("resource_is_removed_from_server_when_last_chan_is_left", + [ + # Join the channel + 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%{irc_server_one}/{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%{irc_server_one}'][@type='groupchat'][@to='{jid_one}/{resource_one}']/subject[not(text())]"), + + # Make it persistent + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']/muc_owner:query/dataform:x/dataform:field[@var='persistent'][@type='boolean']/dataform:value[text()='false']"), + partial(send_stanza, "true"), + partial(expect_stanza, "/iq[@type='result']"), + + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable'][@from='#foo%{irc_server_one}/{nick_one}']"), + + # Join the same channel, with the same JID, but a different resource + partial(send_stanza, + ""), + partial(expect_stanza, + ("/presence[@to='{jid_one}/{resource_two}'][@from='#foo%{irc_server_one}/{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%{irc_server_one}'][@type='groupchat'][@to='{jid_one}/{resource_two}']/subject[not(text())]"), + + # Join some other channel with someone else + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_two}/{resource_one}'), + partial(expect_stanza, + "/message/body[text()='Mode #bar [+nt] by {irc_host_one}']"), + partial(expect_stanza, + ("/presence[@to='{jid_two}/{resource_one}'][@from='#bar%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']", + "/presence/muc_user:x/muc_user:status[@code='110']") + ), + partial(expect_stanza, "/message[@from='#bar%{irc_server_one}'][@type='groupchat'][@to='{jid_two}/{resource_one}']/subject[not(text())]"), + + # Send two messages from the second user to the first one + partial(send_stanza, "kikoo"), + partial(send_stanza, "second kikoo"), + + # We must receive each message only once, no duplicate + partial(expect_stanza, "/message/body[text()='kikoo']"), + partial(expect_stanza, "/message/body[text()='second kikoo']"), + ] + ), Scenario("irc_server_presence_in_roster", [ handshake_sequence(), -- cgit v1.2.3 From 37340e593ffb61eaccc444a1efdb3aa6f784a14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 26 Dec 2017 19:52:41 +0100 Subject: Add a node on outgoing private MUC messages See https://xmpp.org/extensions/xep-0045.html#privatemessage fix #3321 --- tests/end_to_end/__main__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index e024fc5..2becdef 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1088,7 +1088,8 @@ if __name__ == '__main__': # Message is received with a server-wide JID, by the two resources behind nick_one partial(expect_stanza, ("/message[@from='{lower_nick_two}%{irc_server_one}'][@to='{jid_one}/{resource_one}'][@type='chat']/body[text()='RELLO']", "/message/hints:no-copy", - "/message/carbon:private")), + "/message/carbon:private", + "!/message/muc_user:x")), partial(expect_stanza, "/message[@from='{lower_nick_two}%{irc_server_one}'][@to='{jid_one}/{resource_two}'][@type='chat']/body[text()='RELLO']"), @@ -1280,7 +1281,8 @@ if __name__ == '__main__': # Respond to the message, to the server-wide JID partial(send_stanza, "yes"), # The response is received from the in-room JID - partial(expect_stanza, "/message[@from='#foo%{irc_server_one}/{nick_two}'][@to='{jid_one}/{resource_one}'][@type='chat']/body[text()='yes']"), + partial(expect_stanza, ("/message[@from='#foo%{irc_server_one}/{nick_two}'][@to='{jid_one}/{resource_one}'][@type='chat']/body[text()='yes']", + "/message/muc_user:x")), ## Do the exact same thing, from a different chan, # to check if the response comes from the right JID -- cgit v1.2.3 From 131ef9946fff0f5cfd794203e819df931b72600f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 26 Dec 2017 20:21:18 +0100 Subject: Include the nodes in the MAM iq result fix #3322 --- tests/end_to_end/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 2becdef..271f87b 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -130,6 +130,7 @@ def match(stanza, xpath): 'dataform': 'jabber:x:data', 'version': 'jabber:iq:version', 'mam': 'urn:xmpp:mam:2', + 'rms': 'http://jabber.org/protocol/rsm', 'delay': 'urn:xmpp:delay', 'forward': 'urn:xmpp:forward:0', 'client': 'jabber:client', @@ -1852,7 +1853,9 @@ if __name__ == '__main__': ), partial(expect_stanza, - "/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + ("/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']", + "/iq/mam:fin/rms:set/rsm:last", + "/iq/mam:fin/rsm:set/rsm:first")), # Retrieve an empty archive by specifying an early “end” date partial(send_stanza, """ -- cgit v1.2.3 From 2d9f516d1d36bbdd4b114dd3652bbeaebd2fa379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 27 Dec 2017 19:23:28 +0100 Subject: =?UTF-8?q?Don=E2=80=99t=20answer=20to=20some=20requests=20towards?= =?UTF-8?q?=20MUC=20participants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These requests are only meant to be received by the room itself. The participant must answer with not-implemented instead. fix #3323 --- tests/end_to_end/__main__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 271f87b..649e073 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -909,7 +909,13 @@ if __name__ == '__main__': partial(expect_stanza, ("/iq[@type='result']/disco_items:query[@node='http://jabber.org/protocol/commands']", "/iq/disco_items:query/disco_items:item[6]")), ], conf='fixed_server'), - + Scenario("list_muc_user_adhoc", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='error']/error[@type='cancel']/stanza:feature-not-implemented"), + ] + ), Scenario("execute_hello_adhoc_command", [ handshake_sequence(), -- cgit v1.2.3 From f371d9ca46578a722d2ce0d4a88ea35f64dd1d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 18 Jan 2018 19:34:56 +0100 Subject: xep-0106 escape the JIDs listed in a disco#items server query fix #3325 --- tests/end_to_end/__main__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 649e073..e223ead 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2254,6 +2254,21 @@ if __name__ == '__main__': "/iq/disco_items:query/disco_items:item[@jid='#bar%{irc_server_one}']" )) ]), + Scenario("channel_list_escaping", + [ + handshake_sequence(), + + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, + "/message/body[text()='Mode #true/false [+nt] by {irc_host_one}']"), + partial(expect_stanza, + ("/presence[@to='{jid_one}/{resource_one}'][@from='#true\\2ffalse%{irc_server_one}/{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='#true\\2ffalse%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), + ]), Scenario("channel_list_with_rsm", [ handshake_sequence(), -- cgit v1.2.3 From cb831788942b49a28bd79fd62dbdc3d00f15b227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 30 Jan 2018 09:07:21 +0100 Subject: Add the complete='true' attribute only when appropriate --- tests/end_to_end/__main__.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'tests/end_to_end') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index e223ead..c4c149a 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1861,7 +1861,8 @@ if __name__ == '__main__': partial(expect_stanza, ("/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']", "/iq/mam:fin/rms:set/rsm:last", - "/iq/mam:fin/rsm:set/rsm:first")), + "/iq/mam:fin/rsm:set/rsm:first", + "/iq/mam:fin[@complete='true']")), # Retrieve an empty archive by specifying an early “end” date partial(send_stanza, """ @@ -1873,7 +1874,8 @@ if __name__ == '__main__': """), partial(expect_stanza, - "/iq[@type='result'][@id='id2'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + ("/iq[@type='result'][@id='id2'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']", + "/iq/mam:fin[@complete='true']/rsm:set",)), # Retrieve an empty archive by specifying a late “start” date # (note that this test will break in ~1000 years) @@ -1886,7 +1888,8 @@ if __name__ == '__main__': """), partial(expect_stanza, - "/iq[@type='result'][@id='id3'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + ("/iq[@type='result'][@id='id3'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']", + "/iq/mam:fin[@complete='true']/rsm:set")), # Retrieve a limited archive partial(send_stanza, "1"), @@ -1897,7 +1900,8 @@ if __name__ == '__main__': ), partial(expect_stanza, - "/iq[@type='result'][@id='id4'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + ("/iq[@type='result'][@id='id4'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']", + "/iq/mam:fin[@complete='true']/rsm:set")), ]), Scenario("mam_with_timestamps", @@ -1957,7 +1961,8 @@ if __name__ == '__main__': ), partial(expect_stanza, - "/iq[@type='result'][@id='id8'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + ("/iq[@type='result'][@id='id8'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']", + "/iq/mam:fin[@complete='true']/rsm:set")), ]), @@ -2151,8 +2156,11 @@ if __name__ == '__main__': ("/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay", "/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='149']") ), + # And it should not be marked as complete partial(expect_stanza, - "/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + ("/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']", + "!/iq//mam:fin[@complete='true']", + "/iq//mam:fin")), ]), Scenario("channel_history_on_fixed_server", -- cgit v1.2.3