From ceb41e6106f3208841d5541208e557ef8081e9fc Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Tue, 23 May 2023 11:30:35 -0300 Subject: [PATCH] test: Check that error is displayed on decode failure --- ietf/nomcom/tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ietf/nomcom/tests.py b/ietf/nomcom/tests.py index 767570fb3..edb7d71c4 100644 --- a/ietf/nomcom/tests.py +++ b/ietf/nomcom/tests.py @@ -4,6 +4,7 @@ import datetime import io +import mock import random import shutil @@ -1577,6 +1578,16 @@ class NewActiveNomComTests(TestCase): login_testing_unauthorized(self,self.chair.user.username,url) response = self.client.get(url) self.assertEqual(response.status_code,200) + # Check that we get an error if there's an encoding problem talking to openssl + # "\xc3\x28" is an invalid utf8 string + with mock.patch("ietf.nomcom.utils.pipe", return_value=(0, b"\xc3\x28", None)): + response = self.client.post(url, {'key': force_str(key)}) + self.assertFormError( + response.context["form"], + None, + "An internal error occurred while adding your private key to your session." + f"Please contact the secretariat for assistance ({settings.SECRETARIAT_SUPPORT_EMAIL})", + ) response = self.client.post(url,{'key': force_str(key)}) self.assertEqual(response.status_code,302)