From 89868e4cda7100840f967860cdebe4fe8024a427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 16 Nov 2016 20:03:23 +0100 Subject: e2e tests that the IRC server received an ident response --- tests/end_to_end/__main__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 7658d92..442e305 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -345,7 +345,8 @@ confs = { password=coucou db_name=e2e_test.sqlite port=8811 -admin=admin@example.com""", +admin=admin@example.com +identd_port=1113""", 'fixed_server': """hostname=biboumi.localhost @@ -354,6 +355,7 @@ db_name=e2e_test.sqlite port=8811 fixed_irc_server=irc.localhost admin=admin@example.com +identd_port=1113 """} common_replacements = { @@ -402,11 +404,11 @@ def connection_begin_sequence(irc_host, jid): xpath_re % (r'^%s: \*\*\* (Checking Ident|Looking up your hostname...)$' % irc_host)), # These three messages can be received in any order partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* No Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* No Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* No Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), ) -- cgit v1.2.3 From c454a80ed01807d3d1d4fded5a7f7b5d071627ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 8 Dec 2016 00:21:04 +0100 Subject: e2e: Accept even more unordered things in the connection sequence --- tests/end_to_end/__main__.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 442e305..fe68e40 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -397,18 +397,17 @@ def connection_begin_sequence(irc_host, jid): xpath % ('Connecting to %s:6667 (not encrypted)' % irc_host)), partial(expect_stanza, xpath % 'Connected to IRC server.'), - # These two messages can be receive in any order + # These five messages can be receive in any order partial(expect_stanza, - xpath_re % (r'^%s: \*\*\* (Checking Ident|Looking up your hostname...)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), partial(expect_stanza, - xpath_re % (r'^%s: \*\*\* (Checking Ident|Looking up your hostname...)$' % irc_host)), - # These three messages can be received in any order + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), ) -- cgit v1.2.3 From 0a45b096653f7c9fd0275f2755989a869ab35c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 9 Dec 2016 00:50:16 +0100 Subject: e2e: remove the log_message step, because it causes race conditions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After printing the message, it calls “call_soon(run_scenario)”, and sometimes, if a stanza handler has already been queued, then that handler will be called BEFORE the “run_scenario” function could be run, and so no stanza_checker had the possibility to be set. --- tests/end_to_end/__main__.py | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index fe68e40..ddce3f0 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -275,10 +275,6 @@ def expect_unordered(list_of_xpaths, xmpp, biboumi): def expect_unordered_already_formatted(formatted_list_of_xpaths, xmpp, biboumi): xmpp.stanza_checker = partial(check_list_of_xpath, formatted_list_of_xpaths, xmpp) -def log_message(message, xmpp, biboumi): - print("%s" % (message,)) - asyncio.get_event_loop().call_soon(xmpp.run_scenario) - class BiboumiTest: """ @@ -535,8 +531,6 @@ if __name__ == '__main__': [ handshake_sequence(), # First user joins - partial(log_message, - "First user joins"), partial(send_stanza, ""), connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), @@ -549,8 +543,6 @@ if __name__ == '__main__': partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), # Second user joins - partial(log_message, - "Second user joins"), partial(send_stanza, ""), connection_sequence("irc.localhost", '{jid_two}/{resource_one}'), @@ -693,7 +685,6 @@ if __name__ == '__main__': [ handshake_sequence(), - partial(log_message, "Join a channel"), partial(send_stanza, ""), connection_sequence("irc.localhost", '{jid_admin}/{resource_one}'), partial(expect_stanza, "/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"), @@ -760,7 +751,6 @@ if __name__ == '__main__': partial(expect_stanza, "/message[@from='{lower_nick_two}%{irc_server_one}'][@to='{jid_one}/{resource_two}'][@type='chat']/body[text()='RELLO']"), - partial(log_message, "Nickname conflict"), # First occupant (with the two resources) changes her/his nick partial(send_stanza, ""), partial(expect_unordered, [ @@ -770,7 +760,6 @@ if __name__ == '__main__': ("/presence[@to='{jid_one}/{resource_two}'][@from='#foo%{irc_server_one}/{nick_two}'][@type='error']",), ]), - # partial(log_message, "Nickname change"), # First occupant (with the two resources) changes her/his nick partial(send_stanza, ""), partial(expect_unordered, [ @@ -984,10 +973,8 @@ if __name__ == '__main__': ]), # Moderator kicks participant - partial(log_message, "Moderator kicks participant"), partial(send_stanza, "reported"), - partial(log_message, "Presence is sent to everyone"), partial(expect_unordered, [ ("/presence[@type='unavailable'][@to='{jid_two}/{resource_one}']/muc_user:x/muc_user:item[@role='none']/muc_user:actor[@nick='{nick_one}']", "/presence/muc_user:x/muc_user:item/muc_user:reason[text()='reported']", @@ -1034,10 +1021,8 @@ if __name__ == '__main__': partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat'][@to='{jid_two}/{resource_two}']/subject[not(text())]"), # Moderator kicks participant - partial(log_message, "Moderator kicks participant"), partial(send_stanza, "reported"), - partial(log_message, "Unavailable presence is sent to the two resources"), partial(expect_unordered, [ ("/presence[@type='unavailable'][@to='{jid_two}/{resource_one}']/muc_user:x/muc_user:item[@role='none']/muc_user:actor[@nick='{nick_one}']", "/presence/muc_user:x/muc_user:item/muc_user:reason[text()='reported']", @@ -1122,7 +1107,6 @@ if __name__ == '__main__': ]), Scenario("version_on_global_nick", [ - partial(log_message, "Joining the channel"), handshake_sequence(), partial(send_stanza, ""), @@ -1135,15 +1119,12 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), - partial(log_message, "Send a version request to ourself"), partial(send_stanza, ""), - partial(log_message, "Receive our own request"), partial(expect_stanza, "/iq[@from='{lower_nick_one}%{irc_server_one}'][@type='get'][@to='{jid_one}/{resource_one}']", after = partial(save_value, "id", partial(extract_attribute, "/iq", 'id'))), - partial(log_message, "Respond to the request"), partial(send_stanza, "e2e test1.0Fedora"), partial(expect_stanza, @@ -1369,7 +1350,6 @@ if __name__ == '__main__': [ handshake_sequence(), - partial(log_message, "Join first channel #foo"), partial(send_stanza, ""), connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), @@ -1381,7 +1361,6 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), - partial(log_message, "Join second channel #bar"), partial(send_stanza, ""), partial(expect_stanza, @@ -1389,7 +1368,6 @@ if __name__ == '__main__': partial(expect_stanza, "/presence"), partial(expect_stanza, "/message[@from='#bar%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), - partial(log_message, "Request the whole channel list"), partial(send_stanza, ""), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1401,7 +1379,6 @@ if __name__ == '__main__': [ handshake_sequence(), - partial(log_message, "Join first channel #foo"), partial(send_stanza, ""), connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), @@ -1413,7 +1390,6 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), - partial(log_message, "Join second channel #bar"), partial(send_stanza, ""), partial(expect_stanza, @@ -1421,7 +1397,6 @@ if __name__ == '__main__': partial(expect_stanza, "/presence"), partial(expect_stanza, "/message[@from='#bar%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), - partial(log_message, "Join third channel #coucou"), partial(send_stanza, ""), partial(expect_stanza, @@ -1429,13 +1404,11 @@ if __name__ == '__main__': partial(expect_stanza, "/presence"), partial(expect_stanza, "/message[@from='#coucou%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), - partial(log_message, "Request with max=0"), partial(send_stanza, "0"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", )), - partial(log_message, "Request with max=2"), partial(send_stanza, "2"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1446,7 +1419,6 @@ if __name__ == '__main__': "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" )), - partial(log_message, "Request with max=12"), partial(send_stanza, "12"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1458,7 +1430,6 @@ if __name__ == '__main__': "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" )), - partial(log_message, "Request with max=1 after=#bar"), partial(send_stanza, "#bar%{irc_server_one}1"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1468,7 +1439,6 @@ if __name__ == '__main__': "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" )), - partial(log_message, "Request with max=1 after=#bar"), partial(send_stanza, "#bar%{irc_server_one}1"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1482,7 +1452,6 @@ if __name__ == '__main__': [ handshake_sequence(), - partial(log_message, "Join 10 channels"), partial(send_stanza, ""), connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), @@ -1544,7 +1513,6 @@ if __name__ == '__main__': partial(expect_stanza, "/presence"), partial(expect_stanza, "/message"), - partial(log_message, "Request the first page, with a limit of 3"), partial(send_stanza, "3"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1555,7 +1523,6 @@ if __name__ == '__main__': "/iq/disco_items:query/rsm:set/rsm:last[text()='#ccc%{irc_server_one}']" )), - partial(log_message, "Request subsequent pages"), partial(send_stanza, "#ccc%{irc_server_one}3"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1585,7 +1552,6 @@ if __name__ == '__main__': "/iq/disco_items:query/rsm:set/rsm:count[text()='10']" )), - partial(log_message, "Leaving the 10 channels"), partial(send_stanza, ""), partial(send_stanza, ""), partial(send_stanza, ""), @@ -1681,7 +1647,6 @@ if __name__ == '__main__': partial(expect_stanza, "/message[@to='{jid_one}/{resource_two}'][@from='%{irc_server_one}'][@type='groupchat']/subject[re:test(text(), '^This is a virtual channel.*$')]"), - partial(log_message, "Nick change"), partial(send_stanza, ""), partial(expect_unordered, [ @@ -1699,13 +1664,11 @@ if __name__ == '__main__': ]), - partial(log_message, "First resource leaves."), partial(send_stanza, ""), partial(expect_stanza, ("/presence[@type='unavailable'][@from='%{irc_server_one}/{nick_two}'][@to='{jid_one}/{resource_one}']/muc_user:x/muc_user:status[@code='110']", "/presence/status[text()='Biboumi note: 1 resources are still in this channel.']",) ), - partial(log_message, "Second resource leaves."), 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)']"), @@ -1804,11 +1767,9 @@ if __name__ == '__main__': [ handshake_sequence(), - partial(log_message, "Not connected yet"), partial(send_stanza, ""), partial(expect_stanza, "/iq/commands:command/commands:note[text()='You are not connected to the IRC server irc.localhost']"), - partial(log_message, "Join one room"), partial(send_stanza, ""), connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), @@ -1823,11 +1784,9 @@ if __name__ == '__main__': [ handshake_sequence(), - partial(log_message, "Not connected yet"), partial(send_stanza, ""), partial(expect_stanza, "/iq/commands:command/commands:note[text()='You are not connected to the IRC server irc.localhost']"), - partial(log_message, "Join one room"), partial(send_stanza, ""), connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), -- cgit v1.2.3 From eca31ce8db104f17ac74fd74aa9d7ef7e8f1470a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 11 Dec 2016 17:05:52 +0100 Subject: Do not change the nick when joining a second room with a different nick As the doc says, the nick changes must be explicit in an already joined room, and not when joining a room. --- tests/end_to_end/__main__.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index ddce3f0..b265200 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -798,6 +798,33 @@ if __name__ == '__main__': ("/message[@from='{lower_nick_two}%{irc_server_one}'][@to='{jid_one}/{resource_one}'][@type='chat']/body[text()='second']",), ]), ]), + Scenario("channel_join_with_different_nick", + [ + 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())]"), + + # The same resource joins a different channel with a different nick + partial(send_stanza, + ""), + + # We must receive a join presence in response, without any nick change (nick_two) must be ignored + partial(expect_stanza, + "/message/body[text()='Mode #bar [+nt] by {irc_host_one}']"), + partial(expect_stanza, + ("/presence[@to='{jid_one}/{resource_one}'][@from='#bar%{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='#bar%{irc_server_one}'][@type='groupchat'][@to='{jid_one}/{resource_one}']/subject[not(text())]"), + ]), Scenario("channel_messages", [ handshake_sequence(), -- cgit v1.2.3 From c65ae4754921fe1f9888afc30d26ed11d5275258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 12 Dec 2016 00:36:59 +0100 Subject: Auto accept presence subscription --- tests/end_to_end/__main__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index b265200..dcdd560 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1840,6 +1840,19 @@ if __name__ == '__main__': "/presence/muc:x", "/presence/error/stanza:text")), ], conf='fixed_server'), + Scenario("irc_server_presence_subscription", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@to='{jid_one}'][@from='{irc_server_one}'][@type='subscribed']") + ]), + Scenario("fixed_irc_server_presence_subscription", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@to='{jid_one}'][@from='{biboumi_host}'][@type='subscribed']") + ], conf='fixed_server') + ) -- cgit v1.2.3 From 4792c70635cd73d581861a6da9794655a5e72099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 13 Dec 2016 14:48:41 +0100 Subject: Send a presence error from the room, when receiving command ERR_BADCHANNELKEY fix #2886 --- tests/end_to_end/__main__.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index dcdd560..fc55eaf 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -554,6 +554,48 @@ if __name__ == '__main__': ("/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]",), ]), ]), + Scenario("channel_join_with_password", + [ + handshake_sequence(), + # First user joins + 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'][@jid='~nick@localhost'][@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())]"), + + # Set a password in the room, by using /mode +k + partial(send_stanza, "/mode +k SECRET"), + partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='Mode #foo [+k SECRET] by {nick_one}']"), + + # Second user tries to join, without a password + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_two}/{resource_one}'), + + partial(expect_stanza, "/message/body[text()='{irc_host_one}: #foo: Cannot join channel (+k) - bad key']"), + partial(expect_stanza, + "/presence[@type='error'][@from='#foo%{irc_server_one}/{nick_two}']/error[@type='auth']/stanza:not-authorized", + ), + + # Second user joins, with a password + partial(send_stanza, + " SECRET"), + # connection_sequence("irc.localhost", '{jid_two}/{resource_one}'), + partial(expect_unordered, [ + ("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='none'][@role='participant'][@jid='~bobby@localhost']",), + ("/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",), + ("/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='none'][@jid='~bobby@localhost'][@role='participant']", + "/presence/muc_user:x/muc_user:status[@code='110']",), + ("/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]",), + ]), + + ]), Scenario("channel_custom_topic", [ handshake_sequence(), -- cgit v1.2.3 From f512c9c666b2c629e8b9af29ec65c534e536e749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 14 Dec 2016 18:20:57 +0100 Subject: e2e: test connection failure --- tests/end_to_end/__main__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index fc55eaf..4dc61ba 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -468,6 +468,20 @@ if __name__ == '__main__': ""), connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), ]), + Scenario("irc_server_connection_failure", + [ + handshake_sequence(), + partial(send_stanza, + ""), + partial(expect_stanza, + "/message/body[text()='Connecting to doesnotexist:6697 (encrypted)']"), + partial(expect_stanza, + "/message/body[text()='Connection failed: Domain name not found']"), + partial(expect_stanza, + ("/presence[@from='#foo%doesnotexist@{biboumi_host}/{nick_one}']/muc:x", + "/presence/error[@type='cancel']/stanza:item-not-found", + "/presence/error[@type='cancel']/stanza:text[text()='Domain name not found']")), + ]), Scenario("simple_channel_join", [ handshake_sequence(), -- cgit v1.2.3 From 452bf1756b582e56e263297cbba1615aaf47428a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 14 Dec 2016 19:52:51 +0100 Subject: Test the TLS connection --- tests/end_to_end/__main__.py | 54 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 4dc61ba..5149ea3 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -406,6 +406,27 @@ def connection_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_tls_begin_sequence(irc_host, jid): + jid = jid.format_map(common_replacements) + xpath = "/message[@to='" + jid + "'][@from='irc.localhost@biboumi.localhost']/body[text()='%s']" + xpath_re = "/message[@to='" + jid + "'][@from='irc.localhost@biboumi.localhost']/body[re:test(text(), '%s')]" + return ( + partial(expect_stanza, + xpath % ('Connecting to %s:7778 (encrypted)' % irc_host)), + partial(expect_stanza, + xpath % 'Connected to IRC server (encrypted).'), + # These five messages can be receive in any order + partial(expect_stanza, + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + partial(expect_stanza, + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + partial(expect_stanza, + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + partial(expect_stanza, + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + partial(expect_stanza, + 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): jid = jid.format_map(common_replacements) @@ -433,13 +454,16 @@ def connection_end_sequence(irc_host, jid): partial(expect_stanza, xpath % "- This is charybdis MOTD you might replace it, but if not your friends will\n- laugh at you.\n"), partial(expect_stanza, - xpath_re % r'^User mode for \w+ is \[\+i\]$'), + xpath_re % r'^User mode for \w+ is \[\+Z?i\]$'), ) def connection_sequence(irc_host, jid): return connection_begin_sequence(irc_host, jid) + connection_end_sequence(irc_host, jid) +def connection_tls_sequence(irc_host, jid): + return connection_tls_begin_sequence(irc_host, jid) + connection_end_sequence(irc_host, jid) + def extract_attribute(xpath, name, stanza): matched = match(stanza, xpath) @@ -1846,6 +1870,34 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), ]), + Scenario("irc_tls_connection", + [ + handshake_sequence(), + # First, use an adhoc command to configure how we connect to the irc server, configure + # only one TLS port, and disable the cert verification. + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']", + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid"))), + partial(send_stanza, "" + "" + "" + "" + "7778" + "0" + ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"), + + partial(send_stanza, + ""), + connection_tls_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())]"), + ]), Scenario("get_irc_connection_info", [ handshake_sequence(), -- cgit v1.2.3 From e397fc837e00cff58081810c8b54cb741299d993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 18 Dec 2016 17:21:15 +0100 Subject: Send iq error/result when the user changed a MODE command with an iq And add tests for all the mode changes --- tests/end_to_end/__main__.py | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 5149ea3..29c2804 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1095,6 +1095,82 @@ if __name__ == '__main__': ("/iq[@id='kick1'][@type='result']",), ]), ]), + Scenario("mode_change", + [ + handshake_sequence(), + # First user joins + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + 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, + ""), + connection_sequence("irc.localhost", '{jid_two}/{resource_one}'), + 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",), + ]), + + # Change a user mode with a message starting with /mode + partial(send_stanza, + "/mode +v {nick_two}"), + partial(expect_unordered, [ + ("/message[@to='{jid_one}/{resource_one}']/body[text()='Mode #foo [+v {nick_two}] by {nick_one}']",), + ("/message[@to='{jid_two}/{resource_one}']/body[text()='Mode #foo [+v {nick_two}] by {nick_one}']",), + ("/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='member'][@role='participant']",), + ("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='member'][@role='participant']",) + ]), + + # using an iq + partial(send_stanza, + ""), + partial(expect_unordered, [ + ("/message[@to='{jid_one}/{resource_one}']/body[text()='Mode #foo [+o {nick_two}] by {nick_one}']",), + ("/message[@to='{jid_two}/{resource_one}']/body[text()='Mode #foo [+o {nick_two}] by {nick_one}']",), + ("/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",), + ("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",), + ("/iq[@id='id1'][@type='result'][@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}']",), + ]), + + # remove the mode + partial(send_stanza, + ""), + partial(expect_unordered, [ + ("/message[@to='{jid_one}/{resource_one}']/body[text()='Mode #foo [+v-o {nick_two} {nick_two}] by {nick_one}']",), + ("/message[@to='{jid_two}/{resource_one}']/body[text()='Mode #foo [+v-o {nick_two} {nick_two}] by {nick_one}']",), + ("/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='member'][@role='participant']",), + ("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']/muc_user:x/muc_user:item[@affiliation='member'][@role='participant']",), + ("/iq[@id='id1'][@type='result'][@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}']",), + ]), + + # using an iq, an a non-existant nick + partial(send_stanza, + ""), + partial(expect_stanza, "/iq[@type='error']"), + + # using an iq, without the rights to do it + partial(send_stanza, + ""), + partial(expect_unordered, [ + ("/iq[@type='error']",), + ("/message[@type='chat'][@to='{jid_two}/{resource_one}']",), + ]), + + # using an iq, with an unknown mode + partial(send_stanza, + ""), + partial(expect_unordered, [ + ("/iq[@type='error']",), + ("/message[@type='chat'][@to='{jid_two}/{resource_one}']",), + ]), + + ]), Scenario("multisession_kick", [ handshake_sequence(), -- cgit v1.2.3 From 5d801ddcd025f68d2ec91edf0462091a32c779c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 22 Jan 2017 21:31:50 +0100 Subject: Add a linger_time configuration option on IRC servers --- tests/end_to_end/__main__.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 29c2804..20730a7 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1939,6 +1939,7 @@ if __name__ == '__main__': "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='realname']/dataform:value[text()='realname']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']/dataform:value[text()='latin-1']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']/dataform:value[text()='UTF-8']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='linger_time']/dataform:value[text()='0']", "/iq/commands:command/commands:actions/commands:next", ), after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) -- cgit v1.2.3 From 5ae33d6b9ed47bf43626066c5bdc4d91a7b75db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 12 Feb 2017 16:50:47 +0100 Subject: e2e: add tests for the linger time option --- tests/end_to_end/__main__.py | 54 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 20730a7..92a903c 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import collections +import datetime import slixmpp import asyncio import logging @@ -95,7 +96,11 @@ class XMPPComponent(slixmpp.BaseXMPP): def run_scenario(self): if self.scenario.steps: step = self.scenario.steps.pop(0) - step(self, self.biboumi) + try: + step(self, self.biboumi) + except Exception as e: + self.error(e) + self.run_scenario() else: if self.biboumi: self.biboumi.stop() @@ -261,6 +266,16 @@ def expect_stanza(xpaths, xmpp, biboumi, optional=False, after=None): else: print("Warning, from argument type passed to expect_stanza: %s" % (type(xpaths))) +def save_datetime(xmpp, biboumi): + xmpp.saved_values["saved_datetime"] = datetime.datetime.now() + asyncio.get_event_loop().call_soon(xmpp.run_scenario) + +def expect_now_is_after(timedelta, xmpp, biboumi): + time_passed = datetime.datetime.now() - xmpp.saved_values["saved_datetime"] + if time_passed < timedelta: + raise StanzaError("Not enough time has passed: %s instead of %s" % (time_passed, timedelta)) + asyncio.get_event_loop().call_soon(xmpp.run_scenario) + # list_of_xpaths: [(xpath, xpath), (xpath, xpath), (xpath)] def expect_unordered(list_of_xpaths, xmpp, biboumi): formatted_list_of_xpaths = [] @@ -473,7 +488,6 @@ def extract_attribute(xpath, name, stanza): def save_value(name, func, stanza, xmpp): xmpp.saved_values[name] = func(stanza) - if __name__ == '__main__': atexit.register(asyncio.get_event_loop().close) @@ -1947,6 +1961,42 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), ]), + Scenario("irc_server_linger_time", + [ + handshake_sequence(), + # Set a custom value for the linger_time option, using the ad-hoc command + 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 the IRC server irc.localhost']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) + ), + partial(send_stanza, "" + "" + "" + "3" + ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"), + + 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())]"), + + partial(save_datetime), + 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_now_is_after, datetime.timedelta(seconds=3)), + ]), Scenario("irc_tls_connection", [ handshake_sequence(), -- cgit v1.2.3 From fa6635e5487c3efe536c36a27be0ee10b918a346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 13 Feb 2017 10:24:16 +0100 Subject: Add a e2e test for the previous 2 commits ref #3231 --- tests/end_to_end/__main__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 92a903c..945bf6f 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -551,6 +551,22 @@ if __name__ == '__main__': 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", + [ + handshake_sequence(), + partial(send_stanza, + ""), + 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())]"), + ]), Scenario("irc_server_disconnection", [ handshake_sequence(), -- cgit v1.2.3 From dcb48c5a20be1440ad87f1996b3373cb51f0fe07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 28 Feb 2017 18:24:51 +0100 Subject: Add a irc channel ad-hoc configure test --- tests/end_to_end/__main__.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 945bf6f..e26b5db 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1977,6 +1977,37 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), ]), + Scenario("irc_channel_configure", + [ + 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:field[@type='text-single'][@var='encoding_in']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) + ), + partial(send_stanza, "" + "" + "" + "" + "UTF-8" + "latin-1" + ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"), + + 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 the IRC channel #foo on server irc.localhost']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']/dataform:value[text()='latin-1']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']/dataform:value[text()='UTF-8']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) + ), + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), + ]), Scenario("irc_server_linger_time", [ handshake_sequence(), -- cgit v1.2.3 From 9a4b5d96cec0795a3cfdb5af887c273b5538452e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 28 Feb 2017 22:04:20 +0100 Subject: Also test the channel config on a fixed_irc_server instance --- tests/end_to_end/__main__.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index e26b5db..b84c9b1 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2008,6 +2008,37 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), ]), + Scenario("irc_channel_configure_fixed", + [ + 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:field[@type='text-single'][@var='encoding_in']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) + ), + partial(send_stanza, "" + "" + "" + "" + "UTF-8" + "latin-1" + ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"), + + 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 the IRC channel #foo on server irc.localhost']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']/dataform:value[text()='latin-1']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']/dataform:value[text()='UTF-8']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) + ), + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), + ], conf='fixed_server'), Scenario("irc_server_linger_time", [ handshake_sequence(), -- cgit v1.2.3 From c7163791106a01c4dce747096a6c99c3f6ed0cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 28 Feb 2017 23:09:10 +0100 Subject: Add a test for the ad-hoc command disconnect-from-irc-server --- tests/end_to_end/__main__.py | 97 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 84 insertions(+), 13 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index b84c9b1..f176d8b 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -371,7 +371,9 @@ identd_port=1113 common_replacements = { 'irc_server_one': 'irc.localhost@biboumi.localhost', + 'irc_server_two': 'localhost@biboumi.localhost', 'irc_host_one': 'irc.localhost', + 'irc_host_two': 'localhost', 'biboumi_host': 'biboumi.localhost', 'resource_one': 'resource1', 'resource_two': 'resource2', @@ -393,8 +395,8 @@ def handshake_sequence(): def connection_begin_sequence(irc_host, jid): jid = jid.format_map(common_replacements) - xpath = "/message[@to='" + jid + "'][@from='irc.localhost@biboumi.localhost']/body[text()='%s']" - xpath_re = "/message[@to='" + jid + "'][@from='irc.localhost@biboumi.localhost']/body[re:test(text(), '%s')]" + 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')]" return ( partial(expect_stanza, xpath % ('Connecting to %s:6697 (encrypted)' % irc_host)), @@ -410,21 +412,22 @@ def connection_begin_sequence(irc_host, jid): xpath % 'Connected to IRC server.'), # These five messages can be receive in any order partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % 'irc.localhost')), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % 'irc.localhost')), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % 'irc.localhost')), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % 'irc.localhost')), partial(expect_stanza, - xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % 'irc.localhost')), ) def connection_tls_begin_sequence(irc_host, jid): jid = jid.format_map(common_replacements) - xpath = "/message[@to='" + jid + "'][@from='irc.localhost@biboumi.localhost']/body[text()='%s']" - xpath_re = "/message[@to='" + jid + "'][@from='irc.localhost@biboumi.localhost']/body[re:test(text(), '%s')]" + 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, xpath % ('Connecting to %s:7778 (encrypted)' % irc_host)), @@ -445,8 +448,9 @@ def connection_tls_begin_sequence(irc_host, jid): def connection_end_sequence(irc_host, jid): jid = jid.format_map(common_replacements) - xpath = "/message[@to='" + jid + "'][@from='irc.localhost@biboumi.localhost']/body[text()='%s']" - xpath_re = "/message[@to='" + jid + "'][@from='irc.localhost@biboumi.localhost']/body[re:test(text(), '%s')]" + 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, xpath_re % (r'^%s: Your host is .*$' % irc_host)), @@ -744,8 +748,6 @@ 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[5]")), ], conf='fixed_server'), - - Scenario("list_adhoc_irc", [ handshake_sequence(), @@ -812,6 +814,75 @@ if __name__ == '__main__': # Note, charybdis ignores our QUIT message, so we can't test it partial(expect_stanza, "/presence[@type='unavailable'][@to='{jid_admin}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']"), ]), + Scenario("execute_admin_disconnect_from_server_adhoc_command", + [ + handshake_sequence(), + + # Admin connects to first server + partial(send_stanza, ""), + connection_sequence("irc.localhost", '{jid_admin}/{resource_one}'), + partial(expect_stanza, "/message/body[text()='Mode #bar [+nt] by {irc_host_one}']"), + partial(expect_stanza, "/presence"), + partial(expect_stanza, "/message"), + + # Non-Admin connects to first server + 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"), + partial(expect_stanza, "/message"), + + # Non-admin connects to second server + partial(send_stanza, ""), + connection_sequence("localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, "/message/body[text()='Mode #bon [+nt] by {irc_host_one}']"), + partial(expect_stanza, "/presence"), + partial(expect_stanza, "/message"), + + # Execute as admin + partial(send_stanza, ""), + partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='disconnect-from-irc-server'][@sessionid][@status='executing']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='jid'][@type='list-single']/dataform:option[@label='{jid_one}']/dataform:value[text()='{jid_one}']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='jid'][@type='list-single']/dataform:option[@label='{jid_admin}']/dataform:value[text()='{jid_admin}']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq/commands:command[@node='disconnect-from-irc-server']", "sessionid")) + ), + partial(send_stanza, "{jid_one}e2e test one"), + + partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='disconnect-from-irc-server'][@sessionid][@status='executing']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='quit-message'][@type='text-single']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='irc-servers'][@type='list-multi']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='irc-servers']/dataform:option[@label='localhost']/dataform:value[text()='localhost']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='irc-servers']/dataform:option[@label='irc.localhost']/dataform:value[text()='irc.localhost']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq/commands:command[@node='disconnect-from-irc-server']", "sessionid")) + ), + 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']",), + ]), + + + # Execute as non-admin (this skips the first step) + partial(send_stanza, ""), + + partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='disconnect-from-irc-server'][@sessionid][@status='executing']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='quit-message'][@type='text-single']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='irc-servers'][@type='list-multi']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='irc-servers']/dataform:option[@label='irc.localhost']/dataform:value[text()='irc.localhost']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq/commands:command[@node='disconnect-from-irc-server']", "sessionid")) + ), + 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", [ handshake_sequence(), -- cgit v1.2.3 From 58b3345f85e4fff5b133ecfb63456cba9b09604c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 28 Feb 2017 23:35:23 +0100 Subject: e2e: Add an outgoing_bind= conf option --- tests/end_to_end/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index f176d8b..f93025e 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -357,7 +357,8 @@ password=coucou db_name=e2e_test.sqlite port=8811 admin=admin@example.com -identd_port=1113""", +identd_port=1113 +outgoing_bind=127.0.0.1""", 'fixed_server': """hostname=biboumi.localhost -- cgit v1.2.3 From d81c3ad5ac2c12130d90044b7597bf962a7cfe9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 4 Mar 2017 14:00:53 +0100 Subject: Fix the order of from and to address in muc traffic info reply And add a test for it. fix #3238 --- tests/end_to_end/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index f93025e..c298793 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1864,7 +1864,7 @@ if __name__ == '__main__': partial(send_stanza, ""), - partial(expect_stanza, "/iq[@type='result']/disco_info:query[@node='http://jabber.org/protocol/muc#traffic']"), + partial(expect_stanza, "/iq[@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}'][@type='result']/disco_info:query[@node='http://jabber.org/protocol/muc#traffic']"), ]), Scenario("raw_message", [ -- cgit v1.2.3 From f4ffbcabc871e2031d6afb9fa062092302cd16ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 7 Mar 2017 02:48:20 +0100 Subject: e2e: Make the tests work without udns too --- tests/end_to_end/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index c298793..c86ab29 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -519,11 +519,11 @@ if __name__ == '__main__': partial(expect_stanza, "/message/body[text()='Connecting to doesnotexist:6697 (encrypted)']"), partial(expect_stanza, - "/message/body[text()='Connection failed: Domain name not found']"), + "/message/body[re:test(text(), 'Connection failed: (Domain name not found|Name or service not known)')]"), partial(expect_stanza, ("/presence[@from='#foo%doesnotexist@{biboumi_host}/{nick_one}']/muc:x", "/presence/error[@type='cancel']/stanza:item-not-found", - "/presence/error[@type='cancel']/stanza:text[text()='Domain name not found']")), + "/presence/error[@type='cancel']/stanza:text[re:test(text(), '(Domain name not found|Name or service not known)')]")), ]), Scenario("simple_channel_join", [ -- cgit v1.2.3 From 07c8567b9fa4c857b4aa4ba5f0eda2b565fe2a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 28 Mar 2017 10:17:33 +0200 Subject: e2e: Display the correct number of tests that will run --- tests/end_to_end/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index c86ab29..f24df2e 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2257,7 +2257,7 @@ if __name__ == '__main__': if b"now running in foreground mode" in res: break print("irc server started.") - print("Running %s checks for biboumi." % (len(scenarios))) + print("Running %s checks for biboumi." % (len([s for s in scenarios if s.name in scenar_list]))) for s in scenarios: if scenar_list and s.name not in scenar_list: -- cgit v1.2.3 From a3844c1d9ff0e714d07f1a411f3babc31de96e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 29 Mar 2017 23:09:58 +0200 Subject: Change mam namespace to mam:2, instead of mam:1 --- tests/end_to_end/__main__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index f24df2e..042744c 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -125,7 +125,7 @@ def match(stanza, xpath): 'commands': 'http://jabber.org/protocol/commands', 'dataform': 'jabber:x:data', 'version': 'jabber:iq:version', - 'mam': 'urn:xmpp:mam:1', + 'mam': 'urn:xmpp:mam:2', 'delay': 'urn:xmpp:delay', 'forward': 'urn:xmpp:forward:0', 'client': 'jabber:client', @@ -1489,7 +1489,7 @@ if __name__ == '__main__': partial(expect_stanza, "/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou 2']"), # Retrieve the complete archive - partial(send_stanza, ""), + partial(send_stanza, ""), partial(expect_stanza, ("/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay", @@ -1505,9 +1505,9 @@ if __name__ == '__main__': # Retrieve an empty archive by specifying an early “end” date partial(send_stanza, """ - + - urn:xmpp:mam:1 + urn:xmpp:mam:2 2000-06-07T00:00:00Z """), @@ -1518,9 +1518,9 @@ if __name__ == '__main__': # Retrieve an empty archive by specifying a late “start” date # (note that this test will break in ~1000 years) partial(send_stanza, """ - + - urn:xmpp:mam:1 + urn:xmpp:mam:2 3016-06-07T00:00:00Z """), @@ -1550,7 +1550,7 @@ if __name__ == '__main__': partial(expect_stanza, "/message[@from='#foo@{biboumi_host}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou 2']"), # Retrieve the complete archive - partial(send_stanza, ""), + partial(send_stanza, ""), partial(expect_stanza, ("/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay", @@ -1887,7 +1887,7 @@ if __name__ == '__main__': "/iq/disco_info:query/disco_info:feature[@var='jabber:iq:version']", "/iq/disco_info:query/disco_info:feature[@var='http://jabber.org/protocol/commands']", "/iq/disco_info:query/disco_info:feature[@var='urn:xmpp:ping']", - "/iq/disco_info:query/disco_info:feature[@var='urn:xmpp:mam:1']", + "/iq/disco_info:query/disco_info:feature[@var='urn:xmpp:mam:2']", "/iq/disco_info:query/disco_info:feature[@var='jabber:iq:version']", )), ]), -- cgit v1.2.3 From ce2daa5ea093437bf8f14ba92a467d0ae688e6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 29 Mar 2017 23:24:47 +0200 Subject: Respond to disco#info on MUC JIDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise, some client won’t do MAM, since they don’t know biboumi supports it. --- tests/end_to_end/__main__.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 042744c..088be9c 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1866,6 +1866,38 @@ if __name__ == '__main__': ""), partial(expect_stanza, "/iq[@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}'][@type='result']/disco_info:query[@node='http://jabber.org/protocol/muc#traffic']"), ]), + Scenario("muc_disco_info", + [ + handshake_sequence(), + + partial(send_stanza, + ""), + partial(expect_stanza, + ("/iq[@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}'][@type='result']/disco_info:query", + "/iq[@type='result']/disco_info:query/disco_info:identity[@category='conference'][@type='irc'][@name='IRC channel #foo from server {irc_host_one} over biboumi']", + "/iq/disco_info:query/disco_info:feature[@var='jabber:iq:version']", + "/iq/disco_info:query/disco_info:feature[@var='http://jabber.org/protocol/commands']", + "/iq/disco_info:query/disco_info:feature[@var='urn:xmpp:ping']", + "/iq/disco_info:query/disco_info:feature[@var='urn:xmpp:mam:2']", + "/iq/disco_info:query/disco_info:feature[@var='jabber:iq:version']", + )), + ]), + Scenario("fixed_muc_disco_info", + [ + handshake_sequence(), + + partial(send_stanza, + ""), + partial(expect_stanza, + ("/iq[@from='#foo@{biboumi_host}'][@to='{jid_one}/{resource_one}'][@type='result']/disco_info:query", + "/iq[@type='result']/disco_info:query/disco_info:identity[@category='conference'][@type='irc'][@name='IRC channel #foo from server {irc_host_one} over biboumi']", + "/iq/disco_info:query/disco_info:feature[@var='jabber:iq:version']", + "/iq/disco_info:query/disco_info:feature[@var='http://jabber.org/protocol/commands']", + "/iq/disco_info:query/disco_info:feature[@var='urn:xmpp:ping']", + "/iq/disco_info:query/disco_info:feature[@var='urn:xmpp:mam:2']", + "/iq/disco_info:query/disco_info:feature[@var='jabber:iq:version']", + )), + ], conf='fixed_server'), Scenario("raw_message", [ handshake_sequence(), -- cgit v1.2.3 From 7f2127a7ea4c49fc1fbcd6cd6fb13e0265f4d841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 30 Mar 2017 18:16:44 +0200 Subject: Add the archive ID to messages when they are sent to users This makes us compatible with mam 6.0 fix #3249 --- tests/end_to_end/__main__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 088be9c..fd833e2 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -132,7 +132,8 @@ def match(stanza, xpath): 'rsm': 'http://jabber.org/protocol/rsm', 'carbon': 'urn:xmpp:carbons:2', 'hints': 'urn:xmpp:hints', - 'stanza': 'urn:ietf:params:xml:ns:xmpp-stanzas'}) + 'stanza': 'urn:ietf:params:xml:ns:xmpp-stanzas', + 'stable_id': 'urn:xmpp:sid:0'}) return matched @@ -1483,7 +1484,10 @@ if __name__ == '__main__': # 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']"), + 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"), partial(expect_stanza, "/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou 2']"), -- cgit v1.2.3 From e4cc69607c91db43cf154326aaba8afbe97a4c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 4 Apr 2017 18:40:30 +0200 Subject: Handle some iq of type='error' as valid ping response fix #3251 --- tests/end_to_end/__main__.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index fd833e2..09ef501 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1101,6 +1101,44 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#biboumi\\40louiz.org\\3a80%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), ]), + Scenario("self_ping_with_error", + [ + 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 a ping to ourself + partial(send_stanza, + ""), + # We receive our own ping request, + partial(expect_stanza, + "/iq[@from='{lower_nick_one}%{irc_server_one}'][@type='get'][@to='{jid_one}/{resource_one}'][@id='gnip_tsrif']"), + # Respond to the request with an error + partial(send_stanza, + ""), + partial(expect_stanza, + "/iq[@from='#foo%{irc_server_one}/{nick_one}'][@type='result'][@to='{jid_one}/{resource_one}'][@id='first_ping']"), + + # Send a ping to ourself + partial(send_stanza, + ""), + # We receive our own ping request, + partial(expect_stanza, + "/iq[@from='{lower_nick_one}%{irc_server_one}'][@type='get'][@to='{jid_one}/{resource_one}'][@id='gnip_tsrif']"), + # Respond to the request with an error + partial(send_stanza, + ""), + partial(expect_stanza, + "/iq[@from='#foo%{irc_server_one}/{nick_one}'][@type='result'][@to='{jid_one}/{resource_one}'][@id='first_ping']"), + ]), Scenario("self_ping_on_real_channel", [ handshake_sequence(), -- cgit v1.2.3 From 0878a0342c5a2ae6abcfaecc2d9f0c9d3fd0dbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 4 Apr 2017 21:38:53 +0200 Subject: =?UTF-8?q?Do=20not=20allow=20pings=20from=20resources=20that=20ar?= =?UTF-8?q?en=E2=80=99t=20in=20the=20channel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #3252 --- tests/end_to_end/__main__.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 09ef501..2f3a98b 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1139,6 +1139,34 @@ if __name__ == '__main__': partial(expect_stanza, "/iq[@from='#foo%{irc_server_one}/{nick_one}'][@type='result'][@to='{jid_one}/{resource_one}'][@id='first_ping']"), ]), + Scenario("self_ping_not_in_muc", + [ + 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 a ping to ourself, in a muc where we’re not + partial(send_stanza, + ""), + # Immediately receive an error + partial(expect_stanza, + "/iq[@from='#nil%{irc_server_one}/{nick_one}'][@type='error'][@to='{jid_one}/{resource_one}'][@id='first_ping']/error/stanza:not-allowed"), + + # Send a ping to ourself, in a muc where we are, but not this resource + partial(send_stanza, + ""), + # Immediately receive an error + partial(expect_stanza, + "/iq[@from='#foo%{irc_server_one}/{nick_one}'][@type='error'][@to='{jid_one}/{resource_two}'][@id='first_ping']/error/stanza:not-allowed"), + ]), Scenario("self_ping_on_real_channel", [ handshake_sequence(), -- cgit v1.2.3 From b82a14f20effad351cd2b1f344d526202ef11caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 7 Apr 2017 19:01:08 +0200 Subject: Fix the display of the number of checks to be run by the e2e tests --- tests/end_to_end/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 2f3a98b..2d33b92 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2359,7 +2359,8 @@ if __name__ == '__main__': if b"now running in foreground mode" in res: break print("irc server started.") - print("Running %s checks for biboumi." % (len([s for s in scenarios if s.name in scenar_list]))) + checks = len([s for s in scenarios if s.name in scenar_list]) if scenar_list else len(scenarios) + print("Running %s checks for biboumi." % checks) for s in scenarios: if scenar_list and s.name not in scenar_list: -- cgit v1.2.3 From 79b24d7eb5b729c000cce1b56ee1a64d914b9d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 7 Apr 2017 19:55:15 +0200 Subject: Add an e2e test for the ad-hoc ping --- tests/end_to_end/__main__.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 2d33b92..bb5eb1c 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -788,6 +788,12 @@ if __name__ == '__main__': partial(send_stanza, "COUCOU"), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='hello'][@status='completed']/commands:note[@type='info'][text()='Hello COUCOU!']") ]), + Scenario("execute_ping_adhoc_command", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='ping'][@status='completed']/commands:note[@type='info'][text()='Pong']") + ]), Scenario("execute_forbidden_adhoc_command", [ handshake_sequence(), -- cgit v1.2.3 From 68d6b829402592d2d7a00e6e7b5013077aaa745c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 9 Apr 2017 23:03:35 +0200 Subject: Properly handle multiline topics fix #3254 --- tests/end_to_end/__main__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index bb5eb1c..d08d3ae 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -707,6 +707,23 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/subject[text()='TOPIC TEST']"), ]), + Scenario("multiline_topic", + [ + handshake_sequence(), + # User joins + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, + "/message/body"), + partial(expect_stanza, "/presence"), + partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), + + # User tries to set a multiline topic + partial(send_stanza, + "FIRST LINE\nSECOND LINE."), + partial(expect_stanza, "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat'][@to='{jid_one}/{resource_one}']/subject[text()='FIRST LINE SECOND LINE.']"), + ]), Scenario("channel_basic_join_on_fixed_irc_server", [ handshake_sequence(), -- cgit v1.2.3 From dec3e42ae32e61df4de8d58b3cea0f48b4c5d3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 7 Apr 2017 19:57:42 +0200 Subject: Add an e2e test for the ad-hoc reload command --- tests/end_to_end/__main__.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index d08d3ae..e9c9429 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -811,6 +811,12 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='ping'][@status='completed']/commands:note[@type='info'][text()='Pong']") ]), + Scenario("execute_reload_adhoc_command", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='reload'][@status='completed']/commands:note[@type='info'][text()='Configuration reloaded.']") + ]), Scenario("execute_forbidden_adhoc_command", [ handshake_sequence(), -- cgit v1.2.3 From 3a8203c366d46ec2937a601868f5e2ed591c923e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 12 Apr 2017 17:07:39 +0200 Subject: Handle the RSM "max" value in the MAM requests fix #3255 --- tests/end_to_end/__main__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index e9c9429..8acfe14 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1626,6 +1626,18 @@ if __name__ == '__main__': partial(expect_stanza, "/iq[@type='result'][@id='id3'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + + # Retrieve a limited archive + partial(send_stanza, "1"), + + partial(expect_stanza, + ("/message/mam:result[@queryid='qid4']/forward:forwarded/delay:delay", + "/message/mam:result[@queryid='qid4']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='coucou 2']") + ), + + partial(expect_stanza, + "/iq[@type='result'][@id='id4'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + ]), Scenario("mam_on_fixed_server", [ -- cgit v1.2.3 From c2cc9cb96f90586ed6bb2361b82e77fae79c4d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 19 Apr 2017 21:40:50 +0200 Subject: Remove the flood limit in our e2e charybdis configuration --- tests/end_to_end/__main__.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 8acfe14..4483f31 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -454,6 +454,7 @@ def connection_end_sequence(irc_host, jid): 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)), partial(expect_stanza, xpath_re % (r'^%s: Your host is .*$' % irc_host)), partial(expect_stanza, -- cgit v1.2.3 From a4e2e56ad3050f8e48a57638b13c0b23849f76ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 19 Apr 2017 21:41:17 +0200 Subject: Add an e2e test for the mam default limit We send 150 messages, then retrieve the archive. We should receive messages from 50 to 149 only. --- tests/end_to_end/__main__.py | 54 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 4483f31..aca6ffd 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -423,6 +423,7 @@ def connection_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.localhost')), partial(expect_stanza, xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % 'irc.localhost')), + partial(expect_stanza, xpath_re % (r'^%s: \*\*\* You are exempt from flood limits$' % 'irc.localhost')), ) def connection_tls_begin_sequence(irc_host, jid): @@ -446,6 +447,7 @@ 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)), partial(expect_stanza, xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), + partial(expect_stanza, xpath_re % (r'^%s: \*\*\* You are exempt from flood limits$' % 'irc.localhost')), ) def connection_end_sequence(irc_host, jid): @@ -454,7 +456,6 @@ def connection_end_sequence(irc_host, jid): 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)), partial(expect_stanza, xpath_re % (r'^%s: Your host is .*$' % irc_host)), partial(expect_stanza, @@ -492,9 +493,15 @@ def extract_attribute(xpath, name, stanza): return matched[0].get(name) +def extract_text(xpath, stanza): + matched = match(stanza, xpath) + return matched[0].text + + def save_value(name, func, stanza, xmpp): xmpp.saved_values[name] = func(stanza) + if __name__ == '__main__': atexit.register(asyncio.get_event_loop().close) @@ -1673,6 +1680,51 @@ if __name__ == '__main__': "/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo@{biboumi_host}/{nick_one}'][@type='groupchat']/client:body[text()='coucou 2']") ), ], conf="fixed_server"), + Scenario("default_mam_limit", + [ + 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())]", + after = partial(save_value, "counter", lambda x: 0)), + ] + [ + partial(send_stanza, "{counter}"), + partial(expect_stanza, + "/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='{counter}']", + after = partial(save_value, "counter", lambda stanza: str(1 + int(extract_text("/message/body", stanza)))) + ), + ] * 150 + [ + # Retrieve the archive, without any restriction + partial(send_stanza, ""), + # Since we should only receive the last 100 messages from the archive, + # it should start with message "50" + partial(expect_stanza, + ("/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()='50']") + ), + ] + [ + # followed by 98 more messages + partial(expect_stanza, + ("/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") + ), + ] * 98 + [ + # and finally the message "149" + partial(expect_stanza, + ("/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']") + ), + partial(expect_stanza, + "/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + + ]), Scenario("channel_history_on_fixed_server", [ handshake_sequence(), -- cgit v1.2.3 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 --- tests/end_to_end/__main__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/end_to_end/__main__.py') 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 From 51696c091cc7058b05b33f1085b1246f3b5dc59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 19 Apr 2017 23:33:07 +0200 Subject: Make sure the channel is joined before trying to leave it fix #3243 --- tests/end_to_end/__main__.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 4ca7ff8..8be5078 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2457,11 +2457,24 @@ if __name__ == '__main__': handshake_sequence(), partial(send_stanza, ""), partial(expect_stanza, "/presence[@to='{jid_one}'][@from='{biboumi_host}'][@type='subscribed']") - ], conf='fixed_server') - + ], conf='fixed_server'), + Scenario("leave_unjoined_chan", + [ + handshake_sequence(), + partial(send_stanza, ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence"), + partial(expect_stanza, "/message"), + + partial(send_stanza, ""), + connection_begin_sequence("irc.localhost", '{jid_two}/{resource_two}'), + partial(expect_stanza, "/message[@to='{jid_two}/{resource_two}'][@type='chat']/body[text()='irc.localhost: {nick_one}: Nickname is already in use.']"), + partial(expect_stanza, "/presence[@type='error']/error[@type='cancel'][@code='409']/stanza:conflict"), + partial(send_stanza, "") + ]) ) - failures = 0 scenar_list = sys.argv[1:] -- cgit v1.2.3 From 42677ae46cb0daf644ab7cb69831e2e34c791b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Apr 2017 18:06:53 +0200 Subject: =?UTF-8?q?Fix=20the=20tests=20to=20take=20into=20account=20the=20?= =?UTF-8?q?new=20=E2=80=9Cyour=20are=20exempt=20bla=E2=80=9D=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/end_to_end/__main__.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 8be5078..240c979 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -423,7 +423,6 @@ def connection_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.localhost')), partial(expect_stanza, xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % 'irc.localhost')), - partial(expect_stanza, xpath_re % (r'^%s: \*\*\* You are exempt from flood limits$' % 'irc.localhost')), ) def connection_tls_begin_sequence(irc_host, jid): @@ -447,7 +446,6 @@ 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)), partial(expect_stanza, xpath_re % (r'^%s: (\*\*\* Checking Ident|\*\*\* Looking up your hostname\.\.\.|\*\*\* Found your hostname: .*|ACK multi-prefix|\*\*\* Got Ident response)$' % irc_host)), - partial(expect_stanza, xpath_re % (r'^%s: \*\*\* You are exempt from flood limits$' % 'irc.localhost')), ) def connection_end_sequence(irc_host, jid): @@ -480,12 +478,23 @@ 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')]" + 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): - return connection_begin_sequence(irc_host, jid) + connection_end_sequence(irc_host, jid) + return connection_begin_sequence(irc_host, jid) +\ + connection_middle_sequence(irc_host, jid) +\ + connection_end_sequence(irc_host, jid) def connection_tls_sequence(irc_host, jid): - return connection_tls_begin_sequence(irc_host, jid) + connection_end_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 extract_attribute(xpath, name, stanza): @@ -554,6 +563,8 @@ if __name__ == '__main__': partial(send_stanza, ""), connection_begin_sequence("irc.localhost", '{jid_one}/{resource_one}'), + connection_middle_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, ("/presence[@to='{jid_one}/{resource_one}'][@from='%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='none'][@role='participant']", "/presence/muc_user:x/muc_user:status[@code='110']") @@ -587,6 +598,8 @@ if __name__ == '__main__': partial(send_stanza, ""), connection_begin_sequence("irc.localhost", '{jid_one}/{resource_one}'), + connection_middle_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, ("/presence[@to='{jid_one}/{resource_one}'][@from='%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='none'][@role='participant']", "/presence/muc_user:x/muc_user:status[@code='110']") @@ -2136,6 +2149,8 @@ if __name__ == '__main__': partial(send_stanza, ""), connection_begin_sequence("irc.localhost", '{jid_one}/{resource_one}'), + connection_middle_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, ("/presence[@to='{jid_one}/{resource_one}'][@from='%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='none'][@role='participant']", "/presence/muc_user:x/muc_user:status[@code='110']") @@ -2469,6 +2484,7 @@ if __name__ == '__main__': partial(send_stanza, ""), connection_begin_sequence("irc.localhost", '{jid_two}/{resource_two}'), + partial(expect_stanza, "/message[@to='{jid_two}/{resource_two}'][@type='chat']/body[text()='irc.localhost: {nick_one}: Nickname is already in use.']"), partial(expect_stanza, "/presence[@type='error']/error[@type='cancel'][@code='409']/stanza:conflict"), partial(send_stanza, "") -- cgit v1.2.3 From 5ef674c4862f1ad265e76ea6fabc20e180871243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Apr 2017 10:12:00 +0200 Subject: Revert "Add a linger_time configuration option on IRC servers" This reverts commit 5d801ddcd025f68d2ec91edf0462091a32c779c1. --- tests/end_to_end/__main__.py | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 240c979..0d3790b 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2277,7 +2277,6 @@ if __name__ == '__main__': "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='realname']/dataform:value[text()='realname']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']/dataform:value[text()='latin-1']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']/dataform:value[text()='UTF-8']", - "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='linger_time']/dataform:value[text()='0']", "/iq/commands:command/commands:actions/commands:next", ), after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) -- cgit v1.2.3 From 78765a4bc47cb41f88fac99c72b5cd66da8ae486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Apr 2017 10:15:34 +0200 Subject: Remove the e2e test for the linger_time --- tests/end_to_end/__main__.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 0d3790b..7a37efd 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2346,42 +2346,6 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), ], conf='fixed_server'), - Scenario("irc_server_linger_time", - [ - handshake_sequence(), - # Set a custom value for the linger_time option, using the ad-hoc command - 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 the IRC server irc.localhost']", - "/iq/commands:command/commands:actions/commands:next", - ), - after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) - ), - partial(send_stanza, "" - "" - "" - "3" - ""), - partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"), - - 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())]"), - - partial(save_datetime), - 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_now_is_after, datetime.timedelta(seconds=3)), - ]), Scenario("irc_tls_connection", [ handshake_sequence(), -- cgit v1.2.3 From f588ce071eb99ce80fd25f899679e902214606cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 21 Apr 2017 22:47:25 +0200 Subject: Group simultaneous JOINs into a single command, to avoid flooding We still split the JOINs with a key and the ones without --- tests/end_to_end/__main__.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 7a37efd..c5a4288 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -557,6 +557,42 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), ]), + Scenario("multiple_channels_join", + [ + handshake_sequence(), + partial(send_stanza, + ""), + partial(send_stanza, + ""), + partial(send_stanza, + " SECRET"), + + 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())]"), + + partial(expect_stanza, + "/message/body[text()='Mode #bar [+nt] by {irc_host_one}']"), + partial(expect_stanza, + ("/presence[@to='{jid_one}/{resource_one}'][@from='#bar%{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='#bar%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), + + partial(expect_stanza, + "/message/body[text()='Mode #baz [+nt] by {irc_host_one}']"), + partial(expect_stanza, + ("/presence[@to='{jid_one}/{resource_one}'][@from='#baz%{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='#baz%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), + ]), Scenario("virtual_channel", [ handshake_sequence(), -- cgit v1.2.3 From f200126f61559685e866114acc5de5c01bf9ff51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 5 May 2017 00:38:01 +0200 Subject: Add an execute_incomplete_hello_adhoc_command e2e test --- tests/end_to_end/__main__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index c5a4288..17e099a 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -857,11 +857,22 @@ if __name__ == '__main__': "/iq/commands:command/commands:actions/commands:next", ), after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='hello']", "sessionid")) - ), partial(send_stanza, "COUCOU"), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='hello'][@status='completed']/commands:note[@type='info'][text()='Hello COUCOU!']") ]), + Scenario("execute_incomplete_hello_adhoc_command", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='hello'][@sessionid][@status='executing']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='hello']", "sessionid")) + ), + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='error']") + ]), Scenario("execute_ping_adhoc_command", [ handshake_sequence(), -- cgit v1.2.3 From da701069dc9b607ce2eee300519feb49b31901de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Mon, 8 May 2017 18:47:02 +0200 Subject: Little fix and cleanup in the channels list code --- tests/end_to_end/__main__.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 17e099a..6657ae2 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1938,21 +1938,27 @@ if __name__ == '__main__': partial(expect_stanza, "/presence"), partial(expect_stanza, "/message[@from='#coucou%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), + # Ask for 0 item partial(send_stanza, "0"), + + # Get 0 item partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", )), + # Ask for 2 (of 3) items We don’t have the count, + # because biboumi doesn’t have the complete list when + # it sends us the 2 items partial(send_stanza, "2"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", "/iq/disco_items:query/disco_items:item[@jid='#bar%{irc_server_one}']", "/iq/disco_items:query/disco_items:item[@jid='#coucou%{irc_server_one}']", "/iq/disco_items:query/rsm:set/rsm:first[text()='#bar%{irc_server_one}'][@index='0']", - "/iq/disco_items:query/rsm:set/rsm:last[text()='#coucou%{irc_server_one}']", - "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" + "/iq/disco_items:query/rsm:set/rsm:last[text()='#coucou%{irc_server_one}']" )), + # Ask for 12 (of 3) items. We get the whole list, and thus we have the count included. partial(send_stanza, "12"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1964,6 +1970,10 @@ if __name__ == '__main__': "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" )), + # Ask for 1 item, AFTER the first item (so, + # the second). Since we don’t invalidate the cache + # with this request, we should have the count + # included. partial(send_stanza, "#bar%{irc_server_one}1"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", @@ -1973,14 +1983,24 @@ if __name__ == '__main__': "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" )), - partial(send_stanza, "#bar%{irc_server_one}1"), + # Ask for 1 item, AFTER the second item (so, + # the third). + partial(send_stanza, "#coucou%{irc_server_one}1"), partial(expect_stanza, ( "/iq[@type='result']/disco_items:query", - "/iq/disco_items:query/disco_items:item[@jid='#coucou%{irc_server_one}']", - "/iq/disco_items:query/rsm:set/rsm:first[text()='#coucou%{irc_server_one}'][@index='1']", - "/iq/disco_items:query/rsm:set/rsm:last[text()='#coucou%{irc_server_one}']", + "/iq/disco_items:query/disco_items:item[@jid='#foo%{irc_server_one}']", + "/iq/disco_items:query/rsm:set/rsm:first[text()='#foo%{irc_server_one}'][@index='2']", + "/iq/disco_items:query/rsm:set/rsm:last[text()='#foo%{irc_server_one}']", "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" - )) + )), + + # Ask for 1 item, AFTER the third item (so, + # the fourth). Since it doesn't exist, we get 0 item + partial(send_stanza, "#foo%{irc_server_one}1"), + partial(expect_stanza, ( + "/iq[@type='result']/disco_items:query", + "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" + )), ]), Scenario("complete_channel_list_with_pages_of_3", [ -- cgit v1.2.3 From 8cf0b833c47314ada66e6a25bbdb9a2178e096d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 11 May 2017 21:15:43 +0200 Subject: Make the IRC channel configuration form available from the MUC config fix #3250 --- tests/end_to_end/__main__.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 6657ae2..ef81c1f 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -118,6 +118,7 @@ def match(stanza, xpath): tree = lxml.etree.parse(io.StringIO(str(stanza))) matched = tree.xpath(xpath, namespaces={'re': 'http://exslt.org/regular-expressions', 'muc_user': 'http://jabber.org/protocol/muc#user', + 'muc_owner': 'http://jabber.org/protocol/muc#owner', 'muc': 'http://jabber.org/protocol/muc', 'disco_info': 'http://jabber.org/protocol/disco#info', 'muc_traffic': 'http://jabber.org/protocol/muc#traffic', @@ -2382,6 +2383,26 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), ]), + Scenario("irc_channel_configure_xep0045", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, ("/iq[@type='result']/muc_owner:query", + "/iq/muc_owner:query/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']", + "/iq/muc_owner:query/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']", + ), + ), + partial(send_stanza, "" + "" + "" + "" + "UTF-8" + "latin-1" + ""), + partial(expect_stanza, "/iq[@type='result']"), + partial(send_stanza, " "), + partial(expect_stanza, "/iq[@type='result']"), + ]), Scenario("irc_channel_configure_fixed", [ handshake_sequence(), -- cgit v1.2.3 From 34f0685c7237a0e75d65bb258231299fc466c8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 16 May 2017 23:54:58 +0200 Subject: Test the default channel list limit fix #3219 --- tests/end_to_end/__main__.py | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index ef81c1f..53860d7 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -140,9 +140,15 @@ def match(stanza, xpath): def check_xpath(xpaths, xmpp, after, stanza): for xpath in xpaths: + expected = True + real_xpath = xpath + # We can check that a stanza DOESN’T match, by adding a ! before it. + if xpath.startswith('!'): + expected = False + xpath = xpath[1:] matched = match(stanza, xpath) - if not matched: - raise StanzaError("Received stanza “%s” did not match expected xpath “%s”" % (stanza, xpath)) + if (expected and not matched) or (not expected and matched): + raise StanzaError("Received stanza “%s” did not match expected xpath “%s”" % (stanza, real_xpath)) if after: if isinstance(after, collections.Iterable): for af in after: @@ -502,12 +508,14 @@ def extract_attribute(xpath, name, stanza): matched = match(stanza, xpath) return matched[0].get(name) +def chan_name_from_jid(jid): + return jid[1:jid.find('%')] + def extract_text(xpath, stanza): matched = match(stanza, xpath) return matched[0].text - def save_value(name, func, stanza, xmpp): xmpp.saved_values[name] = func(stanza) @@ -2003,6 +2011,34 @@ if __name__ == '__main__': "/iq/disco_items:query/rsm:set/rsm:count[text()='3']" )), ]), + Scenario("default_channel_list_limit", + [ + handshake_sequence(), + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence"), + partial(expect_stanza, "/message", + after = partial(save_value, "counter", lambda x: 0)), + ] + [ + partial(send_stanza, + ""), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence", + after = partial(save_value, "counter", lambda stanza: str(1 + int(chan_name_from_jid(extract_attribute("/presence", "from", stanza)))))), + partial(expect_stanza, "/message") + ] * 110 + [ + partial(send_stanza, ""), + # charybdis sends the list in alphabetic order, so #foo is the last, and #99 is after #120 + partial(expect_stanza, ("/iq/disco_items:query/disco_items:item[@jid='#0%{irc_server_one}']", + "/iq/disco_items:query/disco_items:item[@jid='#1%{irc_server_one}']", + "/iq/disco_items:query/disco_items:item[@jid='#109%{irc_server_one}']", + "/iq/disco_items:query/disco_items:item[@jid='#9%{irc_server_one}']", + "!/iq/disco_items:query/disco_items:item[@jid='#foo%{irc_server_one}']", + "!/iq/disco_items:query/disco_items:item[@jid='#99%{irc_server_one}']", + "!/iq/disco_items:query/disco_items:item[@jid='#90%{irc_server_one}']")), + ]), Scenario("complete_channel_list_with_pages_of_3", [ handshake_sequence(), -- cgit v1.2.3 From bb150d587f080af38a74f2420457f1e0b2606a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Wed, 17 May 2017 00:30:07 +0200 Subject: Redirect welcome NOTICE to their channel, instead of sending a global one fix #3236 --- tests/end_to_end/__main__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 53860d7..3fddedf 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1114,6 +1114,19 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#bar%{irc_server_one}'][@type='groupchat'][@to='{jid_one}/{resource_one}']/subject[not(text())]"), ]), + Scenario("notices", + [ + handshake_sequence(), + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, "/message"), + partial(expect_stanza, "/presence"), + partial(expect_stanza, "/message"), + + partial(send_stanza, "NOTICE {nick_one} :[#foo] Hello in a notice."), + partial(expect_stanza, "/message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/body[text()='[notice] [#foo] Hello in a notice.']"), + ]), Scenario("channel_messages", [ handshake_sequence(), -- cgit v1.2.3 From 1b71e0f7d4764521c0f04190cfbe65ec7cb553dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 23 May 2017 18:44:59 +0200 Subject: Add a e2e to check that timestamps in MAM requests are correctly handled fix #3266 --- tests/end_to_end/__main__.py | 75 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 8 deletions(-) (limited to 'tests/end_to_end/__main__.py') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index 3fddedf..f9e04a8 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1,13 +1,14 @@ #!/usr/bin/env python3 import collections +import lxml.etree import datetime import slixmpp import asyncio import logging import signal import atexit -import lxml.etree +import time import sys import io import os @@ -274,14 +275,13 @@ def expect_stanza(xpaths, xmpp, biboumi, optional=False, after=None): else: print("Warning, from argument type passed to expect_stanza: %s" % (type(xpaths))) -def save_datetime(xmpp, biboumi): - xmpp.saved_values["saved_datetime"] = datetime.datetime.now() - asyncio.get_event_loop().call_soon(xmpp.run_scenario) +def save_current_timestamp_plus_delta(key, delta, message, xmpp): + now_plus_delta = datetime.datetime.utcnow() + delta + xmpp.saved_values[key] = now_plus_delta.strftime("%FT%T.967Z") + print(xmpp.saved_values[key]) -def expect_now_is_after(timedelta, xmpp, biboumi): - time_passed = datetime.datetime.now() - xmpp.saved_values["saved_datetime"] - if time_passed < timedelta: - raise StanzaError("Not enough time has passed: %s instead of %s" % (time_passed, timedelta)) +def sleep_for(duration, xmpp, biboumi): + time.sleep(duration) asyncio.get_event_loop().call_soon(xmpp.run_scenario) # list_of_xpaths: [(xpath, xpath), (xpath, xpath), (xpath)] @@ -1754,6 +1754,65 @@ if __name__ == '__main__': "/iq[@type='result'][@id='id4'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), ]), + Scenario("mam_with_timestamps", + [ + 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))), + + # Retrieve the archive, after our saved datetime + partial(send_stanza, """ + + + urn:xmpp:mam:2 + {first_timestamp} + {second_timestamp} + + + """), + + + partial(expect_stanza, + ("/message/mam:result[@queryid='qid16']/forward:forwarded/delay:delay", + "/message/mam:result/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='coucou 3']") + ), + + partial(expect_stanza, + ("/message/mam:result[@queryid='qid16']/forward:forwarded/delay:delay", + "/message/mam:result/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='coucou 4']") + ), + + partial(expect_stanza, + "/iq[@type='result'][@id='id8'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"), + ]), Scenario("mam_on_fixed_server", [ handshake_sequence(), -- cgit v1.2.3