testNonutf8Realname/testNonutf8Username: Add support for ERROR instead of FAIL/ERR_INVALIDUSERNAME

This is what Sable does, at it fails to decode non-UTF8 data before
it even tries to parse commands.
This commit is contained in:
Val Lorentz 2024-04-19 15:13:51 +02:00 committed by Val Lorentz
parent a1f8fcac49
commit 9f8e712776

View File

@ -57,8 +57,16 @@ class Utf8TestCase(cases.BaseServerTestCase):
self.sendLine(2, "NICK bar")
self.clients[2].conn.sendall(b"USER username * * :i\xe8rc\xe9\r\n")
d = self.clients[2].conn.recv(1024)
if b"FAIL " in d or b"468 " in d: # ERR_INVALIDUSERNAME
d = b""
while True:
try:
buf = self.clients[2].conn.recv(1024)
except TimeoutError:
break
if d and not buf:
break
d += buf
if b"FAIL " in d or b"ERROR " in d or b"468 " in d: # ERR_INVALIDUSERNAME
return # nothing more to test
self.assertIn(b"001 ", d)
@ -74,8 +82,16 @@ class Utf8TestCase(cases.BaseServerTestCase):
self.sendLine(2, "NICK bar")
self.clients[2].conn.sendall(b"USER \xe8rc\xe9 * * :readlname\r\n")
d = self.clients[2].conn.recv(1024)
if b"FAIL " in d or b"468 " in d: # ERR_INVALIDUSERNAME
d = b""
while True:
try:
buf = self.clients[2].conn.recv(1024)
except TimeoutError:
break
if d and not buf:
break
d += buf
if b"FAIL " in d or b"ERROR " in d or b"468 " in d: # ERR_INVALIDUSERNAME
return # nothing more to test
self.assertIn(b"001 ", d)