Skip to content

Commit f265e28

Browse files
authored
update multiline tests (#275)
1 parent e3ffff6 commit f265e28

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

irctest/controllers/ergo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
"enabled": True,
5959
"method": "strict",
6060
},
61+
"login-throttling": {
62+
"enabled": True,
63+
"duration": "1m",
64+
"max-attempts": 3,
65+
},
6166
},
6267
"channels": {"registration": {"enabled": True}},
6368
"datastore": {"path": None},

irctest/server_tests/multiline.py

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from irctest import cases
6-
from irctest.patma import ANYDICT, StrRe
6+
from irctest.patma import ANYDICT, ANYSTR, StrRe
77

88
CAP_NAME = "draft/multiline"
99
BATCH_TYPE = "draft/multiline"
@@ -135,3 +135,86 @@ def testBlankLines(self):
135135
self.assertIn("+client-only-tag", fallback_relay[0].tags)
136136
self.assertIn("+client-only-tag", fallback_relay[1].tags)
137137
self.assertEqual(fallback_relay[0].tags["msgid"], msgid)
138+
139+
@cases.mark_capabilities("draft/multiline")
140+
def testInvalidBatchTag(self):
141+
"""Test that an unexpected change of batch tag results in
142+
FAIL BATCH MULTILINE_INVALID."""
143+
144+
self.connectClient(
145+
"alice", capabilities=(base_caps + [CAP_NAME]), skip_if_cap_nak=True
146+
)
147+
self.joinChannel(1, "#test")
148+
149+
# invalid batch tag:
150+
self.sendLine(1, "BATCH +123 %s #test" % (BATCH_TYPE,))
151+
self.sendLine(1, "@batch=231 PRIVMSG #test :hi")
152+
self.assertMessageMatch(
153+
self.getMessage(1),
154+
command="FAIL",
155+
params=["BATCH", "MULTILINE_INVALID", ANYSTR],
156+
)
157+
158+
@cases.mark_capabilities("draft/multiline")
159+
def testInvalidBlankConcatTag(self):
160+
"""Test that the concat tag on a blank message results in
161+
FAIL BATCH MULTILINE_INVALID."""
162+
163+
self.connectClient(
164+
"alice", capabilities=(base_caps + [CAP_NAME]), skip_if_cap_nak=True
165+
)
166+
self.joinChannel(1, "#test")
167+
168+
# cannot send the concat tag with a blank message:
169+
self.sendLine(1, "BATCH +123 %s #test" % (BATCH_TYPE,))
170+
self.sendLine(1, "@batch=123 PRIVMSG #test :hi")
171+
self.sendLine(1, "@batch=123;%s PRIVMSG #test :" % (CONCAT_TAG,))
172+
self.assertMessageMatch(
173+
self.getMessage(1),
174+
command="FAIL",
175+
params=["BATCH", "MULTILINE_INVALID", ANYSTR],
176+
)
177+
178+
@cases.mark_specifications("Ergo")
179+
def testLineLimit(self):
180+
"""This is an Ergo-specific test for line limit enforcement
181+
in multiline messages. Right now it hardcodes the same limits as in
182+
the Ergo controller; we can generalize it in future for other multiline
183+
implementations.
184+
"""
185+
186+
self.connectClient(
187+
"alice", capabilities=(base_caps + [CAP_NAME]), skip_if_cap_nak=False
188+
)
189+
self.joinChannel(1, "#test")
190+
191+
# line limit exceeded
192+
self.sendLine(1, "BATCH +123 %s #test" % (BATCH_TYPE,))
193+
for i in range(33):
194+
self.sendLine(1, "@batch=123 PRIVMSG #test hi")
195+
self.assertMessageMatch(
196+
self.getMessage(1),
197+
command="FAIL",
198+
params=["BATCH", "MULTILINE_MAX_LINES", "32", ANYSTR],
199+
)
200+
201+
@cases.mark_specifications("Ergo")
202+
def testByteLimit(self):
203+
"""This is an Ergo-specific test for line limit enforcement
204+
in multiline messages (see testLineLimit).
205+
"""
206+
207+
self.connectClient(
208+
"alice", capabilities=(base_caps + [CAP_NAME]), skip_if_cap_nak=False
209+
)
210+
self.joinChannel(1, "#test")
211+
212+
# byte limit exceeded
213+
self.sendLine(1, "BATCH +234 %s #test" % (BATCH_TYPE,))
214+
for i in range(11):
215+
self.sendLine(1, "@batch=234 PRIVMSG #test " + ("x" * 400))
216+
self.assertMessageMatch(
217+
self.getMessage(1),
218+
command="FAIL",
219+
params=["BATCH", "MULTILINE_MAX_BYTES", "4096", ANYSTR],
220+
)

0 commit comments

Comments
 (0)