2016-04-13 19:03:59 -04:00
|
|
|
"""Tests for certbot.errors."""
|
2015-06-23 16:10:20 -04:00
|
|
|
import unittest
|
|
|
|
|
|
2015-10-04 06:37:47 -04:00
|
|
|
import mock
|
|
|
|
|
|
2015-06-23 16:10:20 -04:00
|
|
|
from acme import messages
|
|
|
|
|
|
2016-04-13 19:03:59 -04:00
|
|
|
from certbot import achallenges
|
|
|
|
|
from certbot.tests import acme_util
|
2015-06-23 16:10:20 -04:00
|
|
|
|
|
|
|
|
|
2017-01-26 19:21:54 -05:00
|
|
|
class FailedChallengesTest(unittest.TestCase):
|
2016-04-13 19:03:59 -04:00
|
|
|
"""Tests for certbot.errors.FailedChallenges."""
|
2015-06-23 16:10:20 -04:00
|
|
|
|
|
|
|
|
def setUp(self):
|
2016-04-13 19:03:59 -04:00
|
|
|
from certbot.errors import FailedChallenges
|
2015-06-23 16:10:20 -04:00
|
|
|
self.error = FailedChallenges(set([achallenges.DNS(
|
|
|
|
|
domain="example.com", challb=messages.ChallengeBody(
|
2016-08-07 10:51:25 -04:00
|
|
|
chall=acme_util.DNS01, uri=None,
|
2015-06-23 16:10:20 -04:00
|
|
|
error=messages.Error(typ="tls", detail="detail")))]))
|
|
|
|
|
|
|
|
|
|
def test_str(self):
|
|
|
|
|
self.assertTrue(str(self.error).startswith(
|
2016-08-07 10:51:25 -04:00
|
|
|
"Failed authorization procedure. example.com (dns-01): tls"))
|
2015-06-23 16:10:20 -04:00
|
|
|
|
2017-07-10 22:05:52 -04:00
|
|
|
def test_unicode(self):
|
|
|
|
|
from certbot.errors import FailedChallenges
|
|
|
|
|
arabic_detail = u'\u0639\u062f\u0627\u0644\u0629'
|
|
|
|
|
arabic_error = FailedChallenges(set([achallenges.DNS(
|
|
|
|
|
domain="example.com", challb=messages.ChallengeBody(
|
|
|
|
|
chall=acme_util.DNS01, uri=None,
|
|
|
|
|
error=messages.Error(typ="tls", detail=arabic_detail)))]))
|
|
|
|
|
|
|
|
|
|
self.assertTrue(str(arabic_error).startswith(
|
|
|
|
|
"Failed authorization procedure. example.com (dns-01): tls"))
|
|
|
|
|
|
2015-06-23 16:10:20 -04:00
|
|
|
|
2015-10-04 06:37:47 -04:00
|
|
|
class StandaloneBindErrorTest(unittest.TestCase):
|
2016-04-13 19:03:59 -04:00
|
|
|
"""Tests for certbot.errors.StandaloneBindError."""
|
2015-10-04 06:37:47 -04:00
|
|
|
|
|
|
|
|
def setUp(self):
|
2016-04-13 19:03:59 -04:00
|
|
|
from certbot.errors import StandaloneBindError
|
2015-10-04 06:37:47 -04:00
|
|
|
self.error = StandaloneBindError(mock.sentinel.error, 1234)
|
|
|
|
|
|
|
|
|
|
def test_instance_args(self):
|
|
|
|
|
self.assertEqual(mock.sentinel.error, self.error.socket_error)
|
|
|
|
|
self.assertEqual(1234, self.error.port)
|
|
|
|
|
|
|
|
|
|
def test_str(self):
|
|
|
|
|
self.assertTrue(str(self.error).startswith(
|
|
|
|
|
"Problem binding to port 1234: "))
|
|
|
|
|
|
|
|
|
|
|
2015-06-23 16:10:20 -04:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
unittest.main() # pragma: no cover
|