18 lines
468 B
Python
18 lines
468 B
Python
import pytest
|
|
|
|
from pneumatube.smtp_client import InvalidAddress, validate
|
|
|
|
|
|
def test_validate_accepts_plain_address():
|
|
assert validate(" bob@example.org ") == "bob@example.org"
|
|
|
|
|
|
@pytest.mark.parametrize("address", [
|
|
"not-an-email",
|
|
"bob@localhost",
|
|
"bob@example.org\r\nBcc: evil@example.org",
|
|
"bob@example.org\nX-Injected: 1",
|
|
])
|
|
def test_validate_rejects_bad_addresses(address):
|
|
with pytest.raises(InvalidAddress):
|
|
validate(address)
|