Commit a7bcdf40 authored by MrMan's avatar MrMan

Working basic telnet-style E2E email queue test

parent 24908495
Pipeline #47795126 failed with stage
in 2 minutes and 37 seconds
[[package]]
name = "MacTypes-sys"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "actix"
version = "0.7.9"
......@@ -342,6 +350,23 @@ dependencies = [
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-foundation"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-foundation-sys"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crc"
version = "1.8.1"
......@@ -535,6 +560,19 @@ name = "fnv"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
......@@ -748,6 +786,7 @@ dependencies = [
"mail-core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"mail-headers 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"mail-internals 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"mail-smtp 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"mail-template 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -808,6 +847,19 @@ dependencies = [
"vec1 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mail-smtp"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"mail-core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"mail-headers 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"mail-internals 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"new-tokio-smtp 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mail-template"
version = "0.6.0"
......@@ -960,6 +1012,23 @@ dependencies = [
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "native-tls"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)",
"schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "net2"
version = "0.2.33"
......@@ -970,6 +1039,22 @@ dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "new-tokio-smtp"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"vec1 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nodrop"
version = "0.1.13"
......@@ -1013,6 +1098,35 @@ dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "openssl"
version = "0.10.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "openssl-probe"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "openssl-sys"
version = "0.9.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "owning_ref"
version = "0.4.0"
......@@ -1099,6 +1213,7 @@ dependencies = [
"fern 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mail 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
"new-tokio-smtp 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rusqlite 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -1393,11 +1508,41 @@ name = "safemem"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "schannel"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "scopeguard"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "security-framework"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "security-framework-sys"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
version = "0.9.0"
......@@ -1755,6 +1900,16 @@ dependencies = [
"tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tokio-tls"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tokio-udp"
version = "0.1.3"
......@@ -2091,6 +2246,7 @@ dependencies = [
]
[metadata]
"checksum MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f0d0b1cc33a4d2aee14fb4b2eac03462ef4db29c8ac4057327d8a71ad86f"
"checksum actix 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666"
"checksum actix-net 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8bebfbe6629e0131730746718c9e032b58f02c6ce06ed7c982b9fef6c8545acd"
"checksum actix-web 0.7.18 (registry+https://github.com/rust-lang/crates.io-index)" = "e9f33c941e5e69a58a6bfef33853228042ed3799fc4b5a4923a36a85776fb690"
......@@ -2123,6 +2279,8 @@ dependencies = [
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum cookie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1465f8134efa296b4c19db34d909637cb2bf0f7aaf21299e23e18fa29ac557cf"
"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980"
"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb"
"checksum crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e91d5240c6975ef33aeb5f148f35275c25eda8e8a5f95abe421978b05b8bf192"
"checksum crossbeam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad4c7ea749d9fb09e23c5cb17e3b70650860553a0e2744e38446b1803bf7db94"
......@@ -2145,6 +2303,8 @@ dependencies = [
"checksum fern 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b48af88aaf938b11baef948a5599e66e709cf92854aa2b87c71f1bcf20f80a01"
"checksum flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2291c165c8e703ee54ef3055ad6188e3d51108e2ded18e9f2476e774fc5ad3d4"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
......@@ -2176,6 +2336,7 @@ dependencies = [
"checksum mail-core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2f4e9eef2cf188d6bf1b63c2b455c255d8f716e5eb7c5a2bed11d4e22ee4f330"
"checksum mail-headers 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "87166f1c4552ed1355e4823e6acc3ef4b4e99bbc634bf9c89537390ca9ae8e3a"
"checksum mail-internals 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a538bfc6390bc9a0601adda2a3709477502a1a30ce92fbc76a6ddefa4e9aa92"
"checksum mail-smtp 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "431c3b416b359bb4b4156be190f6b3989e26a2f8aa92d7f5bc3c6b5edebfdf7d"
"checksum mail-template 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "76342a87cf6da8a89e626a72a976368b3a681d36e5a626e3a1d742b593653358"
"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
"checksum maybe-owned 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "006ac35c23dc00cd88083b27297224aedc893d628aff7374352b4f3d57315fa9"
......@@ -2192,13 +2353,18 @@ dependencies = [
"checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432"
"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125"
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
"checksum native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8e08de0070bbf4c31f452ea2a70db092f36f6f2e4d897adf5674477d488fb2"
"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
"checksum new-tokio-smtp 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "717e9c90786599851e2cee9ef780e381042e557975b9309165cfe843c3863c08"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b"
"checksum nom 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b30adc557058ce00c9d0d7cb3c6e0b5bc6f36e2e2eabe74b0ba726d194abd588"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
"checksum openssl 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ec7bd7ca4cce6dbdc77e7c1230682740d307d1218a87fb0349a571272be749f9"
"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
"checksum openssl-sys 0.9.40 (registry+https://github.com/rust-lang/crates.io-index)" = "1bb974e77de925ef426b6bc82fce15fd45bdcbeb5728bffcfc7cdeeb7ce1c2d6"
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"
......@@ -2242,7 +2408,10 @@ dependencies = [
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f"
"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
"checksum schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "0e1a231dc10abf6749cfa5d7767f25888d484201accbd919b66ab5413c502d56"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfab8dda0e7a327c696d893df9ffa19cadc4bd195797997f5223cf5831beaf05"
"checksum security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d6696852716b589dff9e886ff83778bb635150168e83afa8ac6b8a78cb82abc"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "2e20fde37801e83c891a2dc4ebd3b81f0da4d1fb67a9e0a2a3b921e2536a58ee"
......@@ -2280,6 +2449,7 @@ dependencies = [
"checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119"
"checksum tokio-threadpool 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c3fd86cb15547d02daa2b21aadaf4e37dee3368df38a526178a5afa3c034d2fb"
"checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6"
"checksum tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c"
"checksum tokio-udp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66268575b80f4a4a710ef83d087fdfeeabdce9b74c797535fbac18a2cb906e92"
"checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445"
"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
......
......@@ -26,5 +26,6 @@ simple-signal = "1.1.1"
[dev-dependencies]
tempfile = "3"
mail = "0.6.7"
rand = "0.5.0"
\ No newline at end of file
mail = { version = "0.6.7", features = ["smtp"] }
rand = "0.5.0"
new-tokio-smtp = "0.8.1"
\ No newline at end of file
......@@ -14,7 +14,8 @@ VERSION=$(shell awk '/version\s+=\s+\"([0-9|\.]+)\"$$/{print $$3}' Cargo.toml)
CARGO := $(shell command -v cargo 2> /dev/null)
CARGO_WATCH := $(shell command -v cargo-watch 2> /dev/null)
ENV=development # | production
# ENV = development | production
ENV=development
IMAGE_NAME:=postmgr
BUILDER_IMAGE_NAME:=postmgr/builder
......@@ -102,4 +103,4 @@ container-shell:
$(FQ_IMAGE_NAME) \
/bin/bash
test-container: image container
test-container: container
extern crate tempfile;
extern crate rand;
extern crate mail;
extern crate new_tokio_smtp;
use std::process::{Command, Stdio};
use std::net::{TcpListener, Ipv4Addr};
use std::time::Duration;
use std::thread;
// use std::io::{Error as IOError};
use self::rand::{thread_rng, Rng};
use self::rand::distributions::Alphanumeric;
use self::rand::seq::sample_iter;
use std::process::{Command, Stdio, Child as ChildProcess};
use std::net::{TcpListener, Ipv4Addr};
// use std::io::{Error as IOError};
// use self::new_tokio_smtp::command::Noop;
// use self::mail::{
// Domain,
// smtp::{
// ConnectionConfig,
// ConnectionBuilder,
// },
// };
pub const POSTMASTER_AT_LOCALHOST: &'static str = "[email protected]";
pub const CR_LF_END: &'static str = "\r\n.\r\n";
// Get available port
// https://elliotekj.com/2017/07/25/find-available-tcp-port-rust/
......@@ -15,6 +31,9 @@ const TMP_PORT_RANGE_END: u16 = 9000;
const POSTMGR_TEST_IMAGE_NAME: &'static str = "postmgr-test";
const DOCKER_BINARY: &'static str = "docker";
const DEFAULT_DOMAIN_NAME: &'static str = "localhost";
const POST_STARTUP_WAIT: Duration = Duration::from_secs(1);
fn get_available_port() -> Option<u16> {
let mut rng = thread_rng();
......@@ -35,10 +54,15 @@ fn port_is_available(port: u16) -> bool {
pub struct DockerizedPostmgr {
id: String,
container_name: String,
pub container_name: String,
// connection details
host: Ipv4Addr,
smtp_port: u16,
submission_port: u16,
host: Ipv4Addr,
// email-related information
pub domain_name: String,
}
impl DockerizedPostmgr {
......@@ -46,6 +70,7 @@ impl DockerizedPostmgr {
let host = Ipv4Addr::LOCALHOST;
let smtp_port = get_available_port().unwrap();
let submission_port = get_available_port().unwrap();
let domain_name = String::from(DEFAULT_DOMAIN_NAME);
let id = thread_rng()
.sample_iter(&Alphanumeric)
.take(5)
......@@ -75,16 +100,30 @@ impl DockerizedPostmgr {
.expect("docker run command failed");
if !output.status.success() { panic!("docker run returned a non-success exit code"); }
// TODO: process is exiting already
println!("created docker container [{}], waiting 1s for startup...", &container_name);
// Wait a little while for the process to come up
thread::sleep(POST_STARTUP_WAIT);
DockerizedPostmgr{
id,
container_name,
host,
smtp_port,
submission_port,
host,
domain_name,
}
}
pub fn get_smtp_address(&self) -> String {
format!("{}:{}", self.host, self.smtp_port)
}
// pub fn get_submission_address(&self) -> String {
// format!("{}:{}", self.host, self.smtp_port)
// }
}
impl Drop for DockerizedPostmgr {
......@@ -99,3 +138,20 @@ impl Drop for DockerizedPostmgr {
.expect("failed to start docker kill command");
}
}
// /// Create a connection to a post mgr server
// pub fn create_postmgr_conn(postmgr: &DockerizedPostmgr) -> ConnectionConfig<Noop> {
// let domain = Domain::from_unchecked(String::from(postmgr.domain_name));
// ConnectionBuilder::new(
// SocketAddr::from(postmgr.host, postmgr.submission_port),
// domain,
// ).build()
// }
// pub fn create_authenticated_postmgr_conn(
// postmgr: &DockerizedPostmgr,
// username: &str,
// password: &str
// ) -> ConnectionConfig {
// }
mod common;
use crate::common::DockerizedPostmgr;
#[test]
#[ignore]
/// Test basic SMTP connectivity
pub fn test_smtp_connect() {
let postmgr = DockerizedPostmgr::new();
// TODO: start postmgr in a docker container
}
// TODO: test create user & login
// TODO: test sending email
// TODO: test sending email between local users (?)
mod common;
use crate::common::DockerizedPostmgr;
use std::net::TcpStream;
use std::io::{Write, BufRead, BufReader};
use common::{POSTMASTER_AT_LOCALHOST, CR_LF_END};
/// Send an EHLO & verify the response
fn read_ehlo(reader: &mut BufReader<TcpStream>) -> &mut BufReader<TcpStream> {
let mut line = String::new();
reader.read_line(&mut line).unwrap();
println!("EHLO response: [{}]", line.trim());
assert!(line.contains("220"), "EHLO response contained '220'");
assert!(line.contains("Postfix"), "EHLO response contained 'Postfix'");
reader
}
/// Send MAIL FROM and verify response
fn send_mail_from(
address: &str,
mut stream: TcpStream,
mut reader: BufReader<TcpStream>
) -> (TcpStream, BufReader<TcpStream>) {
let cmd = format!("MAIL FROM: {}\n", address);
stream.write(cmd.as_bytes()).unwrap();
let mut line = String::new();
reader.read_line(&mut line).unwrap();
println!("MAIL FROM response: [{}]", line.trim());
assert!(line.contains("250"), "MAIL FROM response succeeded");
(stream, reader)
}
/// Send MAIL FROM and verify response
fn send_rcpt_to(
recipient: &str,
mut stream: TcpStream,
mut reader: BufReader<TcpStream>
) -> (TcpStream, BufReader<TcpStream>) {
let cmd = format!("RCPT TO: {}\n", recipient);
stream.write(cmd.as_bytes()).unwrap();
let mut line = String::new();
reader.read_line(&mut line).unwrap();
println!("RCPT TO response: [{}]", line.trim());
assert!(line.contains("250"), "RCPT TO response succeeded");
(stream, reader)
}
/// Send MAIL FROM and verify response
fn send_test_message(
subject: &str,
body: &str,
mut stream: TcpStream,
mut reader: BufReader<TcpStream>
) -> (TcpStream, BufReader<TcpStream>) {
let mut line = String::new();
// Send data start
let cmd = format!("DATA\n");
stream.write(cmd.as_bytes()).unwrap();
reader.read_line(&mut line).unwrap();
// Postfix sends 354 here to indicate how to end the data
println!("DATA response: [{}]", line.trim());
assert!(line.contains("354") && line.contains("End data with"), "DATA command succeeded");
line.clear();
// Send the test
let cmd = format!("subject: {}\n{}\n{}", subject, body, CR_LF_END);
stream.write(cmd.as_bytes()).unwrap();
reader.read_line(&mut line).unwrap();
println!("Message send response: [{}]", line.trim());
assert!(line.contains("250") && line.contains("Ok:"), "Message successfully queued");
(stream, reader)
}
// #[test]
// #[ignore]
// /// Test basic SMTP connectivity
// pub fn test_smtp_25_connect() {
// // Start postmgr in a docker container
// let postmgr = DockerizedPostmgr::new();
// // Connect to the postmgr over port 25
// println!("connecting to test postmgr @ [{}]", postmgr.get_smtp_address());
// let mut stream = TcpStream::connect(postmgr.get_smtp_address()).unwrap();
// let mut reader = BufReader::new(stream.try_clone().unwrap());
// // Read the response (connection should send SMTP response)
// read_ehlo(&mut reader);
// }
#[test]
#[ignore]
/// Test basic SMTP email sending
pub fn test_smtp_25_email_send() {
// Start postmgr in a docker container
let postmgr = DockerizedPostmgr::new();
// Connect to the postmgr over port 25
println!("connecting to test postmgr @ [{}]", postmgr.get_smtp_address());
let stream = TcpStream::connect(postmgr.get_smtp_address()).unwrap();
let mut reader = BufReader::new(stream.try_clone().unwrap());
// Ensure EHLO was received
read_ehlo(&mut reader);
// MAIL FROM
let (stream, reader) = send_mail_from(POSTMASTER_AT_LOCALHOST, stream, reader);
// RCPT TO
let (stream, reader) = send_rcpt_to(POSTMASTER_AT_LOCALHOST, stream, reader);
// send message contents
send_test_message("test email", "this is a test", stream, reader);
}
// TODO: test create user & login
// TODO: test sending email
// TODO: test sending email between local users
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment