mirror of
https://github.com/progval/irctest.git
synced 2025-04-04 22:39:50 +00:00
Use real metadata keys (#194)
This commit is contained in:
@ -261,8 +261,6 @@ class BaseServerController(_BaseController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]],
|
||||
invalid_metadata_keys: Optional[Set[str]],
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
raise NotImplementedError()
|
||||
|
@ -529,8 +529,6 @@ class BaseServerTestCase(
|
||||
|
||||
password: Optional[str] = None
|
||||
ssl = False
|
||||
valid_metadata_keys: Set[str] = set()
|
||||
invalid_metadata_keys: Set[str] = set()
|
||||
server_support: Optional[Dict[str, Optional[str]]]
|
||||
run_services = False
|
||||
|
||||
@ -550,8 +548,6 @@ class BaseServerTestCase(
|
||||
self.hostname,
|
||||
self.port,
|
||||
password=self.password,
|
||||
valid_metadata_keys=self.valid_metadata_keys,
|
||||
invalid_metadata_keys=self.invalid_metadata_keys,
|
||||
ssl=self.ssl,
|
||||
run_services=self.run_services,
|
||||
faketime=self.faketime,
|
||||
|
@ -3,11 +3,7 @@ import shutil
|
||||
import subprocess
|
||||
from typing import Optional, Set, Type
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
global {{
|
||||
@ -111,15 +107,8 @@ class BahamutController(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
restricted_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
assert self.proc is None
|
||||
self.port = port
|
||||
self.hostname = hostname
|
||||
|
@ -1,12 +1,8 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Optional, Set
|
||||
from typing import Optional
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
|
||||
TEMPLATE_SSL_CONFIG = """
|
||||
ssl_private_key = "{key_path}";
|
||||
@ -40,14 +36,8 @@ class BaseHybridController(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
assert self.proc is None
|
||||
self.port = port
|
||||
self.hostname = hostname
|
||||
|
@ -3,13 +3,9 @@ import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Any, Dict, Optional, Set, Type, Union
|
||||
from typing import Any, Dict, Optional, Type, Union
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
from irctest.cases import BaseServerTestCase
|
||||
|
||||
BASE_CONFIG = {
|
||||
@ -153,17 +149,9 @@ class ErgoController(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
restricted_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
config: Optional[Any] = None,
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
|
||||
self.create_config()
|
||||
if config is None:
|
||||
config = copy.deepcopy(BASE_CONFIG)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import os
|
||||
from typing import Optional, Set, Tuple, Type
|
||||
from typing import Optional, Tuple, Type
|
||||
|
||||
from irctest.basecontrollers import BaseServerController
|
||||
|
||||
@ -39,9 +39,6 @@ class ExternalServerController(BaseServerController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
restricted_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
pass
|
||||
|
@ -1,13 +1,9 @@
|
||||
import functools
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Optional, Set, Type
|
||||
from typing import Optional, Type
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
# Clients:
|
||||
@ -124,15 +120,8 @@ class InspircdController(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
restricted_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str] = None,
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
assert self.proc is None
|
||||
self.port = port
|
||||
self.hostname = hostname
|
||||
|
@ -1,6 +1,6 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Optional, Set, Type
|
||||
from typing import Optional, Type
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
@ -49,14 +49,8 @@ class Irc2Controller(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
if ssl:
|
||||
raise NotImplementedByController("TLS")
|
||||
if run_services:
|
||||
|
@ -1,6 +1,6 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Optional, Set, Type
|
||||
from typing import Optional, Type
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
@ -68,14 +68,8 @@ class Ircu2Controller(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
if ssl:
|
||||
raise NotImplementedByController("TLS")
|
||||
if run_services:
|
||||
|
@ -33,10 +33,10 @@ extensions:
|
||||
- mammon.ext.ircv3.sasl
|
||||
- mammon.ext.misc.nopost
|
||||
metadata:
|
||||
restricted_keys:
|
||||
{restricted_keys}
|
||||
restricted_keys: []
|
||||
whitelist:
|
||||
{authorized_keys}
|
||||
- display-name
|
||||
- avatar
|
||||
monitor:
|
||||
limit: 20
|
||||
motd:
|
||||
@ -89,9 +89,6 @@ class MammonController(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
restricted_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
if password is not None:
|
||||
@ -107,8 +104,6 @@ class MammonController(BaseServerController, DirectoryBasedController):
|
||||
directory=self.directory,
|
||||
hostname=hostname,
|
||||
port=port,
|
||||
authorized_keys=make_list(valid_metadata_keys or set()),
|
||||
restricted_keys=make_list(restricted_metadata_keys or set()),
|
||||
)
|
||||
)
|
||||
# with self.open_file('server.yml', 'r') as fd:
|
||||
|
@ -2,11 +2,7 @@ import shutil
|
||||
import subprocess
|
||||
from typing import Optional, Set, Type
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
[Global]
|
||||
@ -52,15 +48,8 @@ class NgircdController(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
restricted_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
assert self.proc is None
|
||||
self.port = port
|
||||
self.hostname = hostname
|
||||
|
@ -1,6 +1,6 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Optional, Set, Type
|
||||
from typing import Optional, Type
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
@ -67,14 +67,8 @@ class SnircdController(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
if ssl:
|
||||
raise NotImplementedByController("TLS")
|
||||
if run_services:
|
||||
|
@ -5,13 +5,9 @@ from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import textwrap
|
||||
from typing import Callable, ContextManager, Iterator, Optional, Set, Type
|
||||
from typing import Callable, ContextManager, Iterator, Optional, Type
|
||||
|
||||
from irctest.basecontrollers import (
|
||||
BaseServerController,
|
||||
DirectoryBasedController,
|
||||
NotImplementedByController,
|
||||
)
|
||||
from irctest.basecontrollers import BaseServerController, DirectoryBasedController
|
||||
|
||||
TEMPLATE_CONFIG = """
|
||||
include "modules.default.conf";
|
||||
@ -203,15 +199,8 @@ class UnrealircdController(BaseServerController, DirectoryBasedController):
|
||||
password: Optional[str],
|
||||
ssl: bool,
|
||||
run_services: bool,
|
||||
valid_metadata_keys: Optional[Set[str]] = None,
|
||||
invalid_metadata_keys: Optional[Set[str]] = None,
|
||||
restricted_metadata_keys: Optional[Set[str]] = None,
|
||||
faketime: Optional[str],
|
||||
) -> None:
|
||||
if valid_metadata_keys or invalid_metadata_keys:
|
||||
raise NotImplementedByController(
|
||||
"Defining valid and invalid METADATA keys."
|
||||
)
|
||||
assert self.proc is None
|
||||
self.port = port
|
||||
self.hostname = hostname
|
||||
|
@ -6,8 +6,8 @@ from irctest import cases
|
||||
|
||||
|
||||
class MetadataTestCase(cases.BaseServerTestCase):
|
||||
valid_metadata_keys = {"valid_key1", "valid_key2"}
|
||||
invalid_metadata_keys = {"invalid_key1", "invalid_key2"}
|
||||
valid_metadata_keys = {"display-name", "avatar"}
|
||||
invalid_metadata_keys = {"indisplay-name", "inavatar"}
|
||||
|
||||
@cases.mark_specifications("IRCv3", deprecated=True)
|
||||
def testInIsupport(self):
|
||||
@ -36,7 +36,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
def testGetOneUnsetValid(self):
|
||||
"""<http://ircv3.net/specs/core/metadata-3.2.html#metadata-get>"""
|
||||
self.connectClient("foo")
|
||||
self.sendLine(1, "METADATA * GET valid_key1")
|
||||
self.sendLine(1, "METADATA * GET display-name")
|
||||
m = self.getMessage(1)
|
||||
self.assertMessageMatch(
|
||||
m,
|
||||
@ -52,7 +52,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
-- <http://ircv3.net/specs/core/metadata-3.2.html#metadata-get>
|
||||
"""
|
||||
self.connectClient("foo")
|
||||
self.sendLine(1, "METADATA * GET valid_key1 valid_key2")
|
||||
self.sendLine(1, "METADATA * GET display-name avatar")
|
||||
m = self.getMessage(1)
|
||||
self.assertMessageMatch(
|
||||
m,
|
||||
@ -62,10 +62,10 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
)
|
||||
self.assertEqual(
|
||||
m.params[1],
|
||||
"valid_key1",
|
||||
"display-name",
|
||||
m,
|
||||
fail_msg="Response to “METADATA * GET valid_key1 valid_key2” "
|
||||
"did not respond to valid_key1 first: {msg}",
|
||||
fail_msg="Response to “METADATA * GET display-name avatar” "
|
||||
"did not respond to display-name first: {msg}",
|
||||
)
|
||||
m = self.getMessage(1)
|
||||
self.assertMessageMatch(
|
||||
@ -76,10 +76,10 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
)
|
||||
self.assertEqual(
|
||||
m.params[1],
|
||||
"valid_key2",
|
||||
"avatar",
|
||||
m,
|
||||
fail_msg="Response to “METADATA * GET valid_key1 valid_key2” "
|
||||
"did not respond to valid_key2 as second response: {msg}",
|
||||
fail_msg="Response to “METADATA * GET display-name avatar” "
|
||||
"did not respond to avatar as second response: {msg}",
|
||||
)
|
||||
|
||||
@cases.mark_specifications("IRCv3", deprecated=True)
|
||||
@ -135,7 +135,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
)
|
||||
self.assertEqual(
|
||||
m.params[1],
|
||||
"valid_key1",
|
||||
"display-name",
|
||||
m,
|
||||
fail_msg="Second param of 761 after setting “{expects}” to "
|
||||
"“{}” is not “{expects}”: {msg}.",
|
||||
@ -190,7 +190,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
def testSetGetValid(self):
|
||||
"""<http://ircv3.net/specs/core/metadata-3.2.html>"""
|
||||
self.connectClient("foo")
|
||||
self.assertSetGetValue("*", "valid_key1", "myvalue")
|
||||
self.assertSetGetValue("*", "display-name", "myvalue")
|
||||
|
||||
@cases.mark_specifications("IRCv3", deprecated=True)
|
||||
def testSetGetZeroCharInValue(self):
|
||||
@ -198,7 +198,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
-- <http://ircv3.net/specs/core/metadata-3.2.html#metadata-restrictions>
|
||||
"""
|
||||
self.connectClient("foo")
|
||||
self.assertSetGetValue("*", "valid_key1", "zero->\0<-zero", "zero->\\0<-zero")
|
||||
self.assertSetGetValue("*", "display-name", "zero->\0<-zero", "zero->\\0<-zero")
|
||||
|
||||
@cases.mark_specifications("IRCv3", deprecated=True)
|
||||
def testSetGetHeartInValue(self):
|
||||
@ -209,7 +209,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
self.connectClient("foo")
|
||||
self.assertSetGetValue(
|
||||
"*",
|
||||
"valid_key1",
|
||||
"display-name",
|
||||
"->{}<-".format(heart),
|
||||
"zero->{}<-zero".format(heart.encode()),
|
||||
)
|
||||
@ -223,7 +223,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
# Sending directly because it is not valid UTF-8 so Python would
|
||||
# not like it
|
||||
self.clients[1].conn.sendall(
|
||||
b"METADATA * SET valid_key1 " b":invalid UTF-8 ->\xc3<-\r\n"
|
||||
b"METADATA * SET display-name " b":invalid UTF-8 ->\xc3<-\r\n"
|
||||
)
|
||||
commands = {m.command for m in self.getMessages(1)}
|
||||
self.assertNotIn(
|
||||
@ -233,7 +233,7 @@ class MetadataTestCase(cases.BaseServerTestCase):
|
||||
"UTF-8 was answered with 761 (RPL_KEYVALUE)",
|
||||
)
|
||||
self.clients[1].conn.sendall(
|
||||
b"METADATA * SET valid_key1 " b":invalid UTF-8: \xc3\r\n"
|
||||
b"METADATA * SET display-name " b":invalid UTF-8: \xc3\r\n"
|
||||
)
|
||||
commands = {m.command for m in self.getMessages(1)}
|
||||
self.assertNotIn(
|
||||
|
Reference in New Issue
Block a user