intermittent commit
This commit is contained in:
27
tests/test_http_fetch.py
Normal file
27
tests/test_http_fetch.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from govoplan_core.security.http_fetch import is_http_url, validate_http_url
|
||||
|
||||
|
||||
class HttpFetchTests(unittest.TestCase):
|
||||
def test_validate_http_url_accepts_absolute_http_urls_without_credentials(self) -> None:
|
||||
self.assertEqual("https://example.test/catalog.json", validate_http_url("https://example.test/catalog.json"))
|
||||
self.assertTrue(is_http_url("http://example.test/catalog.json"))
|
||||
|
||||
def test_validate_http_url_rejects_non_http_urls_and_embedded_credentials(self) -> None:
|
||||
for value in (
|
||||
"file:///etc/passwd",
|
||||
"/relative/catalog.json",
|
||||
"https://user@example.test/catalog.json",
|
||||
"https://user:secret@example.test/catalog.json",
|
||||
):
|
||||
with self.subTest(value=value):
|
||||
self.assertFalse(is_http_url(value))
|
||||
with self.assertRaises(ValueError):
|
||||
validate_http_url(value)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user