mirror of
https://github.com/progval/irctest.git
synced 2025-04-05 14:59:49 +00:00
Always request the 'sasl' cap before using AUTHENTICATE
InspIRCd ignores AUTHENTICATE when the cap is not negotiated.
This commit is contained in:
@ -561,6 +561,27 @@ class BaseServerTestCase(
|
||||
if m.command == "001":
|
||||
return result
|
||||
|
||||
def requestCapabilities(
|
||||
self,
|
||||
client: TClientName,
|
||||
capabilities: List[str],
|
||||
skip_if_cap_nak: bool = False,
|
||||
) -> None:
|
||||
self.sendLine(client, "CAP REQ :{}".format(" ".join(capabilities)))
|
||||
m = self.getRegistrationMessage(client)
|
||||
try:
|
||||
self.assertMessageMatch(
|
||||
m, command="CAP", fail_msg="Expected CAP ACK, got: {msg}"
|
||||
)
|
||||
self.assertEqual(
|
||||
m.params[1], "ACK", m, fail_msg="Expected CAP ACK, got: {msg}"
|
||||
)
|
||||
except AssertionError:
|
||||
if skip_if_cap_nak:
|
||||
raise runner.CapabilityNotSupported(" or ".join(capabilities))
|
||||
else:
|
||||
raise
|
||||
|
||||
def connectClient(
|
||||
self,
|
||||
nick: str,
|
||||
@ -580,20 +601,7 @@ class BaseServerTestCase(
|
||||
if capabilities:
|
||||
self.sendLine(client, "CAP LS 302")
|
||||
m = self.getRegistrationMessage(client)
|
||||
self.sendLine(client, "CAP REQ :{}".format(" ".join(capabilities)))
|
||||
m = self.getRegistrationMessage(client)
|
||||
try:
|
||||
self.assertMessageMatch(
|
||||
m, command="CAP", fail_msg="Expected CAP ACK, got: {msg}"
|
||||
)
|
||||
self.assertEqual(
|
||||
m.params[1], "ACK", m, fail_msg="Expected CAP ACK, got: {msg}"
|
||||
)
|
||||
except AssertionError:
|
||||
if skip_if_cap_nak:
|
||||
raise runner.CapabilityNotSupported(" or ".join(capabilities))
|
||||
else:
|
||||
raise
|
||||
self.requestCapabilities(client, capabilities, skip_if_cap_nak)
|
||||
if password is not None:
|
||||
if "sasl" not in (capabilities or ()):
|
||||
raise ValueError("Used 'password' option without sasl capbilitiy")
|
||||
|
@ -11,6 +11,7 @@ class MetadataTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
self.sendLine(2, "CAP LS 302")
|
||||
capabilities = self.getCapLs(2)
|
||||
assert "sasl" in capabilities
|
||||
self.requestCapabilities(2, ["sasl"], skip_if_cap_nak=False)
|
||||
self.sendLine(2, "AUTHENTICATE PLAIN")
|
||||
m = self.getRegistrationMessage(2)
|
||||
self.assertMessageMatch(
|
||||
|
@ -31,6 +31,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
capabilities["sasl"],
|
||||
fail_msg="Does not have PLAIN mechanism as the controller " "claims",
|
||||
)
|
||||
self.requestCapabilities(1, ["sasl"], skip_if_cap_nak=False)
|
||||
self.sendLine(1, "AUTHENTICATE PLAIN")
|
||||
m = self.getRegistrationMessage(1)
|
||||
self.assertMessageMatch(
|
||||
@ -90,6 +91,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
capabilities["sasl"],
|
||||
fail_msg="Does not have PLAIN mechanism as the controller " "claims",
|
||||
)
|
||||
self.requestCapabilities(1, ["sasl"], skip_if_cap_nak=False)
|
||||
self.sendLine(1, "AUTHENTICATE PLAIN")
|
||||
m = self.getRegistrationMessage(1)
|
||||
self.assertMessageMatch(
|
||||
@ -122,6 +124,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
capabilities,
|
||||
fail_msg="Does not have SASL as the controller claims.",
|
||||
)
|
||||
self.requestCapabilities(1, ["sasl"], skip_if_cap_nak=False)
|
||||
self.sendLine(1, "AUTHENTICATE FOO")
|
||||
m = self.getRegistrationMessage(1)
|
||||
self.assertMessageMatch(
|
||||
@ -155,6 +158,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
capabilities["sasl"],
|
||||
fail_msg="Does not have PLAIN mechanism as the controller " "claims",
|
||||
)
|
||||
self.requestCapabilities(1, ["sasl"], skip_if_cap_nak=False)
|
||||
self.sendLine(1, "AUTHENTICATE PLAIN")
|
||||
m = self.getRegistrationMessage(1)
|
||||
self.assertMessageMatch(
|
||||
@ -217,6 +221,7 @@ class SaslTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
capabilities["sasl"],
|
||||
fail_msg="Does not have PLAIN mechanism as the controller " "claims",
|
||||
)
|
||||
self.requestCapabilities(1, ["sasl"], skip_if_cap_nak=False)
|
||||
self.sendLine(1, "AUTHENTICATE PLAIN")
|
||||
m = self.getRegistrationMessage(1)
|
||||
self.assertMessageMatch(
|
||||
|
Reference in New Issue
Block a user