From 155f72ad645536707778e886880f4c698f755ff2 Mon Sep 17 00:00:00 2001 From: Himadri Bhattacharjee <107522312+lavafroth@users.noreply.github.com> Date: Mon, 1 Dec 2025 09:46:26 +0530 Subject: [PATCH] feat: add tests for fingerprinting multiple ssh keys --- src/authfile.rs | 18 ++++++++++++++++++ tests/fixtures/multiple_entries_authfile | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 tests/fixtures/multiple_entries_authfile diff --git a/src/authfile.rs b/src/authfile.rs index 25f7b48..083ce09 100644 --- a/src/authfile.rs +++ b/src/authfile.rs @@ -55,4 +55,22 @@ mod tests { .await .expect("failed to read valid authfile fixture"); } + + #[tokio::test] + async fn test_authfile_multiple_entries() { + let authfile = read(Path::new("tests/fixtures/multiple_entries_authfile")) + .await + .expect("failed to read authfile with multiple entries"); + + assert_eq!(authfile.entities.len(), 2); + + let fingerprints = [ + "SHA256:Ps6A7BicnJXgw9YM1kkN3hmDiuRG5KTD03IQ7czGalY", + "SHA256:Fbq5FVTRTm/FKKKTQcQXetbt6FKwTmQUBKjCIsUWZYA", + ]; + + for (entity, fingerprint) in authfile.entities.iter().zip(fingerprints) { + assert_eq!(fingerprint, entity.fingerprint()) + } + } } diff --git a/tests/fixtures/multiple_entries_authfile b/tests/fixtures/multiple_entries_authfile new file mode 100644 index 0000000..0ad2c58 --- /dev/null +++ b/tests/fixtures/multiple_entries_authfile @@ -0,0 +1,2 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM7w9XepGj/eclXfAd/8bndayZyOCG0KOOfC8u5dkZ+R dri@home +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA/wbGoIUsbBHFbnXj2g+23C8sUgYkZTq0TrBm0MMWnx h@cafe