loutilities 3.13.1.dev1__tar.gz → 3.13.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/PKG-INFO +4 -1
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/views/userrole.py +6 -3
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/version.py +1 -1
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities.egg-info/PKG-INFO +4 -1
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities.egg-info/SOURCES.txt +2 -1
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities.egg-info/requires.txt +3 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/setup.py +3 -0
- loutilities-3.13.2/tests/test_userrole.py +134 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/README.md +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/__init__.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/agegrade.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/anonymize_db.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/apikey.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/applytemplate.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/bfile.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/boolexpr.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/config.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/configparser.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/csvu.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/csvwt.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/extconfigparser.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/filetrigger.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/filtercsv.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/filters.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/flask/__init__.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/flask/user/__init__.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/flask/user/views.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/flask_helpers/__init__.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/flask_helpers/as_blueprint.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/flask_helpers/blueprints.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/flask_helpers/decorators.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/flask_helpers/mailer.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/geo.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/googleauth.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/kmlutils.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/makerst.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/namesplitter.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/nesteddict.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/nicknames.csv +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/nicknames.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/renderrun.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/sqlalchemy_helpers.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/background-post-data-manager.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/branding.css +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/buttons.colvis.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/charts.css +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/charts.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/datatables-childrow.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/datatables.css +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/datatables.dataRender.datetime.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/datatables.dataRender.ellipsis.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/datatables.dataRender.googledoc.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/datatables.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor-saeditor.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.buttons.editchildrowrefresh.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.buttons.editrefresh.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.buttons.separator.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.ckeditor5.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.css +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.displayController.onPage.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.fieldType.display.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.googledoc.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.select2.mymethods.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/eventscalendar.css +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/filters.css +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/filters.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/jquery.ui.dialog-clickoutside.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/jqueryui.theme.adjust.css +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/legend.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/mutex-promise.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/user/admin/beforedatatables.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/user/admin/groups.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/utils.js +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/bare-layout.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/datatables.html +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/datatables.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/layout-base.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/layout.html +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/layout.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/security/change_password.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/security/email/reset_instructions.html +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/security/email/reset_instructions.txt +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/security/forgot_password.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/security/login_user.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/security/reset_password.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/select-view.jinja2 +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/textreader.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/timeu.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/transform.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/__init__.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/applogging.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/audit_mixin.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/model.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/roles.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/scripts/__init__.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/scripts/users_init.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/settings.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/tablefiles.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/tables.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/user/views/__init__.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/wxextensions.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/xmldict.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities.egg-info/dependency_links.txt +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities.egg-info/entry_points.txt +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities.egg-info/not-zip-safe +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities.egg-info/top_level.txt +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/setup.cfg +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/tests/__init__.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/tests/models.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/tests/test_manage_local_tables.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/tests/test_sqlalchemy_helpers.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/tests/test_tables.py +0 -0
- {loutilities-3.13.1.dev1 → loutilities-3.13.2}/tests/test_user_tables.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: loutilities
|
|
3
|
-
Version: 3.13.
|
|
3
|
+
Version: 3.13.2
|
|
4
4
|
Summary: some hopefully useful utilities
|
|
5
5
|
Home-page: http://github.com/louking/loutilities
|
|
6
6
|
Author: Lou King
|
|
@@ -9,7 +9,10 @@ License: Apache License, Version 2.0
|
|
|
9
9
|
Requires-Dist: fasteners
|
|
10
10
|
Requires-Dist: flask-security-too>=5.5.0
|
|
11
11
|
Requires-Dist: flask-sqlalchemy>=3.0.5
|
|
12
|
+
Requires-Dist: pytz>=2022.1
|
|
12
13
|
Requires-Dist: pyyaml
|
|
14
|
+
Requires-Dist: tzlocal>=4.2
|
|
15
|
+
Requires-Dist: validators>=0.20.0
|
|
13
16
|
Dynamic: author
|
|
14
17
|
Dynamic: author-email
|
|
15
18
|
Dynamic: description
|
|
@@ -42,6 +42,9 @@ user_dbattrs = 'id,email,name,given_name,roles,interests,last_login_at,current_l
|
|
|
42
42
|
user_formfields = 'rowid,email,name,given_name,roles,interests,last_login_at,current_login_at,last_login_ip,current_login_ip,login_count,active'.split(',')
|
|
43
43
|
user_dbmapping = dict(zip(user_dbattrs, user_formfields))
|
|
44
44
|
user_formmapping = dict(zip(user_formfields, user_dbattrs))
|
|
45
|
+
# a pasted address can carry surrounding whitespace, which MySQL ignores when
|
|
46
|
+
# comparing but other systems (e.g., Discourse) reject (louking/members#758)
|
|
47
|
+
user_dbmapping['email'] = lambda formrow: formrow['email'].strip()
|
|
45
48
|
|
|
46
49
|
user_formmapping['last_login_at'] = lambda dbrow: ymdtime.dt2asc(dbrow.last_login_at) if dbrow.last_login_at else ''
|
|
47
50
|
user_formmapping['current_login_at'] = lambda dbrow: ymdtime.dt2asc(dbrow.current_login_at) if dbrow.current_login_at else ''
|
|
@@ -49,7 +52,7 @@ user_formmapping['current_login_at'] = lambda dbrow: ymdtime.dt2asc(dbrow.curren
|
|
|
49
52
|
def user_validate(action, formdata):
|
|
50
53
|
results = []
|
|
51
54
|
|
|
52
|
-
if formdata['email'] and not email(formdata['email']):
|
|
55
|
+
if formdata['email'] and not email(formdata['email'].strip()):
|
|
53
56
|
results.append({ 'name' : 'email', 'status' : 'invalid email: correct format is like john.doe@example.com' })
|
|
54
57
|
|
|
55
58
|
# check apps which user will have access to
|
|
@@ -103,7 +106,7 @@ class RolesPicker(DteDbRelationship):
|
|
|
103
106
|
# these are the roles from the form, but limited to allowed_roles if not ROLE_SUPER_ADMIN
|
|
104
107
|
resultroles = super().set(formrow)
|
|
105
108
|
if not current_user.has_role(ROLE_SUPER_ADMIN):
|
|
106
|
-
theuser = User.query.filter_by(email=formrow['email']).one_or_none()
|
|
109
|
+
theuser = User.query.filter_by(email=formrow['email'].strip()).one_or_none()
|
|
107
110
|
allowed_roles = self.allowed_roles()
|
|
108
111
|
if theuser:
|
|
109
112
|
otherroles = [r for r in theuser.roles if r not in allowed_roles]
|
|
@@ -172,7 +175,7 @@ class UserCrudApi(DbCrudApiRolePermissions):
|
|
|
172
175
|
:return:
|
|
173
176
|
'''
|
|
174
177
|
# create the user
|
|
175
|
-
email = formdata['email']
|
|
178
|
+
email = formdata['email'].strip()
|
|
176
179
|
name = formdata['name']
|
|
177
180
|
given_name = formdata['given_name']
|
|
178
181
|
roles = [Role.query.filter_by(id=id).one() for id in formdata['roles']['id'].split(SEPARATOR)]
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# this string is used for the version string in the documentation, as well as the egg
|
|
2
|
-
__version__ = '3.13.
|
|
2
|
+
__version__ = '3.13.2'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: loutilities
|
|
3
|
-
Version: 3.13.
|
|
3
|
+
Version: 3.13.2
|
|
4
4
|
Summary: some hopefully useful utilities
|
|
5
5
|
Home-page: http://github.com/louking/loutilities
|
|
6
6
|
Author: Lou King
|
|
@@ -9,7 +9,10 @@ License: Apache License, Version 2.0
|
|
|
9
9
|
Requires-Dist: fasteners
|
|
10
10
|
Requires-Dist: flask-security-too>=5.5.0
|
|
11
11
|
Requires-Dist: flask-sqlalchemy>=3.0.5
|
|
12
|
+
Requires-Dist: pytz>=2022.1
|
|
12
13
|
Requires-Dist: pyyaml
|
|
14
|
+
Requires-Dist: tzlocal>=4.2
|
|
15
|
+
Requires-Dist: validators>=0.20.0
|
|
13
16
|
Dynamic: author
|
|
14
17
|
Dynamic: author-email
|
|
15
18
|
Dynamic: description
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
###########################################################################################
|
|
2
|
+
# Date Author Reason
|
|
3
|
+
# ---- ------ ------
|
|
4
|
+
# 12/01/26 Lou King Create
|
|
5
|
+
#
|
|
6
|
+
# Copyright 2026 Lou King. All rights reserved
|
|
7
|
+
###########################################################################################
|
|
8
|
+
'''
|
|
9
|
+
test_userrole - tests for loutilities.user.views.userrole
|
|
10
|
+
|
|
11
|
+
Covers trimming of surrounding whitespace from the user email on the user admin
|
|
12
|
+
form (louking/members#758). Role, Interest, db and current_user are mocked so no
|
|
13
|
+
live Flask-SQLAlchemy app or flask-security session is needed.
|
|
14
|
+
'''
|
|
15
|
+
# standard
|
|
16
|
+
import unittest
|
|
17
|
+
from unittest.mock import MagicMock, patch
|
|
18
|
+
|
|
19
|
+
# pypi
|
|
20
|
+
from flask import Flask, g
|
|
21
|
+
|
|
22
|
+
# homegrown
|
|
23
|
+
from loutilities.user.views import userrole
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TestUserDbmappingEmail(unittest.TestCase):
|
|
27
|
+
"""user_dbmapping['email'] strips surrounding whitespace before the value is stored."""
|
|
28
|
+
|
|
29
|
+
def test_strips_surrounding_whitespace(self):
|
|
30
|
+
self.assertEqual(userrole.user_dbmapping['email']({'email': ' a.b@example.com '}), 'a.b@example.com')
|
|
31
|
+
|
|
32
|
+
def test_strips_trailing_tab_and_newline(self):
|
|
33
|
+
self.assertEqual(userrole.user_dbmapping['email']({'email': 'a.b@example.com\t\n'}), 'a.b@example.com')
|
|
34
|
+
|
|
35
|
+
def test_clean_value_unchanged(self):
|
|
36
|
+
self.assertEqual(userrole.user_dbmapping['email']({'email': 'a.b@example.com'}), 'a.b@example.com')
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class TestUserValidateEmail(unittest.TestCase):
|
|
40
|
+
"""
|
|
41
|
+
user_validate() checks the trimmed email. The user is given one role whose
|
|
42
|
+
applications include g.loutility, so the role check passes and only the email
|
|
43
|
+
check can produce an error.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def setUp(self):
|
|
47
|
+
self.app = Flask(__name__)
|
|
48
|
+
self.loutility = MagicMock()
|
|
49
|
+
self.role = MagicMock()
|
|
50
|
+
self.role.applications = [self.loutility]
|
|
51
|
+
|
|
52
|
+
def _validate(self, emailaddr):
|
|
53
|
+
formdata = {'email': emailaddr, 'roles': {'id': '1'}, 'active': 'yes'}
|
|
54
|
+
with self.app.app_context():
|
|
55
|
+
g.loutility = self.loutility
|
|
56
|
+
with patch.object(userrole, 'Role') as mock_role:
|
|
57
|
+
mock_role.query.filter_by.return_value.one.return_value = self.role
|
|
58
|
+
return userrole.user_validate('create', formdata)
|
|
59
|
+
|
|
60
|
+
def test_accepts_address_with_surrounding_spaces(self):
|
|
61
|
+
self.assertEqual(self._validate(' a.b@example.com '), [])
|
|
62
|
+
|
|
63
|
+
def test_accepts_address_with_trailing_space(self):
|
|
64
|
+
self.assertEqual(self._validate('a.b@example.com '), [])
|
|
65
|
+
|
|
66
|
+
def test_rejects_invalid_address(self):
|
|
67
|
+
results = self._validate('bad')
|
|
68
|
+
self.assertEqual([r['name'] for r in results], ['email'])
|
|
69
|
+
|
|
70
|
+
def test_rejects_invalid_address_with_spaces(self):
|
|
71
|
+
results = self._validate(' bad ')
|
|
72
|
+
self.assertEqual([r['name'] for r in results], ['email'])
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class TestRolesPickerSetEmail(unittest.TestCase):
|
|
76
|
+
"""
|
|
77
|
+
RolesPicker.set() looks up the existing user by the trimmed email, so a
|
|
78
|
+
non-super-admin edit keeps the roles the editor can't see.
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
def test_lookup_uses_stripped_email(self):
|
|
82
|
+
picker = userrole.RolesPicker.__new__(userrole.RolesPicker)
|
|
83
|
+
visible = MagicMock(name='visible')
|
|
84
|
+
hidden = MagicMock(name='hidden')
|
|
85
|
+
existing = MagicMock()
|
|
86
|
+
existing.roles = [visible, hidden]
|
|
87
|
+
mock_user = MagicMock()
|
|
88
|
+
mock_user.has_role.return_value = False
|
|
89
|
+
mock_user.roles = [visible]
|
|
90
|
+
|
|
91
|
+
with patch.object(userrole.DteDbRelationship, 'set', return_value=[visible]), \
|
|
92
|
+
patch.object(userrole, 'current_user', mock_user), \
|
|
93
|
+
patch.object(userrole, 'User') as mock_usermodel:
|
|
94
|
+
mock_usermodel.query.filter_by.return_value.one_or_none.return_value = existing
|
|
95
|
+
result = picker.set({'email': ' a.b@example.com '})
|
|
96
|
+
|
|
97
|
+
mock_usermodel.query.filter_by.assert_called_once_with(email='a.b@example.com')
|
|
98
|
+
self.assertEqual(result, [visible, hidden])
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class TestUserCrudApiCreaterowEmail(unittest.TestCase):
|
|
102
|
+
"""createrow() passes the trimmed email to user_datastore.create_user()."""
|
|
103
|
+
|
|
104
|
+
def test_create_user_gets_stripped_email(self):
|
|
105
|
+
app = Flask(__name__)
|
|
106
|
+
# skip the DbCrudApi __init__ chain, which needs a full Flask-SQLAlchemy setup
|
|
107
|
+
api = userrole.UserCrudApi.__new__(userrole.UserCrudApi)
|
|
108
|
+
api.user_datastore = MagicMock()
|
|
109
|
+
api.dte = MagicMock()
|
|
110
|
+
mock_user = MagicMock()
|
|
111
|
+
mock_user.has_role.return_value = False
|
|
112
|
+
|
|
113
|
+
formdata = {
|
|
114
|
+
'email': ' a.b@example.com ',
|
|
115
|
+
'name': 'A B',
|
|
116
|
+
'given_name': 'A',
|
|
117
|
+
'roles': {'id': '1'},
|
|
118
|
+
}
|
|
119
|
+
with app.test_request_context('/', method='POST', data={}):
|
|
120
|
+
g.interest = 'myclub'
|
|
121
|
+
with patch.object(userrole, 'Role'), \
|
|
122
|
+
patch.object(userrole, 'Interest'), \
|
|
123
|
+
patch.object(userrole, 'db'), \
|
|
124
|
+
patch.object(userrole, 'current_user', mock_user), \
|
|
125
|
+
patch.object(userrole, 'send_reset_password_instructions') as mock_reset:
|
|
126
|
+
api.createrow(formdata)
|
|
127
|
+
|
|
128
|
+
api.user_datastore.create_user.assert_called_once()
|
|
129
|
+
self.assertEqual(api.user_datastore.create_user.call_args.kwargs['email'], 'a.b@example.com')
|
|
130
|
+
mock_reset.assert_not_called()
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
if __name__ == '__main__':
|
|
134
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/branding.css
RENAMED
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/buttons.colvis.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/datatables.css
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/datatables.js
RENAMED
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor-saeditor.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.ckeditor5.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/editor.googledoc.js
RENAMED
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/eventscalendar.css
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/mutex-promise.js
RENAMED
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/static/user/admin/groups.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/datatables.html
RENAMED
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/datatables.jinja2
RENAMED
|
File without changes
|
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/layout.html
RENAMED
|
File without changes
|
{loutilities-3.13.1.dev1 → loutilities-3.13.2}/loutilities/tables-assets/templates/layout.jinja2
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|