test: Check that error is displayed on decode failure

This commit is contained in:
Jennifer Richards 2023-05-23 11:30:35 -03:00
parent 5f0e1a524b
commit ceb41e6106
No known key found for this signature in database
GPG key ID: 9B2BF5C5ADDA6A6E

View file

@ -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)