From ba3d1523c26c4a8bd80ae5f16ed20682a272af37 Mon Sep 17 00:00:00 2001 From: Rath Pascal Date: Sat, 31 Aug 2024 00:31:33 +0200 Subject: [PATCH] moved tests, fixed imports --- .github/workflows/lint.yml | 2 +- .github/workflows/test-integration.yml | 2 +- .github/workflows/test-unit.yml | 2 +- pyproject.toml | 2 + src/dmarc_report_parser/__init__.py | 2 +- src/dmarc_report_parser/cli.py | 14 ++-- src/dmarc_report_parser/input/gmail.py | 2 +- src/dmarc_report_parser/input/imap.py | 2 +- src/dmarc_report_parser/input/main.py | 8 +- src/dmarc_report_parser/main.py | 12 +-- .../main_test.py} | 71 +++++++++--------- .../output/loganalytics.py | 2 +- src/dmarc_report_parser/testdata.py | 4 + .../!example.com!1538204542!1538463818.xml | 0 ...arge-example.com!1711897200!1711983600.xml | 0 ...ogle.com Report-ID- 949348866075514174.eml | 0 ....com!example.com!1536105600!1536191999.xml | 0 .../testdata}/aggregate/empty_reason.xml | 0 ...ple.com!1536853302!1536939702!2940.xml.zip | Bin ....net!example.com!1529366400!1529452799.xml | 0 ...com!1516060800!1516147199!102675056.xml.gz | Bin ...a.com!example.de!1538690400!1538776800.xml | 0 .../testdata}/aggregate/invalid_utf_8.xml | 0 .../testdata}/aggregate/invalid_xml.xml | 0 .../aggregate/mimecast-weird-gzip.eml | 0 .../aggregate/old_draft_from_wiki.xml | 0 ....com!example.com!1711756800!1711843200.xml | 0 .../testdata}/aggregate/twilight.eml | 0 ....com!example.com!1538784000!1538870399.xml | 0 ....com!example.com!1530133200!1530219600.xml | 0 .../report_with_upper_cased_pass.xml | 0 .../testdata}/empty.xml | 0 .../extract_report/changed-input.xml | 0 .../testdata}/extract_report/nice-input.xml | 0 .../extract_report/nice-input.xml.gz | Bin .../extract_report/nice-input.xml.zip | Bin ...=sharepoint@domain.de, ip=10.10.10.10).eml | 0 ...se DMARC Failure Report] Rent Reminder.eml | 0 .../dmarc_ruf_report_linkedin.crlf.eml | 0 .../forensic/dmarc_ruf_report_linkedin.eml | 0 .../testdata}/smtp_tls/mail.ru.json | 0 .../testdata}/smtp_tls/rfc8460.json | 0 .../testdata}/smtp_tls/smtp_tls.json | 0 src/dmarc_report_parser/utils/main.py | 2 +- 44 files changed, 64 insertions(+), 63 deletions(-) rename src/{test/tests.py => dmarc_report_parser/main_test.py} (64%) create mode 100644 src/dmarc_report_parser/testdata.py rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/!example.com!1538204542!1538463818.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/!large-example.com!1711897200!1711983600.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/Report domain- borschow.com Submitter- google.com Report-ID- 949348866075514174.eml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/addisonfoods.com!example.com!1536105600!1536191999.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/empty_reason.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/estadocuenta1.infonacot.gob.mx!example.com!1536853302!1536939702!2940.xml.zip (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/example.net!example.com!1529366400!1529452799.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/fastmail.com!example.com!1516060800!1516147199!102675056.xml.gz (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/ikea.com!example.de!1538690400!1538776800.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/invalid_utf_8.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/invalid_xml.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/mimecast-weird-gzip.eml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/old_draft_from_wiki.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/twilight.eml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/usssa.com!example.com!1538784000!1538870399.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate/veeam.com!example.com!1530133200!1530219600.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/aggregate_invalid/report_with_upper_cased_pass.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/empty.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/extract_report/changed-input.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/extract_report/nice-input.xml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/extract_report/nice-input.xml.gz (100%) rename src/{test/samples => dmarc_report_parser/testdata}/extract_report/nice-input.xml.zip (100%) rename src/{test/samples => dmarc_report_parser/testdata}/forensic/DMARC Failure Report for domain.de (mail-from=sharepoint@domain.de, ip=10.10.10.10).eml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/forensic/[Netease DMARC Failure Report] Rent Reminder.eml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/forensic/dmarc_ruf_report_linkedin.crlf.eml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/forensic/dmarc_ruf_report_linkedin.eml (100%) rename src/{test/samples => dmarc_report_parser/testdata}/smtp_tls/mail.ru.json (100%) rename src/{test/samples => dmarc_report_parser/testdata}/smtp_tls/rfc8460.json (100%) rename src/{test/samples => dmarc_report_parser/testdata}/smtp_tls/smtp_tls.json (100%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1aef59ff..b5d44da4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,7 +21,7 @@ on: jobs: build: runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 2 steps: - name: Checkout diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 815c88da..65387434 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -18,7 +18,7 @@ on: jobs: build: runs-on: ubuntu-latest - timeout-minutes: 3 + timeout-minutes: 1 defaults: run: shell: bash diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 1a4a2d48..2b8cd591 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -18,7 +18,7 @@ on: jobs: build: runs-on: ubuntu-latest - timeout-minutes: 3 + timeout-minutes: 1 defaults: run: shell: bash diff --git a/pyproject.toml b/pyproject.toml index 73c97226..ba05555f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,8 @@ version = {file = ["VERSION"]} [tool.setuptools.packages.find] where = ["src"] +include = ["dmarc_report_parser"] +exclude = ["dmarc_report_parser.testdata"] [tool.setuptools.package-data] "*" = ["*.txt"] diff --git a/src/dmarc_report_parser/__init__.py b/src/dmarc_report_parser/__init__.py index 8ce87340..01c0c792 100644 --- a/src/dmarc_report_parser/__init__.py +++ b/src/dmarc_report_parser/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -from main import * +from .main import * diff --git a/src/dmarc_report_parser/cli.py b/src/dmarc_report_parser/cli.py index bae5dfde..2959fe32 100644 --- a/src/dmarc_report_parser/cli.py +++ b/src/dmarc_report_parser/cli.py @@ -16,16 +16,14 @@ import sys from tqdm import tqdm -from main import get_dmarc_reports_from_mailbox, watch_inbox, \ +from .main import get_dmarc_reports_from_mailbox, watch_inbox, \ parse_report_file, get_dmarc_reports_from_mbox, save_output, email_results, ParserError, \ __version__, InvalidDMARCReport -from output import kafkaclient, splunk, s3, syslog, loganalytics, gelf, elastic, opensearch - -from input.main import IMAPConnection, MSGraphConnection, GmailConnection -from input.graph import AuthMethod - -from utils.log import logger -from utils.main import is_mbox +from .output import kafkaclient, splunk, s3, syslog, loganalytics, gelf, elastic, opensearch +from .input.main import IMAPConnection, MSGraphConnection, GmailConnection +from .input.graph import AuthMethod +from .utils.log import logger +from .utils.main import is_mbox formatter = logging.Formatter( fmt='%(levelname)8s:%(filename)s:%(lineno)d:%(message)s', diff --git a/src/dmarc_report_parser/input/gmail.py b/src/dmarc_report_parser/input/gmail.py index 55aaa9ef..9c289cfd 100644 --- a/src/dmarc_report_parser/input/gmail.py +++ b/src/dmarc_report_parser/input/gmail.py @@ -11,7 +11,7 @@ from googleapiclient.errors import HttpError from ..utils.log import logger -from mailbox_connection import MailboxConnection +from .mailbox_connection import MailboxConnection def _get_creds(token_file, credentials_file, scopes, oauth2_port): diff --git a/src/dmarc_report_parser/input/imap.py b/src/dmarc_report_parser/input/imap.py index 565409a8..f5d8cb87 100644 --- a/src/dmarc_report_parser/input/imap.py +++ b/src/dmarc_report_parser/input/imap.py @@ -5,7 +5,7 @@ from socket import timeout from ..utils.log import logger -from mailbox_connection import MailboxConnection +from .mailbox_connection import MailboxConnection class IMAPConnection(MailboxConnection): diff --git a/src/dmarc_report_parser/input/main.py b/src/dmarc_report_parser/input/main.py index 63ac6576..2c0d7de9 100644 --- a/src/dmarc_report_parser/input/main.py +++ b/src/dmarc_report_parser/input/main.py @@ -1,7 +1,7 @@ -from mailbox_connection import MailboxConnection -from graph import MSGraphConnection -from gmail import GmailConnection -from imap import IMAPConnection +from .mailbox_connection import MailboxConnection +from .graph import MSGraphConnection +from .gmail import GmailConnection +from .imap import IMAPConnection __all__ = ["MailboxConnection", "MSGraphConnection", diff --git a/src/dmarc_report_parser/main.py b/src/dmarc_report_parser/main.py index c6198f38..cc7a3f1e 100644 --- a/src/dmarc_report_parser/main.py +++ b/src/dmarc_report_parser/main.py @@ -25,12 +25,12 @@ from lxml import etree from mailsuite.smtp import send_email -from utils.log import logger -from input.main import MailboxConnection -from utils.main import get_base_domain, get_ip_address_info -from utils.main import is_outlook_msg, convert_outlook_msg -from utils.main import parse_email -from utils.main import timestamp_to_human, human_timestamp_to_datetime +from .utils.log import logger +from .input.main import MailboxConnection +from .utils.main import get_base_domain, get_ip_address_info +from .utils.main import is_outlook_msg, convert_outlook_msg +from .utils.main import parse_email +from .utils.main import timestamp_to_human, human_timestamp_to_datetime __version__ = '0.0.0' diff --git a/src/test/tests.py b/src/dmarc_report_parser/main_test.py similarity index 64% rename from src/test/tests.py rename to src/dmarc_report_parser/main_test.py index 21d4fd2d..89cce03a 100644 --- a/src/test/tests.py +++ b/src/dmarc_report_parser/main_test.py @@ -1,13 +1,13 @@ -from __future__ import absolute_import, print_function, unicode_literals - import os import unittest from glob import glob from lxml import etree -import dmarc_report_parser -import dmarc_report_parser.utils +from .utils import main as util +from .main import extract_report, parse_report_file, parsed_forensic_reports_to_csv, \ + parsed_aggregate_reports_to_csv, parse_report_email, parsed_smtp_tls_reports_to_csv, ParserError +from .testdata import td def minify_xml(xml_string): @@ -28,26 +28,25 @@ def testBase64Decoding(self): """Test base64 decoding""" # Example from Wikipedia Base64 article b64_str = "YW55IGNhcm5hbCBwbGVhcw" - decoded_str = dmarc_report_parser.utils.decode_base64(b64_str) + decoded_str = util.decode_base64(b64_str) assert decoded_str == b"any carnal pleas" def testPSLDownload(self): subdomain = "foo.example.com" - result = dmarc_report_parser.utils.get_base_domain(subdomain) + result = util.get_base_domain(subdomain) assert result == "example.com" # Test newer PSL entries subdomain = "e3191.c.akamaiedge.net" - result = dmarc_report_parser.utils.get_base_domain(subdomain) + result = util.get_base_domain(subdomain) assert result == "c.akamaiedge.net" def testExtractReportXMLComparator(self): """Test XML comparator function""" print() - xmlnice = open("samples/extract_report/nice-input.xml").read() + xmlnice = open(f"{td()}/extract_report/nice-input.xml").read() print(xmlnice) - xmlchanged = minify_xml(open( - "samples/extract_report/changed-input.xml").read()) + xmlchanged = minify_xml(open(f"{td()}/extract_report/changed-input.xml").read()) print(xmlchanged) self.assertTrue(compare_xml(xmlnice, xmlnice)) self.assertTrue(compare_xml(xmlchanged, xmlchanged)) @@ -58,48 +57,46 @@ def testExtractReportXMLComparator(self): def testExtractReportBytes(self): """Test extract report function for bytes string input""" print() - file = "samples/extract_report/nice-input.xml" + file = f"{td()}/extract_report/nice-input.xml" with open(file, 'rb') as f: data = f.read() print("Testing {0}: " .format(file), end="") - xmlout = dmarc_report_parser.extract_report(data) - xmlin = open("samples/extract_report/nice-input.xml").read() + xmlout = extract_report(data) + xmlin = open(f"{td()}/extract_report/nice-input.xml").read() self.assertTrue(compare_xml(xmlout, xmlin)) print("Passed!") def testExtractReportXML(self): """Test extract report function for XML input""" print() - file = "samples/extract_report/nice-input.xml" + file = f"{td()}/extract_report/nice-input.xml" print("Testing {0}: " .format(file), end="") - xmlout = dmarc_report_parser.extract_report(file) - xmlin = open("samples/extract_report/nice-input.xml").read() + xmlout = extract_report(file) + xmlin = open(f"{td()}/extract_report/nice-input.xml").read() self.assertTrue(compare_xml(xmlout, xmlin)) print("Passed!") def testExtractReportGZip(self): """Test extract report function for gzip input""" print() - file = "samples/extract_report/nice-input.xml.gz" + file = f"{td()}/extract_report/nice-input.xml.gz" print("Testing {0}: " .format(file), end="") - xmlout = dmarc_report_parser.extract_report(file) - xmlin = open("samples/extract_report/nice-input.xml").read() + xmlout = extract_report(file) + xmlin = open(f"{td()}/extract_report/nice-input.xml").read() self.assertTrue(compare_xml(xmlout, xmlin)) print("Passed!") def testExtractReportZip(self): """Test extract report function for zip input""" print() - file = "samples/extract_report/nice-input.xml.zip" + file = f"{td()}/extract_report/nice-input.xml.zip" print("Testing {0}: " .format(file), end="") - xmlout = dmarc_report_parser.extract_report(file) + xmlout = extract_report(file) print(xmlout) - xmlin = minify_xml(open( - "samples/extract_report/nice-input.xml").read()) + xmlin = minify_xml(open(f"{td()}/extract_report/nice-input.xml").read()) print(xmlin) self.assertTrue(compare_xml(xmlout, xmlin)) - xmlin = minify_xml(open( - "samples/extract_report/changed-input.xml").read()) + xmlin = minify_xml(open(f"{td()}/extract_report/changed-input.xml").read()) print(xmlin) self.assertFalse(compare_xml(xmlout, xmlin)) print("Passed!") @@ -107,47 +104,47 @@ def testExtractReportZip(self): def testAggregateSamples(self): """Test sample aggregate/rua DMARC reports""" print() - sample_paths = glob("samples/aggregate/*") + sample_paths = glob(f"{td()}/aggregate/*") for sample_path in sample_paths: if os.path.isdir(sample_path): continue print("Testing {0}: " .format(sample_path), end="") - parsed_report = dmarc_report_parser.parse_report_file( + parsed_report = parse_report_file( sample_path, always_use_local_files=True)["report"] - dmarc_report_parser.parsed_aggregate_reports_to_csv(parsed_report) + parsed_aggregate_reports_to_csv(parsed_report) print("Passed!") def testEmptySample(self): """Test empty/unparasable report""" - with self.assertRaises(dmarc_report_parser.ParserError): - dmarc_report_parser.parse_report_file('samples/empty.xml') + with self.assertRaises(ParserError): + parse_report_file(f"{td()}/empty.xml") def testForensicSamples(self): """Test sample forensic/ruf/failure DMARC reports""" print() - sample_paths = glob("samples/forensic/*.eml") + sample_paths = glob(f"{td()}/forensic/*.eml") for sample_path in sample_paths: print("Testing {0}: ".format(sample_path), end="") with open(sample_path) as sample_file: sample_content = sample_file.read() - parsed_report = dmarc_report_parser.parse_report_email( + parsed_report = parse_report_email( sample_content)["report"] - parsed_report = dmarc_report_parser.parse_report_file( + parsed_report = parse_report_file( sample_path)["report"] - dmarc_report_parser.parsed_forensic_reports_to_csv(parsed_report) + parsed_forensic_reports_to_csv(parsed_report) print("Passed!") def testSmtpTlsSamples(self): """Test sample SMTP TLS reports""" print() - sample_paths = glob("samples/smtp_tls/*") + sample_paths = glob(f"{td()}/smtp_tls/*") for sample_path in sample_paths: if os.path.isdir(sample_path): continue print("Testing {0}: " .format(sample_path), end="") - parsed_report = dmarc_report_parser.parse_report_file( + parsed_report = parse_report_file( sample_path)["report"] - dmarc_report_parser.parsed_smtp_tls_reports_to_csv(parsed_report) + parsed_smtp_tls_reports_to_csv(parsed_report) print("Passed!") diff --git a/src/dmarc_report_parser/output/loganalytics.py b/src/dmarc_report_parser/output/loganalytics.py index f2484cb6..1cc5a28d 100644 --- a/src/dmarc_report_parser/output/loganalytics.py +++ b/src/dmarc_report_parser/output/loganalytics.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from log import logger +from ..utils.log import logger from azure.core.exceptions import HttpResponseError from azure.identity import ClientSecretCredential from azure.monitor.ingestion import LogsIngestionClient diff --git a/src/dmarc_report_parser/testdata.py b/src/dmarc_report_parser/testdata.py new file mode 100644 index 00000000..1a8e3d77 --- /dev/null +++ b/src/dmarc_report_parser/testdata.py @@ -0,0 +1,4 @@ +from pathlib import Path + +def td() -> Path: + return Path(__file__).parent.resolve() / 'testdata' diff --git a/src/test/samples/aggregate/!example.com!1538204542!1538463818.xml b/src/dmarc_report_parser/testdata/aggregate/!example.com!1538204542!1538463818.xml similarity index 100% rename from src/test/samples/aggregate/!example.com!1538204542!1538463818.xml rename to src/dmarc_report_parser/testdata/aggregate/!example.com!1538204542!1538463818.xml diff --git a/src/test/samples/aggregate/!large-example.com!1711897200!1711983600.xml b/src/dmarc_report_parser/testdata/aggregate/!large-example.com!1711897200!1711983600.xml similarity index 100% rename from src/test/samples/aggregate/!large-example.com!1711897200!1711983600.xml rename to src/dmarc_report_parser/testdata/aggregate/!large-example.com!1711897200!1711983600.xml diff --git a/src/test/samples/aggregate/Report domain- borschow.com Submitter- google.com Report-ID- 949348866075514174.eml b/src/dmarc_report_parser/testdata/aggregate/Report domain- borschow.com Submitter- google.com Report-ID- 949348866075514174.eml similarity index 100% rename from src/test/samples/aggregate/Report domain- borschow.com Submitter- google.com Report-ID- 949348866075514174.eml rename to src/dmarc_report_parser/testdata/aggregate/Report domain- borschow.com Submitter- google.com Report-ID- 949348866075514174.eml diff --git a/src/test/samples/aggregate/addisonfoods.com!example.com!1536105600!1536191999.xml b/src/dmarc_report_parser/testdata/aggregate/addisonfoods.com!example.com!1536105600!1536191999.xml similarity index 100% rename from src/test/samples/aggregate/addisonfoods.com!example.com!1536105600!1536191999.xml rename to src/dmarc_report_parser/testdata/aggregate/addisonfoods.com!example.com!1536105600!1536191999.xml diff --git a/src/test/samples/aggregate/empty_reason.xml b/src/dmarc_report_parser/testdata/aggregate/empty_reason.xml similarity index 100% rename from src/test/samples/aggregate/empty_reason.xml rename to src/dmarc_report_parser/testdata/aggregate/empty_reason.xml diff --git a/src/test/samples/aggregate/estadocuenta1.infonacot.gob.mx!example.com!1536853302!1536939702!2940.xml.zip b/src/dmarc_report_parser/testdata/aggregate/estadocuenta1.infonacot.gob.mx!example.com!1536853302!1536939702!2940.xml.zip similarity index 100% rename from src/test/samples/aggregate/estadocuenta1.infonacot.gob.mx!example.com!1536853302!1536939702!2940.xml.zip rename to src/dmarc_report_parser/testdata/aggregate/estadocuenta1.infonacot.gob.mx!example.com!1536853302!1536939702!2940.xml.zip diff --git a/src/test/samples/aggregate/example.net!example.com!1529366400!1529452799.xml b/src/dmarc_report_parser/testdata/aggregate/example.net!example.com!1529366400!1529452799.xml similarity index 100% rename from src/test/samples/aggregate/example.net!example.com!1529366400!1529452799.xml rename to src/dmarc_report_parser/testdata/aggregate/example.net!example.com!1529366400!1529452799.xml diff --git a/src/test/samples/aggregate/fastmail.com!example.com!1516060800!1516147199!102675056.xml.gz b/src/dmarc_report_parser/testdata/aggregate/fastmail.com!example.com!1516060800!1516147199!102675056.xml.gz similarity index 100% rename from src/test/samples/aggregate/fastmail.com!example.com!1516060800!1516147199!102675056.xml.gz rename to src/dmarc_report_parser/testdata/aggregate/fastmail.com!example.com!1516060800!1516147199!102675056.xml.gz diff --git a/src/test/samples/aggregate/ikea.com!example.de!1538690400!1538776800.xml b/src/dmarc_report_parser/testdata/aggregate/ikea.com!example.de!1538690400!1538776800.xml similarity index 100% rename from src/test/samples/aggregate/ikea.com!example.de!1538690400!1538776800.xml rename to src/dmarc_report_parser/testdata/aggregate/ikea.com!example.de!1538690400!1538776800.xml diff --git a/src/test/samples/aggregate/invalid_utf_8.xml b/src/dmarc_report_parser/testdata/aggregate/invalid_utf_8.xml similarity index 100% rename from src/test/samples/aggregate/invalid_utf_8.xml rename to src/dmarc_report_parser/testdata/aggregate/invalid_utf_8.xml diff --git a/src/test/samples/aggregate/invalid_xml.xml b/src/dmarc_report_parser/testdata/aggregate/invalid_xml.xml similarity index 100% rename from src/test/samples/aggregate/invalid_xml.xml rename to src/dmarc_report_parser/testdata/aggregate/invalid_xml.xml diff --git a/src/test/samples/aggregate/mimecast-weird-gzip.eml b/src/dmarc_report_parser/testdata/aggregate/mimecast-weird-gzip.eml similarity index 100% rename from src/test/samples/aggregate/mimecast-weird-gzip.eml rename to src/dmarc_report_parser/testdata/aggregate/mimecast-weird-gzip.eml diff --git a/src/test/samples/aggregate/old_draft_from_wiki.xml b/src/dmarc_report_parser/testdata/aggregate/old_draft_from_wiki.xml similarity index 100% rename from src/test/samples/aggregate/old_draft_from_wiki.xml rename to src/dmarc_report_parser/testdata/aggregate/old_draft_from_wiki.xml diff --git a/src/test/samples/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml b/src/dmarc_report_parser/testdata/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml similarity index 100% rename from src/test/samples/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml rename to src/dmarc_report_parser/testdata/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml diff --git a/src/test/samples/aggregate/twilight.eml b/src/dmarc_report_parser/testdata/aggregate/twilight.eml similarity index 100% rename from src/test/samples/aggregate/twilight.eml rename to src/dmarc_report_parser/testdata/aggregate/twilight.eml diff --git a/src/test/samples/aggregate/usssa.com!example.com!1538784000!1538870399.xml b/src/dmarc_report_parser/testdata/aggregate/usssa.com!example.com!1538784000!1538870399.xml similarity index 100% rename from src/test/samples/aggregate/usssa.com!example.com!1538784000!1538870399.xml rename to src/dmarc_report_parser/testdata/aggregate/usssa.com!example.com!1538784000!1538870399.xml diff --git a/src/test/samples/aggregate/veeam.com!example.com!1530133200!1530219600.xml b/src/dmarc_report_parser/testdata/aggregate/veeam.com!example.com!1530133200!1530219600.xml similarity index 100% rename from src/test/samples/aggregate/veeam.com!example.com!1530133200!1530219600.xml rename to src/dmarc_report_parser/testdata/aggregate/veeam.com!example.com!1530133200!1530219600.xml diff --git a/src/test/samples/aggregate_invalid/report_with_upper_cased_pass.xml b/src/dmarc_report_parser/testdata/aggregate_invalid/report_with_upper_cased_pass.xml similarity index 100% rename from src/test/samples/aggregate_invalid/report_with_upper_cased_pass.xml rename to src/dmarc_report_parser/testdata/aggregate_invalid/report_with_upper_cased_pass.xml diff --git a/src/test/samples/empty.xml b/src/dmarc_report_parser/testdata/empty.xml similarity index 100% rename from src/test/samples/empty.xml rename to src/dmarc_report_parser/testdata/empty.xml diff --git a/src/test/samples/extract_report/changed-input.xml b/src/dmarc_report_parser/testdata/extract_report/changed-input.xml similarity index 100% rename from src/test/samples/extract_report/changed-input.xml rename to src/dmarc_report_parser/testdata/extract_report/changed-input.xml diff --git a/src/test/samples/extract_report/nice-input.xml b/src/dmarc_report_parser/testdata/extract_report/nice-input.xml similarity index 100% rename from src/test/samples/extract_report/nice-input.xml rename to src/dmarc_report_parser/testdata/extract_report/nice-input.xml diff --git a/src/test/samples/extract_report/nice-input.xml.gz b/src/dmarc_report_parser/testdata/extract_report/nice-input.xml.gz similarity index 100% rename from src/test/samples/extract_report/nice-input.xml.gz rename to src/dmarc_report_parser/testdata/extract_report/nice-input.xml.gz diff --git a/src/test/samples/extract_report/nice-input.xml.zip b/src/dmarc_report_parser/testdata/extract_report/nice-input.xml.zip similarity index 100% rename from src/test/samples/extract_report/nice-input.xml.zip rename to src/dmarc_report_parser/testdata/extract_report/nice-input.xml.zip diff --git a/src/test/samples/forensic/DMARC Failure Report for domain.de (mail-from=sharepoint@domain.de, ip=10.10.10.10).eml b/src/dmarc_report_parser/testdata/forensic/DMARC Failure Report for domain.de (mail-from=sharepoint@domain.de, ip=10.10.10.10).eml similarity index 100% rename from src/test/samples/forensic/DMARC Failure Report for domain.de (mail-from=sharepoint@domain.de, ip=10.10.10.10).eml rename to src/dmarc_report_parser/testdata/forensic/DMARC Failure Report for domain.de (mail-from=sharepoint@domain.de, ip=10.10.10.10).eml diff --git a/src/test/samples/forensic/[Netease DMARC Failure Report] Rent Reminder.eml b/src/dmarc_report_parser/testdata/forensic/[Netease DMARC Failure Report] Rent Reminder.eml similarity index 100% rename from src/test/samples/forensic/[Netease DMARC Failure Report] Rent Reminder.eml rename to src/dmarc_report_parser/testdata/forensic/[Netease DMARC Failure Report] Rent Reminder.eml diff --git a/src/test/samples/forensic/dmarc_ruf_report_linkedin.crlf.eml b/src/dmarc_report_parser/testdata/forensic/dmarc_ruf_report_linkedin.crlf.eml similarity index 100% rename from src/test/samples/forensic/dmarc_ruf_report_linkedin.crlf.eml rename to src/dmarc_report_parser/testdata/forensic/dmarc_ruf_report_linkedin.crlf.eml diff --git a/src/test/samples/forensic/dmarc_ruf_report_linkedin.eml b/src/dmarc_report_parser/testdata/forensic/dmarc_ruf_report_linkedin.eml similarity index 100% rename from src/test/samples/forensic/dmarc_ruf_report_linkedin.eml rename to src/dmarc_report_parser/testdata/forensic/dmarc_ruf_report_linkedin.eml diff --git a/src/test/samples/smtp_tls/mail.ru.json b/src/dmarc_report_parser/testdata/smtp_tls/mail.ru.json similarity index 100% rename from src/test/samples/smtp_tls/mail.ru.json rename to src/dmarc_report_parser/testdata/smtp_tls/mail.ru.json diff --git a/src/test/samples/smtp_tls/rfc8460.json b/src/dmarc_report_parser/testdata/smtp_tls/rfc8460.json similarity index 100% rename from src/test/samples/smtp_tls/rfc8460.json rename to src/dmarc_report_parser/testdata/smtp_tls/rfc8460.json diff --git a/src/test/samples/smtp_tls/smtp_tls.json b/src/dmarc_report_parser/testdata/smtp_tls/smtp_tls.json similarity index 100% rename from src/test/samples/smtp_tls/smtp_tls.json rename to src/dmarc_report_parser/testdata/smtp_tls/smtp_tls.json diff --git a/src/dmarc_report_parser/utils/main.py b/src/dmarc_report_parser/utils/main.py index 96247e83..bcc91e8a 100644 --- a/src/dmarc_report_parser/utils/main.py +++ b/src/dmarc_report_parser/utils/main.py @@ -33,7 +33,7 @@ import publicsuffixlist import requests -from log import logger +from .log import logger from ..resources import dbip as resource_dbip from ..resources import maps as resource_maps