Skip to content

Commit c3eb85f

Browse files
authored
test/cksum: implement test_signed_checksums (#10714)
1 parent c7ad6ff commit c3eb85f

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

tests/by-util/test_cksum.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,9 +2524,33 @@ mod gnu_cksum_c {
25242524
}
25252525

25262526
#[test]
2527-
#[ignore = "todo"]
25282527
fn test_signed_checksums() {
2529-
todo!()
2528+
let ts = TestScenario::new(util_name!());
2529+
let at = &ts.fixtures;
2530+
2531+
let filename = "test_file";
2532+
at.touch(filename);
2533+
2534+
let checksum_result = ts.ucmd().arg("-a").arg("sha256").arg(filename).succeeds();
2535+
let valid_checksum_line = checksum_result.stdout_str().trim();
2536+
2537+
let signed_content = format!(
2538+
"-----BEGIN PGP SIGNED MESSAGE-----\n\
2539+
Hash: SHA256\n\
2540+
\n\
2541+
# This is a comment that should be ignored\n\
2542+
{valid_checksum_line}\n\
2543+
-----BEGIN PGP SIGNATURE-----\n\
2544+
\n\
2545+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\
2546+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\
2547+
=PlaceHolder\n\
2548+
-----END PGP SIGNATURE-----"
2549+
);
2550+
2551+
at.write("signed_CHECKSUMS", &signed_content);
2552+
2553+
ts.ucmd().arg("--check").arg("signed_CHECKSUMS").succeeds();
25302554
}
25312555

25322556
#[test]

0 commit comments

Comments
 (0)