From 1ecaa8ccaf810c2b24268dd7beb14d95e53fdea1 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 24 Jun 2019 10:42:16 +0200 Subject: [PATCH] csv_import: set ou of created users (#34253) --- src/authentic2/csv_import.py | 2 +- tests/test_csv_import.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/authentic2/csv_import.py b/src/authentic2/csv_import.py index 575c47fb5..c4b813fb3 100644 --- a/src/authentic2/csv_import.py +++ b/src/authentic2/csv_import.py @@ -538,7 +538,7 @@ class UserCsvImporter(object): return False if not user: - user = User() + user = User(ou=self.ou) for cell in row.cells: if not cell.header.field: diff --git a/tests/test_csv_import.py b/tests/test_csv_import.py index a6cb07f56..cbbb0bc66 100644 --- a/tests/test_csv_import.py +++ b/tests/test_csv_import.py @@ -153,6 +153,7 @@ x,x,x,x''' assert User.objects.count() == 2 thomas = User.objects.get(email='tnoel@entrouvert.com') + assert thomas.ou == get_default_ou() assert thomas.email_verified is True assert thomas.first_name == 'Thomas' assert thomas.attributes.first_name == 'Thomas' @@ -161,6 +162,7 @@ x,x,x,x''' assert thomas.attributes.phone == '1234' fpeters = User.objects.get(email='fpeters@entrouvert.com') + assert fpeters.ou == get_default_ou() assert fpeters.first_name == 'Frédéric' assert fpeters.email_verified is True assert fpeters.attributes.first_name == 'Frédéric' @@ -376,6 +378,7 @@ app1,2,tnoel@entrouvert.com,Thomas,Noël,1234 userexternalid__source='app1', userexternalid__external_id=external_id) + assert thomas.ou == get_default_ou() assert thomas.email_verified is True assert thomas.first_name == 'Thomas' assert thomas.attributes.first_name == 'Thomas'