From 86b1b64b1c2a75103640599cb3fd0d97fb651dfa Mon Sep 17 00:00:00 2001
From: Valentin Rigal <rigal@teklia.com>
Date: Tue, 28 May 2024 15:25:22 +0200
Subject: [PATCH] Add test case

---
 arkindex/users/tests/test_registration.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arkindex/users/tests/test_registration.py b/arkindex/users/tests/test_registration.py
index b934db8ef8..ccf8c617fb 100644
--- a/arkindex/users/tests/test_registration.py
+++ b/arkindex/users/tests/test_registration.py
@@ -64,6 +64,22 @@ class TestRegistration(FixtureAPITestCase):
         )
         self.assertEqual(response.status_code, status.HTTP_200_OK)
 
+    def test_update_password_validation(self):
+        self.client.force_login(self.user)
+        response = self.client.patch(
+            reverse("api:user-retrieve"),
+            data={"password": "email"},
+            format="json",
+        )
+        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+        self.assertDictEqual(response.json(), {
+            "password": [
+                "The password is too similar to the email address.",
+                "This password is too short. It must contain at least 8 characters.",
+                "This password is too common.",
+            ]
+        })
+
     def test_update_display_name(self):
         self.client.force_login(self.user)
         response = self.client.patch(
-- 
GitLab