Commit 2a3455f7 authored by MrMan's avatar MrMan

Re-add drop logic

parent 7ba26c84
Pipeline #47897647 passed with stage
in 6 minutes and 48 seconds
......@@ -172,14 +172,14 @@ impl Drop for DockerizedPostmgr {
fn drop(&mut self) {
// DEBUG: comment the lines below to leave dangling containers after tests
// // Kill the docker process
// Command::new(DOCKER_BINARY)
// .arg("kill")
// .arg(&self.container_name)
// .stdin(Stdio::null())
// .stdout(Stdio::null()) // NOTE: comment this out to get docker kill output
// .output()
// .expect("failed to start docker kill command");
// Kill the docker process
Command::new(DOCKER_BINARY)
.arg("kill")
.arg(&self.container_name)
.stdin(Stdio::null())
.stdout(Stdio::null()) // NOTE: comment this out to get docker kill output
.output()
.expect("failed to start docker kill command");
}
}
......@@ -195,7 +195,7 @@ pub fn read_ehlo(reader: &mut BufReader<TcpStream>) -> &mut BufReader<TcpStream>
}
/// Send MAIL FROM and verify response
fn send_mail_from(
pub fn send_mail_from(
address: &str,
mut stream: TcpStream,
mut reader: BufReader<TcpStream>
......@@ -212,7 +212,7 @@ fn send_mail_from(
}
/// Send RCPT TO and verify response
fn send_rcpt_to(
pub fn send_rcpt_to(
recipient: &str,
mut stream: TcpStream,
mut reader: BufReader<TcpStream>
......@@ -229,7 +229,7 @@ fn send_rcpt_to(
}
/// Send a test message with a given subject/body
fn send_test_message(
pub fn send_test_message(
subject: &str,
body: &str,
mut stream: TcpStream,
......
......@@ -16,6 +16,9 @@ use common::{
read_ehlo,
send_ehlo,
send_test_message,
send_rcpt_to,
send_mail_from,
login_with_username_password,
};
......@@ -56,46 +59,46 @@ pub fn test_email_send() {
send_test_message("test email", "this is a test", stream, reader);
}
// #[test]
// #[ignore]
// pub fn test_user_creation() {
// /// Test user creation & interaction over basic SMTP relay
// // Start postmgr in a docker container
// 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!("http://{}/{}", &base_url, "api/v1/users");
// let test_user = fixtures::test_user();
// let mut resp = client.post(url.as_str())
// .json(&test_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();
// // Ensure EHLO was received
// read_ehlo(&mut reader);
// // Send a client EHLO
// let (stream, reader) = send_ehlo(DOMAIN_NAME, stream, reader);
// // Login with username/pw
// let user = fixtures::test_user();
// login_with_username_password(
// &user.username,
// &user.password,
// stream,
// reader,
// );
// }
#[test]
#[ignore]
pub fn test_user_creation() {
/// Test user creation & interaction over basic SMTP relay
// Start postmgr in a docker container
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!("http://{}/{}", &base_url, "api/v1/users");
let test_user = fixtures::test_user();
let mut resp = client.post(url.as_str())
.json(&test_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();
// Ensure EHLO was received
read_ehlo(&mut reader);
// Send a client EHLO
let (stream, reader) = send_ehlo(DOMAIN_NAME, stream, reader);
// Login with username/pw
let user = fixtures::test_user();
login_with_username_password(
&user.username,
&user.password,
stream,
reader,
);
}
// TODO: test sending email between two local accounts
// TODO: test user delete (after deleting through the API a user should be unable to log in)
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