Ejemplo n.º 1
0
 def _get_send_password_form(self, pubreq):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "foo.cz",
         "confirmation_method": "signed_email",
         "send_to_0": "email_in_registry",
     })
     self.assertTrue(form.is_valid())
     return form
Ejemplo n.º 2
0
 def test_field_is_required(self):
     form = SendPasswordForm({})
     self.assertEqual(
         form.errors, {
             'object_type': ['This field is required.'],
             'handle': ['This field is required.'],
             'send_to': ['This field is required.'],
         })
Ejemplo n.º 3
0
 def test_stripped_handle(self):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "  foo  ",
         "confirmation_method": "signed_email",
         "send_to_0": "email_in_registry",
     })
     self.assertEqual(form.errors, {})
     self.assertEqual(form.cleaned_data["handle"], "foo")
Ejemplo n.º 4
0
 def test_invalid_custom_email(self):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "foo.cz",
         "confirmation_method": "signed_email",
         "send_to_0": "email_in_registry",
         "send_to_1": "foo",
     })
     self.assertEqual(form.errors,
                      {'send_to': ['Enter a valid email address.']})
Ejemplo n.º 5
0
 def test_max_length(self):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "o" * 256,
         "confirmation_method": "signed_email",
         "send_to_0": "email_in_registry",
     })
     self.assertEqual(
         form.errors, {
             'handle':
             ['Ensure this value has at most 255 characters (it has 256).']
         })
Ejemplo n.º 6
0
 def test_notarized_letter_without_custom_email(self):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "foo.cz",
         "confirmation_method": "notarized_letter",
         "send_to_0": "custom_email",
     })
     self.assertEqual(
         form.errors, {
             'send_to': [
                 'Custom email is required as "Send to custom email" option is selected. Please fill it in.'
             ]
         })
Ejemplo n.º 7
0
 def test_logged_call_to_registry_no_logger(self, mock_localdate):
     mock_localdate.return_value = datetime(2017, 3, 8)
     pubreq = DebugPublicRequest()
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "foo.cz",
         "confirmation_method": "signed_email",
         "send_to_0": "email_in_registry",
     })
     self.assertTrue(form.is_valid())
     pubreq.logged_call_to_registry(form)
     cleaned_data = {
         'handle': 'foo.cz',
         'object_type': 'domain',
         'confirmation_method': ConfirmationMethod.SIGNED_EMAIL,
         'send_to': DeliveryType('email_in_registry', ''),
     }
     self.assertEqual(cache.get(pubreq.public_key), {
         'cleaned_data': cleaned_data,
         'public_request_id': 42
     })
     self.assertEqual(self.LOGGER.mock_calls, [])
Ejemplo n.º 8
0
 def test_get_log_properties(self: SimpleTestCase):
     data = (
         # post, properties
         ({
             'object_type': 'contact',
             'handle': 'kryten',
             'send_to_0': 'email_in_registry'
         }, [('handle', 'kryten'), ('handleType', 'contact'),
             ('sendTo', 'email_in_registry')]),
         ({
             'object_type': 'contact',
             'handle': 'kryten',
             'send_to_0': 'custom_email',
             'send_to_1': '*****@*****.**'
         }, [('handle', 'kryten'), ('handleType', 'contact'),
             ('sendTo', 'custom_email'),
             ('customEmail', '*****@*****.**')]),
     )
     for post, properties in data:
         with self.subTest(post=post):
             form = SendPasswordForm(post)
             form.is_valid()
             self.assertEqual(form.get_log_properties(), properties)
Ejemplo n.º 9
0
 def test_notarized_letter_send_to_registry(self):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "foo.cz",
         "confirmation_method": "notarized_letter",
         "send_to_0": "email_in_registry",
         "send_to_1": "",
     })
     self.assertEqual(
         form.errors, {
             '__all__': [
                 'Letter with officially verified signature can be sent only to the custom email. '
                 'Please select "Send to custom email" and enter it.'
             ]
         })
Ejemplo n.º 10
0
 def test_custom_email_and_sent_to_registry(self):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "foo.cz",
         "confirmation_method": "signed_email",
         "send_to_0": "email_in_registry",
         "send_to_1": "*****@*****.**",
     })
     self.assertEqual(
         form.errors, {
             'send_to': [
                 'Option "Send to email in registry" is incompatible with custom email. '
                 'Please choose one of the two options.'
             ]
         })
Ejemplo n.º 11
0
 def test_is_valid(self):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "foo.cz",
         "confirmation_method": "signed_email",
         "send_to_0": "email_in_registry",
     })
     self.assertEqual(form.errors, {})
     self.assertEqual(
         form.cleaned_data, {
             'object_type': 'domain',
             'handle': 'foo.cz',
             'send_to': DeliveryType('email_in_registry', ""),
             'confirmation_method': ConfirmationMethod.SIGNED_EMAIL,
         })
Ejemplo n.º 12
0
 def test_notarized_letter(self):
     form = SendPasswordForm({
         "object_type": "domain",
         "handle": "foo.cz",
         "confirmation_method": "notarized_letter",
         "send_to_0": "custom_email",
         "send_to_1": "*****@*****.**",
     })
     self.assertEqual(form.errors, {})
     self.assertEqual(
         form.cleaned_data, {
             "object_type": "domain",
             "handle": "foo.cz",
             "confirmation_method": ConfirmationMethod.NOTARIZED_LETTER,
             "send_to": DeliveryType("custom_email", "*****@*****.**"),
         })
Ejemplo n.º 13
0
 def test_enum_types(self):
     form = SendPasswordForm({
         "object_type": "foo",
         "handle": "foo.cz",
         "confirmation_method": "foo",
         "send_to_0": "foo",
     })
     self.assertEqual(
         form.errors, {
             'confirmation_method': [
                 'Select a valid choice. foo is not one of the available choices.'
             ],
             'object_type': [
                 'Select a valid choice. foo is not one of the available choices.'
             ],
             'send_to': [
                 'Select a valid choice. foo is not one of the available choices.'
             ],
         })