Skip to content

Commit

Permalink
Remove bundled filesystem dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey committed Feb 19, 2024
1 parent b63132c commit e7d63ee
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
5 changes: 0 additions & 5 deletions .reuse/dep5

This file was deleted.

10 changes: 10 additions & 0 deletions failure-paths.md
Original file line number Diff line number Diff line change
@@ -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
38 changes: 32 additions & 6 deletions src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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(())
})
Expand All @@ -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)),
Expand Down Expand Up @@ -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!("/"));
Expand Down
Binary file removed test_fs/fido-trussed-auth.lfs
Binary file not shown.
Binary file removed test_fs/fido-trussed.lfs
Binary file not shown.

0 comments on commit e7d63ee

Please sign in to comment.