From 524df061c00727931101429ebe4a1208d1c4b804 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Tue, 23 Sep 2025 10:10:51 +0200 Subject: [PATCH] Fixed tests --- modoboa/contacts/tests.py | 6 ++---- modoboa/core/tests/test_ldap.py | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modoboa/contacts/tests.py b/modoboa/contacts/tests.py index 5c18b7a81..b717c37ee 100644 --- a/modoboa/contacts/tests.py +++ b/modoboa/contacts/tests.py @@ -72,8 +72,7 @@ class ViewsTestCase(TestDataMixin, ModoAPITestCase): def test_user_settings(self): """Check that remote collection creation request is sent.""" # 1. Addressbook with contacts must be synced manually - data = {"username": self.user.username, "password": "toto"} - self.client.post(reverse("core:login"), data) + self.client.force_authenticate(self.user) self.enable_cdav_sync() self.addressbook.refresh_from_db() self.assertIs(self.addressbook.last_sync, None) @@ -81,8 +80,7 @@ class ViewsTestCase(TestDataMixin, ModoAPITestCase): # 2. Addressbook with no contacts can be considered synced user = core_models.User.objects.get(username="user@test2.com") abook = user.addressbook_set.first() - data = {"username": user.username, "password": "toto"} - self.client.post(reverse("core:login"), data) + self.client.force_authenticate(user) abook.refresh_from_db() self.assertIs(abook.last_sync, None) # Now enable sync. diff --git a/modoboa/core/tests/test_ldap.py b/modoboa/core/tests/test_ldap.py index 4e386f247..0631ebf0b 100644 --- a/modoboa/core/tests/test_ldap.py +++ b/modoboa/core/tests/test_ldap.py @@ -158,6 +158,8 @@ class ProfileTestCase(LDAPTestCaseMixin, ModoAPITestCase): username = "testuser@example.com" self.authenticate(username, "test") + user = models.User.objects.get(username=username) + self.client.force_authenticate(user) response = self.client.post( reverse("v2:account-set-me-password"), {"password": "test", "new_password": "Toto1234"},