From 81cd1e2c4f92a60c38951cde69a68606d693732e Mon Sep 17 00:00:00 2001 From: Tom Wojcik Date: Fri, 7 Jun 2024 14:35:35 +0200 Subject: [PATCH] add test case for user does not exist in LoginFieldBackend --- ...st_token_create_custom_username_login_fields.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/testproject/testapp/tests/test_token_create_custom_username_login_fields.py b/testproject/testapp/tests/test_token_create_custom_username_login_fields.py index bccb2819..f77d0d2d 100644 --- a/testproject/testapp/tests/test_token_create_custom_username_login_fields.py +++ b/testproject/testapp/tests/test_token_create_custom_username_login_fields.py @@ -274,3 +274,17 @@ def test_failing_login( send_field, user_can_authenticate, ) + + def test_user_does_not_exist(self, client, settings, mocker): + self.configure_djoser_settings( + settings=settings, + mocker=mocker, + login_field="username", + username_field="username", + user_can_authenticate=True, + ) + data = {"username": "idontexist1337", "password": "P455W0RD"} + + response = client.post(self.url, data) + + assert response.status_code == status.HTTP_400_BAD_REQUEST