mirror of
https://github.com/progval/irctest.git
synced 2025-04-04 14:29:46 +00:00
Remove Ergo-specific configuration from draft/account-registration (#239)
This commit is contained in:
@ -38,6 +38,14 @@ class TestCaseControllerConfig:
|
||||
chathistory: bool = False
|
||||
"""Whether to enable chathistory features."""
|
||||
|
||||
account_registration_before_connect: bool = False
|
||||
"""Whether draft/account-registration should be allowed before completing
|
||||
connection registration (NICK + USER + CAP END)"""
|
||||
|
||||
account_registration_requires_email: bool = False
|
||||
"""Whether an email address must be provided when using draft/account-registration.
|
||||
This does not imply servers must validate it."""
|
||||
|
||||
ergo_roleplay: bool = False
|
||||
"""Whether to enable the Ergo role-play commands."""
|
||||
|
||||
|
@ -166,6 +166,16 @@ class ErgoController(BaseServerController, DirectoryBasedController):
|
||||
if enable_roleplay:
|
||||
config["roleplay"] = {"enabled": True}
|
||||
|
||||
if self.test_config.account_registration_before_connect:
|
||||
config["accounts"]["registration"]["allow-before-connect"] = True # type: ignore
|
||||
if self.test_config.account_registration_requires_email:
|
||||
config["accounts"]["registration"]["email-verification"] = { # type: ignore
|
||||
"enabled": True,
|
||||
"sender": "test@example.com",
|
||||
"require-tls": True,
|
||||
"helo-domain": "example.com",
|
||||
}
|
||||
|
||||
if self.test_config.ergo_config:
|
||||
self.test_config.ergo_config(config)
|
||||
|
||||
|
@ -314,6 +314,11 @@ class SableController(BaseServerController, DirectoryBasedController):
|
||||
raise NotImplementedByController("PASS command")
|
||||
if ssl:
|
||||
raise NotImplementedByController("SSL")
|
||||
if self.test_config.account_registration_before_connect:
|
||||
raise NotImplementedByController("account-registration with before-connect")
|
||||
if self.test_config.account_registration_requires_email:
|
||||
raise NotImplementedByController("account-registration with email-required")
|
||||
|
||||
assert self.proc is None
|
||||
self.port = port
|
||||
self.create_config()
|
||||
|
@ -15,9 +15,8 @@ class RegisterBeforeConnectTestCase(cases.BaseServerTestCase):
|
||||
@staticmethod
|
||||
def config() -> cases.TestCaseControllerConfig:
|
||||
return cases.TestCaseControllerConfig(
|
||||
ergo_config=lambda config: config["accounts"]["registration"].update(
|
||||
{"allow-before-connect": True}
|
||||
)
|
||||
account_registration_requires_email=False,
|
||||
account_registration_before_connect=True,
|
||||
)
|
||||
|
||||
def testBeforeConnect(self):
|
||||
@ -26,7 +25,7 @@ class RegisterBeforeConnectTestCase(cases.BaseServerTestCase):
|
||||
self.sendLine("bar", "CAP LS 302")
|
||||
caps = self.getCapLs("bar")
|
||||
self.assertIn(REGISTER_CAP_NAME, caps)
|
||||
self.assertIn("before-connect", caps[REGISTER_CAP_NAME])
|
||||
self.assertIn("before-connect", caps[REGISTER_CAP_NAME] or "")
|
||||
self.sendLine("bar", "NICK bar")
|
||||
self.sendLine("bar", "REGISTER * * shivarampassphrase")
|
||||
msgs = self.getMessages("bar")
|
||||
@ -40,9 +39,8 @@ class RegisterBeforeConnectDisallowedTestCase(cases.BaseServerTestCase):
|
||||
@staticmethod
|
||||
def config() -> cases.TestCaseControllerConfig:
|
||||
return cases.TestCaseControllerConfig(
|
||||
ergo_config=lambda config: config["accounts"]["registration"].update(
|
||||
{"allow-before-connect": False}
|
||||
)
|
||||
account_registration_requires_email=False,
|
||||
account_registration_before_connect=False,
|
||||
)
|
||||
|
||||
def testBeforeConnect(self):
|
||||
@ -51,7 +49,7 @@ class RegisterBeforeConnectDisallowedTestCase(cases.BaseServerTestCase):
|
||||
self.sendLine("bar", "CAP LS 302")
|
||||
caps = self.getCapLs("bar")
|
||||
self.assertIn(REGISTER_CAP_NAME, caps)
|
||||
self.assertEqual(caps[REGISTER_CAP_NAME], None)
|
||||
self.assertNotIn("before-connect", caps[REGISTER_CAP_NAME] or "")
|
||||
self.sendLine("bar", "NICK bar")
|
||||
self.sendLine("bar", "REGISTER * * shivarampassphrase")
|
||||
msgs = self.getMessages("bar")
|
||||
@ -64,21 +62,12 @@ class RegisterBeforeConnectDisallowedTestCase(cases.BaseServerTestCase):
|
||||
|
||||
@cases.mark_services
|
||||
@cases.mark_specifications("IRCv3")
|
||||
class RegisterEmailVerifiedTestCase(cases.BaseServerTestCase):
|
||||
class RegisterEmailVerifiedBeforeConnectTestCase(cases.BaseServerTestCase):
|
||||
@staticmethod
|
||||
def config() -> cases.TestCaseControllerConfig:
|
||||
return cases.TestCaseControllerConfig(
|
||||
ergo_config=lambda config: config["accounts"]["registration"].update(
|
||||
{
|
||||
"email-verification": {
|
||||
"enabled": True,
|
||||
"sender": "test@example.com",
|
||||
"require-tls": True,
|
||||
"helo-domain": "example.com",
|
||||
},
|
||||
"allow-before-connect": True,
|
||||
}
|
||||
)
|
||||
account_registration_requires_email=True,
|
||||
account_registration_before_connect=True,
|
||||
)
|
||||
|
||||
def testBeforeConnect(self):
|
||||
@ -89,10 +78,8 @@ class RegisterEmailVerifiedTestCase(cases.BaseServerTestCase):
|
||||
self.sendLine("bar", "CAP LS 302")
|
||||
caps = self.getCapLs("bar")
|
||||
self.assertIn(REGISTER_CAP_NAME, caps)
|
||||
self.assertEqual(
|
||||
set(caps[REGISTER_CAP_NAME].split(",")),
|
||||
{"before-connect", "email-required"},
|
||||
)
|
||||
self.assertIn("email-required", caps[REGISTER_CAP_NAME] or "")
|
||||
self.assertIn("before-connect", caps[REGISTER_CAP_NAME] or "")
|
||||
self.sendLine("bar", "NICK bar")
|
||||
self.sendLine("bar", "REGISTER * * shivarampassphrase")
|
||||
msgs = self.getMessages("bar")
|
||||
@ -101,10 +88,25 @@ class RegisterEmailVerifiedTestCase(cases.BaseServerTestCase):
|
||||
fail_response, params=["REGISTER", "INVALID_EMAIL", ANYSTR, ANYSTR]
|
||||
)
|
||||
|
||||
|
||||
@cases.mark_services
|
||||
@cases.mark_specifications("IRCv3")
|
||||
class RegisterEmailVerifiedAfterConnectTestCase(cases.BaseServerTestCase):
|
||||
@staticmethod
|
||||
def config() -> cases.TestCaseControllerConfig:
|
||||
return cases.TestCaseControllerConfig(
|
||||
account_registration_before_connect=False,
|
||||
account_registration_requires_email=True,
|
||||
)
|
||||
|
||||
def testAfterConnect(self):
|
||||
self.connectClient(
|
||||
"bar", name="bar", capabilities=[REGISTER_CAP_NAME], skip_if_cap_nak=True
|
||||
)
|
||||
self.sendLine("bar", "CAP LS 302")
|
||||
caps = self.getCapLs("bar")
|
||||
self.assertIn(REGISTER_CAP_NAME, caps)
|
||||
self.assertIn("email-required", caps[REGISTER_CAP_NAME] or "")
|
||||
self.sendLine("bar", "REGISTER * * shivarampassphrase")
|
||||
msgs = self.getMessages("bar")
|
||||
fail_response = [msg for msg in msgs if msg.command == "FAIL"][0]
|
||||
@ -119,9 +121,8 @@ class RegisterNoLandGrabsTestCase(cases.BaseServerTestCase):
|
||||
@staticmethod
|
||||
def config() -> cases.TestCaseControllerConfig:
|
||||
return cases.TestCaseControllerConfig(
|
||||
ergo_config=lambda config: config["accounts"]["registration"].update(
|
||||
{"allow-before-connect": True}
|
||||
)
|
||||
account_registration_requires_email=False,
|
||||
account_registration_before_connect=True,
|
||||
)
|
||||
|
||||
def testBeforeConnect(self):
|
||||
|
Reference in New Issue
Block a user