From e560352fcf95ba70891d1a847973160c923fb702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 26 Aug 2018 17:39:16 +0200 Subject: Force connect to a server when a presence is received on a server JID --- tests/end_to_end/__main__.py | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'tests') diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index cb92cb0..81263c2 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -3383,6 +3383,71 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/presence[@type='unavailable'][@from='#foo%{irc_server_one}/{nick_one}']"), partial(expect_stanza, "/presence[@from='{irc_server_one}'][@to='{jid_one}'][@type='unavailable']"), + + # Send a directed available presence to the IRC server JID + partial(send_stanza, ""), + # Nothing happens because no Nick is configured. + # Send a directed unavailable presence + partial(send_stanza, ""), + # Now, configure a nick + + 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[@type='text-single'][@var='nick']", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='configure']", "sessionid")) + ), + partial(send_stanza, "" + "" + "" + "{nick_one}" + "6667" + "66976670" + "99996670" + ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"), + + # Send a directed available presence to the IRC server JID, again + partial(send_stanza, ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', True), + # also from a second resource + partial(send_stanza, ""), + + # Second resource stops being force connected. But we are not disconnected yet + partial(send_stanza, ""), + # first (and last) resources stops being force connected + partial(send_stanza, ""), + # we get disconnected from the server + # TODO, these two next stanzas aren’t supposed to be there. + 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']"), + + # Re-force connect from one resource + partial(send_stanza, ""), + connection_sequence("irc.localhost", '{jid_one}/{resource_one}', True), + + # and then join some channel + partial(send_stanza, + ""), + 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())]"), + + # leave that channel + partial(send_stanza, ""), + partial(expect_stanza, "/presence[@type='unavailable']/muc_user:x/muc_user:status[@code='110']"), + + # first (and last) resources stops being force connected + partial(send_stanza, ""), + # we get disconnected from the server + partial(expect_stanza, "/presence[@from='{irc_server_one}'][@to='{jid_one}'][@type='unavailable']"), ]) ) -- cgit v1.2.3