fix: better host detection and cerbot only on valid hosts
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import parameterized
|
||||
|
||||
from stapler.strings import sanitize_string, valid_host
|
||||
|
||||
from . import BaseTestCase
|
||||
|
||||
|
||||
class TestStrings(BaseTestCase):
|
||||
def test_sanitize(self) -> None:
|
||||
self.assertEqual("??A??", sanitize_string("\n\tA\x00\x99"))
|
||||
|
||||
@parameterized.parameterized.expand(
|
||||
[("example.com"), ("test-test.com"), ("subdomain.example.com")]
|
||||
)
|
||||
def test_valid_host(self, host: str) -> None:
|
||||
self.assertTrue(valid_host(host), host)
|
||||
|
||||
@parameterized.parameterized.expand(
|
||||
[("example.c"), ("localhost"), ("127.0.0.1"), ("test..com"), ("www-.test.com")]
|
||||
)
|
||||
def test_invalid_host(self, host: str) -> None:
|
||||
self.assertFalse(valid_host(host), host)
|
||||
Reference in New Issue
Block a user