Not localhost from coverage container

This commit is contained in:
Jon Gjengset 2019-09-03 11:18:10 -04:00
parent 327eed8b97
commit cd2c3a58c5
No known key found for this signature in database
GPG key ID: FAEA8B761ADA5F4C
2 changed files with 29 additions and 10 deletions

View file

@ -78,6 +78,8 @@ stages:
codecov_token: $(CODECOV_TOKEN_SECRET) codecov_token: $(CODECOV_TOKEN_SECRET)
services: services:
greenmail: greenmail greenmail: greenmail
envs:
TEST_HOST: greenmail
resources: resources:
repositories: repositories:

View file

@ -14,10 +14,17 @@ fn tls() -> native_tls::TlsConnector {
} }
fn session(user: &str) -> imap::Session<native_tls::TlsStream<TcpStream>> { fn session(user: &str) -> imap::Session<native_tls::TlsStream<TcpStream>> {
let mut s = imap::connect("127.0.0.1:3993", "imap.example.com", &tls()) let mut s = imap::connect(
.unwrap() &format!(
.login(user, user) "{}:3993",
.unwrap(); std::env::var("TEST_HOST").unwrap_or("127.0.0.1".to_string())
),
"imap.example.com",
&tls(),
)
.unwrap()
.login(user, user)
.unwrap();
s.debug = true; s.debug = true;
s s
} }
@ -25,7 +32,10 @@ fn session(user: &str) -> imap::Session<native_tls::TlsStream<TcpStream>> {
fn smtp(user: &str) -> lettre::SmtpTransport { fn smtp(user: &str) -> lettre::SmtpTransport {
let creds = lettre::smtp::authentication::Credentials::new(user.to_string(), user.to_string()); let creds = lettre::smtp::authentication::Credentials::new(user.to_string(), user.to_string());
lettre::SmtpClient::new( lettre::SmtpClient::new(
"127.0.0.1:3465", &format!(
"{}:3465",
std::env::var("TEST_HOST").unwrap_or("127.0.0.1".to_string())
),
lettre::ClientSecurity::Wrapper(lettre::ClientTlsParameters { lettre::ClientSecurity::Wrapper(lettre::ClientTlsParameters {
connector: tls(), connector: tls(),
domain: "smpt.example.com".to_string(), domain: "smpt.example.com".to_string(),
@ -38,17 +48,24 @@ fn smtp(user: &str) -> lettre::SmtpTransport {
#[test] #[test]
fn connect_insecure() { fn connect_insecure() {
imap::connect_insecure("127.0.0.1:3143").unwrap(); imap::connect_insecure(&format!(
"{}:3143",
std::env::var("TEST_HOST").unwrap_or("127.0.0.1".to_string())
))
.unwrap();
} }
#[test] #[test]
#[ignore] #[ignore]
fn connect_insecure_then_secure() { fn connect_insecure_then_secure() {
// ignored because of https://github.com/greenmail-mail-test/greenmail/issues/135 // ignored because of https://github.com/greenmail-mail-test/greenmail/issues/135
imap::connect_insecure("127.0.0.1:3143") imap::connect_insecure(&format!(
.unwrap() "{}:3143",
.secure("imap.example.com", &tls()) std::env::var("TEST_HOST").unwrap_or("127.0.0.1".to_string())
.unwrap(); ))
.unwrap()
.secure("imap.example.com", &tls())
.unwrap();
} }
#[test] #[test]