sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #06221
[Merge] ~troyanov/maas:better-sslerror-mock into maas:master
Anton Troyanov has proposed merging ~troyanov/maas:better-sslerror-mock into maas:master.
Commit message:
chore(cli): include str(SSLError) in CommandError
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~troyanov/maas/+git/maas/+merge/439231
--
Your team MAAS Committers is subscribed to branch maas:master.
diff --git a/src/maascli/api.py b/src/maascli/api.py
index 1a4c14c..e5afe81 100644
--- a/src/maascli/api.py
+++ b/src/maascli/api.py
@@ -52,8 +52,7 @@ def http_request(
except httplib2.ssl.SSLError as error:
raise CommandError(
"Certificate verification failed, use --insecure/-k to "
- "disable the certificate check."
- f"{getattr(error, 'reason', '')}"
+ "disable the certificate check.\n" + str(error)
)
diff --git a/src/maascli/tests/test_api.py b/src/maascli/tests/test_api.py
index 9b2f659..99450e5 100644
--- a/src/maascli/tests/test_api.py
+++ b/src/maascli/tests/test_api.py
@@ -129,7 +129,14 @@ class TestFunctions(MAASTestCase):
def test_http_request_raises_error_if_cert_verify_fails(self):
self.patch(
- httplib2.Http, "request", Mock(side_effect=httplib2.ssl.SSLError())
+ httplib2.Http,
+ "request",
+ Mock(
+ side_effect=httplib2.ssl.SSLError(
+ 997,
+ "ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED]",
+ )
+ ),
)
error = self.assertRaises(
CommandError,
@@ -139,7 +146,8 @@ class TestFunctions(MAASTestCase):
)
error_expected = (
"Certificate verification failed, use --insecure/-k to "
- "disable the certificate check."
+ "disable the certificate check.\n"
+ "ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED]"
)
self.assertEqual(error_expected, "%s" % error)
Follow ups