Projet

Général

Profil

Development #51368

un POST sur /api/users/?get_or_create=email considère même les comptes désactivés

Ajouté par Thomas Noël il y a environ 3 ans. Mis à jour il y a environ 3 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Catégorie:
-
Version cible:
-
Début:
23 février 2021
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

Il faudrait que le get du get_or_create ne prenne pas en considération les comptes deactivation/deleted


Fichiers

Révisions associées

Révision 49233873 (diff)
Ajouté par Benjamin Dauvergne il y a environ 3 ans

api: do not mix get_queryset() and filter_queryset() (#51368)

Révision ebd152fe (diff)
Ajouté par Benjamin Dauvergne il y a environ 3 ans

api: ignore deleted users when using update/get_or_create (#51368)

Historique

#2

Mis à jour par Thomas Noël il y a environ 3 ans

Voici, selon moi, le test qui devrait passer :

diff --git a/tests/test_api.py b/tests/test_api.py
index cf276c6e..5b13d81b 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -1462,6 +1462,11 @@ def test_api_users_get_or_create(settings, app, admin):
     assert User.objects.get(id=id).password != password
     assert User.objects.get(id=id).check_password('secret')

+    # do not get deleted user, create a new one
+    User.objects.get(id=id).mark_as_deleted()
+    resp = app.post_json('/api/users/?get_or_create=email', params=payload, status=200)
+    assert id != resp.json['id']
+

 def test_api_users_get_or_create_email_is_unique(settings, app, admin):
     settings.A2_EMAIL_IS_UNIQUE = True
#3

Mis à jour par Benjamin Dauvergne il y a environ 3 ans

  • Assigné à mis à Benjamin Dauvergne
#5

Mis à jour par Paul Marillonnet il y a environ 3 ans

  • Statut changé de Solution proposée à Solution validée

Le build est cassé mais rien à voir avec ce ticket, je vais faire un autre ticket.
Sinon c’est bon pour moi.

#6

Mis à jour par Paul Marillonnet il y a environ 3 ans

Paul Marillonnet a écrit :

Le build est cassé mais rien à voir avec ce ticket, je vais faire un autre ticket.

#51376

#7

Mis à jour par Benjamin Dauvergne il y a environ 3 ans

  • Statut changé de Solution validée à Résolu (à déployer)
commit ebd152fe8669f3875cade43ba5c5990c44c97cd3
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Feb 23 15:14:32 2021 +0100

    api: ignore deleted users when using update/get_or_create (#51368)

commit 49233873d49c441397976419bb6d458657be1379
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Feb 23 15:04:36 2021 +0100

    api: do not mix get_queryset() and filter_queryset() (#51368)
#8

Mis à jour par Frédéric Péters il y a environ 3 ans

  • Statut changé de Résolu (à déployer) à Solution déployée

Formats disponibles : Atom PDF