From 9f7782bb0c5915969fd7477e0ed7c10b1a5c2d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 6 Jul 2017 22:24:42 +0200 Subject: =?UTF-8?q?Add=20a=20global=20=E2=80=9Cpersistent=E2=80=9D=20optio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 19dc270..580f8e4 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2392,6 +2392,7 @@ if __name__ == '__main__': "/iq/commands:command/dataform:x[@type='form']/dataform:instructions[text()='Edit the form, to configure your global settings for the component.']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='max_history_length']/dataform:value[text()='42']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='record_history']/dataform:value[text()='false']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='persistent']/dataform:value[text()='false']", "/iq/commands:command/commands:actions/commands:next", ), after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) -- cgit v1.2.3 From 3a95076db40dbdff4b130c5d9b8db81e537a750d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 8 Jul 2017 16:59:29 +0200 Subject: Send a 110 status code on a QUIT received for ourself --- tests/end_to_end/__main__.py | 20 ++++++++++++++++++++ 1 file changed, 20 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 580f8e4..4cbcefc 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -565,6 +565,26 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), ]), + Scenario("quit_message", + [ + 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 raw QUIT message + partial(send_stanza, "QUIT bye bye"), + partial(expect_stanza, "/presence[@from='#foo%{irc_server_one}/{nick_one}'][@type='unavailable']/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), + partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), + ]), Scenario("multiple_channels_join", [ handshake_sequence(), -- cgit v1.2.3 From 9fa1852c7ea094086f45e840fa22cc83d56b744e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 8 Jul 2017 18:10:47 +0200 Subject: =?UTF-8?q?Send=20status=20code=3D'332'=20on=20biboumi=20or=20IRC?= =?UTF-8?q?=20server=E2=80=99s=20shutdown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/end_to_end/__main__.py | 5 +++-- 1 file changed, 3 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 4cbcefc..7259999 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -565,7 +565,7 @@ if __name__ == '__main__': ), partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), ]), - Scenario("quit_message", + Scenario("quit", [ handshake_sequence(), partial(send_stanza, @@ -581,7 +581,8 @@ if __name__ == '__main__': # Send a raw QUIT message partial(send_stanza, "QUIT bye bye"), - partial(expect_stanza, "/presence[@from='#foo%{irc_server_one}/{nick_one}'][@type='unavailable']/muc_user:x/muc_user:status[@code='110']"), + partial(expect_stanza, ("/presence[@from='#foo%{irc_server_one}/{nick_one}'][@type='unavailable']/muc_user:x/muc_user:status[@code='110']", + "/presence[@from='#foo%{irc_server_one}/{nick_one}'][@type='unavailable']/muc_user:x/muc_user:status[@code='110']",)), partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), ]), -- cgit v1.2.3 From 7e5cd2f13036b61781e1799565597ab798b50a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 23 Jun 2017 14:49:10 +0200 Subject: Add e2e tests for the (un)subscribe thing --- tests/end_to_end/__main__.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 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 7259999..a718a63 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -49,6 +49,8 @@ class XMPPComponent(slixmpp.BaseXMPP): def __init__(self, scenario, biboumi): super().__init__(jid="biboumi.localhost", default_ns="jabber:component:accept") self.is_component = True + self.auto_authorize = None # Do not accept or reject subscribe requests automatically + self.auto_subscribe = False self.stream_header = '' % ( 'xmlns="jabber:component:accept"', 'xmlns:stream="%s"' % self.stream_ns, @@ -2671,7 +2673,28 @@ if __name__ == '__main__': 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, "") - ]) + ]), + Scenario("basic_subscribe_unsubscribe", + [ + handshake_sequence(), + + # Mutual subscription exchange + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='subscribed'][@id='subid1']"), + + # Get the current presence of the biboumi gateway + partial(expect_stanza, "/presence"), + + partial(expect_stanza, "/presence[@type='subscribe']"), + partial(send_stanza, ""), + + + # Unsubscribe + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable']"), + partial(expect_stanza, "/presence[@type='unsubscribe']"), + partial(send_stanza, ""), + ]) ) failures = 0 -- cgit v1.2.3 From 368bb82818d4b68e4984698ea4454091ecb049a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 23 Jun 2017 15:05:07 +0200 Subject: Send an additional unsubscribed presence when receiving an unsubscribe one --- tests/end_to_end/__main__.py | 2 ++ 1 file changed, 2 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 a718a63..2957820 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2692,8 +2692,10 @@ if __name__ == '__main__': # Unsubscribe partial(send_stanza, ""), partial(expect_stanza, "/presence[@type='unavailable']"), + partial(expect_stanza, "/presence[@type='unsubscribed']"), partial(expect_stanza, "/presence[@type='unsubscribe']"), partial(send_stanza, ""), + partial(send_stanza, ""), ]) ) -- cgit v1.2.3 From a95197509c262e6294930c4a60d2c96487986e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 8 Jul 2017 19:37:28 +0200 Subject: Add an e2e test for the IRC server roster presence --- tests/end_to_end/__main__.py | 49 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 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 2957820..2a722e8 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -403,11 +403,11 @@ def handshake_sequence(): partial(send_stanza, "")) -def connection_begin_sequence(irc_host, jid): +def connection_begin_sequence(irc_host, jid, expected_irc_presence=False): jid = jid.format_map(common_replacements) xpath = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[text()='%s']" xpath_re = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[re:test(text(), '%s')]" - return ( + result = ( partial(expect_stanza, xpath % ('Connecting to %s:6697 (encrypted)' % irc_host)), partial(expect_stanza, @@ -419,8 +419,13 @@ def connection_begin_sequence(irc_host, jid): partial(expect_stanza, xpath % ('Connecting to %s:6667 (not encrypted)' % irc_host)), partial(expect_stanza, - xpath % 'Connected to IRC server.'), + xpath % 'Connected to IRC server.')) + + if expected_irc_presence: + result += (partial(expect_stanza, "/presence[@from='" + irc_host + "@biboumi.localhost']"),) + # These five messages can be receive in any order + result += ( 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, @@ -433,6 +438,8 @@ 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')), ) + return result + def connection_tls_begin_sequence(irc_host, jid): jid = jid.format_map(common_replacements) xpath = "/message[@to='" + jid + "'][@from='" + irc_host + "@biboumi.localhost']/body[text()='%s']" @@ -494,8 +501,8 @@ def connection_middle_sequence(irc_host, jid): ) -def connection_sequence(irc_host, jid): - return connection_begin_sequence(irc_host, jid) +\ +def connection_sequence(irc_host, jid, expected_irc_presence=False): + return connection_begin_sequence(irc_host, jid, expected_irc_presence) +\ connection_middle_sequence(irc_host, jid) +\ connection_end_sequence(irc_host, jid) @@ -2696,6 +2703,38 @@ if __name__ == '__main__': partial(expect_stanza, "/presence[@type='unsubscribe']"), partial(send_stanza, ""), partial(send_stanza, ""), + ]), + Scenario("irc_server_presence_in_roster", + [ + handshake_sequence(), + + # Mutual subscription exchange + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='subscribed'][@id='subid1']"), + + partial(expect_stanza, "/presence[@type='subscribe']"), + partial(send_stanza, ""), + + # Join a channel on that server + partial(send_stanza, + ""), + + # We must receive the IRC server presence, in the connection sequence + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', True), + 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())]"), + + # Leave the channel, and thus the IRC server + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable'][@from='#foo%{irc_server_one}/{nick_one}']"), + partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), + partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), + partial(expect_stanza, "/presence[@from='{irc_server_one}'][@to='{jid_one}'][@type='unavailable']"), ]) ) -- cgit v1.2.3 From c0611c23f0d5962f1d56ca3024e550856cdce1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 16 Jul 2017 20:08:07 +0200 Subject: Add a failing test demonstrating 3277 --- tests/end_to_end/__main__.py | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 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 2a722e8..2eb7f6c 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -1116,6 +1116,65 @@ if __name__ == '__main__': ("/message[@from='{lower_nick_two}%{irc_server_one}'][@to='{jid_one}/{resource_one}'][@type='chat']/body[text()='second']",), ]), ]), + Scenario("persistent_channel", + [ + # Join the channel with user 1 + handshake_sequence(), + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}'), + partial(expect_stanza, + "/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"), + partial(expect_stanza, + ("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']", + "/presence/muc_user:x/muc_user:status[@code='110']") + ), + partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat'][@to='{jid_one}/{resource_one}']/subject[not(text())]"), + + # Make it persistent for user 1 + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']/muc_owner:query/dataform:x/dataform:field[@var='persistent'][@type='boolean']/dataform:value[text()='false']"), + partial(send_stanza, "true"), + partial(expect_stanza, "/iq[@type='result']"), + + # Check that the value is now effectively true + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']/muc_owner:query/dataform:x/dataform:field[@var='persistent'][@type='boolean']/dataform:value[text()='true']"), + + # A second user joins the same channel + partial(send_stanza, + ""), + connection_sequence("irc.localhost", '{jid_two}/{resource_one}'), + + partial(expect_unordered, [ + ("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']",), + ("/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']", + "/presence/muc_user:x/muc_user:status[@code='110']",), + ("/presence[@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']",), + ] + ), + + partial(expect_stanza, "/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"), + + # First user leaves the room (but biboumi will stay in the channel) + partial(send_stanza, + ""), + # Only user 1 receives the unavailable presence + partial(expect_stanza, + "/presence[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='unavailable']/muc_user:x/muc_user:status[@code='110']"), + + # Second user sends a channel message + partial(send_stanza, "coucou"), + + # Message should only be received by user 2, since user 1 has no resource in the room + partial(expect_stanza, "/message[@type='groupchat'][@to='{jid_two}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_two}']"), + + # Second user leaves the channel + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable'][@from='#foo%{irc_server_one}/{nick_two}']"), + partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Closing Link: localhost (Client Quit)']"), + partial(expect_stanza, "/message[@from='{irc_server_one}']/body[text()='ERROR: Connection closed.']"), + ]), Scenario("channel_join_with_different_nick", [ handshake_sequence(), -- cgit v1.2.3 From 407f95a108c275db5e9b07398f553ab573cd46bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Jul 2017 21:29:33 +0200 Subject: Do not reply with an error when receiving a presence for a user JID fix #3224 --- tests/end_to_end/__main__.py | 16 ---------------- 1 file changed, 16 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 2eb7f6c..ce9add6 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2696,22 +2696,6 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, r"/iq/commands:command/commands:note[re:test(text(), 'Connected to IRC server irc.localhost on port 6667 since \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d \(\d+ seconds ago\)\.\n#foo from 1 resource: {resource_one}.*')]"), ], conf='fixed_server'), - Scenario("invalid_room_jid", - [ - handshake_sequence(), - partial(send_stanza, ""), - partial(expect_stanza, ("/presence[@type='error'][@to='{jid_one}/{resource_one}'][@from='invalid%{irc_server_one}/{nick_one}']/error[@type='cancel']/stanza:item-not-found", - "/presence/muc:x", - "/presence/error/stanza:text")), - ]), - Scenario("invalid_room_jid_fixed", - [ - handshake_sequence(), - partial(send_stanza, ""), - partial(expect_stanza, ("/presence[@type='error'][@to='{jid_one}/{resource_one}'][@from='invalid@{biboumi_host}/{nick_one}']/error[@type='cancel']/stanza:item-not-found", - "/presence/muc:x", - "/presence/error/stanza:text")), - ], conf='fixed_server'), Scenario("irc_server_presence_subscription", [ handshake_sequence(), -- cgit v1.2.3 From f125de4833d65a83d1f550f4bfbff4d5e4c333b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 20 Jul 2017 23:09:37 +0200 Subject: Add the possibility to invite any external JID to a room fix #3285 --- tests/end_to_end/__main__.py | 3 +++ 1 file changed, 3 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 ce9add6..8c2d8e9 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2406,6 +2406,9 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/message/body[text()='{nick_two} has been invited to #foo']"), partial(expect_stanza, "/message[@to='{jid_two}/{resource_two}'][@from='#foo%{irc_server_one}']/muc_user:x/muc_user:invite[@from='#foo%{irc_server_one}/{nick_one}']"), + + partial(send_stanza, ""), + partial(expect_stanza, "/message[@to='bertrand@example.com'][@from='#foo%{irc_server_one}']/muc_user:x/muc_user:invite[@from='{jid_one}/{resource_one}']"), ]), Scenario("virtual_channel_multisession", [ -- cgit v1.2.3 From 308869aa73c7c03d7e9fad2a780bf132e03c8c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 21 Jul 2017 17:27:03 +0200 Subject: Do not ignore empty values when receiving a data form Otherwise, these fields cannot be emptied by the user fix #3281 --- tests/end_to_end/__main__.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 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 8c2d8e9..c6607d0 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -2551,6 +2551,41 @@ if __name__ == '__main__': ), partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), + + # Same thing, but try to empty some values + 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, "" + "" + "" + "" + "" + "" + "" + "" + "" + ""), + 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 server irc.localhost']", + "/iq/commands:command/dataform:x[@type='form']/dataform:instructions[text()='Edit the form, to configure the settings of the IRC server irc.localhost']", + "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='pass']/dataform:value", + "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='after_connect_command']/dataform:value", + "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='username']/dataform:value", + "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='realname']/dataform:value", + "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='encoding_in']/dataform:value", + "!/iq/commands:command/dataform:x[@type='form']/dataform:field[@var='encoding_out']/dataform:value", + "/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_channel_configure", [ -- cgit v1.2.3