make a more complete test

This commit is contained in:
holger krekel
2024-06-27 15:25:22 +02:00
parent 0b8402c187
commit 67be981176
2 changed files with 15 additions and 5 deletions

View File

@@ -2,6 +2,9 @@
## untagged ## untagged
- Test and fix for attempts to create inadmissible accounts
([#333](https://github.com/deltachat/chatmail/pull/321))
- Reject DKIM signatures that do not cover the whole message body. - Reject DKIM signatures that do not cover the whole message body.
([#321](https://github.com/deltachat/chatmail/pull/321)) ([#321](https://github.com/deltachat/chatmail/pull/321))

View File

@@ -11,8 +11,8 @@ from chatmaild.doveauth import (
get_user_data, get_user_data,
handle_dovecot_protocol, handle_dovecot_protocol,
handle_dovecot_request, handle_dovecot_request,
lookup_passdb,
is_allowed_to_create, is_allowed_to_create,
lookup_passdb,
) )
from chatmaild.newemail import create_newemail_dict from chatmaild.newemail import create_newemail_dict
@@ -28,10 +28,17 @@ def test_basic(db, example_config):
def test_invalid_username_length(example_config): def test_invalid_username_length(example_config):
creds = create_newemail_dict(example_config) config = example_config
assert not is_allowed_to_create(example_config, creds['email'][1:], creds['password']) config.username_min_length = 6
# for checking the max_length, we need to get it from the config config.username_max_length = 10
# assert not is_allowed_to_create(example_config, 'a' + creds['email'], creds['password']) password = create_newemail_dict(config)["password"]
assert not is_allowed_to_create(config, f"a1234@{config.mail_domain}", password)
assert is_allowed_to_create(config, f"012345@{config.mail_domain}", password)
assert is_allowed_to_create(config, f"0123456@{config.mail_domain}", password)
assert is_allowed_to_create(config, f"0123456789@{config.mail_domain}", password)
assert not is_allowed_to_create(
config, f"0123456789x@{config.mail_domain}", password
)
def test_dont_overwrite_password_on_wrong_login(db, example_config): def test_dont_overwrite_password_on_wrong_login(db, example_config):