Coverage for gws-app/gws/base/auth/_test/user_test.py: 100%
16 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 22:59 +0200
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 22:59 +0200
1import gws
2import gws.test.util as u
3import gws.base.auth
6@u.fixture(scope='module')
7def root():
8 cfg = '''
9 auth {
10 providers+ {
11 uid "AUTH_1"
12 type 'mockAuthProvider1'
13 allowedMethods ['mockAuthMethod1']
14 }
15 methods+ { type 'mockAuthMethod2' }
16 }
17 '''
19 yield u.gws_root(cfg)
22##
25def test_from_record(root: gws.Root):
26 prov = root.app.authMgr.get_provider('AUTH_1')
27 rec = dict(
28 localUid='a',
29 displayName='b',
30 mfauid='MFA',
31 email='bob',
32 other1='x1',
33 other2='x2',
34 )
35 usr = gws.base.auth.user.from_record(prov, rec)
37 assert usr.uid == gws.u.join_uid(prov.uid, rec['localUid'])
38 assert usr.displayName == 'b'
39 assert usr.mfaUid == 'MFA'
40 assert usr.email == 'bob'
41 assert usr.data == dict(other1='x1', other2='x2')