From f18162c02ddabb4599d3208f6ed4a7be242b4bb1 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 15 Apr 2023 18:56:27 +0200 Subject: [PATCH] Add untested 'before-connect' test --- irctest/server_tests/metadata_2.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/irctest/server_tests/metadata_2.py b/irctest/server_tests/metadata_2.py index fad89f0..a77cf5b 100644 --- a/irctest/server_tests/metadata_2.py +++ b/irctest/server_tests/metadata_2.py @@ -8,7 +8,7 @@ import itertools import pytest -from irctest import cases +from irctest import cases, runner from irctest.patma import ANYDICT, ANYSTR, StrRe @@ -165,6 +165,29 @@ class MetadataTestCase(cases.BaseServerTestCase): self.assertSetValue(set_target, "valid_key1", "myvalue") self.assertGetValue(get_target, "valid_key1", "myvalue") + @cases.mark_specifications("IRCv3") + def testSetGetValidBeforeConnect(self): + """""" + self.addClient(1) + + self.sendLine(1, "CAP LS 302") + caps = self.getCapLs(1) + if "before-connect" not in (caps["draft/metadata-2"] or "").split(","): + raise runner.OptionalExtensionNotSupported( + "draft/metadata-2=before-connect" + ) + + self.requestCapabilities(1, ["draft/metadata-2", "batch"], skip_if_cap_nak=True) + + self.assertSetValue("*", "valid_key1", "myvalue") + + self.sendLine(1, "NICK foo") + self.sendLine(1, "USER foo 0 * :foo") + self.sendLine(1, "CAP END") + self.skipToWelcome(1) + + self.assertGetValue("*", "valid_key1", "myvalue") + @cases.mark_specifications("IRCv3") def testSetGetHeartInValue(self): """“Values are unrestricted, except that they MUST be UTF-8.”