summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorlouiz <louiz@louiz.org>2017-04-19 23:15:49 +0200
committerlouiz <louiz@louiz.org>2017-04-19 23:15:49 +0200
commit47ff1cd3116424342c79d173d30a0f118859bc9f (patch)
tree6de3edf0dc0ba152d1e96157b11f32acda09460f /tests
parenteec8f68de71b642fbeb39c65c96124a8a784f78f (diff)
parent96d460de480617ec2ade3b5cc428bd144a1659f3 (diff)
downloadbiboumi-47ff1cd3116424342c79d173d30a0f118859bc9f.tar.gz
biboumi-47ff1cd3116424342c79d173d30a0f118859bc9f.tar.bz2
biboumi-47ff1cd3116424342c79d173d30a0f118859bc9f.tar.xz
biboumi-47ff1cd3116424342c79d173d30a0f118859bc9f.zip
Merge branch 'mam_default_limit' into 'master'
Limit of 100 MAM messages, if no other limit has been set by the client Closes #3256 See merge request !9
Diffstat (limited to 'tests')
-rw-r--r--tests/end_to_end/__main__.py53
-rw-r--r--tests/end_to_end/ircd.conf1
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py
index bd25f55..4ca7ff8 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):
@@ -491,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)
@@ -1697,6 +1705,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,
+ "<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/{nick_one}' />"),
+ 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, "<message from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}' type='groupchat'><body>{counter}</body></message>"),
+ 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, "<iq to='#foo%{irc_server_one}' from='{jid_one}/{resource_one}' type='set' id='id1'><query xmlns='urn:xmpp:mam:2' queryid='qid1' /></iq>"),
+ # 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(),
diff --git a/tests/end_to_end/ircd.conf b/tests/end_to_end/ircd.conf
index ec55884..0c0afa9 100644
--- a/tests/end_to_end/ircd.conf
+++ b/tests/end_to_end/ircd.conf
@@ -221,6 +221,7 @@ auth {
auth {
user = "*@*";
class = "users";
+ flags = flood_exempt;
};
/* privset {} blocks MUST be specified before anything that uses them. That