Skip to content

Commit a16b456

Browse files
committed
tests: connect to example.com via platform verifier
1 parent 4eb6bd5 commit a16b456

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

tests/client_server.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ fn client_server_integration() {
4242
client_tests: vec![
4343
ClientTest {
4444
name: "No client auth",
45+
host: HOST,
46+
port: PORT,
4547
valgrind: valgrind.clone(),
4648
env: vec![("CA_FILE", "testdata/minica.pem")],
4749
expect_error: true, // Client connecting w/o AUTH_CERT/AUTH_KEY should err.
4850
},
4951
ClientTest {
5052
name: "Valid client auth",
53+
host: HOST,
54+
port: PORT,
5155
valgrind: valgrind.clone(),
5256
env: vec![
5357
("CA_FILE", "testdata/minica.pem"),
@@ -71,6 +75,8 @@ fn client_server_integration() {
7175
client_tests: vec![
7276
ClientTest {
7377
name: "Valid client auth",
78+
host: HOST,
79+
port: PORT,
7480
valgrind: valgrind.clone(),
7581
env: vec![
7682
("CA_FILE", "testdata/minica.pem"),
@@ -81,6 +87,8 @@ fn client_server_integration() {
8187
},
8288
ClientTest {
8389
name: "Revoked client auth",
90+
host: HOST,
91+
port: PORT,
8492
valgrind: valgrind.clone(),
8593
env: vec![
8694
("CA_FILE", "testdata/minica.pem"),
@@ -105,30 +113,40 @@ fn standard_client_tests(valgrind: Option<String>) -> Vec<ClientTest> {
105113
vec![
106114
ClientTest {
107115
name: "rustls-platform-verifier",
116+
host: HOST,
117+
port: PORT,
108118
valgrind: valgrind.clone(),
109119
env: vec![("RUSTLS_PLATFORM_VERIFIER", "1")],
110120
expect_error: true,
111121
},
112122
ClientTest {
113123
name: "With CA_FILE",
124+
host: HOST,
125+
port: PORT,
114126
valgrind: valgrind.clone(),
115127
env: vec![("CA_FILE", "testdata/minica.pem")],
116128
expect_error: false,
117129
},
118130
ClientTest {
119131
name: "No certificate validation",
132+
host: HOST,
133+
port: PORT,
120134
valgrind: valgrind.clone(),
121135
env: vec![("NO_CHECK_CERTIFICATE", "1")],
122136
expect_error: false,
123137
},
124138
ClientTest {
125139
name: "Client Vectored I/O",
140+
host: HOST,
141+
port: PORT,
126142
valgrind: valgrind.clone(),
127143
env: vec![("CA_FILE", "testdata/minica.pem"), ("USE_VECTORED", "1")],
128144
expect_error: false,
129145
},
130146
ClientTest {
131147
name: "Client authentication",
148+
host: HOST,
149+
port: PORT,
132150
valgrind: valgrind.clone(),
133151
env: vec![
134152
("CA_FILE", "testdata/minica.pem"),
@@ -142,6 +160,8 @@ fn standard_client_tests(valgrind: Option<String>) -> Vec<ClientTest> {
142160

143161
struct ClientTest {
144162
name: &'static str,
163+
host: &'static str,
164+
port: &'static str,
145165
valgrind: Option<String>,
146166
env: Vec<(&'static str, &'static str)>,
147167
expect_error: bool,
@@ -150,7 +170,7 @@ struct ClientTest {
150170
impl ClientTest {
151171
fn run(&self) {
152172
let client_binary = client_binary();
153-
let args = vec![HOST, PORT, "/"];
173+
let args = vec![self.host, self.port, "/"];
154174
let (program, args) = match &self.valgrind {
155175
None => (client_binary.as_str(), args),
156176
Some(valgrind) => (
@@ -232,6 +252,20 @@ impl TestCase {
232252
}
233253
}
234254

255+
#[test]
256+
#[ignore] // This test requires the client binary be present.
257+
fn platform_verifier() {
258+
ClientTest {
259+
name: "Platform verifier to example.com",
260+
host: "example.com",
261+
port: "443",
262+
valgrind: env::var("VALGRIND").ok(),
263+
env: vec![("RUSTLS_PLATFORM_VERIFIER", "1")],
264+
expect_error: false,
265+
}
266+
.run();
267+
}
268+
235269
fn client_binary() -> String {
236270
let custom_client_binary = env::var("CLIENT_BINARY").ok();
237271
#[cfg(not(target_os = "windows"))]

0 commit comments

Comments
 (0)