mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 19:52:34 +02:00
This commit is contained in:
committed by
Brad Warren
parent
f0e1be55d6
commit
7531c98916
@@ -137,7 +137,6 @@ class TestSimpleTLSSNI01Server(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
self.old_cwd = os.getcwd()
|
self.old_cwd = os.getcwd()
|
||||||
os.chdir(self.test_cwd)
|
os.chdir(self.test_cwd)
|
||||||
self.thread.start()
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
os.chdir(self.old_cwd)
|
os.chdir(self.old_cwd)
|
||||||
@@ -146,13 +145,12 @@ class TestSimpleTLSSNI01Server(unittest.TestCase):
|
|||||||
|
|
||||||
def test_it(self):
|
def test_it(self):
|
||||||
max_attempts = 5
|
max_attempts = 5
|
||||||
while max_attempts:
|
for attempt in range(max_attempts):
|
||||||
max_attempts -= 1
|
|
||||||
try:
|
try:
|
||||||
cert = crypto_util.probe_sni(
|
cert = crypto_util.probe_sni(
|
||||||
b'localhost', b'0.0.0.0', self.port)
|
b'localhost', b'0.0.0.0', self.port)
|
||||||
except errors.Error:
|
except errors.Error:
|
||||||
self.assertTrue(max_attempts > 0, "Timeout!")
|
self.assertTrue(attempt + 1 < max_attempts, "Timeout!")
|
||||||
time.sleep(1) # wait until thread starts
|
time.sleep(1) # wait until thread starts
|
||||||
else:
|
else:
|
||||||
self.assertEqual(jose.ComparableX509(cert),
|
self.assertEqual(jose.ComparableX509(cert),
|
||||||
@@ -160,6 +158,11 @@ class TestSimpleTLSSNI01Server(unittest.TestCase):
|
|||||||
'rsa2048_cert.pem'))
|
'rsa2048_cert.pem'))
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if attempt == 0:
|
||||||
|
# the first attempt is always meant to fail, so we can test
|
||||||
|
# the socket failure code-path for probe_sni, as well
|
||||||
|
self.thread.start()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main() # pragma: no cover
|
unittest.main() # pragma: no cover
|
||||||
|
|||||||
Reference in New Issue
Block a user