tests: add tests for authfile

This commit is contained in:
Himadri Bhattacharjee
2025-11-24 07:27:45 +05:30
parent 10b440de08
commit 296a4e6647
2 changed files with 22 additions and 0 deletions

View File

@@ -35,3 +35,24 @@ pub enum Error {
#[error("failed to parse entity: {0}")]
PublicKeyParsing(#[from] crate::entity::Error),
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_read_nonexistent_file() {
let nonexistent = Path::new("tests/fixtures/nonexistent.txt");
match read(nonexistent).await {
Err(Error::FileNotReadable(_)) => {}
_ => panic!("reading nonexistent authfile succeded: should have failed"),
};
}
#[tokio::test]
async fn test_valid_authfile() {
read(Path::new("tests/fixtures/valid_authfile"))
.await
.expect("failed to read valid authfile fixture");
}
}

1
tests/fixtures/valid_authfile vendored Normal file
View File

@@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA/wbGoIUsbBHFbnXj2g+23C8sUgYkZTq0TrBm0MMWnx h@cafe