Skip to content

Commit

Permalink
test(dovecot_model): We check that if the password modified in the da…
Browse files Browse the repository at this point in the history
…tabase is no longer consistent with ARGON2ID, we get an exception
  • Loading branch information
octohuguesdumont committed Jul 12, 2024
1 parent ad8de3d commit 4fddf33
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/sql_dovecot/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from .. import sql_dovecot
from . import database
from . import database, models


def test_database():
Expand Down Expand Up @@ -88,3 +88,14 @@ def test_get_users(db_dovecot_session):
# On teste la récupération des users du domaine
users = sql_dovecot.get_users(db_dovecot_session, "example.com")
assert len(users) == 2

def test_imap__check_password():
imap_user = models.ImapUser()
imap_user.set_password("secret")
assert imap_user.check_password("secret")
assert not imap_user.check_password("wrong")

with pytest.raises(Exception) as e:
imap_user.password = "wrong"
imap_user.check_password("wrong")
assert "This password was not encoded by me, i can't check it" in str(e.value)

0 comments on commit 4fddf33

Please sign in to comment.