1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2020-2021 by the Free Software Foundation, Inc.
4 # This file is part of Postorius.
6 # Postorius is free software: you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free
8 # Software Foundation, either version 3 of the License, or (at your option)
11 # Postorius is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 # You should have received a copy of the GNU General Public License along with
17 # Postorius. If not, see <http://www.gnu.org/licenses/>.
21 from django
.contrib
.auth
.models
import User
23 from allauth
.account
.models
import EmailAddress
25 from postorius
.auth
.utils
import user_is_in_list_roster
26 from postorius
.tests
.utils
import ViewTestCase
29 class AuthTestCase(ViewTestCase
):
33 self
.domain
= self
.mm_client
.create_domain('example.com')
34 self
.mlist
= self
.domain
.create_list('authlist')
35 self
.user1
= User
.objects
.create_user(
36 'aperson', 'aperson@example.com', 'pass')
37 EmailAddress
.objects
.create(user
=self
.user1
,
38 email
=self
.user1
.email
,
40 self
.user2
= User
.objects
.create_user(
41 'bperson', 'BPERSON@example.com', 'pass')
42 EmailAddress
.objects
.create(user
=self
.user2
,
43 email
=self
.user2
.email
,
46 'APERSON@example.com',
47 pre_verified
=True, pre_confirmed
=True, pre_approved
=True)
49 'bperson@example.com',
50 pre_verified
=True, pre_confirmed
=True, pre_approved
=True)
52 def test_user_in_roster_case_sensitivity(self
):
53 # Test that if Core stores the email adddress with Upper case letters
54 # and Postorius stores it in lower case, the matching works.
56 user_is_in_list_roster(self
.user1
, self
.mlist
, 'member'))
59 user_is_in_list_roster(self
.user2
, self
.mlist
, 'member'))