From 7674b26c16ab2ab5db8651aad56d83749b3dd9b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sun, 30 Apr 2023 13:06:37 +0200 Subject: [PATCH] Write an integration test script --- src/signature.rs | 6 +- test_samples/mailparse_test_email_01.txt | 92 ---------- test_samples/single_message.txt | 20 --- test_samples/single_message_raw.txt | 14 -- .../single_message_with_boundaries.txt | 40 ----- tests/key-db.sqlite3 | Bin 0 -> 28672 bytes tests/start_test.py | 170 ++++++++++++++++++ tests/test_01.msg | 10 ++ 8 files changed, 183 insertions(+), 169 deletions(-) delete mode 100644 test_samples/mailparse_test_email_01.txt delete mode 100644 test_samples/single_message.txt delete mode 100644 test_samples/single_message_raw.txt delete mode 100644 test_samples/single_message_with_boundaries.txt create mode 100644 tests/key-db.sqlite3 create mode 100755 tests/start_test.py create mode 100644 tests/test_01.msg diff --git a/src/signature.rs b/src/signature.rs index b4d896b..340f2e7 100644 --- a/src/signature.rs +++ b/src/signature.rs @@ -176,7 +176,7 @@ mod tests { const KEY_ED25519: &str = "Av46g0s6+qCczlLeIkSmD/yD7GX5pDjl8SVTSeVZIhc="; const KEY_RSA2048: &str = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDDYGEHGABdLxLbvqiuaGdYV9ndsFzdO31AaZoSfCVF0TVPeJ5B/YWyUzc6YIr7qFyfA4tiRPu3/Fy2vzYzG2lcYBkSzJsQWkiOWv6C3CpxYX2tBrAKnJx3ADyr9P3whztyKQBbSNLy+CCNJQ5967Z+PCOeiFAX4XvfCFMpwxsUo6Pv2SYi9PwOq8HwzUQHyy39zOs68XIUF85DCXiQ1kztXzu8HX8nuLX7AnLrf0ZiFGrbSbUjj/F7XVPh2QJxcBLZjrnpve73nrrYsIVnbCvfV563CuFq0PvsUofW7Ckbpwdx26AD59ssaOBNp/uK04xqPSQZyADEngcfkOBdqeHlAgMBAAECggEAYqZQd6d7z5FMQV5Uh7O5sta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+8XMKvWilY2MFRCZIlTAQBasEfj9+YZSLY7kFHfWKcUKhqVQ+5M+LgbuZjf6X/0Y+2Lqc585NoxmMDc4GC/1t4eagXqMvcuh10S2JP9RWp"; - const MSG_01_RAW: &[u8] = include_bytes!("../test_samples/single_message_raw.txt"); + const MSG_01_RAW: &[u8] = include_bytes!("../tests/test_01.msg"); const MSG_01_HEADERS: &[&str] = &[ "Date", "From", @@ -189,7 +189,7 @@ mod tests { #[test] fn test_simple_simple() { - let ref_sig_header = "DKIM-Signature: v=1; a=ed25519-sha256; k=ed25519; c=simple/simple;\r\n\tt=1681595158;\r\n\td=example.org;\r\n\ts=dkim-b3fb546a27bb44dd88a1fd2b4b3e2e96;\r\n\th=Date:From:Resent-Date:Subject:To:cc:reply-to;\r\n\tbh=z85OKVJZHnmg3qFlSpLbpPCZ00irfBdrzQUtabiSl3A=;\r\n\tb=854DPGA77UnhEagQIK+x/PLz/YEzoxZO2PDDk6ojASwhUqcuSkOdy9XiuTsQSgpaSQwjui3OuYm9VG6/j3G+AQ=="; + let ref_sig_header = "DKIM-Signature: v=1; a=ed25519-sha256; k=ed25519; c=simple/simple;\r\n\tt=1681595158;\r\n\td=example.org;\r\n\ts=dkim-b3fb546a27bb44dd88a1fd2b4b3e2e96;\r\n\th=Date:From:Resent-Date:Subject:To:cc:reply-to;\r\n\tbh=z85OKVJZHnmg3qFlSpLbpPCZ00irfBdrzQUtabiSl3A=;\r\n\tb=YGbtIaodjitU3jNtwRA2+AJ/i5W4VxmZuESKnv08ofZ7nuYLUiqaS1sR3DGeJ1t83R5ZmPSJAQPBYRg3usJxBg=="; let msg = ParsedMessage::from_bytes(MSG_01_RAW).unwrap(); let mut sig = Signature { algorithm: Algorithm::Ed25519Sha256, @@ -210,7 +210,7 @@ mod tests { #[test] fn test_relaxed_relaxed() { - let ref_sig_header = "DKIM-Signature: v=1; a=rsa-sha256; k=rsa; c=relaxed/relaxed;\r\n\tt=1681593844; x=1682889844;\r\n\td=example.org;\r\n\ts=dkim-681d955d9fc84d978d71a7d7f8ce7dd6;\r\n\th=Date:From:Resent-Date:Subject:To:cc:reply-to;\r\n\tbh=z85OKVJZHnmg3qFlSpLbpPCZ00irfBdrzQUtabiSl3A=;\r\n\tb=o83MyMVH6fz4lhGG5za33rmE/D8RJLezFw9Jqds2l6Pt9uDUZCHbh6YjWJjBBbaKJBlrGWGyKBe4x5ns84oHjGyehd8mbyJc9mu1HjJZQVH7bZPPb0N0gt9tl+7hz9S5GvPE6hE4c3VxynhV/KxoJXa6tdM8JUlTKhcaZyacl1kFcgUlFriyMcID9451evmlmEJ8hiGnxqpXdThxVluKNqV9jYlLAlH4/eIqKWh9RkAqeQufTd8jbfokoF7KDCYRaM+y7uoi3Ir6KKt3NuwrYYv6lmhkzuhF4/4+o6CeNtCQ4boAlVBiGFBX5MDKeHg410yfQZqHm/2mlV9pNU+H4g=="; + let ref_sig_header = "DKIM-Signature: v=1; a=rsa-sha256; k=rsa; c=relaxed/relaxed;\r\n\tt=1681593844; x=1682889844;\r\n\td=example.org;\r\n\ts=dkim-681d955d9fc84d978d71a7d7f8ce7dd6;\r\n\th=Date:From:Resent-Date:Subject:To:cc:reply-to;\r\n\tbh=z85OKVJZHnmg3qFlSpLbpPCZ00irfBdrzQUtabiSl3A=;\r\n\tb=mvdT944tidhpbJHJdbYtIedkXIxNERP7xpAXjWxen5tTULYD72JCQBQy7HbMqix3S0JAex6VVdyqmMjEC053yWNOckVH5E62sGaMyDj8Us1isTmcqIu3VSSQhLpMKkdMv55esqMoaTNC+L+I9p44AHst64sodJmbDA33vLhqoGRja8IylrSK0O4XqgWl2XzGfcyXuDT8miO1NLUU3Hgfgs7edRjBkF2iTMraWiObr0ZW2vI9+Ib9DeuupcC3GMg1MheWlmWNnHlrlSmnkd2VuWEX/ydqlxxXz3/oPjY5ATgYVPBc8apk4KkMDqoQ9EkUvItsvDUz0UhhbXMP3pGGrA=="; let msg = ParsedMessage::from_bytes(MSG_01_RAW).unwrap(); let mut sig = Signature { algorithm: Algorithm::Rsa2048Sha256, diff --git a/test_samples/mailparse_test_email_01.txt b/test_samples/mailparse_test_email_01.txt deleted file mode 100644 index 370fb32..0000000 --- a/test_samples/mailparse_test_email_01.txt +++ /dev/null @@ -1,92 +0,0 @@ -config|smtpd-version|6.8.0p2 -config|smtp-session-timeout|300 -config|subsystem|smtp-in -config|admd|localhost.localdomain -config|ready -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Subject: Test with attachments -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Type: multipart/mixed; -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| boundary="------------E5401F4DD68F2F7A872C2A83" -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Language: en-US -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|This is a multi-part message in MIME format. -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|--------------E5401F4DD68F2F7A872C2A83 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Type: text/html; charset=utf-8 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Transfer-Encoding: 7bit -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Test with attachments -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|--------------E5401F4DD68F2F7A872C2A83 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Type: application/pdf; -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| name="sample.pdf" -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Transfer-Encoding: base64 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Disposition: attachment; -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| filename="sample.pdf" -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|JVBERi0xLjMNCiXi48/TDQoNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL091dGxp -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|bmVzIDIgMCBSDQovUGFnZXMgMyAwIFINCj4+DQplbmRvYmoNCg0KMiAwIG9iag0KPDwNCi9U -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|eXBlIC9PdXRsaW5lcw0KL0NvdW50IDANCj4+DQplbmRvYmoNCg0KMyAwIG9iag0KPDwNCi9U -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|eXBlIC9QYWdlcw0KL0NvdW50IDINCi9LaWRzIFsgNCAwIFIgNiAwIFIgXSANCj4+DQplbmRv -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|YmoNCg0KNCAwIG9iag0KPDwNCi9UeXBlIC9QYWdlDQovUGFyZW50IDMgMCBSDQovUmVzb3Vy -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Y2VzIDw8DQovRm9udCA8PA0KL0YxIDkgMCBSIA0KPj4NCi9Qcm9jU2V0IDggMCBSDQo+Pg0K -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|L01lZGlhQm94IFswIDAgNjEyLjAwMDAgNzkyLjAwMDBdDQovQ29udGVudHMgNSAwIFINCj4+ -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|DQplbmRvYmoNCg0KNSAwIG9iag0KPDwgL0xlbmd0aCAxMDc0ID4+DQpzdHJlYW0NCjIgSg0K -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|QlQNCjAgMCAwIHJnDQovRjEgMDAyNyBUZg0KNTcuMzc1MCA3MjIuMjgwMCBUZA0KKCBBIFNp -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|bXBsZSBQREYgRmlsZSApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDY4OC42 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MDgwIFRkDQooIFRoaXMgaXMgYSBzbWFsbCBkZW1vbnN0cmF0aW9uIC5wZGYgZmlsZSAtICkg -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|VGoNCkVUDQpCVA0KL0YxIDAwMTAgVGYNCjY5LjI1MDAgNjY0LjcwNDAgVGQNCigganVzdCBm -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|b3IgdXNlIGluIHRoZSBWaXJ0dWFsIE1lY2hhbmljcyB0dXRvcmlhbHMuIE1vcmUgdGV4dC4g -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|QW5kIG1vcmUgKSBUag0KRVQNCkJUDQovRjEgMDAxMCBUZg0KNjkuMjUwMCA2NTIuNzUyMCBU -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|ZA0KKCB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|LiApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDYyOC44NDgwIFRkDQooIEFu -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|ZCBtb3JlIHRleHQuIEFuZCBtb3JlIHRleHQuIEFuZCBtb3JlIHRleHQuIEFuZCBtb3JlIHRl -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|eHQuIEFuZCBtb3JlICkgVGoNCkVUDQpCVA0KL0YxIDAwMTAgVGYNCjY5LjI1MDAgNjE2Ljg5 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|NjAgVGQNCiggdGV4dC4gQW5kIG1vcmUgdGV4dC4gQm9yaW5nLCB6enp6ei4gQW5kIG1vcmUg -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|dGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kICkgVGoNCkVUDQpCVA0KL0YxIDAwMTAgVGYNCjY5 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|LjI1MDAgNjA0Ljk0NDAgVGQNCiggbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9y -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|ZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiApIFRqDQpFVA0KQlQNCi9G -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MSAwMDEwIFRmDQo2OS4yNTAwIDU5Mi45OTIwIFRkDQooIEFuZCBtb3JlIHRleHQuIEFuZCBt -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|b3JlIHRleHQuICkgVGoNCkVUDQpCVA0KL0YxIDAwMTAgVGYNCjY5LjI1MDAgNTY5LjA4ODAg -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|VGQNCiggQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5k -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|IG1vcmUgdGV4dC4gQW5kIG1vcmUgKSBUag0KRVQNCkJUDQovRjEgMDAxMCBUZg0KNjkuMjUw -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MCA1NTcuMTM2MCBUZA0KKCB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBF -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|dmVuIG1vcmUuIENvbnRpbnVlZCBvbiBwYWdlIDIgLi4uKSBUag0KRVQNCmVuZHN0cmVhbQ0K -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|ZW5kb2JqDQoNCjYgMCBvYmoNCjw8DQovVHlwZSAvUGFnZQ0KL1BhcmVudCAzIDAgUg0KL1Jl -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|c291cmNlcyA8PA0KL0ZvbnQgPDwNCi9GMSA5IDAgUiANCj4+DQovUHJvY1NldCA4IDAgUg0K -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Pj4NCi9NZWRpYUJveCBbMCAwIDYxMi4wMDAwIDc5Mi4wMDAwXQ0KL0NvbnRlbnRzIDcgMCBS -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|DQo+Pg0KZW5kb2JqDQoNCjcgMCBvYmoNCjw8IC9MZW5ndGggNjc2ID4+DQpzdHJlYW0NCjIg -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Sg0KQlQNCjAgMCAwIHJnDQovRjEgMDAyNyBUZg0KNTcuMzc1MCA3MjIuMjgwMCBUZA0KKCBT -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|aW1wbGUgUERGIEZpbGUgMiApIFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDY4 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|OC42MDgwIFRkDQooIC4uLmNvbnRpbnVlZCBmcm9tIHBhZ2UgMS4gWWV0IG1vcmUgdGV4dC4g -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|QW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gKSBUag0KRVQNCkJUDQovRjEgMDAxMCBU -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Zg0KNjkuMjUwMCA2NzYuNjU2MCBUZA0KKCBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSApIFRqDQpFVA0KQlQN -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Ci9GMSAwMDEwIFRmDQo2OS4yNTAwIDY2NC43MDQwIFRkDQooIHRleHQuIE9oLCBob3cgYm9y -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|aW5nIHR5cGluZyB0aGlzIHN0dWZmLiBCdXQgbm90IGFzIGJvcmluZyBhcyB3YXRjaGluZyAp -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|IFRqDQpFVA0KQlQNCi9GMSAwMDEwIFRmDQo2OS4yNTAwIDY1Mi43NTIwIFRkDQooIHBhaW50 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|IGRyeS4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5kIG1vcmUgdGV4dC4gQW5k -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|IG1vcmUgdGV4dC4gKSBUag0KRVQNCkJUDQovRjEgMDAxMCBUZg0KNjkuMjUwMCA2NDAuODAw -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MCBUZA0KKCBCb3JpbmcuICBNb3JlLCBhIGxpdHRsZSBtb3JlIHRleHQuIFRoZSBlbmQsIGFu -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|ZCBqdXN0IGFzIHdlbGwuICkgVGoNCkVUDQplbmRzdHJlYW0NCmVuZG9iag0KDQo4IDAgb2Jq -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|DQpbL1BERiAvVGV4dF0NCmVuZG9iag0KDQo5IDAgb2JqDQo8PA0KL1R5cGUgL0ZvbnQNCi9T -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|dWJ0eXBlIC9UeXBlMQ0KL05hbWUgL0YxDQovQmFzZUZvbnQgL0hlbHZldGljYQ0KL0VuY29k -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|aW5nIC9XaW5BbnNpRW5jb2RpbmcNCj4+DQplbmRvYmoNCg0KMTAgMCBvYmoNCjw8DQovQ3Jl -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|YXRvciAoUmF2ZSBcKGh0dHA6Ly93d3cubmV2cm9uYS5jb20vcmF2ZVwpKQ0KL1Byb2R1Y2Vy -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|IChOZXZyb25hIERlc2lnbnMpDQovQ3JlYXRpb25EYXRlIChEOjIwMDYwMzAxMDcyODI2KQ0K -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Pj4NCmVuZG9iag0KDQp4cmVmDQowIDExDQowMDAwMDAwMDAwIDY1NTM1IGYNCjAwMDAwMDAw -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MTkgMDAwMDAgbg0KMDAwMDAwMDA5MyAwMDAwMCBuDQowMDAwMDAwMTQ3IDAwMDAwIG4NCjAw -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MDAwMDAyMjIgMDAwMDAgbg0KMDAwMDAwMDM5MCAwMDAwMCBuDQowMDAwMDAxNTIyIDAwMDAw -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|IG4NCjAwMDAwMDE2OTAgMDAwMDAgbg0KMDAwMDAwMjQyMyAwMDAwMCBuDQowMDAwMDAyNDU2 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|IDAwMDAwIG4NCjAwMDAwMDI1NzQgMDAwMDAgbg0KDQp0cmFpbGVyDQo8PA0KL1NpemUgMTEN -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Ci9Sb290IDEgMCBSDQovSW5mbyAxMCAwIFINCj4+DQoNCnN0YXJ0eHJlZg0KMjcxNA0KJSVF -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|T0YNCg== -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|--------------E5401F4DD68F2F7A872C2A83 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Type: text/plain; charset=UTF-8; -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| name="sample.txt" -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Transfer-Encoding: base64 -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Disposition: attachment; -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| filename="sample.txt" -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|dHh0IGZpbGUgY29udGV4dCBmb3IgZW1haWwgY29sbGVjdG9yCjEyMzQ1Njc4OTA5ODc2NTQz -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MjEK -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|--------------E5401F4DD68F2F7A872C2A83-- -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|. diff --git a/test_samples/single_message.txt b/test_samples/single_message.txt deleted file mode 100644 index 33274ed..0000000 --- a/test_samples/single_message.txt +++ /dev/null @@ -1,20 +0,0 @@ -config|smtpd-version|6.8.0p2 -config|smtp-session-timeout|300 -config|subsystem|smtp-in -config|admd|localhost.localdomain -config|ready -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Received: from example.com (localhost.localdomain [::1]) -filter|0.6|1679685611.545184|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| by localhost.localdomain (OpenSMTPD) with SMTP id 8b29bb25 -filter|0.6|1679685611.545186|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| for ; -filter|0.6|1679685611.545200|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| Fri, 24 Mar 2023 19:20:11 +0000 (UTC) -filter|0.6|1679685617.258766|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|From: Derp Sender -filter|0.6|1679685627.765325|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|To: derp.derpson@localhost -filter|0.6|1679685627.765542|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Resent-Date: Fri, 24 Mar 2023 09:42:21 +0100 -filter|0.6|1679685627.765973|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Subject: This is a test -filter|0.6|1679685627.766188|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MIME-Version: 1.0 -filter|0.6|1679685627.766200|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Transfer-Encoding: 8bit -filter|0.6|1679685627.766221|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Message-Id: -filter|0.6|1679685627.766224|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Date: Mon, 13 Mar 2023 10:04:21 +0100 -filter|0.6|1679685627.766227|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766227|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Hello World! -filter|0.6|1679685640.319648|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|. diff --git a/test_samples/single_message_raw.txt b/test_samples/single_message_raw.txt deleted file mode 100644 index 43a6623..0000000 --- a/test_samples/single_message_raw.txt +++ /dev/null @@ -1,14 +0,0 @@ -Received: from example.com (localhost.localdomain [::1]) - by localhost.localdomain (OpenSMTPD) with SMTP id 8b29bb25 - for ; - Fri, 24 Mar 2023 19:20:11 +0000 (UTC) -From: Derp Sender -To: derp.derpson@localhost -Resent-Date: Fri, 24 Mar 2023 09:42:21 +0100 -Subject: This is a test -MIME-Version: 1.0 -Content-Transfer-Encoding: 8bit -Message-Id: -Date: Mon, 13 Mar 2023 10:04:21 +0100 - -Hello World! diff --git a/test_samples/single_message_with_boundaries.txt b/test_samples/single_message_with_boundaries.txt deleted file mode 100644 index ae2a90b..0000000 --- a/test_samples/single_message_with_boundaries.txt +++ /dev/null @@ -1,40 +0,0 @@ -config|smtpd-version|6.8.0p2 -config|smtp-session-timeout|300 -config|subsystem|smtp-in -config|admd|localhost.localdomain -config|ready -filter|0.6|1679685611.545169|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Received: from example.com (localhost.localdomain [::1]) -filter|0.6|1679685611.545184|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| by localhost.localdomain (OpenSMTPD) with SMTP id 8b29bb25 -filter|0.6|1679685611.545186|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| for ; -filter|0.6|1679685611.545200|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| Fri, 24 Mar 2023 19:20:11 +0000 (UTC) -filter|0.6|1679685617.258766|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|From: Derp Sender -filter|0.6|1679685627.765325|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|To: derp.derpson@localhost -filter|0.6|1679685627.765542|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Resent-Date: Fri, 24 Mar 2023 09:42:21 +0100 -filter|0.6|1679685627.765973|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Subject: This is a test -filter|0.6|1679685627.766188|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|MIME-Version: 1.0 -filter|0.6|1679685627.766196|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Type: multipart/alternative; charset=UTF-8; boundary="MSGBOUNDARY" -filter|0.6|1679685627.766200|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Transfer-Encoding: 8bit -filter|0.6|1679685627.766221|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Message-Id: -filter|0.6|1679685627.766224|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Date: Mon, 13 Mar 2023 10:04:21 +0100 -filter|0.6|1679685627.766227|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766231|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|--MSGBOUNDARY -filter|0.6|1679685627.766246|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Type: text/plain; charset=UTF-8 -filter|0.6|1679685627.766249|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Transfer-Encoding: 8bit -filter|0.6|1679685627.766252|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Hello, world! -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|--MSGBOUNDARY -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Type: text/html; charset=UTF-8 -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|Content-Transfer-Encoding: 8bit -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|test -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|

Hello, world!

-filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685627.766266|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685636.505171|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b| -filter|0.6|1679685638.642533|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|--MSGBOUNDARY-- -filter|0.6|1679685640.319648|smtp-in|data-line|b6004c087262f6d4|ca08b19d70c81a8b|. diff --git a/tests/key-db.sqlite3 b/tests/key-db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..7c952ca14aaf8827d8ed9029650a628de3b64b08 GIT binary patch literal 28672 zcmeI4$?xn~me=3Qp|UcS)d>ixXd$F0vB{J>)AQ8oRO2Z;g=a_Djuv|I91hQ8IJ_$w zvFS~*LWl(th$TX*MFAVcro{sB7xW4VS_~3w03o$n!Y`-J%5GJwSE#Du%8vNOz1KgV z`?15m-*Zmbv5v)*zRKF64yRY>i@)^Z<;xd;>(#3lFJ64OukU@ezTDs6+ShmX_3QGc z?$0Y9zW6NrZ$J3x|Gs$p2mk!Vul?Rf|8jqOmM4KHfhU0{fhU0{fhU0{fhU0{fhU0{ zfj^JHkACOv_kQ^6zy9)f|MC<@Ra&Nx*Gcr{>pPq+Fs|^*W!R(e>dU%UAAj)vm{w^# zwZr@GyMpij#$J&W$@|}Y3ah*wis@Q^QxgwqI2CR4{`<1-3Zh`|+cfR;I?SeY|1W=1 zIiyP)|EaFs996}5P4|7UhH(@aec!$tiY1)V*SlHY?B|P)@t;(E@X6o#S!3+rl_~_k z@kM)*j`2`*ZwCD84WL)Lv9G7&@yq6-8K z7>1EJg<>%kr&L@t(-3}^u3_C(>1XYb4`YZx81?CR4H2A3g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GiP-uQ z3~omrQF>si5mrG4f-JhQ*3rPdFn*wSmj~>a&G`#OV(~$!gi5 zaZ3AmIo<5C3UGz<+HAduxXQ%$b`@Q;6i)jDTt1L0;bql6>FhyicZBr5NILrYR-*Ii zLo-M8b1tU)NlcFY|J1jPsg11m-H-)k5qVLFB4F3Aa(YcVv_sH z!vchD;`!`~aAWT7j{O;5*}Un_+$g{jOF`FQcCoQ*rHoVAWyZdSn>hOhmeO?o|nf(lm}^D=1}$$2jV-fDyrfRbnxPNINGAZx`(sXtCf~& zf7cvQIR<9R?1>2HcqtjdQr<*-t;%9d;dV=0fl$Uh_!tRq>Z2Y)igJ#!^s zkGHmQm(avS9CtT&9NP!1x$9*MvlNSE%DQGKUmsJm-*Dn#lEchr&!F7-f8tt;k_L`!EA5Fb46 zM;(RDkHJB3UIH9dgt)BR-4=Ni(oOEv_vvgv^xFAJcS1$f534(3P`>0h%VO~q9cp>g5zcBTMv?bP`mCF^QC8RyvIJc_D%5g|&?uly%>s=u%AOP}^ zs|V*tbT*Nb_bhOf2C0O8Qw3>Gvj~s+4sIP zF^iD>{zc;miVy@wkr0jS?sy{1A~>QbjM~%QzRAM-c@r~`1suY=O^=D0FDb#nrW+kE z<1yMZj_~u`Seb-&NZ&hW`SUEm#e*EpE}+$R03v7Pf;|Ldzd}^E)tMh&R%1tHI`|v& p`LE{u`8nz*fhU0{fhU0{fhU0{fhU0{fhU0{fhU0{fnO~G{|~=zh~oeN literal 0 HcmV?d00001 diff --git a/tests/start_test.py b/tests/start_test.py new file mode 100755 index 0000000..8524780 --- /dev/null +++ b/tests/start_test.py @@ -0,0 +1,170 @@ +#!/usr/bin/env python3 + +import dkim +import glob +import logging +import os +import pathlib +import smtplib +import sqlite3 +import stat +import subprocess +import sys +import tempfile +import time + +ADDR_FROM = "test.from@example.org" +ADDR_TO = "test@example.com" +DB_NAME = "key-db.sqlite3" +DEFAULT_PORT = 2525 + + +def cp_tmp_file(path, executable=False): + file = tempfile.NamedTemporaryFile(suffix=f"-{path.name}", delete=False) + with open(path, mode="rb") as f: + file.write(f.read()) + file.flush() + flags = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH + if executable: + flags = flags | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH + os.chmod(file.name, flags) + file.close() + return file + + +def get_cmd_filter_dkimout(test_dir, algorithm, canonicalization, target): + filter_path = test_dir.parent / "target" / target / "filter-dkimout" + filter_path = cp_tmp_file(filter_path, executable=True).name + db_path = test_dir / DB_NAME + db_path = cp_tmp_file(db_path).name + return ( + filter_path, + db_path, + f"{filter_path} --algorithm '{algorithm}' --canonicalization '{canonicalization}' --key-data-base '{db_path}' --domain 'example.com' --domain 'example.org' --dns-update-cmd 'builtin:none'", + ) + + +def get_opensmtpd_config(port, filter_cmd, maildir_path): + cfg_content = f"""# OpenSMTPD test configuration + +# DKIM filter +filter "dkim" proc-exec "{filter_cmd}" + +# Users +table vuser {{ "test" = "1000:100:{maildir_path}" }} + +# Listening +listen on 127.0.0.1 port {port} filter "dkim" +listen on ::1 port {port} filter "dkim" + +# Delivering +action "deliver" maildir userbase +match from any for any action "deliver" +""" + cfg_file = tempfile.NamedTemporaryFile(prefix="smtpd-", suffix=".conf") + cfg_file.write(cfg_content.encode()) + cfg_file.flush() + return cfg_file + + +def get_smtp_session(port): + return smtplib.SMTP(host="localhost", port=port) + + +def send_msg(smtp, msg_file): + with open(msg_file) as f: + msg = f.read() + smtp.sendmail(ADDR_FROM, ADDR_TO, msg) + return 1 + return 0 + + +def custom_get_txt(name, timeout=5): + db_path = pathlib.Path(__file__).parent.resolve() / DB_NAME + algs_assoc = { + "ed25519-sha256": "ed25519", + "rsa2048-sha256": "rsa", + "rsa3072-sha256": "rsa", + "rsa4096-sha256": "rsa", + } + name = name.decode("UTF-8") + selector, domain = name.split("._domainkey.") + if domain.endswith("."): + domain = domain[:-1] + con = sqlite3.connect(db_path) + cur = con.cursor() + res = cur.execute( + "SELECT algorithm, public_key FROM key_db WHERE selector = ? AND sdid = ? LIMIT 1", + (selector, domain), + ) + key = res.fetchone() + if key: + algorithm = algs_assoc[key[0]] + key = key[1] + key = f"v=DKIM1; k={algorithm}; p={key}" + return key + + +def test_dkim(message_path): + with open(message_path, mode="rb") as f: + msg = f.read() + d = dkim.DKIM(msg, logger=logging) + if d.verify(dnsfunc=custom_get_txt): + return 1 + return 0 + + +def start_tests(test_dir, maildir, smtp_port): + # Sending emails to OpenSMTPD + f, d, filter_cmd = get_cmd_filter_dkimout( + test_dir, "ed25519-sha256", "relaxed/relaxed", "debug" + ) + nb = 0 + nb_total = 0 + try: + cfg_path = get_opensmtpd_config(smtp_port, filter_cmd, maildir.name) + print("Start OpenSMTPD using the following command then press enter:") + print(f'smtpd -d -f "{cfg_path.name}"') + input("") + with get_smtp_session(smtp_port) as smtp_session: + for test_msg in glob.iglob(f"{test_dir}/*.msg"): + nb_total += 1 + nb += send_msg(smtp_session, test_msg) + finally: + os.remove(f) + os.remove(d) + msg = "messages" if nb > 1 else "message" + print(f"{nb} {msg} delivered") + nb_failed = nb_total - nb + if nb_failed > 0: + msg = "messages" if nb_failed > 1 else "message" + print(f"{nb_failed} {msg} could not be delivered") + + # Testing DKIM signatures + nb_dkim_ok = 0 + nb_dkim_total = 0 + maildir_glob = f"{maildir.name}/Maildir/new/*" + while len(glob.glob(maildir_glob)) < nb_total: + time.sleep(1) + for test_msg in glob.glob(maildir_glob): + nb_dkim_total += 1 + nb_dkim_ok += test_dkim(test_msg) + msg = "messages" if nb_dkim_ok > 1 else "message" + print(f"{nb_dkim_ok} {msg} passed the DKIM signature test") + nb_failed = nb_dkim_total - nb_dkim_ok + if nb_failed > 0: + msg = "messages" if nb_failed > 1 else "message" + print(f"{nb_failed} {msg} failed the DKIM signature test") + + input("\nPress enter to exit.") + + +def main(): + test_dir = pathlib.Path(__file__).parent.resolve() + os.chdir(test_dir.parent) + maildir = tempfile.TemporaryDirectory(prefix="Maildir_") + start_tests(test_dir, maildir, DEFAULT_PORT) + + +if __name__ == "__main__": + main() diff --git a/tests/test_01.msg b/tests/test_01.msg new file mode 100644 index 0000000..6b0fe23 --- /dev/null +++ b/tests/test_01.msg @@ -0,0 +1,10 @@ +From: Test Sender +To: test@example.com +Resent-Date: Fri, 24 Mar 2023 09:42:21 +0100 +Subject: This is a test +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: +Date: Mon, 13 Mar 2023 10:04:21 +0100 + +Hello World!