summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2018-07-05 10:04:20 +0100
committerGitHub <noreply@github.com>2018-07-05 10:04:20 +0100
commit1a886406770f4a51dd03c31c15fbd1e2d33ff202 (patch)
tree3a668e42377a871519e97fbeb8997758a5edbb91 /tests
parentMerge pull request #3481 from matrix-org/rav/fix_cachedescriptor_test (diff)
parentMore server_name validation (diff)
downloadsynapse-1a886406770f4a51dd03c31c15fbd1e2d33ff202.tar.xz
Merge pull request #3483 from matrix-org/rav/more_server_name_validation
More server_name validation
Diffstat (limited to 'tests')
-rw-r--r--tests/http/test_endpoint.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/http/test_endpoint.py b/tests/http/test_endpoint.py
index cd74825c85..b8a48d20a4 100644
--- a/tests/http/test_endpoint.py
+++ b/tests/http/test_endpoint.py
@@ -12,7 +12,10 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from synapse.http.endpoint import parse_server_name
+from synapse.http.endpoint import (
+    parse_server_name,
+    parse_and_validate_server_name,
+)
 from tests import unittest
 
 
@@ -30,17 +33,23 @@ class ServerNameTestCase(unittest.TestCase):
         for i, o in test_data.items():
             self.assertEqual(parse_server_name(i), o)
 
-    def test_parse_bad_server_names(self):
+    def test_validate_bad_server_names(self):
         test_data = [
             "",  # empty
             "localhost:http",  # non-numeric port
             "1234]",  # smells like ipv6 literal but isn't
+            "[1234",
+            "underscore_.com",
+            "percent%65.com",
+            "1234:5678:80",   # too many colons
         ]
         for i in test_data:
             try:
-                parse_server_name(i)
+                parse_and_validate_server_name(i)
                 self.fail(
-                    "Expected parse_server_name(\"%s\") to throw" % i,
+                    "Expected parse_and_validate_server_name('%s') to throw" % (
+                        i,
+                    ),
                 )
             except ValueError:
                 pass