fix(auth): garder l identite Discord du cote verifie
This commit is contained in:
@@ -257,3 +257,36 @@ class TestSeedAccountCheck:
|
||||
output = capsys.readouterr().out
|
||||
assert 'password has been changed' in output
|
||||
assert 'PASSWORD IS STILL' not in output
|
||||
|
||||
|
||||
class TestDiscordIdentityCheck:
|
||||
def test_it_finds_identity_collisions_before_the_unique_migration(self, live_db, app, capsys):
|
||||
engine, _tamper = live_db
|
||||
path = str(engine.url).replace('sqlite:///', '')
|
||||
connection = sqlite3.connect(path)
|
||||
for username in ('alice', 'bob'):
|
||||
connection.execute(
|
||||
'INSERT INTO users '
|
||||
'(username, password_hash, role, full_name, email, '
|
||||
'is_active_account, discord_user_id) '
|
||||
"VALUES (?, 'hash', 'player', ?, ?, 1, '222222222222222222')",
|
||||
(username, username.title(), f'{username}@example.test'),
|
||||
)
|
||||
connection.commit()
|
||||
connection.close()
|
||||
|
||||
with app.app_context():
|
||||
result = main(['--url', str(engine.url), '--check-discord-identities'])
|
||||
|
||||
output = capsys.readouterr().out
|
||||
assert result == 1
|
||||
assert '222222222222222222: 2 accounts (alice, bob)' in output
|
||||
|
||||
def test_a_clean_identity_set_does_not_change_the_exit_code(self, live_db, app, capsys):
|
||||
engine, _tamper = live_db
|
||||
|
||||
with app.app_context():
|
||||
result = main(['--url', str(engine.url), '--check-discord-identities'])
|
||||
|
||||
assert result == 0
|
||||
assert 'No Discord identity is shared' in capsys.readouterr().out
|
||||
|
||||
Reference in New Issue
Block a user