Make flake8 pass, and run it automatically.

This commit is contained in:
2021-02-22 19:27:43 +01:00
committed by Valentin Lorentz
parent 836cc5d6d2
commit f9d0ec18ff
31 changed files with 235 additions and 281 deletions

View File

@ -9,3 +9,8 @@ repos:
rev: 5.5.2 rev: 5.5.2
hooks: hooks:
- id: isort - id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8

View File

@ -1,5 +1,4 @@
import importlib import importlib
import sys
import unittest import unittest
import _pytest.unittest import _pytest.unittest
@ -81,8 +80,8 @@ def pytest_collection_modifyitems(session, config, items):
# and that node references the UnitTest class # and that node references the UnitTest class
assert issubclass(item.parent.cls, unittest.TestCase) assert issubclass(item.parent.cls, unittest.TestCase)
# and in this project, TestCase classes all inherit either from BaseClientController # and in this project, TestCase classes all inherit either from
# or BaseServerController. # BaseClientController or BaseServerController.
if issubclass(item.parent.cls, BaseServerTestCase): if issubclass(item.parent.cls, BaseServerTestCase):
if server_tests: if server_tests:
filtered_items.append(item) filtered_items.append(item)

View File

@ -147,5 +147,5 @@ class BaseServerController(_BaseController):
c.close() c.close()
self.port_open = True self.port_open = True
except Exception as e: except Exception:
continue continue

View File

@ -58,15 +58,9 @@ class _IrcTestCase(unittest.TestCase):
method_doc = self._testMethodDoc method_doc = self._testMethodDoc
if not method_doc: if not method_doc:
return "" return ""
return ( return "\t" + normalizeWhitespace(
"\t" method_doc, removeNewline=False
+ normalizeWhitespace( ).strip().replace("\n ", "\n\t")
method_doc,
removeNewline=False,
)
.strip()
.replace("\n ", "\n\t")
)
def setUp(self): def setUp(self):
super().setUp() super().setUp()
@ -229,10 +223,7 @@ class ClientNegociationHelper:
def readCapLs(self, auth=None, tls_config=None): def readCapLs(self, auth=None, tls_config=None):
(hostname, port) = self.server.getsockname() (hostname, port) = self.server.getsockname()
self.controller.run( self.controller.run(
hostname=hostname, hostname=hostname, port=port, auth=auth, tls_config=tls_config
port=port,
auth=auth,
tls_config=tls_config,
) )
self.acceptClient() self.acceptClient()
m = self.getMessage() m = self.getMessage()

View File

@ -1,8 +1,7 @@
import base64 import base64
import hashlib
import ecdsa import ecdsa
from ecdsa.util import sigdecode_der, sigencode_der from ecdsa.util import sigdecode_der
try: try:
import pyxmpp2_scram as scram import pyxmpp2_scram as scram

View File

@ -3,7 +3,6 @@ import ssl
from irctest import cases, tls from irctest import cases, tls
from irctest.exceptions import ConnectionClosed from irctest.exceptions import ConnectionClosed
from irctest.irc_utils.message_parser import Message
BAD_CERT = """ BAD_CERT = """
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
@ -120,26 +119,20 @@ class TlsTestCase(cases.BaseClientTestCase):
tls_config = tls.TlsConfig(enable=True, trusted_fingerprints=[GOOD_FINGERPRINT]) tls_config = tls.TlsConfig(enable=True, trusted_fingerprints=[GOOD_FINGERPRINT])
(hostname, port) = self.server.getsockname() (hostname, port) = self.server.getsockname()
self.controller.run( self.controller.run(
hostname=hostname, hostname=hostname, port=port, auth=None, tls_config=tls_config
port=port,
auth=None,
tls_config=tls_config,
) )
self.acceptClient(tls_cert=GOOD_CERT, tls_key=GOOD_KEY) self.acceptClient(tls_cert=GOOD_CERT, tls_key=GOOD_KEY)
m = self.getMessage() self.getMessage()
def testUntrustedCertificate(self): def testUntrustedCertificate(self):
tls_config = tls.TlsConfig(enable=True, trusted_fingerprints=[GOOD_FINGERPRINT]) tls_config = tls.TlsConfig(enable=True, trusted_fingerprints=[GOOD_FINGERPRINT])
(hostname, port) = self.server.getsockname() (hostname, port) = self.server.getsockname()
self.controller.run( self.controller.run(
hostname=hostname, hostname=hostname, port=port, auth=None, tls_config=tls_config
port=port,
auth=None,
tls_config=tls_config,
) )
self.acceptClient(tls_cert=BAD_CERT, tls_key=BAD_KEY) self.acceptClient(tls_cert=BAD_CERT, tls_key=BAD_KEY)
with self.assertRaises((ConnectionClosed, ConnectionResetError)): with self.assertRaises((ConnectionClosed, ConnectionResetError)):
m = self.getMessage() self.getMessage()
class StsTestCase(cases.BaseClientTestCase, cases.OptionalityHelper): class StsTestCase(cases.BaseClientTestCase, cases.OptionalityHelper):
@ -162,10 +155,7 @@ class StsTestCase(cases.BaseClientTestCase, cases.OptionalityHelper):
# Connect client to insecure server # Connect client to insecure server
(hostname, port) = self.insecure_server.getsockname() (hostname, port) = self.insecure_server.getsockname()
self.controller.run( self.controller.run(
hostname=hostname, hostname=hostname, port=port, auth=None, tls_config=tls_config
port=port,
auth=None,
tls_config=tls_config,
) )
self.acceptClient(server=self.insecure_server) self.acceptClient(server=self.insecure_server)
@ -194,10 +184,7 @@ class StsTestCase(cases.BaseClientTestCase, cases.OptionalityHelper):
# Run the client, still configured to connect to the insecure server # Run the client, still configured to connect to the insecure server
self.controller.run( self.controller.run(
hostname=hostname, hostname=hostname, port=port, auth=None, tls_config=tls_config
port=port,
auth=None,
tls_config=tls_config,
) )
# The client should remember the STS policy and connect to the secure # The client should remember the STS policy and connect to the secure
@ -208,11 +195,7 @@ class StsTestCase(cases.BaseClientTestCase, cases.OptionalityHelper):
def testStsInvalidCertificate(self): def testStsInvalidCertificate(self):
# Connect client to insecure server # Connect client to insecure server
(hostname, port) = self.insecure_server.getsockname() (hostname, port) = self.insecure_server.getsockname()
self.controller.run( self.controller.run(hostname=hostname, port=port, auth=None)
hostname=hostname,
port=port,
auth=None,
)
self.acceptClient(server=self.insecure_server) self.acceptClient(server=self.insecure_server)
# Send STS policy to client # Send STS policy to client

View File

@ -1,10 +1,6 @@
import os import os
import shutil
import subprocess import subprocess
import tempfile
import time
from irctest import authentication, client_mock
from irctest.basecontrollers import ( from irctest.basecontrollers import (
BaseServerController, BaseServerController,
DirectoryBasedController, DirectoryBasedController,
@ -74,9 +70,7 @@ class CharybdisController(BaseServerController, DirectoryBasedController):
if ssl: if ssl:
self.gen_ssl() self.gen_ssl()
ssl_config = TEMPLATE_SSL_CONFIG.format( ssl_config = TEMPLATE_SSL_CONFIG.format(
key_path=self.key_path, key_path=self.key_path, pem_path=self.pem_path, dh_path=self.dh_path
pem_path=self.pem_path,
dh_path=self.dh_path,
) )
else: else:
ssl_config = "" ssl_config = ""

View File

@ -1,10 +1,6 @@
import os import os
import shutil
import subprocess import subprocess
import tempfile
import time
from irctest import authentication, client_mock
from irctest.basecontrollers import ( from irctest.basecontrollers import (
BaseServerController, BaseServerController,
DirectoryBasedController, DirectoryBasedController,
@ -72,9 +68,7 @@ class HybridController(BaseServerController, DirectoryBasedController):
if ssl: if ssl:
self.gen_ssl() self.gen_ssl()
ssl_config = TEMPLATE_SSL_CONFIG.format( ssl_config = TEMPLATE_SSL_CONFIG.format(
key_path=self.key_path, key_path=self.key_path, pem_path=self.pem_path, dh_path=self.dh_path
pem_path=self.pem_path,
dh_path=self.dh_path,
) )
else: else:
ssl_config = "" ssl_config = ""

View File

@ -1,10 +1,6 @@
import os import os
import shutil
import subprocess import subprocess
import tempfile
import time
from irctest import authentication
from irctest.basecontrollers import ( from irctest.basecontrollers import (
BaseServerController, BaseServerController,
DirectoryBasedController, DirectoryBasedController,
@ -62,9 +58,7 @@ class InspircdController(BaseServerController, DirectoryBasedController):
if ssl: if ssl:
self.gen_ssl() self.gen_ssl()
ssl_config = TEMPLATE_SSL_CONFIG.format( ssl_config = TEMPLATE_SSL_CONFIG.format(
key_path=self.key_path, key_path=self.key_path, pem_path=self.pem_path, dh_path=self.dh_path
pem_path=self.pem_path,
dh_path=self.dh_path,
) )
else: else:
ssl_config = "" ssl_config = ""

View File

@ -2,11 +2,7 @@ import os
import subprocess import subprocess
from irctest import authentication, tls from irctest import authentication, tls
from irctest.basecontrollers import ( from irctest.basecontrollers import BaseClientController, DirectoryBasedController
BaseClientController,
DirectoryBasedController,
NotImplementedByController,
)
TEMPLATE_CONFIG = """ TEMPLATE_CONFIG = """
supybot.directories.conf: {directory}/conf supybot.directories.conf: {directory}/conf

View File

@ -1,6 +1,5 @@
import os import os
import subprocess import subprocess
import time
from irctest.basecontrollers import ( from irctest.basecontrollers import (
BaseServerController, BaseServerController,
@ -62,16 +61,13 @@ server:
""" """
def make_list(l): def make_list(list_):
return "\n".join(map(" - {}".format, l)) return "\n".join(map(" - {}".format, list_))
class MammonController(BaseServerController, DirectoryBasedController): class MammonController(BaseServerController, DirectoryBasedController):
software_name = "Mammon" software_name = "Mammon"
supported_sasl_mechanisms = { supported_sasl_mechanisms = {"PLAIN", "ECDSA-NIST256P-CHALLENGE"}
"PLAIN",
"ECDSA-NIST256P-CHALLENGE",
}
supported_capabilities = set() # Not exhaustive supported_capabilities = set() # Not exhaustive
def create_config(self): def create_config(self):
@ -115,7 +111,7 @@ class MammonController(BaseServerController, DirectoryBasedController):
self.proc = subprocess.Popen( self.proc = subprocess.Popen(
[ [
"mammond", "mammond",
"--nofork", #'--debug', "--nofork", # '--debug',
"--config", "--config",
os.path.join(self.directory, "server.yml"), os.path.join(self.directory, "server.yml"),
] ]

View File

@ -12,9 +12,7 @@ from irctest.basecontrollers import (
OPER_PWD = "frenchfries" OPER_PWD = "frenchfries"
BASE_CONFIG = { BASE_CONFIG = {
"network": { "network": {"name": "OragonoTest"},
"name": "OragonoTest",
},
"server": { "server": {
"name": "oragono.test", "name": "oragono.test",
"listeners": {}, "listeners": {},
@ -38,11 +36,7 @@ BASE_CONFIG = {
"exempted": ["localhost"], "exempted": ["localhost"],
}, },
"enforce-utf8": True, "enforce-utf8": True,
"relaymsg": { "relaymsg": {"enabled": True, "separators": "/", "available-to-chanops": True},
"enabled": True,
"separators": "/",
"available-to-chanops": True,
},
}, },
"accounts": { "accounts": {
"authentication-enabled": True, "authentication-enabled": True,
@ -63,30 +57,19 @@ BASE_CONFIG = {
"method": "strict", "method": "strict",
}, },
}, },
"channels": { "channels": {"registration": {"enabled": True}},
"registration": { "datastore": {"path": None},
"enabled": True,
},
},
"datastore": {
"path": None,
},
"limits": { "limits": {
"awaylen": 200, "awaylen": 200,
"chan-list-modes": 60, "chan-list-modes": 60,
"channellen": 64, "channellen": 64,
"kicklen": 390, "kicklen": 390,
"linelen": { "linelen": {"rest": 2048},
"rest": 2048,
},
"monitor-entries": 100, "monitor-entries": 100,
"nicklen": 32, "nicklen": 32,
"topiclen": 390, "topiclen": 390,
"whowas-entries": 100, "whowas-entries": 100,
"multiline": { "multiline": {"max-bytes": 4096, "max-lines": 32},
"max-bytes": 4096,
"max-lines": 32,
},
}, },
"history": { "history": {
"enabled": True, "enabled": True,
@ -118,7 +101,7 @@ BASE_CONFIG = {
"chanreg", "chanreg",
"relaymsg", "relaymsg",
], ],
}, }
}, },
"opers": { "opers": {
"root": { "root": {
@ -126,19 +109,11 @@ BASE_CONFIG = {
"whois-line": "is a server admin", "whois-line": "is a server admin",
# OPER_PWD # OPER_PWD
"password": "$2a$04$3GzUZB5JapaAbwn7sogpOu9NSiLOgnozVllm2e96LiNPrm61ZsZSq", "password": "$2a$04$3GzUZB5JapaAbwn7sogpOu9NSiLOgnozVllm2e96LiNPrm61ZsZSq",
}, }
}, },
} }
LOGGING_CONFIG = { LOGGING_CONFIG = {"logging": [{"method": "stderr", "level": "debug", "type": "*"}]}
"logging": [
{
"method": "stderr",
"level": "debug",
"type": "*",
},
]
}
def hash_password(password): def hash_password(password):
@ -155,9 +130,7 @@ def hash_password(password):
class OragonoController(BaseServerController, DirectoryBasedController): class OragonoController(BaseServerController, DirectoryBasedController):
software_name = "Oragono" software_name = "Oragono"
supported_sasl_mechanisms = { supported_sasl_mechanisms = {"PLAIN"}
"PLAIN",
}
_port_wait_interval = 0.01 _port_wait_interval = 0.01
supported_capabilities = set() # Not exhaustive supported_capabilities = set() # Not exhaustive
@ -195,9 +168,7 @@ class OragonoController(BaseServerController, DirectoryBasedController):
config = self.addMysqlToConfig(config) config = self.addMysqlToConfig(config)
if enable_roleplay: if enable_roleplay:
config["roleplay"] = { config["roleplay"] = {"enabled": True}
"enabled": True,
}
if "oragono_config" in self.test_config: if "oragono_config" in self.test_config:
self.test_config["oragono_config"](config) self.test_config["oragono_config"](config)
@ -208,9 +179,7 @@ class OragonoController(BaseServerController, DirectoryBasedController):
if ssl: if ssl:
self.key_path = os.path.join(self.directory, "ssl.key") self.key_path = os.path.join(self.directory, "ssl.key")
self.pem_path = os.path.join(self.directory, "ssl.pem") self.pem_path = os.path.join(self.directory, "ssl.pem")
listener_conf = { listener_conf = {"tls": {"cert": self.pem_path, "key": self.key_path}}
"tls": {"cert": self.pem_path, "key": self.key_path},
}
config["server"]["listeners"][bind_address] = listener_conf config["server"]["listeners"][bind_address] = listener_conf
config["datastore"]["path"] = os.path.join(self.directory, "ircd.db") config["datastore"]["path"] = os.path.join(self.directory, "ircd.db")

View File

@ -11,7 +11,7 @@ host = {hostname}
use_ssl = false use_ssl = false
port = {port} port = {port}
owner = me owner = me
channels = channels =
timeout = 5 timeout = 5
auth_username = {username} auth_username = {username}
auth_password = {password} auth_password = {password}
@ -21,9 +21,7 @@ auth_password = {password}
class SopelController(BaseClientController): class SopelController(BaseClientController):
software_name = "Sopel" software_name = "Sopel"
supported_sasl_mechanisms = { supported_sasl_mechanisms = {"PLAIN"}
"PLAIN",
}
supported_capabilities = set() # Not exhaustive supported_capabilities = set() # Not exhaustive
def __init__(self, test_config): def __init__(self, test_config):
@ -44,7 +42,7 @@ class SopelController(BaseClientController):
return open(os.path.join(os.path.expanduser("~/.sopel/"), filename), mode) return open(os.path.join(os.path.expanduser("~/.sopel/"), filename), mode)
def create_config(self): def create_config(self):
with self.open_file(self.filename) as fd: with self.open_file(self.filename):
pass pass
def run(self, hostname, port, auth, tls_config): def run(self, hostname, port, auth, tls_config):

View File

@ -1,6 +1,6 @@
def cap_list_to_dict(l): def cap_list_to_dict(caps):
d = {} d = {}
for cap in l: for cap in caps:
if "=" in cap: if "=" in cap:
(key, value) = cap.split("=", 1) (key, value) = cap.split("=", 1)
else: else:

View File

@ -54,9 +54,4 @@ def parse_message(s):
prefix = None prefix = None
command = tokens.pop(0) command = tokens.pop(0)
params = tokens params = tokens
return Message( return Message(tags=tags, prefix=prefix, command=command, params=params)
tags=tags,
prefix=prefix,
command=command,
params=params,
)

View File

@ -1,5 +1,4 @@
import collections import collections
import operator
import unittest import unittest

View File

@ -34,7 +34,8 @@ class AwayNotifyTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
def testAwayNotifyOnJoin(self): def testAwayNotifyOnJoin(self):
"""The away-notify specification states: """The away-notify specification states:
"Clients will be sent an AWAY message [...] when a user joins and has an away message set." "Clients will be sent an AWAY message [...] when a user joins
and has an away message set."
""" """
self.connectClient("foo", capabilities=["away-notify"], skip_if_cap_nak=True) self.connectClient("foo", capabilities=["away-notify"], skip_if_cap_nak=True)
self.getMessages(1) self.getMessages(1)

View File

@ -10,7 +10,7 @@ class CapTestCase(cases.BaseServerTestCase):
“Clients that support capabilities but do not wish to enter “Clients that support capabilities but do not wish to enter
negotiation SHOULD send CAP END upon connection to the server.” negotiation SHOULD send CAP END upon connection to the server.”
-- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-end-subcommand> -- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-end-subcommand>
""" """ # noqa
self.addClient(1) self.addClient(1)
self.sendLine(1, "CAP LS 302") self.sendLine(1, "CAP LS 302")
self.getCapLs(1) self.getCapLs(1)
@ -55,7 +55,7 @@ class CapTestCase(cases.BaseServerTestCase):
first 100 characters of the capability list in the REQ subcommand which first 100 characters of the capability list in the REQ subcommand which
triggered the NAK.” triggered the NAK.”
-- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-nak-subcommand> -- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-nak-subcommand>
""" """ # noqa
self.addClient(1) self.addClient(1)
self.sendLine(1, "CAP LS 302") self.sendLine(1, "CAP LS 302")
self.getCapLs(1) self.getCapLs(1)
@ -77,7 +77,7 @@ class CapTestCase(cases.BaseServerTestCase):
"""“The capability identifier set must be accepted as a whole, or """“The capability identifier set must be accepted as a whole, or
rejected entirely.” rejected entirely.”
-- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-req-subcommand> -- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-req-subcommand>
""" """ # noqa
self.addClient(1) self.addClient(1)
self.sendLine(1, "CAP LS 302") self.sendLine(1, "CAP LS 302")
self.assertIn("multi-prefix", self.getCapLs(1)) self.assertIn("multi-prefix", self.getCapLs(1))

View File

@ -51,10 +51,7 @@ class JoinTestCase(cases.BaseServerTestCase):
self.connectClient("foo") self.connectClient("foo")
self.sendLine(1, "JOIN #chan") self.sendLine(1, "JOIN #chan")
received_commands = {m.command for m in self.getMessages(1)} received_commands = {m.command for m in self.getMessages(1)}
expected_commands = { expected_commands = {"353", "366"} # RPL_NAMREPLY # RPL_ENDOFNAMES
"353", # RPL_NAMREPLY
"366", # RPL_ENDOFNAMES
}
self.assertTrue( self.assertTrue(
expected_commands.issubset(received_commands), expected_commands.issubset(received_commands),
"Server sent {} commands, but at least {} were expected.".format( "Server sent {} commands, but at least {} were expected.".format(
@ -218,7 +215,8 @@ class JoinTestCase(cases.BaseServerTestCase):
self.getMessages(2) self.getMessages(2)
self.sendLine(1, "PART #chan :bye everyone") self.sendLine(1, "PART #chan :bye everyone")
# both the PART'ing client and the other channel member should receive a PART line: # both the PART'ing client and the other channel member should receive
# a PART line:
m = self.getMessage(1) m = self.getMessage(1)
self.assertMessageEqual(m, command="PART", params=["#chan", "bye everyone"]) self.assertMessageEqual(m, command="PART", params=["#chan", "bye everyone"])
m = self.getMessage(2) m = self.getMessage(2)
@ -463,7 +461,8 @@ class JoinTestCase(cases.BaseServerTestCase):
@cases.SpecificationSelector.requiredBySpecification("RFC2812") @cases.SpecificationSelector.requiredBySpecification("RFC2812")
def testKickPrivileges(self): def testKickPrivileges(self):
"""Test who has the ability to kick / what error codes are sent for invalid kicks.""" """Test who has the ability to kick / what error codes are sent
for invalid kicks."""
self.connectClient("foo") self.connectClient("foo")
self.sendLine(1, "JOIN #chan") self.sendLine(1, "JOIN #chan")
self.getMessages(1) self.getMessages(1)
@ -487,7 +486,8 @@ class JoinTestCase(cases.BaseServerTestCase):
ERR_NOTONCHANNEL in replies ERR_NOTONCHANNEL in replies
or ERR_CHANOPRIVSNEEDED in replies or ERR_CHANOPRIVSNEEDED in replies
or ERR_NOSUCHCHANNEL in replies, or ERR_NOSUCHCHANNEL in replies,
f"did not receive acceptable error code for kick from outside channel: {replies}", f"did not receive acceptable error code for kick from outside channel: "
f"{replies}",
) )
self.joinChannel(3, "#chan") self.joinChannel(3, "#chan")
@ -604,15 +604,15 @@ class JoinTestCase(cases.BaseServerTestCase):
self.getMessages(2) self.getMessages(2)
self.sendLine(1, "INVITE #chan bar") self.sendLine(1, "INVITE #chan bar")
self.getMessages(1) self.getMessages(1)
l = self.getMessages(2) messages = self.getMessages(2)
self.assertNotEqual( self.assertNotEqual(
l, messages,
[], [],
fail_msg="After using “INVITE #chan bar” while #chan does " fail_msg="After using “INVITE #chan bar” while #chan does "
"not exist, “bar” received nothing.", "not exist, “bar” received nothing.",
) )
self.assertMessageEqual( self.assertMessageEqual(
l[0], messages[0],
command="INVITE", command="INVITE",
params=["#chan", "bar"], params=["#chan", "bar"],
fail_msg="After “foo” invited “bar” do non-existing channel " fail_msg="After “foo” invited “bar” do non-existing channel "
@ -636,15 +636,15 @@ class JoinTestCase(cases.BaseServerTestCase):
self.getMessages(1) self.getMessages(1)
self.getMessages(2) self.getMessages(2)
self.sendLine(1, "INVITE #chan bar") self.sendLine(1, "INVITE #chan bar")
l = self.getMessages(1) messages = self.getMessages(1)
self.assertNotEqual( self.assertNotEqual(
l, messages,
[], [],
fail_msg="After using “INVITE #chan bar” while #chan does " fail_msg="After using “INVITE #chan bar” while #chan does "
"not exist, the author received nothing.", "not exist, the author received nothing.",
) )
self.assertMessageEqual( self.assertMessageEqual(
l[0], messages[0],
command="INVITE", command="INVITE",
params=["#chan", "bar"], params=["#chan", "bar"],
fail_msg="After “foo” invited “bar” do non-existing channel " fail_msg="After “foo” invited “bar” do non-existing channel "
@ -891,24 +891,9 @@ class AuditoriumTestCase(cases.BaseServerTestCase):
return result return result
self.assertEqual(names("bar"), {"@bar", "guest1", "guest2", "guest3"}) self.assertEqual(names("bar"), {"@bar", "guest1", "guest2", "guest3"})
self.assertEqual( self.assertEqual(names("guest1"), {"@bar"})
names("guest1"), self.assertEqual(names("guest2"), {"@bar"})
{ self.assertEqual(names("guest3"), {"@bar"})
"@bar",
},
)
self.assertEqual(
names("guest2"),
{
"@bar",
},
)
self.assertEqual(
names("guest3"),
{
"@bar",
},
)
self.sendLine("bar", "MODE #auditorium +v guest1") self.sendLine("bar", "MODE #auditorium +v guest1")
modeLine = [msg for msg in self.getMessages("bar") if msg.command == "MODE"][0] modeLine = [msg for msg in self.getMessages("bar") if msg.command == "MODE"][0]
@ -951,7 +936,8 @@ class AuditoriumTestCase(cases.BaseServerTestCase):
class TopicPrivileges(cases.BaseServerTestCase): class TopicPrivileges(cases.BaseServerTestCase):
@cases.SpecificationSelector.requiredBySpecification("RFC2812") @cases.SpecificationSelector.requiredBySpecification("RFC2812")
def testTopicPrivileges(self): def testTopicPrivileges(self):
# test the +t channel mode, which prevents unprivileged users from changing the topic # test the +t channel mode, which prevents unprivileged users
# from changing the topic
self.connectClient("bar", name="bar") self.connectClient("bar", name="bar")
self.joinChannel("bar", "#chan") self.joinChannel("bar", "#chan")
self.getMessages("bar") self.getMessages("bar")

View File

@ -35,9 +35,7 @@ def validate_chathistory_batch(msgs):
class ChathistoryTestCase(cases.BaseServerTestCase): class ChathistoryTestCase(cases.BaseServerTestCase):
@staticmethod @staticmethod
def config(): def config():
return { return {"chathistory": True}
"chathistory": True,
}
@cases.SpecificationSelector.requiredBySpecification("Oragono") @cases.SpecificationSelector.requiredBySpecification("Oragono")
def testInvalidTargets(self): def testInvalidTargets(self):
@ -259,7 +257,8 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
], ],
) )
# messages should be stored and retrievable by c1, even though c3 is not registered # messages should be stored and retrievable by c1,
# even though c3 is not registered
self.getMessages(1) self.getMessages(1)
self.sendLine(1, "CHATHISTORY LATEST %s * 10" % (c3,)) self.sendLine(1, "CHATHISTORY LATEST %s * 10" % (c3,))
results = [ results = [
@ -277,7 +276,8 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
# regression test for #833 # regression test for #833
self.sendLine(3, "QUIT") self.sendLine(3, "QUIT")
self.assertDisconnected(3) self.assertDisconnected(3)
# register c3 as an account, then attempt to retrieve the conversation history with c1 # register c3 as an account, then attempt to retrieve
# the conversation history with c1
self.controller.registerUser(self, c3, "sesame3") self.controller.registerUser(self, c3, "sesame3")
self.connectClient( self.connectClient(
c3, c3,
@ -408,7 +408,8 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
result = validate_chathistory_batch(self.getMessages(user)) result = validate_chathistory_batch(self.getMessages(user))
self.assertEqual(echo_messages[1:-1], result) self.assertEqual(echo_messages[1:-1], result)
# BETWEEN forwards and backwards with a limit, should get different results this time # BETWEEN forwards and backwards with a limit, should get
# different results this time
self.sendLine( self.sendLine(
user, user,
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d" "CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"

View File

@ -140,7 +140,7 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase):
IRCv3.2: “Servers MUST NOT send messages described by this document if IRCv3.2: “Servers MUST NOT send messages described by this document if
the client only supports version 3.1.” the client only supports version 3.1.”
-- <http://ircv3.net/specs/core/capability-negotiation-3.2.html#version-in-cap-ls> -- <http://ircv3.net/specs/core/capability-negotiation-3.2.html#version-in-cap-ls>
""" """ # noqa
self.addClient() self.addClient()
self.sendLine(1, "CAP LS") self.sendLine(1, "CAP LS")
m = self.getRegistrationMessage(1) m = self.getRegistrationMessage(1)
@ -162,7 +162,7 @@ class ConnectionRegistrationTestCase(cases.BaseServerTestCase):
def testEmptyCapList(self): def testEmptyCapList(self):
"""“If no capabilities are active, an empty parameter must be sent.” """“If no capabilities are active, an empty parameter must be sent.”
-- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-list-subcommand> -- <http://ircv3.net/specs/core/capability-negotiation-3.1.html#the-cap-list-subcommand>
""" """ # noqa
self.addClient() self.addClient()
self.sendLine(1, "CAP LIST") self.sendLine(1, "CAP LIST")
m = self.getRegistrationMessage(1) m = self.getRegistrationMessage(1)

View File

@ -51,7 +51,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m2.tags, m2.tags,
m2, m2,
fail_msg="When sending a PRIVMSG with a label, the target users shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a PRIVMSG with a label, "
"the target users shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
self.assertMessageEqual( self.assertMessageEqual(
m3, m3,
@ -62,7 +66,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m3.tags, m3.tags,
m3, m3,
fail_msg="When sending a PRIVMSG with a label, the target users shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a PRIVMSG with a label, "
"the target users shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
self.assertMessageEqual( self.assertMessageEqual(
m4, m4,
@ -73,7 +81,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m4.tags, m4.tags,
m4, m4,
fail_msg="When sending a PRIVMSG with a label, the target users shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a PRIVMSG with a label, "
"the target users shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
self.assertMessageEqual( self.assertMessageEqual(
@ -109,7 +121,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m2.tags, m2.tags,
m2, m2,
fail_msg="When sending a PRIVMSG with a label, the target user shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a PRIVMSG with a label, "
"the target user shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
self.assertMessageEqual( self.assertMessageEqual(
@ -121,13 +137,19 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m.tags, m.tags,
m, m,
fail_msg="When sending a PRIVMSG with a label, the echo'd message didn't contain the label at all: {msg}", fail_msg=(
"When sending a PRIVMSG with a label, "
"the echo'd message didn't contain the label at all: {msg}"
),
) )
self.assertEqual( self.assertEqual(
m.tags["label"], m.tags["label"],
"12345", "12345",
m, m,
fail_msg="Echo'd PRIVMSG to a client did not contain the same label we sent it with(should be '12345'): {msg}", fail_msg=(
"Echo'd PRIVMSG to a client did not contain the same label "
"we sent it with(should be '12345'): {msg}"
),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -168,7 +190,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
mt.tags, mt.tags,
mt, mt,
fail_msg="When sending a PRIVMSG with a label, the target user shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a PRIVMSG with a label, "
"the target user shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
# ensure sender correctly receives msg # ensure sender correctly receives msg
@ -179,13 +205,19 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
ms.tags, ms.tags,
ms, ms,
fail_msg="When sending a PRIVMSG with a label, the source user should receive the label but didn't: {msg}", fail_msg=(
"When sending a PRIVMSG with a label, "
"the source user should receive the label but didn't: {msg}"
),
) )
self.assertEqual( self.assertEqual(
ms.tags["label"], ms.tags["label"],
"12345", "12345",
ms, ms,
fail_msg="Echo'd label doesn't match the label we sent (should be '12345'): {msg}", fail_msg=(
"Echo'd label doesn't match the label we sent "
"(should be '12345'): {msg}"
),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -214,16 +246,21 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
m.tags["label"], m.tags["label"],
"12345", "12345",
m, m,
fail_msg="Echo'd label doesn't match the label we sent (should be '12345'): {msg}", fail_msg=(
"Echo'd label doesn't match the label we sent "
"(should be '12345'): {msg}"
),
) )
self.assertEqual( self.assertEqual(
number_of_labels, number_of_labels,
1, 1,
m1, m1,
fail_msg="When sending a PRIVMSG to self with echo-message, we only expect one message to contain the label. Instead, {} messages had the label".format( fail_msg=(
number_of_labels "When sending a PRIVMSG to self with echo-message, "
), "we only expect one message to contain the label. "
"Instead, {} messages had the label"
).format(number_of_labels),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -255,7 +292,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m2.tags, m2.tags,
m2, m2,
fail_msg="When sending a NOTICE with a label, the target user shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a NOTICE with a label, "
"the target user shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
self.assertMessageEqual( self.assertMessageEqual(
@ -267,13 +308,19 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m.tags, m.tags,
m, m,
fail_msg="When sending a NOTICE with a label, the echo'd message didn't contain the label at all: {msg}", fail_msg=(
"When sending a NOTICE with a label, "
"the echo'd message didn't contain the label at all: {msg}"
),
) )
self.assertEqual( self.assertEqual(
m.tags["label"], m.tags["label"],
"12345", "12345",
m, m,
fail_msg="Echo'd NOTICE to a client did not contain the same label we sent it with(should be '12345'): {msg}", fail_msg=(
"Echo'd NOTICE to a client did not contain the same label "
"we sent it with (should be '12345'): {msg}"
),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -314,7 +361,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
mt.tags, mt.tags,
mt, mt,
fail_msg="When sending a NOTICE with a label, the target user shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a NOTICE with a label, "
"the target user shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
# ensure sender correctly receives msg # ensure sender correctly receives msg
@ -325,13 +376,19 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
ms.tags, ms.tags,
ms, ms,
fail_msg="When sending a NOTICE with a label, the source user should receive the label but didn't: {msg}", fail_msg=(
"When sending a NOTICE with a label, "
"the source user should receive the label but didn't: {msg}"
),
) )
self.assertEqual( self.assertEqual(
ms.tags["label"], ms.tags["label"],
"12345", "12345",
ms, ms,
fail_msg="Echo'd label doesn't match the label we sent (should be '12345'): {msg}", fail_msg=(
"Echo'd label doesn't match the label we sent "
"(should be '12345'): {msg}"
),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -358,16 +415,21 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
m.tags["label"], m.tags["label"],
"12345", "12345",
m, m,
fail_msg="Echo'd label doesn't match the label we sent (should be '12345'): {msg}", fail_msg=(
"Echo'd label doesn't match the label we sent "
"(should be '12345'): {msg}"
),
) )
self.assertEqual( self.assertEqual(
number_of_labels, number_of_labels,
1, 1,
m1, m1,
fail_msg="When sending a NOTICE to self with echo-message, we only expect one message to contain the label. Instead, {} messages had the label".format( fail_msg=(
number_of_labels "When sending a NOTICE to self with echo-message, "
), "we only expect one message to contain the label. "
"Instead, {} messages had the label"
).format(number_of_labels),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -399,7 +461,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m2.tags, m2.tags,
m2, m2,
fail_msg="When sending a TAGMSG with a label, the target user shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a TAGMSG with a label, "
"the target user shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
self.assertIn( self.assertIn(
"+draft/reply", "+draft/reply",
@ -435,13 +501,19 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
m.tags, m.tags,
m, m,
fail_msg="When sending a TAGMSG with a label, the echo'd message didn't contain the label at all: {msg}", fail_msg=(
"When sending a TAGMSG with a label, "
"the echo'd message didn't contain the label at all: {msg}"
),
) )
self.assertEqual( self.assertEqual(
m.tags["label"], m.tags["label"],
"12345", "12345",
m, m,
fail_msg="Echo'd TAGMSG to a client did not contain the same label we sent it with(should be '12345'): {msg}", fail_msg=(
"Echo'd TAGMSG to a client did not contain the same label "
"we sent it with (should be '12345'): {msg}"
),
) )
self.assertIn( self.assertIn(
"+draft/reply", "+draft/reply",
@ -504,7 +576,11 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
mt.tags, mt.tags,
mt, mt,
fail_msg="When sending a TAGMSG with a label, the target user shouldn't receive the label (only the sending user should): {msg}", fail_msg=(
"When sending a TAGMSG with a label, "
"the target user shouldn't receive the label "
"(only the sending user should): {msg}"
),
) )
# ensure sender correctly receives msg # ensure sender correctly receives msg
@ -515,13 +591,19 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
"label", "label",
ms.tags, ms.tags,
ms, ms,
fail_msg="When sending a TAGMSG with a label, the source user should receive the label but didn't: {msg}", fail_msg=(
"When sending a TAGMSG with a label, "
"the source user should receive the label but didn't: {msg}"
),
) )
self.assertEqual( self.assertEqual(
ms.tags["label"], ms.tags["label"],
"12345", "12345",
ms, ms,
fail_msg="Echo'd label doesn't match the label we sent (should be '12345'): {msg}", fail_msg=(
"Echo'd label doesn't match the label we sent "
"(should be '12345'): {msg}"
),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -548,16 +630,21 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
m.tags["label"], m.tags["label"],
"12345", "12345",
m, m,
fail_msg="Echo'd label doesn't match the label we sent (should be '12345'): {msg}", fail_msg=(
"Echo'd label doesn't match the label we sent "
"(should be '12345'): {msg}"
),
) )
self.assertEqual( self.assertEqual(
number_of_labels, number_of_labels,
1, 1,
m1, m1,
fail_msg="When sending a TAGMSG to self with echo-message, we only expect one message to contain the label. Instead, {} messages had the label".format( fail_msg=(
number_of_labels "When sending a TAGMSG to self with echo-message, "
), "we only expect one message to contain the label. "
"Instead, {} messages had the label"
).format(number_of_labels),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -609,7 +696,8 @@ class LabeledResponsesTestCase(cases.BaseServerTestCase, cases.OptionalityHelper
self.getMessages(1) self.getMessages(1)
self.sendLine(1, "@label=98765 PING adhoctestline") self.sendLine(1, "@label=98765 PING adhoctestline")
# no BATCH should be initiated for a one-line response, it should just be labeled # no BATCH should be initiated for a one-line response,
# it should just be labeled
ms = self.getMessages(1) ms = self.getMessages(1)
self.assertEqual(len(ms), 1) self.assertEqual(len(ms), 1)
m = ms[0] m = ms[0]

View File

@ -55,7 +55,7 @@ class LusersTestCase(cases.BaseServerTestCase):
result.GlobalVisible = int(match.group(1)) result.GlobalVisible = int(match.group(1))
result.GlobalInvisible = int(match.group(2)) result.GlobalInvisible = int(match.group(2))
result.Servers = int(match.group(3)) result.Servers = int(match.group(3))
except: except Exception:
raise ValueError("corrupt reply for 251 RPL_LUSERCLIENT", luserclient_param) raise ValueError("corrupt reply for 251 RPL_LUSERCLIENT", luserclient_param)
if RPL_LUSEROP in by_numeric: if RPL_LUSEROP in by_numeric:
@ -78,7 +78,7 @@ class LusersTestCase(cases.BaseServerTestCase):
match = LUSERME_REGEX.match(luserme_param) match = LUSERME_REGEX.match(luserme_param)
localTotalFromUserme = int(match.group(1)) localTotalFromUserme = int(match.group(1))
serversFromUserme = int(match.group(2)) serversFromUserme = int(match.group(2))
except: except Exception:
raise ValueError("corrupt reply for 255 RPL_LUSERME", luserme_param) raise ValueError("corrupt reply for 255 RPL_LUSERME", luserme_param)
self.assertEqual(result.LocalTotal, localTotalFromUserme) self.assertEqual(result.LocalTotal, localTotalFromUserme)
# serversFromUserme is "servers i'm currently connected to", generally undefined # serversFromUserme is "servers i'm currently connected to", generally undefined

View File

@ -72,7 +72,7 @@ class MessageTagsTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
getAllMessages() getAllMessages()
# test TAGMSG and basic escaping # test TAGMSG and basic escaping
self.sendLine("bob", "@+buzz=fizz\:buzz;cat=dog;+steel=wootz TAGMSG #test") self.sendLine("bob", r"@+buzz=fizz\:buzz;cat=dog;+steel=wootz TAGMSG #test")
bob_msg = self.getMessage("bob") # bob has echo-message bob_msg = self.getMessage("bob") # bob has echo-message
alice_msg = self.getMessage("alice") alice_msg = self.getMessage("alice")
# carol MUST NOT receive TAGMSG at all # carol MUST NOT receive TAGMSG at all

View File

@ -132,10 +132,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
command="761", # RPL_KEYVALUE command="761", # RPL_KEYVALUE
fail_msg="Did not reply with 761 (RPL_KEYVALUE) to a valid " fail_msg="Did not reply with 761 (RPL_KEYVALUE) to a valid "
"“METADATA * SET {} :{}”: {msg}", "“METADATA * SET {} :{}”: {msg}",
extra_format=( extra_format=(key, displayable_value),
key,
displayable_value,
),
) )
self.assertEqual( self.assertEqual(
m.params[1], m.params[1],

View File

@ -263,19 +263,27 @@ class MonitorTestCase(cases.BaseServerTestCase):
self.getMessages(1) self.getMessages(1)
self.getMessages(2) self.getMessages(2)
self.sendLine(2, "MONITOR - qux") self.sendLine(2, "MONITOR - qux")
l = self.getMessages(2) messages = self.getMessages(2)
self.assertEqual( self.assertEqual(
l, [], fail_msg="Got response to “MONITOR -”: {}", extra_format=(l,) messages,
[],
fail_msg="Got response to “MONITOR -”: {}",
extra_format=(messages,),
) )
self.connectClient("qux") self.connectClient("qux")
self.getMessages(3) self.getMessages(3)
l = self.getMessages(1) messages = self.getMessages(1)
self.assertNotEqual( self.assertNotEqual(
l, [], fail_msg="Received no message after MONITORed client " "connects." messages,
[],
fail_msg="Received no message after MONITORed client " "connects.",
) )
l = self.getMessages(2) messages = self.getMessages(2)
self.assertEqual( self.assertEqual(
l, [], fail_msg="Got response to unmonitored client: {}", extra_format=(l,) messages,
[],
fail_msg="Got response to unmonitored client: {}",
extra_format=(messages,),
) )
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
@ -300,36 +308,17 @@ class MonitorTestCase(cases.BaseServerTestCase):
self.sendLine(1, "MONITOR + qux") self.sendLine(1, "MONITOR + qux")
self.getMessages(1) self.getMessages(1)
self.sendLine(1, "MONITOR L") self.sendLine(1, "MONITOR L")
checkMonitorSubjects( checkMonitorSubjects(self.getMessages(1), "bar", {"qux"})
self.getMessages(1),
"bar",
{
"qux",
},
)
self.sendLine(1, "MONITOR + bazbat") self.sendLine(1, "MONITOR + bazbat")
self.getMessages(1) self.getMessages(1)
self.sendLine(1, "MONITOR L") self.sendLine(1, "MONITOR L")
checkMonitorSubjects( checkMonitorSubjects(self.getMessages(1), "bar", {"qux", "bazbat"})
self.getMessages(1),
"bar",
{
"qux",
"bazbat",
},
)
self.sendLine(1, "MONITOR - qux") self.sendLine(1, "MONITOR - qux")
self.getMessages(1) self.getMessages(1)
self.sendLine(1, "MONITOR L") self.sendLine(1, "MONITOR L")
checkMonitorSubjects( checkMonitorSubjects(self.getMessages(1), "bar", {"bazbat"})
self.getMessages(1),
"bar",
{
"bazbat",
},
)
@cases.SpecificationSelector.requiredBySpecification("IRCv3.2") @cases.SpecificationSelector.requiredBySpecification("IRCv3.2")
def testNickChange(self): def testNickChange(self):

View File

@ -9,9 +9,7 @@ RELAYMSG_TAG_NAME = "draft/relaymsg"
class RelaymsgTestCase(cases.BaseServerTestCase): class RelaymsgTestCase(cases.BaseServerTestCase):
@staticmethod @staticmethod
def config(): def config():
return { return {"chathistory": True}
"chathistory": True,
}
@cases.SpecificationSelector.requiredBySpecification("Oragono") @cases.SpecificationSelector.requiredBySpecification("Oragono")
def testRelaymsg(self): def testRelaymsg(self):

View File

@ -63,8 +63,8 @@ class ResumeTestCase(cases.BaseServerTestCase):
) )
channelMsgTime = privmsgs[0].tags.get("time") channelMsgTime = privmsgs[0].tags.get("time")
# tokens MUST be cryptographically secure; therefore, this token should be invalid # tokens MUST be cryptographically secure; therefore, this token should be
# with probability at least 1 - 1/(2**128) # invalid with probability at least 1 - 1/(2**128)
bad_token = "a" * len(token) bad_token = "a" * len(token)
self.addClient() self.addClient()
self.sendLine(3, "CAP LS") self.sendLine(3, "CAP LS")
@ -127,8 +127,8 @@ class ResumeTestCase(cases.BaseServerTestCase):
privmsgs[1], command="PRIVMSG", params=["baz", "hello friend singular"] privmsgs[1], command="PRIVMSG", params=["baz", "hello friend singular"]
) )
# should replay with the original server-time # should replay with the original server-time
# TODO this probably isn't testing anything because the timestamp only has second resolution, # TODO this probably isn't testing anything because the timestamp only
# hence will typically match by accident # has second resolution, hence will typically match by accident
self.assertEqual(privmsgs[0].tags.get("time"), channelMsgTime) self.assertEqual(privmsgs[0].tags.get("time"), channelMsgTime)
# legacy client should receive a QUIT and a JOIN # legacy client should receive a QUIT and a JOIN

View File

@ -6,9 +6,7 @@ from irctest.numerics import ERR_CANNOTSENDRP
class RoleplayTestCase(cases.BaseServerTestCase): class RoleplayTestCase(cases.BaseServerTestCase):
@staticmethod @staticmethod
def config(): def config():
return { return {"oragono_roleplay": True}
"oragono_roleplay": True,
}
@cases.SpecificationSelector.requiredBySpecification("Oragono") @cases.SpecificationSelector.requiredBySpecification("Oragono")
def testRoleplay(self): def testRoleplay(self):

View File

@ -11,7 +11,8 @@ class StatusmsgTestCase(cases.BaseServerTestCase):
@cases.SpecificationSelector.requiredBySpecification("Oragono") @cases.SpecificationSelector.requiredBySpecification("Oragono")
def testStatusmsg(self): def testStatusmsg(self):
"""Test that STATUSMSG are sent to the intended recipients, with the intended prefixes.""" """Test that STATUSMSG are sent to the intended recipients,
with the intended prefixes."""
self.connectClient("chanop") self.connectClient("chanop")
self.joinChannel(1, "#chan") self.joinChannel(1, "#chan")
self.getMessages(1) self.getMessages(1)

View File

@ -20,9 +20,7 @@ def extract_playback_privmsgs(messages):
class ZncPlaybackTestCase(cases.BaseServerTestCase): class ZncPlaybackTestCase(cases.BaseServerTestCase):
@staticmethod @staticmethod
def config(): def config():
return { return {"chathistory": True}
"chathistory": True,
}
@cases.SpecificationSelector.requiredBySpecification("Oragono") @cases.SpecificationSelector.requiredBySpecification("Oragono")
def testZncPlayback(self): def testZncPlayback(self):
@ -112,7 +110,8 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase):
password=pw, password=pw,
) )
mid_timestamp = ircv3_timestamp_to_unixtime(echo_messages[5].time) mid_timestamp = ircv3_timestamp_to_unixtime(echo_messages[5].time)
# exclude message 5 itself (oragono's CHATHISTORY implementation corrects for this, but znc.in/playback does not because whatever) # exclude message 5 itself (oragono's CHATHISTORY implementation
# corrects for this, but znc.in/playback does not because whatever)
mid_timestamp += 0.001 mid_timestamp += 0.001
self.sendLine("viewer", "PRIVMSG *playback :play * %s" % (mid_timestamp,)) self.sendLine("viewer", "PRIVMSG *playback :play * %s" % (mid_timestamp,))
messages = extract_playback_privmsgs(self.getMessages("viewer")) messages = extract_playback_privmsgs(self.getMessages("viewer"))
@ -139,32 +138,16 @@ class ZncPlaybackTestCase(cases.BaseServerTestCase):
self.sendLine( self.sendLine(
"viewer", "viewer",
"PRIVMSG *playback :play %s %s %s" "PRIVMSG *playback :play %s %s %s"
% ( % (chname, start_timestamp, end_timestamp),
chname,
start_timestamp,
end_timestamp,
),
) )
messages = extract_playback_privmsgs(self.getMessages("viewer")) messages = extract_playback_privmsgs(self.getMessages("viewer"))
self.assertEqual(messages, echo_messages[3:7]) self.assertEqual(messages, echo_messages[3:7])
# test nicknames as targets # test nicknames as targets
self.sendLine( self.sendLine("viewer", "PRIVMSG *playback :play %s %d" % (qux, early_time))
"viewer",
"PRIVMSG *playback :play %s %d"
% (
qux,
early_time,
),
)
messages = extract_playback_privmsgs(self.getMessages("viewer")) messages = extract_playback_privmsgs(self.getMessages("viewer"))
self.assertEqual(messages, [dm]) self.assertEqual(messages, [dm])
self.sendLine( self.sendLine(
"viewer", "viewer", "PRIVMSG *playback :play %s %d" % (qux.upper(), early_time)
"PRIVMSG *playback :play %s %d"
% (
qux.upper(),
early_time,
),
) )
messages = extract_playback_privmsgs(self.getMessages("viewer")) messages = extract_playback_privmsgs(self.getMessages("viewer"))
self.assertEqual(messages, [dm]) self.assertEqual(messages, [dm])