Bump version to 1.3.6 and update NEWS.rst for 1.3.5
[mailman-postorious.git] / src / postorius / tests / mailman_api_tests / test_auth_utils.py
blob3709ca828767b1c225ebf2da9602c0bfe783568a
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)
9 # any later version.
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
14 # more details.
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):
31 def setUp(self):
32 super().setUp()
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,
39 verified=True)
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,
44 verified=True)
45 self.mlist.subscribe(
46 'APERSON@example.com',
47 pre_verified=True, pre_confirmed=True, pre_approved=True)
48 self.mlist.subscribe(
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.
55 self.assertTrue(
56 user_is_in_list_roster(self.user1, self.mlist, 'member'))
58 self.assertTrue(
59 user_is_in_list_roster(self.user2, self.mlist, 'member'))