diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-03-02 16:40:00 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-03-02 16:40:00 +0100 |
commit | 28a021483c13e974e00b6159f0653b0727df9d10 (patch) | |
tree | e5aa55337a5b2e5c5e34b7892a0cbe0997eb0da8 /test/utils/test_uri.py | |
parent | b66ed641d5cbb4cb83f4a571223e4d65d80ed05c (diff) | |
download | bsfs-28a021483c13e974e00b6159f0653b0727df9d10.tar.gz bsfs-28a021483c13e974e00b6159f0653b0727df9d10.tar.bz2 bsfs-28a021483c13e974e00b6159f0653b0727df9d10.zip |
prohibit certain characters in URI and ensure URIs in bsfs.graph
Diffstat (limited to 'test/utils/test_uri.py')
-rw-r--r-- | test/utils/test_uri.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/test/utils/test_uri.py b/test/utils/test_uri.py index 6ee2ef7..1c4c9f9 100644 --- a/test/utils/test_uri.py +++ b/test/utils/test_uri.py @@ -35,6 +35,16 @@ class TestURI(unittest.TestCase): self.assertTrue(URI.is_parseable('telnet://192.0.2.16:80/')) self.assertTrue(URI.is_parseable('urn:oasis:names:specification:docbook:dtd:xml:4.1.2')) + # some characters are prohibited + self.assertFalse(URI.is_parseable('http://example.com/foo<bar')) + self.assertFalse(URI.is_parseable('http://example.com/foo>bar')) + self.assertFalse(URI.is_parseable('http://example.com/foo bar')) + self.assertFalse(URI.is_parseable('http://example.com/foo{bar')) + self.assertFalse(URI.is_parseable('http://example.com/foo}bar')) + self.assertFalse(URI.is_parseable('http://example.com/foo|bar')) + self.assertFalse(URI.is_parseable('http://example.com/foo^bar')) + self.assertFalse(URI.is_parseable('http://example.com/foo\\bar')) + # uri cannot end with a scheme delimiter self.assertFalse(URI.is_parseable('http://')) # port must be a number @@ -159,10 +169,10 @@ class TestURI(unittest.TestCase): def test_overloaded(self): # composition - self.assertIsInstance(URI('http://user@www.example.com:1234/{}/path1?{}#fragment') + 'hello', URI) - self.assertIsInstance(URI('http://user@www.example.com:1234/{}/path1?{}#fragment') * 2, URI) - self.assertIsInstance(2 * URI('http://user@www.example.com:1234/{}/path1?{}#fragment'), URI) # rmul - self.assertIsInstance(URI('http://user@www.example.com:1234/{}/path1?{}#fragment').join(['hello', 'world']) , URI) + self.assertIsInstance(URI('http://user@www.example.com:1234/path0/path1?query#fragment') + 'hello', URI) + self.assertIsInstance(URI('http://user@www.example.com:1234/path0/path1?query#fragment') * 2, URI) + self.assertIsInstance(2 * URI('http://user@www.example.com:1234/path0/path1?query#fragment'), URI) # rmul + self.assertIsInstance(URI('http://user@www.example.com:1234/path0/path1?query#fragment').join(['hello', 'world']) , URI) # stripping self.assertIsInstance(URI('http://user@www.example.com:1234/path0/path1?query#fragment').strip(), URI) self.assertIsInstance(URI('http://user@www.example.com:1234/path0/path1?query#fragment').lstrip(), URI) @@ -171,7 +181,6 @@ class TestURI(unittest.TestCase): self.assertIsInstance(URI('http://user@www.example.com:1234/path0/path1?query#fragment').lower(), URI) self.assertIsInstance(URI('http://user@www.example.com:1234/path0/path1?query#fragment').upper(), URI) # formatting - self.assertIsInstance(URI('http://user@www.example.com:1234/{}/path1?{}#fragment').format('hello', 'world'), URI) self.assertIsInstance(URI('http://user@www.example.com:1234/%s/path1?%s#fragment') % ('hello', 'world'), URI) self.assertIsInstance(URI('http://user@www.example.com:1234/path0/path1?query#fragment').replace('path0', 'pathX'), URI) |