Skip to content

Commit d643e0a

Browse files
committed
Enable bouncer tests for Sable
1 parent f33b666 commit d643e0a

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

irctest/server_tests/bouncer.py

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,26 @@ def setUp(self):
3232
self.sendLine(2, "USER a 0 * a")
3333
self.sendLine(2, "CAP REQ :server-time message-tags")
3434
self.sendLine(2, "CAP END")
35-
messages = self.getMessages(2)
36-
welcomes = [message for message in messages if message.command == RPL_WELCOME]
37-
self.assertEqual(len(welcomes), 1)
38-
# should see a regburst for testnick
39-
self.assertMessageMatch(welcomes[0], params=["testnick", ANYSTR])
35+
self._waitForWelcome(2, "testnick")
4036
self.joinChannel(2, "#chan")
4137

38+
def _waitForWelcome(self, client, nick):
39+
"""Waits for numeric 001, and returns every message after that."""
40+
while True:
41+
messages = iter(self.getMessages(client, synchronize=False))
42+
for message in messages:
43+
if message.command == "001":
44+
# should see a regburst for testnick
45+
self.assertMessageMatch(message, params=[nick, ANYSTR])
46+
47+
messages_after_welcome = list(messages)
48+
messages_after_welcome += self.getMessages(client)
49+
50+
# check there is no other 001
51+
for message in messages_after_welcome:
52+
self.assertNotEqual(message.command, "001")
53+
return messages_after_welcome
54+
4255
def _connectClient3(self):
4356
self.addClient()
4457
self.sendLine(3, "CAP LS 302")
@@ -48,11 +61,8 @@ def _connectClient3(self):
4861
self.sendLine(3, "USER a 0 * a")
4962
self.sendLine(3, "CAP REQ :server-time message-tags account-tag")
5063
self.sendLine(3, "CAP END")
51-
messages = self.getMessages(3)
52-
welcomes = [message for message in messages if message.command == RPL_WELCOME]
53-
self.assertEqual(len(welcomes), 1)
5464
# should see the *same* regburst for testnick
55-
self.assertMessageMatch(welcomes[0], params=["testnick", ANYSTR])
65+
messages = self._waitForWelcome(3, "testnick")
5666
joins = [message for message in messages if message.command == "JOIN"]
5767
# we should be automatically joined to #chan
5868
self.assertMessageMatch(joins[0], params=["#chan"])
@@ -68,16 +78,15 @@ def _connectClient4(self):
6878
self.sendLine(4, "USER a 0 * a")
6979
self.sendLine(4, "CAP REQ server-time")
7080
self.sendLine(4, "CAP END")
71-
messages = self.getMessages(4)
72-
welcomes = [message for message in messages if message.command == RPL_WELCOME]
73-
self.assertEqual(len(welcomes), 1)
81+
# should see the *same* regburst for testnick
82+
self._waitForWelcome(4, "testnick")
7483

75-
@cases.mark_specifications("Ergo")
84+
@cases.mark_specifications("Ergo", "Sable")
7685
def testAutomaticResumption(self):
7786
"""Test logging into an account that already has a client joins the client's session"""
7887
self._connectClient3()
7988

80-
@cases.mark_specifications("Ergo")
89+
@cases.mark_specifications("Ergo", "Sable")
8190
def testChannelMessageFromOther(self):
8291
"""Test that all clients attached to a session get messages sent by someone else
8392
to a channel"""
@@ -111,7 +120,7 @@ def testChannelMessageFromOther(self):
111120
self.assertNotIn("account", messageforfour.tags)
112121
self.assertNotIn("msgid", messageforfour.tags)
113122

114-
@cases.mark_specifications("Ergo")
123+
@cases.mark_specifications("Ergo", "Sable")
115124
def testChannelMessageFromSelf(self):
116125
"""Test that all clients attached to a session get messages sent by an other client
117126
@@ -149,7 +158,7 @@ def testChannelMessageFromSelf(self):
149158
self.assertNotIn("account", messageforfour.tags)
150159
self.assertNotIn("msgid", messageforfour.tags)
151160

152-
@cases.mark_specifications("Ergo")
161+
@cases.mark_specifications("Ergo", "Sable")
153162
def testDirectMessageFromOther(self):
154163
"""Test that all clients attached to a session get copies of messages sent
155164
by an other client of that session directly to an other user"""
@@ -167,7 +176,7 @@ def testDirectMessageFromOther(self):
167176
self.assertEqual(messagefortwo.params, messageforthree.params)
168177
self.assertEqual(messagefortwo.tags["msgid"], messageforthree.tags["msgid"])
169178

170-
@cases.mark_specifications("Ergo")
179+
@cases.mark_specifications("Ergo", "Sable")
171180
def testDirectMessageFromSelf(self):
172181
"""Test that all clients attached to a session get copies of messages sent
173182
by an other client of that session directly to an other user"""
@@ -187,17 +196,20 @@ def testDirectMessageFromSelf(self):
187196
messageForRecipient.tags["msgid"], copyForOtherSession.tags["msgid"]
188197
)
189198

190-
@cases.mark_specifications("Ergo")
199+
@cases.mark_specifications("Ergo", "Sable")
191200
def testQuit(self):
192201
"""Test that a single client of a session does not make the whole user quit
193202
(and is generally not visible to anyone else, not even their other sessions),
194203
until the last client quits"""
195204
self._connectClient3()
196205
self._connectClient4()
197206
self.sendLine(2, "QUIT :two out")
198-
quitLines = [msg for msg in self.getMessages(2) if msg.command == "QUIT"]
207+
quitLines = [
208+
msg for msg in self.getMessages(2) if msg.command in ("QUIT", "ERROR")
209+
]
199210
self.assertEqual(len(quitLines), 1)
200-
self.assertMessageMatch(quitLines[0], params=[StrRe(".*two out.*")])
211+
if quitLines[0].command == "QUIT":
212+
self.assertMessageMatch(quitLines[0], params=[StrRe(".*two out.*")])
201213
# neither the observer nor the other attached session should see a quit here
202214
quitLines = [msg for msg in self.getMessages(1) if msg.command == "QUIT"]
203215
self.assertEqual(quitLines, [])
@@ -218,9 +230,12 @@ def testQuit(self):
218230
self.sendLine(4, "QUIT :four out")
219231
self.getMessages(4)
220232
self.sendLine(3, "QUIT :three out")
221-
quitLines = [msg for msg in self.getMessages(3) if msg.command == "QUIT"]
233+
quitLines = [
234+
msg for msg in self.getMessages(3) if msg.command in ("QUIT", "ERROR")
235+
]
222236
self.assertEqual(len(quitLines), 1)
223-
self.assertMessageMatch(quitLines[0], params=[StrRe(".*three out.*")])
237+
if quitLines[0].command == "QUIT":
238+
self.assertMessageMatch(quitLines[0], params=[StrRe(".*three out.*")])
224239
# observer should see *this* quit
225240
quitLines = [msg for msg in self.getMessages(1) if msg.command == "QUIT"]
226241
self.assertEqual(len(quitLines), 1)

irctest/specifications.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Specifications(enum.Enum):
99
RFC2812 = "RFC2812"
1010
IRCv3 = "IRCv3" # Mark with capabilities whenever possible
1111
Ergo = "Ergo"
12+
SABLE = "Sable"
1213

1314
Ircdocs = "ircdocs"
1415
"""Any document on ircdocs.horse (especially defs.ircdocs.horse),

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ markers =
88
modern
99
ircdocs
1010
Ergo
11+
Sable
1112

1213
# misc marks
1314
strict

0 commit comments

Comments
 (0)