0001-auth_fc-disable-auto-linking-by-default-72870.patch
src/authentic2_auth_fc/migrations/0009_auto_20230102_1416.py | ||
---|---|---|
1 |
# Generated by Django 2.2.26 on 2023-01-02 13:16 |
|
2 | ||
3 |
from django.db import migrations, models |
|
4 | ||
5 | ||
6 |
class Migration(migrations.Migration): |
|
7 | ||
8 |
dependencies = [ |
|
9 |
('authentic2_auth_fc', '0008_fcauthenticator_link_by_email'), |
|
10 |
] |
|
11 | ||
12 |
operations = [ |
|
13 |
migrations.AlterField( |
|
14 |
model_name='fcauthenticator', |
|
15 |
name='link_by_email', |
|
16 |
field=models.BooleanField(default=False, verbose_name='Link by email address'), |
|
17 |
), |
|
18 |
] |
src/authentic2_auth_fc/models.py | ||
---|---|---|
66 | 66 |
verbose_name=_('Scopes'), |
67 | 67 |
default=get_default_scopes, |
68 | 68 |
) |
69 |
link_by_email = models.BooleanField(_('Link by email address'), default=True)
|
|
69 |
link_by_email = models.BooleanField(_('Link by email address'), default=False)
|
|
70 | 70 | |
71 | 71 |
type = 'fc' |
72 | 72 |
how = ['france-connect'] |
tests/auth_fc/test_migrations.py | ||
---|---|---|
41 | 41 |
FcAccount = new_apps.get_model('authentic2_auth_fc', 'FcAccount') |
42 | 42 |
assert len(set(FcAccount.objects.values_list('user_id', 'order'))) == 5 |
43 | 43 |
assert len(set(FcAccount.objects.values_list('sub', 'order'))) == 5 |
44 | ||
45 | ||
46 |
def test_migration_0009_autolink_disable(migration): |
|
47 |
migrate_from = [('authentic2_auth_fc', '0008_fcauthenticator_link_by_email')] |
|
48 |
migrate_to = [('authentic2_auth_fc', '0009_auto_20230102_1416')] |
|
49 | ||
50 |
old_apps = migration.before(migrate_from, at_end=False) |
|
51 |
FcAuthenticator = old_apps.get_model('authentic2_auth_fc', 'FcAuthenticator') |
|
52 |
authenticator = FcAuthenticator.objects.create() |
|
53 |
assert authenticator.link_by_email is True |
|
54 | ||
55 |
# setting unchanged on existing authenticators |
|
56 |
new_apps = migration.apply(migrate_to) |
|
57 |
FcAuthenticator = new_apps.get_model('authentic2_auth_fc', 'FcAuthenticator') |
|
58 |
authenticator = FcAuthenticator.objects.get() |
|
59 |
assert authenticator.link_by_email is True |
|
60 | ||
61 |
# new authenticators get the new default value |
|
62 |
authenticator.delete() |
|
63 |
new_authenticator = FcAuthenticator.objects.create() |
|
64 |
assert new_authenticator.link_by_email is False |
|
44 |
- |