mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 02:22:44 +01:00
Each user can add channels that forward their notifications: a webhook posting RomM's JSON (optionally HMAC-signed), a Discord embed or an ntfy message, or an email address confirmed with a code. A channel filters by minimum level and by topic, and every stored notification that passes goes out in its own RQ job, retried three times; ten failures in a row turn the channel off and tell its owner. Channel configs are sealed with a key derived from ROMM_AUTH_SECRET_KEY, since a webhook URL carries its own token. Only an admin's webhooks may reach private addresses; everyone else's go through the SSRF guard. Email goes out over the SMTP_* settings, which the heartbeat reports as NOTIFICATIONS.EMAIL_ENABLED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
655 B
Python
26 lines
655 B
Python
import pytest
|
|
from cryptography.fernet import Fernet
|
|
|
|
from utils.secret_box import UnsealError, seal, unseal
|
|
|
|
|
|
def test_a_sealed_value_opens_back_up():
|
|
value = {"url": "https://discord.com/api/webhooks/1/token", "secret": None}
|
|
|
|
sealed = seal(value)
|
|
|
|
assert "token" not in sealed
|
|
assert unseal(sealed) == value
|
|
|
|
|
|
def test_a_value_sealed_under_another_key_does_not_open():
|
|
foreign = Fernet(Fernet.generate_key()).encrypt(b'{"url": "x"}').decode()
|
|
|
|
with pytest.raises(UnsealError):
|
|
unseal(foreign)
|
|
|
|
|
|
def test_plain_text_is_not_a_sealed_value():
|
|
with pytest.raises(UnsealError):
|
|
unseal("https://example.com/hook")
|