This commit is contained in:
Adrià Casajús 2022-03-17 21:36:25 +01:00
parent e8013f8e0c
commit c9cbaeb460
No known key found for this signature in database
GPG Key ID: F0033226A5AFC9B9
4 changed files with 10 additions and 6 deletions

View File

@ -1371,7 +1371,7 @@ def get_queue_id(msg: Message) -> Optional[str]:
"""Get the Postfix queue-id from a message"""
header_values = msg.get_all(headers.RSPAM_QUEUE_ID)
if header_values:
#Get last in case somebody tries to inject a header
# Get last in case somebody tries to inject a header
return header_values[-1]
received_header = str(msg[headers.RECEIVED])

View File

@ -65,10 +65,10 @@ def test_is_automatic_out_of_office():
msg[headers.AUTO_SUBMITTED] = "auto-generated"
assert is_automatic_out_of_office(msg)
def test_process_spoofed():
msg = load_eml_file("gmail_spoof.eml")
breakpoint()
a = msg['a']
b=1
c=2
a = msg["a"]
b = 1
c = 2

View File

@ -747,10 +747,12 @@ def test_get_queue_id():
assert get_queue_id(msg) == "4FxQmw1DXdz2vK2"
def test_get_queue_id_from_double_header():
msg = load_eml_file("double_queue_id_header.eml")
assert get_queue_id(msg) == "6D8C13F069"
def test_should_ignore_bounce(flask_client):
assert not should_ignore_bounce("not-exist")

View File

@ -47,6 +47,8 @@ def pretty(d):
def load_eml_file(filename: str) -> EmailMessage:
emails_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),"example_emls")
emails_dir = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "example_emls"
)
fullpath = os.path.join(emails_dir, filename)
return email.message_from_file(open(fullpath))