mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-03 04:25:24 +02:00
fix: group creation (#1126)
* fix: unify group creation - closes #1100 * tests: disable password hashing during testing * tests: fix email config tests
This commit is contained in:
parent
e9bb39c744
commit
c988de1921
11 changed files with 113 additions and 33 deletions
22
tests/unit_tests/core/test_security.py
Normal file
22
tests/unit_tests/core/test_security.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from pytest import MonkeyPatch
|
||||
|
||||
from mealie.core.config import get_app_settings
|
||||
from mealie.core.security.hasher import FakeHasher, PasslibHasher, get_hasher
|
||||
|
||||
|
||||
def test_get_hasher(monkeypatch: MonkeyPatch):
|
||||
hasher = get_hasher()
|
||||
|
||||
assert isinstance(hasher, FakeHasher)
|
||||
|
||||
monkeypatch.setenv("TESTING", "0")
|
||||
|
||||
get_hasher.cache_clear()
|
||||
get_app_settings.cache_clear()
|
||||
|
||||
hasher = get_hasher()
|
||||
|
||||
assert isinstance(hasher, PasslibHasher)
|
||||
|
||||
get_app_settings.cache_clear()
|
||||
get_hasher.cache_clear()
|
|
@ -44,8 +44,11 @@ def email_service(monkeypatch) -> EmailService:
|
|||
return email_service
|
||||
|
||||
|
||||
def test_email_disabled():
|
||||
def test_email_disabled(monkeypatch):
|
||||
email_service = EmailService(TestEmailSender())
|
||||
|
||||
monkeypatch.setenv("SMTP_HOST", "") # disable email
|
||||
|
||||
get_app_settings.cache_clear()
|
||||
email_service.settings = get_app_settings()
|
||||
success = email_service.send_test_email(FAKE_ADDRESS)
|
||||
|
|
|
@ -60,8 +60,17 @@ def test_pg_connection_args(monkeypatch):
|
|||
|
||||
|
||||
def test_smtp_enable(monkeypatch):
|
||||
monkeypatch.setenv("SMTP_HOST", "")
|
||||
monkeypatch.setenv("SMTP_PORT", "")
|
||||
monkeypatch.setenv("SMTP_TLS", "true")
|
||||
monkeypatch.setenv("SMTP_FROM_NAME", "")
|
||||
monkeypatch.setenv("SMTP_FROM_EMAIL", "")
|
||||
monkeypatch.setenv("SMTP_USER", "")
|
||||
monkeypatch.setenv("SMTP_PASSWORD", "")
|
||||
|
||||
get_app_settings.cache_clear()
|
||||
app_settings = get_app_settings()
|
||||
|
||||
assert app_settings.SMTP_ENABLE is False
|
||||
|
||||
monkeypatch.setenv("SMTP_HOST", "email.mealie.io")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue