summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorlouiz <louiz@louiz.org>2017-07-16 01:13:04 +0200
committerlouiz <louiz@louiz.org>2017-07-16 01:13:04 +0200
commit9131e63b74412ca75a26de27a308a1843984a43f (patch)
tree15fc0c2cd67651a0bf938cdd787e50e793cf946e /tests
parentb2334707107e65dd15590b7472c990bbf79549eb (diff)
parent88770979c3a46f3dde76fa2756e3e07ff79c3e12 (diff)
downloadbiboumi-9131e63b74412ca75a26de27a308a1843984a43f.tar.gz
biboumi-9131e63b74412ca75a26de27a308a1843984a43f.tar.bz2
biboumi-9131e63b74412ca75a26de27a308a1843984a43f.tar.xz
biboumi-9131e63b74412ca75a26de27a308a1843984a43f.zip
Merge branch 'biboumi_jid_in_users_rosters' into 'master'
Use a db roster to manage biboumi’s presence with the contacts Closes #3217 See merge request !13
Diffstat (limited to 'tests')
-rw-r--r--tests/end_to_end/__main__.py76
1 files changed, 70 insertions, 6 deletions
diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py
index 7259999..2a722e8 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 = '<stream:stream %s %s from="%s" id="%s">' % (
'xmlns="jabber:component:accept"',
'xmlns:stream="%s"' % self.stream_ns,
@@ -401,11 +403,11 @@ def handshake_sequence():
partial(send_stanza, "<handshake xmlns='jabber:component:accept'/>"))
-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,
@@ -417,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,
@@ -431,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']"
@@ -492,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)
@@ -2671,7 +2680,62 @@ 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, "<presence from='{jid_two}/{resource_two}' to='#foo%{irc_server_one}/{nick_one}' type='unavailable' />")
- ])
+ ]),
+ Scenario("basic_subscribe_unsubscribe",
+ [
+ handshake_sequence(),
+
+ # Mutual subscription exchange
+ partial(send_stanza, "<presence from='{jid_one}' to='{biboumi_host}' type='subscribe' id='subid1' />"),
+ 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, "<presence from='{jid_one}' to='{biboumi_host}' type='subscribed' />"),
+
+
+ # Unsubscribe
+ partial(send_stanza, "<presence from='{jid_one}' to='{biboumi_host}' type='unsubscribe' id='unsubid1' />"),
+ partial(expect_stanza, "/presence[@type='unavailable']"),
+ partial(expect_stanza, "/presence[@type='unsubscribed']"),
+ partial(expect_stanza, "/presence[@type='unsubscribe']"),
+ partial(send_stanza, "<presence from='{jid_one}' to='{biboumi_host}' type='unavailable' />"),
+ partial(send_stanza, "<presence from='{jid_one}' to='{biboumi_host}' type='unsubscribed' />"),
+ ]),
+ Scenario("irc_server_presence_in_roster",
+ [
+ handshake_sequence(),
+
+ # Mutual subscription exchange
+ partial(send_stanza, "<presence from='{jid_one}' to='{irc_server_one}' type='subscribe' id='subid1' />"),
+ partial(expect_stanza, "/presence[@type='subscribed'][@id='subid1']"),
+
+ partial(expect_stanza, "/presence[@type='subscribe']"),
+ partial(send_stanza, "<presence from='{jid_one}' to='{irc_server_one}' type='subscribed' />"),
+
+ # Join a channel on that server
+ partial(send_stanza,
+ "<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/{nick_one}' />"),
+
+ # 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, "<presence type='unavailable' from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/{nick_one}' />"),
+ 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']"),
+ ])
)
failures = 0