0001-auth_fc-discard-deprecated-scopes-71868.patch
src/authentic2_auth_fc/migrations/0005_fcauthenticator.py | ||
---|---|---|
63 | 63 |
('family_name', 'family name (family_name)'), |
64 | 64 |
('email', 'email (email)'), |
65 | 65 |
('preferred_username', 'usual family name (preferred_username)'), |
66 |
('address', 'address (address)'), |
|
67 |
('phone', 'phone (phone)'), |
|
68 | 66 |
('identite_pivot', 'core id (identite_pivot)'), |
69 | 67 |
('profile', 'profile (profile)'), |
70 | 68 |
('birth', 'birth profile (birth)'), |
src/authentic2_auth_fc/models.py | ||
---|---|---|
40 | 40 |
('family_name', _('family name (family_name)')), |
41 | 41 |
('email', _('email (email)')), |
42 | 42 |
('preferred_username', _('usual family name (preferred_username)')), |
43 |
('address', _('address (address)')), |
|
44 |
('phone', _('phone (phone)')), |
|
45 | 43 |
('identite_pivot', _('core id (identite_pivot)')), |
46 | 44 |
('profile', _('profile (profile)')), |
47 | 45 |
('birth', _('birth profile (birth)')), |
... | ... | |
90 | 88 | |
91 | 89 |
def get_scopes_display(self): |
92 | 90 |
scope_dict = {k: v for k, v in SCOPE_CHOICES} |
93 |
return ', '.join(str(scope_dict[scope]) for scope in self.scopes) |
|
91 |
return ', '.join(str(scope_dict[scope]) for scope in self.scopes if scope in scope_dict)
|
|
94 | 92 | |
95 | 93 |
@property |
96 | 94 |
def authorize_url(self): |
tests/auth_fc/test_auth_fc.py | ||
---|---|---|
326 | 326 |
def test_login_with_missing_required_attributes(settings, app, franceconnect): |
327 | 327 |
Attribute.objects.create(label='Title', name='title', required=True, user_editable=True, kind='title') |
328 | 328 |
Attribute.objects.create( |
329 |
label='Phone', name='phone', required=True, user_editable=True, kind='phone_number'
|
|
329 |
label='Birth country', name='birthcountry', required=True, user_editable=True, kind='string'
|
|
330 | 330 |
) |
331 | 331 | |
332 | 332 |
assert User.objects.count() == 0 |
333 | 333 |
assert models.FcAccount.objects.count() == 0 |
334 | 334 | |
335 |
franceconnect.user_info['phone'] = '0102030405'
|
|
336 |
settings.A2_FC_USER_INFO_MAPPINGS = {'phone': {'ref': 'phone'}}
|
|
335 |
franceconnect.user_info['birthcountry'] = '99512' # Solomon Islands
|
|
336 |
settings.A2_FC_USER_INFO_MAPPINGS = {'birthcountry': {'ref': 'birthcountry'}}
|
|
337 | 337 | |
338 | 338 |
response = app.get('/login/?service=portail&next=/idp/') |
339 | 339 |
response = response.click(href='callback') |
tests/test_manager_authenticators.py | ||
---|---|---|
420 | 420 |
'scopes', |
421 | 421 |
None, |
422 | 422 |
] |
423 |
assert 'phone' not in resp.pyquery('#id_scopes').html() |
|
424 |
assert 'address' not in resp.pyquery('#id_scopes').html() |
|
425 | ||
423 | 426 |
resp.form['platform'] = 'prod' |
424 | 427 |
resp.form['client_id'] = '211286433e39cce01db448d80181bdfd005554b19cd51b3fe7943f6b3b86ab6k' |
425 | 428 |
resp.form['client_secret'] = '211286433e39cce01db448d80181bdfd005554b19cd51b3fe7943f6b3b86ab6d' |
... | ... | |
442 | 445 |
resp = app.get('/manage/authenticators/') |
443 | 446 |
assert 'class="section disabled"' not in resp.text |
444 | 447 | |
448 |
provider.refresh_from_db() |
|
449 |
provider.scopes.extend(['phone', 'address']) # deprecated scopes |
|
450 |
provider.save() |
|
451 | ||
452 |
resp = app.get(provider.get_absolute_url()) |
|
453 |
resp = resp.click('Edit') |
|
454 |
resp.form.submit().follow() |
|
455 |
provider.refresh_from_db() |
|
456 |
assert 'phone' not in provider.scopes |
|
457 |
assert 'address' not in provider.scopes |
|
458 | ||
445 | 459 | |
446 | 460 |
def test_authenticators_saml(app, superuser, ou1, ou2): |
447 | 461 |
resp = login(app, superuser, path='/manage/authenticators/') |
448 |
- |