From 0010035c89d36a1da07c211269d5992e43cd3d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Tue, 26 Jan 2021 11:13:55 +0100 Subject: [PATCH 1/2] Disable internal alias too with the account (fix #2120) --- modoboa/admin/forms/account.py | 5 ++--- modoboa/admin/tests/test_account.py | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modoboa/admin/forms/account.py b/modoboa/admin/forms/account.py index f2ca42690..51d246480 100644 --- a/modoboa/admin/forms/account.py +++ b/modoboa/admin/forms/account.py @@ -206,9 +206,8 @@ class AccountFormGeneral(forms.ModelForm): account.role = self.cleaned_data["role"] if hasattr(account, "mailbox"): # Update forward status according to account status - models.Alias.objects.filter( - address=account.email, internal=False).update( - enabled=account.is_active) + models.Alias.objects.filter(address=account.email).update( + enabled=account.is_active) return account diff --git a/modoboa/admin/tests/test_account.py b/modoboa/admin/tests/test_account.py index 4eb722c45..0c4bb27e7 100644 --- a/modoboa/admin/tests/test_account.py +++ b/modoboa/admin/tests/test_account.py @@ -119,8 +119,10 @@ class AccountTestCase(ModoTestCase): account = User.objects.get(username=values["username"]) self.assertEqual(account.language, "fr") - def test_forward_updated_on_edit(self): + def test_aliases_update_on_disable(self): + """Check if aliases are updated when account is disabled.""" account = User.objects.get(username="user@test.com") + internal = models.Alias.objects.get(address=account.email, internal=True) forward = models.Alias.objects.create(address=account.email, internal=False) values = { "username": "user@test.com", @@ -133,12 +135,16 @@ class AccountTestCase(ModoTestCase): self.ajax_post( reverse("admin:account_change", args=[account.id]), values ) + internal.refresh_from_db() + self.assertFalse(internal.enabled) forward.refresh_from_db() self.assertFalse(forward.enabled) values["is_active"] = True self.ajax_post( reverse("admin:account_change", args=[account.id]), values ) + internal.refresh_from_db() + self.assertTrue(internal.enabled) forward.refresh_from_db() self.assertTrue(forward.enabled) From 63a8e8435351cd5aeee47c322146b085c7f5978b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Tue, 26 Jan 2021 12:25:03 +0100 Subject: [PATCH 2/2] Resynchronize the package index in tests --- .github/workflows/modoboa.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/modoboa.yml b/.github/workflows/modoboa.yml index cfd765302..37be44fae 100644 --- a/.github/workflows/modoboa.yml +++ b/.github/workflows/modoboa.yml @@ -66,7 +66,9 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - sudo apt-get install postfix librrd-dev rrdtool libldap2-dev libsasl2-dev libssl-dev + sudo apt-get update -y \ + && sudo apt-get install -y \ + postfix librrd-dev rrdtool libldap2-dev libsasl2-dev libssl-dev python -m pip install --upgrade pip pip install -r requirements.txt pip install -r ldap-requirements.txt