Skip to content

Commit

Permalink
tests: connect to example.com via platform verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
amesgen committed Apr 13, 2024
1 parent 4eb6bd5 commit a16b456
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/client_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ fn client_server_integration() {
client_tests: vec![
ClientTest {
name: "No client auth",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![("CA_FILE", "testdata/minica.pem")],
expect_error: true, // Client connecting w/o AUTH_CERT/AUTH_KEY should err.
},
ClientTest {
name: "Valid client auth",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![
("CA_FILE", "testdata/minica.pem"),
Expand All @@ -71,6 +75,8 @@ fn client_server_integration() {
client_tests: vec![
ClientTest {
name: "Valid client auth",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![
("CA_FILE", "testdata/minica.pem"),
Expand All @@ -81,6 +87,8 @@ fn client_server_integration() {
},
ClientTest {
name: "Revoked client auth",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![
("CA_FILE", "testdata/minica.pem"),
Expand All @@ -105,30 +113,40 @@ fn standard_client_tests(valgrind: Option<String>) -> Vec<ClientTest> {
vec![
ClientTest {
name: "rustls-platform-verifier",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![("RUSTLS_PLATFORM_VERIFIER", "1")],
expect_error: true,
},
ClientTest {
name: "With CA_FILE",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![("CA_FILE", "testdata/minica.pem")],
expect_error: false,
},
ClientTest {
name: "No certificate validation",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![("NO_CHECK_CERTIFICATE", "1")],
expect_error: false,
},
ClientTest {
name: "Client Vectored I/O",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![("CA_FILE", "testdata/minica.pem"), ("USE_VECTORED", "1")],
expect_error: false,
},
ClientTest {
name: "Client authentication",
host: HOST,
port: PORT,
valgrind: valgrind.clone(),
env: vec![
("CA_FILE", "testdata/minica.pem"),
Expand All @@ -142,6 +160,8 @@ fn standard_client_tests(valgrind: Option<String>) -> Vec<ClientTest> {

struct ClientTest {
name: &'static str,
host: &'static str,
port: &'static str,
valgrind: Option<String>,
env: Vec<(&'static str, &'static str)>,
expect_error: bool,
Expand All @@ -150,7 +170,7 @@ struct ClientTest {
impl ClientTest {
fn run(&self) {
let client_binary = client_binary();
let args = vec![HOST, PORT, "/"];
let args = vec![self.host, self.port, "/"];
let (program, args) = match &self.valgrind {
None => (client_binary.as_str(), args),
Some(valgrind) => (
Expand Down Expand Up @@ -232,6 +252,20 @@ impl TestCase {
}
}

#[test]
#[ignore] // This test requires the client binary be present.
fn platform_verifier() {
ClientTest {
name: "Platform verifier to example.com",
host: "example.com",
port: "443",
valgrind: env::var("VALGRIND").ok(),
env: vec![("RUSTLS_PLATFORM_VERIFIER", "1")],
expect_error: false,
}
.run();
}

fn client_binary() -> String {
let custom_client_binary = env::var("CLIENT_BINARY").ok();
#[cfg(not(target_os = "windows"))]
Expand Down

0 comments on commit a16b456

Please sign in to comment.