Skip to content

Commit 57086d1

Browse files
authored
test(jetsocat): fix doctor_verify_chain_with_json_output test (#1562)
The leaf certificate of the certification chain asset is now expired. The test was updated accordingly.
1 parent 8b50a24 commit 57086d1

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

testsuite/tests/cli/jetsocat.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,14 @@ fn doctor_no_args_is_valid() {
288288
#[test]
289289
#[cfg_attr(windows, ignore = "does not pass on Windows")] // FIXME
290290
fn doctor_verify_chain_with_json_output() {
291+
#[cfg(unix)]
292+
const CHAIN_CHECK_NAME: &str = "rustls_check_chain";
293+
#[cfg(windows)]
294+
const CHAIN_CHECK_NAME: &str = "schannel_check_chain";
295+
291296
let tempdir = tempfile::tempdir().unwrap();
292-
let chain_file_path = tempdir.path().join("devolutions-net-chain.pem");
293-
std::fs::write(&chain_file_path, DEVOLUTIONS_NET_CHAIN).unwrap();
297+
let chain_file_path = tempdir.path().join("expired-devolutions-net-chain.pem");
298+
std::fs::write(&chain_file_path, EXPIRED_DEVOLUTIONS_NET_CHAIN).unwrap();
294299

295300
let output = jetsocat_assert_cmd()
296301
.args([
@@ -303,7 +308,7 @@ fn doctor_verify_chain_with_json_output() {
303308
"json",
304309
])
305310
.assert()
306-
.success();
311+
.failure();
307312

308313
let stdout = std::str::from_utf8(&output.get_output().stdout).unwrap();
309314

@@ -328,9 +333,17 @@ fn doctor_verify_chain_with_json_output() {
328333
_ => panic!("unexpected key: {key}"),
329334
}
330335
}
336+
337+
if entry["name"].as_str().unwrap() == CHAIN_CHECK_NAME {
338+
// Since the leaf certificate is expired, this check should fail.
339+
assert!(!entry["success"].as_bool().unwrap());
340+
} else {
341+
// All the other checks should succeed.
342+
assert!(entry["success"].as_bool().unwrap());
343+
}
331344
}
332345

333-
const DEVOLUTIONS_NET_CHAIN: &str = "
346+
const EXPIRED_DEVOLUTIONS_NET_CHAIN: &str = "
334347
-----BEGIN CERTIFICATE-----
335348
MIIHjDCCBXSgAwIBAgIQA+YDg5H+4+jZc0rMWYNN1zANBgkqhkiG9w0BAQsFADBc
336349
MQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xNDAyBgNVBAMT

0 commit comments

Comments
 (0)