Commit 5b161afb authored by MrMan's avatar MrMan

Introduce state for app, to enable sending messages to postfix

parent 76744245
......@@ -500,6 +500,14 @@ name = "encoding_index_tests"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "encoding_rs"
version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "error-chain"
version = "0.8.1"
......@@ -647,6 +655,44 @@ name = "httparse"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hyper"
version = "0.12.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"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)",
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"h2 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-reactor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-threadpool 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hyper-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"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)",
"hyper 0.12.24 (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 = "idna"
version = "0.1.5"
......@@ -722,6 +768,16 @@ name = "libc"
version = "0.2.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libflate"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libsqlite3-sys"
version = "0.9.3"
......@@ -1215,6 +1271,7 @@ dependencies = [
"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)",
"reqwest 0.9.9 (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)",
"serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -1449,6 +1506,35 @@ dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "reqwest"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.16 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.24 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libflate 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)",
"native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-threadpool 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "resolv-conf"
version = "0.6.2"
......@@ -2030,6 +2116,11 @@ dependencies = [
"trust-dns-proto 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "try-lock"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "ucd-util"
version = "0.1.3"
......@@ -2186,6 +2277,16 @@ name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "want"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "widestring"
version = "0.2.2"
......@@ -2296,6 +2397,7 @@ dependencies = [
"checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
"checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
"checksum encoding_rs 0.8.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0535f350c60aac0b87ccf28319abc749391e912192255b0c00a2c12c6917bd73"
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
"checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
......@@ -2314,6 +2416,8 @@ dependencies = [
"checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e"
"checksum http 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "1a10e5b573b9a0146545010f50772b9e8b1dd0a256564cc4307694c68832a2f5"
"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83"
"checksum hyper 0.12.24 (registry+https://github.com/rust-lang/crates.io-index)" = "fdfa9b401ef6c4229745bb6e9b2529192d07b920eed624cdee2a82348cd550af"
"checksum hyper-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "32cd73f14ad370d3b4d4b7dce08f69b81536c82e39fcc89731930fe5788cd661"
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
......@@ -2325,6 +2429,7 @@ dependencies = [
"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047"
"checksum libflate 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "bff3ac7d6f23730d3b533c35ed75eef638167634476a499feef16c428d74b57b"
"checksum libsqlite3-sys 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d3711dfd91a1081d2458ad2d06ea30a8755256e74038be2ad927d94e1c955ca8"
"checksum linked-hash-map 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7860ec297f7008ff7a1e3382d7f7e1dcd69efc94751a2284bafc3d013c2aa939"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
......@@ -2400,6 +2505,7 @@ dependencies = [
"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f"
"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum reqwest 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)" = "09d6e187a58d923ee132fcda141c94e716bcfe301c2ea2bef5c81536e0085376"
"checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb"
"checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a"
"checksum rusqlite 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9409d78a5a9646685688266e1833df8f08b71ffcae1b5db6c1bfb5970d8a80f"
......@@ -2458,6 +2564,7 @@ dependencies = [
"checksum trust-dns-proto 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0838272e89f1c693b4df38dc353412e389cf548ceed6f9fd1af5a8d6e0e7cf74"
"checksum trust-dns-proto 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "09144f0992b0870fa8d2972cc069cbf1e3c0fda64d1f3d45c4d68d0e0b52ad4e"
"checksum trust-dns-resolver 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8a9f877f7a1ad821ab350505e1f1b146a4960402991787191d6d8cab2ce2de2c"
"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86"
"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33"
"checksum unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d3218ea14b4edcaccfa0df0a64a3792a2c32cc706f1b336e48867f9d3147f90"
......@@ -2480,6 +2587,7 @@ dependencies = [
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3"
"checksum widestring 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7157704c2e12e3d2189c507b7482c52820a16dfa4465ba91add92f266667cadb"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
......
......@@ -28,4 +28,5 @@ simple-signal = "1.1.1"
tempfile = "3"
mail = { version = "0.6.7", features = ["smtp"] }
rand = "0.5.0"
new-tokio-smtp = "0.8.1"
\ No newline at end of file
new-tokio-smtp = "0.8.1"
reqwest = "0.9.9"
\ No newline at end of file
use actix_web::{App, HttpRequest, Json, Result, Path};
use actix_web::error::ErrorNotImplemented;
use actix_web::http::Method;
use actix_web::{App, HttpRequest, Json, Result, Path};
use components::ReqResp;
use components::postfix::PostfixCmd;
use components::web_admin::AppState;
use models::user::MailboxUser;
use std::sync::mpsc::Sender;
pub fn app(
postfix_tx: Sender<ReqResp<PostfixCmd>>
) -> App<AppState> {
let state = AppState {
postfix_tx: Some(postfix_tx)
};
pub fn app() -> App {
App::new()
App::with_state(state)
.prefix("/api/v1")
.resource("/", |r| r.f(api_index))
.resource("/components/{name}/status", |r| r.method(Method::GET).with(component_status))
.resource("/users", |r| r.method(Method::POST).with(add_user))
}
#[derive(Serialize)]
......@@ -21,7 +34,7 @@ struct ComponentStatus {
state: &'static str,
}
fn api_index(_req: &HttpRequest) -> Result<Json<APIStatus>> {
fn api_index(_req: &HttpRequest<AppState>) -> Result<Json<APIStatus>> {
Ok(Json(APIStatus{
version: &env!("CARGO_PKG_VERSION")
}))
......@@ -35,3 +48,10 @@ fn component_status(info: Path<String>) -> Result<Json<ComponentStatus>> {
state: "running"
}))
}
/// Add a user
fn add_user(user: Json<MailboxUser>) -> Result<Json<MailboxUser>> {
// TODO: send a message with the new MailboxUser to the Postfix component
return Err(ErrorNotImplemented("not implemented yet"))
}
......@@ -7,6 +7,7 @@ use components::web_admin::api::v1::{app as api_v1_app};
use components::web_admin::root::{app as root_app};
use components::{Component, ReqResp, ComponentCmd, Error};
use config::WebAdminCfg;
use models::user::MailboxUser;
use std::sync::mpsc::Sender;
#[allow(dead_code)]
......@@ -22,6 +23,10 @@ pub enum WebAdminCmd {
Lifecycle(ComponentCmd)
}
pub struct AppState {
postfix_tx: Option<Sender<ReqResp<PostfixCmd>>>
}
impl WebAdmin {
pub fn new(cfg: WebAdminCfg, postfix_tx_chan: Sender<ReqResp<PostfixCmd>>) -> Result<WebAdmin, Error> {
Ok(WebAdmin { cfg, postfix_tx_chan })
......@@ -36,7 +41,7 @@ impl Component for WebAdmin {
server::new(|| {
vec![
api_v1_app(),
api_v1_app(self.postfix_tx_chan.clone()),
root_app(),
]
})
......
use actix_web::{App, HttpRequest, fs::NamedFile, fs::StaticFiles, Result};
use components::web_admin::AppState;
pub fn app() -> App {
pub fn app() -> App<AppState> {
// TODO: provide 'frontend/' using frontend_dir app config variable
App::new()
App::with_state(AppState{postfix_tx: None})
.prefix("/")
.resource("/", |r| r.f(serve_index_html))
.handler("/js", StaticFiles::new("frontend/js").unwrap())
.handler("/images", StaticFiles::new("frontend/images").unwrap())
}
fn serve_index_html(_req: &HttpRequest) -> Result<NamedFile> {
fn serve_index_html(_req: &HttpRequest<AppState>) -> Result<NamedFile> {
Ok(NamedFile::open("frontend/index.html")?)
}
......@@ -65,6 +65,7 @@ pub struct DockerizedPostmgr {
host: Ipv4Addr,
smtp_port: u16,
submission_port: u16,
http_port: u16,
// email-related information
pub domain_name: String,
......@@ -75,16 +76,34 @@ impl DockerizedPostmgr {
let host = Ipv4Addr::LOCALHOST;
let smtp_port = get_available_port().unwrap();
let submission_port = get_available_port().unwrap();
let http_port = get_available_port().unwrap();
let domain_name = String::from(DEFAULT_DOMAIN_NAME);
let id = thread_rng()
.sample_iter(&Alphanumeric)
.take(5)
.collect::<String>();
let container_name = format!("postmgr-test-{}", &id);
DockerizedPostmgr{
id,
container_name,
host,
smtp_port,
submission_port,
http_port,
domain_name,
}
}
pub fn start(self) -> Self {
// Create the docker child process
let smtp_port_assignment = format!("{}:25", smtp_port.to_string());
let submission_port_assignment = format!("{}:587", submission_port.to_string());
let container_name = format!("postmgr-test-{}", &id);
let smtp_port_assignment = format!("{}:25", self.smtp_port);
let submission_port_assignment = format!("{}:587", self.submission_port);
let http_port_assignment = format!("{}:8080", self.http_port);
let process = Command::new(DOCKER_BINARY)
.arg("run")
.arg("--detach")
......@@ -92,8 +111,10 @@ impl DockerizedPostmgr {
.arg(smtp_port_assignment)
.arg("-p")
.arg(submission_port_assignment)
.arg("-p")
.arg(http_port_assignment)
.arg("--name")
.arg(&container_name)
.arg(&self.container_name)
.arg(POSTMGR_TEST_IMAGE_NAME)
.stdin(Stdio::null())
.stdout(Stdio::null()) // NOTE: comment this out to get docker run output
......@@ -105,21 +126,12 @@ impl DockerizedPostmgr {
.expect("docker run command failed");
if !output.status.success() { panic!("docker run returned a non-success exit code"); }
println!("created docker container [{}], waiting 1s for startup...", &container_name);
println!("created docker container [{}], waiting 1s for startup...", &self.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,
domain_name,
}
self
}
/// Connect to the instance over TCP
......@@ -136,6 +148,10 @@ impl DockerizedPostmgr {
// pub fn get_submission_address(&self) -> String {
// format!("{}:{}", self.host, self.smtp_port)
// }
pub fn get_http_address(&self) -> String {
format!("{}:{}", self.host, self.http_port)
}
}
/// Send an EHLO & verify the response
......
extern crate reqwest;
mod common;
use reqwest::header::COOKIE;
use crate::common::DockerizedPostmgr;
use std::net::TcpStream;
use std::io::{Write, BufRead, BufReader};
......@@ -12,6 +15,7 @@ use common::{
read_ehlo,
};
/// Send MAIL FROM and verify response
fn send_mail_from(
address: &str,
......@@ -107,7 +111,7 @@ fn send_test_message(
// /// Test basic SMTP connectivity
// pub fn test_connect() {
// // Start postmgr in a docker container
// let postmgr = DockerizedPostmgr::new();
// let postmgr = DockerizedPostmgr::new().start();
// // Connect to the postmgr over port 25
// let mut stream = TcpStream::connect(postmgr.get_smtp_address()).unwrap();
......@@ -122,7 +126,7 @@ fn send_test_message(
// /// Test basic SMTP email sending
// pub fn test_email_send() {
// // Start postmgr in a docker container
// let postmgr = DockerizedPostmgr::new();
// let postmgr = DockerizedPostmgr::new().start();
// // Connect to the postmgr over port 25
// let stream = TcpStream::connect(postmgr.get_smtp_address()).unwrap();
......@@ -146,9 +150,20 @@ pub fn test_user_creation() {
/// Test user creation & interaction over basic SMTP relay
// Start postmgr in a docker container
let postmgr = DockerizedPostmgr::new();
let postmgr = DockerizedPostmgr::new().start();
// TODO: Create a new user through the API
let base_url = postmgr.get_http_address();
let client = reqwest::Client::new();
// Add a new user
let url = format!("{}/{}", &base_url, "/users");
let resp = client.post(url)
.json(fixtures.new_user)
.send()
.expect("failed to POST new user");
assert_eq!(resp.status(), 201, "new user creation worked");
// Connect to the postmgr over (unprotected) port 25
let (stream, mut reader) = postmgr.connect_tcp().unwrap();
......
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