Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
b44690da by Philipp Hörist at 2024-09-11T20:27:21+02:00
other: Add tests for resource validation
- - - - -
1 changed file:
- test/unit/test_jid_parsing.py
Changes:
=====================================
test/unit/test_jid_parsing.py
=====================================
@@ -9,6 +9,7 @@ from nbxmpp.protocol import LocalpartByteLimit
from nbxmpp.protocol import LocalpartNotAllowedChar
from nbxmpp.protocol import ResourcepartByteLimit
from nbxmpp.protocol import ResourcepartNotAllowedChar
+from nbxmpp.protocol import validate_resourcepart
class JIDParsing(unittest.TestCase):
@@ -68,6 +69,24 @@ class JIDParsing(unittest.TestCase):
del os.environ['NBXMPP_ENFORCE_PRECIS']
+ def test_resources(self):
+ valid_resources = [
+ 'res👔',
+ 'res🔫',
+ ]
+
+ for res in valid_resources:
+ validate_resourcepart(res)
+
+ invalid_resources = [
+ ('res😀️', ResourcepartNotAllowedChar),
+ ('res🤖️', ResourcepartNotAllowedChar),
+ ]
+
+ for res, exception in invalid_resources:
+ with self.assertRaises(exception):
+ validate_resourcepart(res)
+
def test_ip_literals(self):
tests = [
('juliet@[2002:4559:1FE2::4559:1FE2]/res'),
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/b44690dafeef45a0dcb9dd4561e65f20f94daf49
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/b44690dafeef45a0dcb9dd4561e65f20f94daf49
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]