1 Commits

Author SHA1 Message Date
c0678ec350 Enable bouncer tests for Sable 2025-03-29 20:27:39 +01:00
3 changed files with 39 additions and 22 deletions

View File

@ -32,13 +32,26 @@ class BouncerTestCase(cases.BaseServerTestCase):
self.sendLine(2, "USER a 0 * a") self.sendLine(2, "USER a 0 * a")
self.sendLine(2, "CAP REQ :server-time message-tags") self.sendLine(2, "CAP REQ :server-time message-tags")
self.sendLine(2, "CAP END") self.sendLine(2, "CAP END")
messages = self.getMessages(2) self._waitForWelcome(2, "testnick")
welcomes = [message for message in messages if message.command == RPL_WELCOME]
self.assertEqual(len(welcomes), 1)
# should see a regburst for testnick
self.assertMessageMatch(welcomes[0], params=["testnick", ANYSTR])
self.joinChannel(2, "#chan") self.joinChannel(2, "#chan")
def _waitForWelcome(self, client, nick):
"""Waits for numeric 001, and returns every message after that."""
while True:
messages = iter(self.getMessages(client, synchronize=False))
for message in messages:
if message.command == "001":
# should see a regburst for testnick
self.assertMessageMatch(message, params=[nick, ANYSTR])
messages_after_welcome = list(messages)
messages_after_welcome += self.getMessages(client)
# check there is no other 001
for message in messages_after_welcome:
self.assertNotEqual(message.command, "001")
return messages_after_welcome
def _connectClient3(self): def _connectClient3(self):
self.addClient() self.addClient()
self.sendLine(3, "CAP LS 302") self.sendLine(3, "CAP LS 302")
@ -48,11 +61,8 @@ class BouncerTestCase(cases.BaseServerTestCase):
self.sendLine(3, "USER a 0 * a") self.sendLine(3, "USER a 0 * a")
self.sendLine(3, "CAP REQ :server-time message-tags account-tag") self.sendLine(3, "CAP REQ :server-time message-tags account-tag")
self.sendLine(3, "CAP END") self.sendLine(3, "CAP END")
messages = self.getMessages(3)
welcomes = [message for message in messages if message.command == RPL_WELCOME]
self.assertEqual(len(welcomes), 1)
# should see the *same* regburst for testnick # should see the *same* regburst for testnick
self.assertMessageMatch(welcomes[0], params=["testnick", ANYSTR]) messages = self._waitForWelcome(3, "testnick")
joins = [message for message in messages if message.command == "JOIN"] joins = [message for message in messages if message.command == "JOIN"]
# we should be automatically joined to #chan # we should be automatically joined to #chan
self.assertMessageMatch(joins[0], params=["#chan"]) self.assertMessageMatch(joins[0], params=["#chan"])
@ -68,16 +78,15 @@ class BouncerTestCase(cases.BaseServerTestCase):
self.sendLine(4, "USER a 0 * a") self.sendLine(4, "USER a 0 * a")
self.sendLine(4, "CAP REQ server-time") self.sendLine(4, "CAP REQ server-time")
self.sendLine(4, "CAP END") self.sendLine(4, "CAP END")
messages = self.getMessages(4) # should see the *same* regburst for testnick
welcomes = [message for message in messages if message.command == RPL_WELCOME] self._waitForWelcome(4, "testnick")
self.assertEqual(len(welcomes), 1)
@cases.mark_specifications("Ergo") @cases.mark_specifications("Ergo", "Sable")
def testAutomaticResumption(self): def testAutomaticResumption(self):
"""Test logging into an account that already has a client joins the client's session""" """Test logging into an account that already has a client joins the client's session"""
self._connectClient3() self._connectClient3()
@cases.mark_specifications("Ergo") @cases.mark_specifications("Ergo", "Sable")
def testChannelMessageFromOther(self): def testChannelMessageFromOther(self):
"""Test that all clients attached to a session get messages sent by someone else """Test that all clients attached to a session get messages sent by someone else
to a channel""" to a channel"""
@ -111,7 +120,7 @@ class BouncerTestCase(cases.BaseServerTestCase):
self.assertNotIn("account", messageforfour.tags) self.assertNotIn("account", messageforfour.tags)
self.assertNotIn("msgid", messageforfour.tags) self.assertNotIn("msgid", messageforfour.tags)
@cases.mark_specifications("Ergo") @cases.mark_specifications("Ergo", "Sable")
def testChannelMessageFromSelf(self): def testChannelMessageFromSelf(self):
"""Test that all clients attached to a session get messages sent by an other client """Test that all clients attached to a session get messages sent by an other client
@ -149,7 +158,7 @@ class BouncerTestCase(cases.BaseServerTestCase):
self.assertNotIn("account", messageforfour.tags) self.assertNotIn("account", messageforfour.tags)
self.assertNotIn("msgid", messageforfour.tags) self.assertNotIn("msgid", messageforfour.tags)
@cases.mark_specifications("Ergo") @cases.mark_specifications("Ergo", "Sable")
def testDirectMessageFromOther(self): def testDirectMessageFromOther(self):
"""Test that all clients attached to a session get copies of messages sent """Test that all clients attached to a session get copies of messages sent
by an other client of that session directly to an other user""" by an other client of that session directly to an other user"""
@ -167,7 +176,7 @@ class BouncerTestCase(cases.BaseServerTestCase):
self.assertEqual(messagefortwo.params, messageforthree.params) self.assertEqual(messagefortwo.params, messageforthree.params)
self.assertEqual(messagefortwo.tags["msgid"], messageforthree.tags["msgid"]) self.assertEqual(messagefortwo.tags["msgid"], messageforthree.tags["msgid"])
@cases.mark_specifications("Ergo") @cases.mark_specifications("Ergo", "Sable")
def testDirectMessageFromSelf(self): def testDirectMessageFromSelf(self):
"""Test that all clients attached to a session get copies of messages sent """Test that all clients attached to a session get copies of messages sent
by an other client of that session directly to an other user""" by an other client of that session directly to an other user"""
@ -187,7 +196,7 @@ class BouncerTestCase(cases.BaseServerTestCase):
messageForRecipient.tags["msgid"], copyForOtherSession.tags["msgid"] messageForRecipient.tags["msgid"], copyForOtherSession.tags["msgid"]
) )
@cases.mark_specifications("Ergo") @cases.mark_specifications("Ergo", "Sable")
def testQuit(self): def testQuit(self):
"""Test that a single client of a session does not make the whole user quit """Test that a single client of a session does not make the whole user quit
(and is generally not visible to anyone else, not even their other sessions), (and is generally not visible to anyone else, not even their other sessions),
@ -195,8 +204,11 @@ class BouncerTestCase(cases.BaseServerTestCase):
self._connectClient3() self._connectClient3()
self._connectClient4() self._connectClient4()
self.sendLine(2, "QUIT :two out") self.sendLine(2, "QUIT :two out")
quitLines = [msg for msg in self.getMessages(2) if msg.command == "QUIT"] quitLines = [
msg for msg in self.getMessages(2) if msg.command in ("QUIT", "ERROR")
]
self.assertEqual(len(quitLines), 1) self.assertEqual(len(quitLines), 1)
if quitLines[0].command == "QUIT":
self.assertMessageMatch(quitLines[0], params=[StrRe(".*two out.*")]) self.assertMessageMatch(quitLines[0], params=[StrRe(".*two out.*")])
# neither the observer nor the other attached session should see a quit here # neither the observer nor the other attached session should see a quit here
quitLines = [msg for msg in self.getMessages(1) if msg.command == "QUIT"] quitLines = [msg for msg in self.getMessages(1) if msg.command == "QUIT"]
@ -218,8 +230,11 @@ class BouncerTestCase(cases.BaseServerTestCase):
self.sendLine(4, "QUIT :four out") self.sendLine(4, "QUIT :four out")
self.getMessages(4) self.getMessages(4)
self.sendLine(3, "QUIT :three out") self.sendLine(3, "QUIT :three out")
quitLines = [msg for msg in self.getMessages(3) if msg.command == "QUIT"] quitLines = [
msg for msg in self.getMessages(3) if msg.command in ("QUIT", "ERROR")
]
self.assertEqual(len(quitLines), 1) self.assertEqual(len(quitLines), 1)
if quitLines[0].command == "QUIT":
self.assertMessageMatch(quitLines[0], params=[StrRe(".*three out.*")]) self.assertMessageMatch(quitLines[0], params=[StrRe(".*three out.*")])
# observer should see *this* quit # observer should see *this* quit
quitLines = [msg for msg in self.getMessages(1) if msg.command == "QUIT"] quitLines = [msg for msg in self.getMessages(1) if msg.command == "QUIT"]

View File

@ -9,6 +9,7 @@ class Specifications(enum.Enum):
RFC2812 = "RFC2812" RFC2812 = "RFC2812"
IRCv3 = "IRCv3" # Mark with capabilities whenever possible IRCv3 = "IRCv3" # Mark with capabilities whenever possible
Ergo = "Ergo" Ergo = "Ergo"
SABLE = "Sable"
Ircdocs = "ircdocs" Ircdocs = "ircdocs"
"""Any document on ircdocs.horse (especially defs.ircdocs.horse), """Any document on ircdocs.horse (especially defs.ircdocs.horse),

View File

@ -8,6 +8,7 @@ markers =
modern modern
ircdocs ircdocs
Ergo Ergo
Sable
# misc marks # misc marks
strict strict