diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index 4cdc386..0000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,5 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ - -Files: test_fs/* -Copyright: Nitrokey GmbH -License: CC0-1.0 diff --git a/failure-paths.md b/failure-paths.md new file mode 100644 index 0000000..c549707 --- /dev/null +++ b/failure-paths.md @@ -0,0 +1,10 @@ +- can_lifecycle_run -> not because other ops would also not fail +- Length check -> not because error is different +- admin_verified check -> error is different +- state.reset_user_code_with_pw3 + - get_user_key() + - admin_kek() -> Can't be because different error, and admin was checked + - unwrap_key + - set_pin_with_key can't because panic + - Bytes::from_slice -> can't because length is checked + - set_pin_len() could fail but this would be weird diff --git a/src/migrate.rs b/src/migrate.rs index d6aa020..6e98215 100644 --- a/src/migrate.rs +++ b/src/migrate.rs @@ -82,6 +82,25 @@ mod tests { File(usize), } + fn prepare_fs(fs: &dyn DynFilesystem, value: &FsValues, path: &Path) { + match value { + FsValues::File(f_data_len) => { + fs.create_file_and_then(path,&mut |f| { + f.set_len(*f_data_len).unwrap(); + Ok(()) + }).unwrap(); + } + FsValues::Dir(d) => { + if path != path!("/") { + fs.create_dir(path).unwrap(); + } + for (p, v) in *d { + prepare_fs(fs, v, &path.join(p)); + } + } + } + } + fn test_fs_equality(fs: &dyn DynFilesystem, value: &FsValues, path: &Path) { match value { FsValues::Dir(d) => { @@ -176,9 +195,13 @@ mod tests { ), ]); - Filesystem::mount_and_then(&mut NoBackendStorage::new(&mut storage), |fs| { + let backend = &mut NoBackendStorage::new(&mut storage); + + Filesystem::format(backend).unwrap(); + Filesystem::mount_and_then(backend, |fs| { + prepare_fs(fs, &TEST_VALUES, path!("/")); test_fs_equality(fs, &TEST_VALUES, path!("/")); - migrate_remove_dat(fs, &[path!("fido")]).unwrap(); + migrate_remove_dat(fs, &[path!("secrets"), path!("opcard")]).unwrap(); test_fs_equality(fs, &TEST_VALUES, path!("/")); Ok(()) }) @@ -187,9 +210,7 @@ mod tests { #[test] fn migration_full() { - let mut storage = RamDirect { - buf: *include_bytes!("../test_fs/fido-trussed-auth.lfs"), - }; + let mut storage = RamDirect::default(); const AUTH_SECRETS_DIR: FsValues = FsValues::Dir(&[ (path!("application_salt"), FsValues::File(16)), @@ -246,7 +267,12 @@ mod tests { ), ]); - Filesystem::mount_and_then(&mut NoBackendStorage::new(&mut storage), |fs| { + + let backend = &mut NoBackendStorage::new(&mut storage); + + Filesystem::format(backend).unwrap(); + Filesystem::mount_and_then(backend, |fs| { + prepare_fs(fs, &TEST_BEFORE, path!("/")); test_fs_equality(fs, &TEST_BEFORE, path!("/")); migrate_remove_dat(fs, &[path!("secrets"), path!("opcard")]).unwrap(); test_fs_equality(fs, &TEST_AFTER, path!("/")); diff --git a/test_fs/fido-trussed-auth.lfs b/test_fs/fido-trussed-auth.lfs deleted file mode 100644 index f3e16fd..0000000 Binary files a/test_fs/fido-trussed-auth.lfs and /dev/null differ diff --git a/test_fs/fido-trussed.lfs b/test_fs/fido-trussed.lfs deleted file mode 100644 index ca6495c..0000000 Binary files a/test_fs/fido-trussed.lfs and /dev/null differ