From 5a9e7f87baa58783686a800558a90def256cd008 Mon Sep 17 00:00:00 2001 From: Sebastian Hoffmann Date: Thu, 4 Feb 2016 02:33:24 +0100 Subject: [PATCH] Strengthed uri Pattern tests and fixed parsing edge case --- autobahn/wamp/test/test_uri_pattern.py | 14 ++++++++++++++ autobahn/wamp/uri.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/autobahn/wamp/test/test_uri_pattern.py b/autobahn/wamp/test/test_uri_pattern.py index c0d823a8b..f296954b7 100644 --- a/autobahn/wamp/test/test_uri_pattern.py +++ b/autobahn/wamp/test/test_uri_pattern.py @@ -48,6 +48,7 @@ def test_valid_uris(self): for u in [u"com.myapp.proc1", u"123", u"com.myapp..update", + u"com.myapp...list" ]: p = Pattern(u, Pattern.URI_TARGET_ENDPOINT) self.assertIsInstance(p, Pattern) @@ -67,6 +68,19 @@ def test_parse_uris(self): (u"com.myapp.123456.update", {u'product': u'123456'}), (u"com.myapp..update", None), ] + ), + (u"com.myapp..update", [ + (u"com.myapp.0.update", {u'product': u'0'}), + (u"com.myapp.abc.update", {u'product': u'abc'}), + (u"com.myapp..update", None), + ] + ), + (u"com.myapp...list", [ + (u"com.myapp.cosmetic.shampoo.list", {u'category': u'cosmetic', u'subcategory': u'shampoo'}), + (u"com.myapp...list", None), + (u"com.myapp.cosmetic..list", None), + (u"com.myapp..shampoo.list", None), + ] ) ] for test in tests: diff --git a/autobahn/wamp/uri.py b/autobahn/wamp/uri.py index f05bb7ad0..c2a86b0af 100644 --- a/autobahn/wamp/uri.py +++ b/autobahn/wamp/uri.py @@ -132,7 +132,7 @@ def __init__(self, uri, target): raise Exception("invalid URI") nc[name] = str - pl.append("(?P<{0}>[a-z][a-z0-9_]*)".format(name)) + pl.append("(?P<{0}>[a-z0-9_]+)".format(name)) continue match = Pattern._URI_COMPONENT.match(component)