From c0e296ae9132fa37d1f48dcbf38b3fa0c24bc604 Mon Sep 17 00:00:00 2001 From: Anthony Bourguignon Date: Sun, 14 Oct 2018 11:09:04 +0200 Subject: [PATCH] add tests for password schemes --- modoboa/core/tests/test_authentication.py | 3 +++ modoboa/core/tests/test_views.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modoboa/core/tests/test_authentication.py b/modoboa/core/tests/test_authentication.py index 509425503..29ed8e220 100644 --- a/modoboa/core/tests/test_authentication.py +++ b/modoboa/core/tests/test_authentication.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals +import os import smtplib from unittest import skipIf @@ -23,6 +24,8 @@ except ImportError: import mock +@override_settings( + DOVECOT_LOOKUP_PATH=["{}/doveadm".format(os.path.dirname(__file__))]) class AuthenticationTestCase(ModoTestCase): """Validate authentication scenarios.""" diff --git a/modoboa/core/tests/test_views.py b/modoboa/core/tests/test_views.py index 69d1c285e..20d730a0a 100644 --- a/modoboa/core/tests/test_views.py +++ b/modoboa/core/tests/test_views.py @@ -35,7 +35,7 @@ SETTINGS_SAMPLE = { "limits-enable_domain_limits": "False", "csrfmiddlewaretoken": "SGgMVZsA4TPqoiV786TMST6xgOlhAf4F", "limits-deflt_user_mailboxes_limit": "0", - "core-password_scheme": "sha512crypt", + "core-password_scheme": "plain", "core-update_scheme": True, "core-items_per_page": "30", "limits-deflt_user_mailbox_aliases_limit": "0", @@ -175,6 +175,15 @@ class SettingsTestCase(ModoTestCase): settings = SETTINGS_SAMPLE.copy() response = self.client.post(url, settings, format="json") self.assertEqual(response.status_code, 200) + settings["core-password_scheme"] = "sha512crypt" + response = self.client.post(url, settings, format="json") + self.assertEqual(response.status_code, 400) + compare(response.json(), { + "form_errors": {"password_scheme": ["Select a valid choice. \ +sha512crypt is not one of the available choices."]}, + "prefix": "core" + }) + settings["core-password_scheme"] = "plain" settings["core-rounds_number"] = "" response = self.client.post(url, settings, format="json") self.assertEqual(response.status_code, 400)