Skip to content

Commit a3c2110

Browse files
progvalslingamn
andauthored
Add tests for IRCv3 draft/metadata-2 (#228)
* Copy metadata.py to metadata2.py * Adapt metadata_2 to stdreplies, and run it on Unreal Passes on progval/unrealircd-contrib@3968354 * expect batches * Improve testing for invalid UTF8, and add test for too-long values * Test for nick instead of * as target * Fix fail code * Add untested 'before-connect' test * Add a bunch of GetSet tests * Add tests for KEY_NO_PERMISSION * Use real metadata keys * Add tests for SUB * enable metadata in ergo * rename deprecated test case * fix race condition * Fix failure on servers that don't implement draft/metadata-2 * accommodate UTF8ONLY spec * fix race condition * fix race condition * consolidate redundant test code * fix race condition * Download Unreal's third/metadata2 module * Don't install third/metadata2.c on Unreal 5 * Update third/metadata2.c so it builds on all Unreal versions * Only load third/metadata2 on Unreal 6 (it doesn't support Unreal 5) * confirm that friends do not receive updates for invalid values --------- Co-authored-by: Shivaram Lingamneni <[email protected]>
1 parent 15c847e commit a3c2110

File tree

10 files changed

+673
-4
lines changed

10 files changed

+673
-4
lines changed

.github/workflows/test-devel.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ jobs:
358358
run: |
359359
cd $GITHUB_WORKSPACE/unrealircd/
360360
cp $GITHUB_WORKSPACE/data/unreal/* .
361+
wget https://raw.githubusercontent.com/progval/unrealircd-contrib/50e839c2e2f1d8b9924126f34bc2f50965c0a557/files/metadata2.c -O src/modules/third/metadata2.c
361362
# Need to use a specific -march, because GitHub has inconsistent
362363
# architectures across workers, which result in random SIGILL with some
363364
# worker combinations

.github/workflows/test-stable.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ jobs:
399399
run: |
400400
cd $GITHUB_WORKSPACE/unrealircd/
401401
cp $GITHUB_WORKSPACE/data/unreal/* .
402+
wget https://raw.githubusercontent.com/progval/unrealircd-contrib/50e839c2e2f1d8b9924126f34bc2f50965c0a557/files/metadata2.c -O src/modules/third/metadata2.c
402403
# Need to use a specific -march, because GitHub has inconsistent
403404
# architectures across workers, which result in random SIGILL with some
404405
# worker combinations

irctest/client_mock.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,19 @@ def getMessages(
7474
continue
7575
if not synchronize:
7676
got_pong = True
77-
for line in data.decode().split("\r\n"):
77+
try:
78+
decoded_data = data.decode()
79+
except UnicodeDecodeError:
80+
print(
81+
"{time:.3f}{ssl} S -> {client} - failed to decode: {data!r}".format(
82+
time=time.time(),
83+
ssl=" (ssl)" if self.ssl else "",
84+
client=self.name,
85+
data=data,
86+
)
87+
)
88+
raise
89+
for line in decoded_data.split("\r\n"):
7890
if line:
7991
if self.show_io:
8092
print(

irctest/controllers/ergo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@
118118
"password": "$2a$04$bKb6k5A6yuFA2wx.iJtxcuT2dojHQAjHd5ZPK/I2sjJml7p4spxjG",
119119
}
120120
},
121+
"metadata": {
122+
"enabled": True,
123+
"max-subs": 100,
124+
"max-keys": 1000,
125+
},
121126
}
122127

123128
LOGGING_CONFIG = {"logging": [{"method": "stderr", "level": "debug", "type": "*"}]}

irctest/controllers/unrealircd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def run(
211211
"""
212212
include "snomasks.default.conf";
213213
loadmodule "cloak_md5";
214+
loadmodule "third/metadata2";
214215
"""
215216
)
216217
set_v6only = SET_V6ONLY

irctest/numerics.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@
186186
RPL_MONLIST = "732"
187187
RPL_ENDOFMONLIST = "733"
188188
ERR_MONLISTFULL = "734"
189+
RPL_WHOISKEYVALUE = "760"
190+
RPL_KEYVALUE = "761"
191+
RPL_KEYNOTSET = "766"
192+
RPL_METADATASUBOK = "770"
193+
RPL_METADATAUNSUBOK = "771"
194+
RPL_METADATASUBS = "772"
195+
RPL_METADATASYNCLATER = "774"
189196
RPL_LOGGEDIN = "900"
190197
RPL_LOGGEDOUT = "901"
191198
ERR_NICKLOCKED = "902"

irctest/server_tests/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from irctest import cases
66

77

8-
class MetadataTestCase(cases.BaseServerTestCase):
8+
class MetadataDeprecatedTestCase(cases.BaseServerTestCase):
99
valid_metadata_keys = {"display-name", "avatar"}
1010
invalid_metadata_keys = {"indisplay-name", "inavatar"}
1111

0 commit comments

Comments
 (0)