Skip to content

Commit e7e110c

Browse files
committed
cleanup and enhance test cases
1 parent 6d1d297 commit e7e110c

File tree

1 file changed

+3
-94
lines changed

1 file changed

+3
-94
lines changed

apps/vault/src/actions.rs

Lines changed: 3 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -747,98 +747,6 @@ impl<'a> ActionManager<'a> {
747747
}
748748
#[cfg(feature="vaultperf")]
749749
self.perfentry(&self.pm, PERFMETA_ENDBLOCK, 1, std::line!());
750-
751-
/* DELETEME: kept around for quick debugging without having to look through commit history
752-
once we have confidence in the new method, we can drop this code right away.
753-
754-
#[cfg(feature="vaultperf")]
755-
self.perfentry(&self.pm, PERFMETA_STARTBLOCK, 1, std::line!());
756-
let keylist = match self.pddb.borrow().list_keys(VAULT_PASSWORD_DICT, None) {
757-
Ok(keylist) => keylist,
758-
Err(e) => {
759-
match e.kind() {
760-
std::io::ErrorKind::NotFound => {
761-
log::debug!("Password dictionary not yet created");
762-
}
763-
_ => {
764-
log::error!("Dictionary error accessing password database");
765-
self.report_err("Dictionary error accessing password database", Some(e))
766-
},
767-
}
768-
Vec::new()
769-
}
770-
};
771-
#[cfg(feature="vaultperf")]
772-
self.perfentry(&self.pm, PERFMETA_ENDBLOCK, 1, std::line!());
773-
log::info!("listing took {} ms", self.tt.elapsed_ms() - start);
774-
let start = self.tt.elapsed_ms();
775-
let klen = keylist.len();
776-
#[cfg(feature="vaultperf")]
777-
self.perfentry(&self.pm, PERFMETA_STARTBLOCK, 2, std::line!());
778-
let pddb = self.pddb.borrow();
779-
for key in keylist {
780-
#[cfg(feature="vaultperf")]
781-
self.perfentry(&self.pm, PERFMETA_STARTBLOCK, 3, std::line!());
782-
match pddb.get(
783-
VAULT_PASSWORD_DICT,
784-
&key,
785-
None,
786-
false, false, None,
787-
Some(crate::basis_change)
788-
) {
789-
Ok(mut record) => {
790-
// determine the exact length of the record and read it in one go.
791-
// read_to_end() performs ~5x read calls to do the same thing, because it
792-
// has to "guess" the total record length starting with a 32-byte increment
793-
let len = record.attributes().unwrap().len;
794-
let mut data = Vec::<u8>::with_capacity(len);
795-
data.resize(len, 0);
796-
#[cfg(feature="vaultperf")]
797-
self.perfentry(&self.pm, PERFMETA_NONE, 3, std::line!());
798-
match record.read_exact(&mut data) {
799-
Ok(_len) => {
800-
if let Some(pw) = storage::PasswordRecord::try_from(data).ok() {
801-
#[cfg(feature="vaultperf")]
802-
self.perfentry(&self.pm, PERFMETA_NONE, 3, std::line!());
803-
let extra = format!("{}; {}{}",
804-
crate::ux::atime_to_str(pw.atime),
805-
t!("vault.u2f.appinfo.authcount", xous::LANG),
806-
pw.count,
807-
);
808-
let desc = format!("{}/{}", pw.description, pw.username);
809-
let li = ListItem {
810-
name: desc,
811-
extra,
812-
dirty: true,
813-
guid: key,
814-
};
815-
il.push(li);
816-
#[cfg(feature="vaultperf")]
817-
self.perfentry(&self.pm, PERFMETA_NONE, 3, std::line!());
818-
} else {
819-
log::error!("Couldn't deserialize password");
820-
self.report_err("Couldn't deserialize password:", Some(key));
821-
}
822-
}
823-
Err(e) => {
824-
log::error!("Couldn't access password key");
825-
self.report_err("Couldn't access password key", Some(e))
826-
},
827-
}
828-
}
829-
Err(e) => {
830-
log::error!("Couldn't access password key");
831-
self.report_err("Couldn't access password key", Some(e))
832-
},
833-
}
834-
#[cfg(feature="vaultperf")]
835-
self.perfentry(&self.pm, PERFMETA_ENDBLOCK, 3, std::line!());
836-
#[cfg(feature="vaultperf")]
837-
self.pm.flush().ok();
838-
}
839-
#[cfg(feature="vaultperf")]
840-
self.perfentry(&self.pm, PERFMETA_ENDBLOCK, 2, std::line!());
841-
*/
842750
log::info!("readout took {} ms for {} elements", self.tt.elapsed_ms() - start, klen);
843751
}
844752
VaultMode::Fido => {
@@ -1130,9 +1038,10 @@ impl<'a> ActionManager<'a> {
11301038
self.modals.dynamic_notification(Some("Creating test entries..."), None).ok();
11311039
let words = [
11321040
"bunnie", "foo", "turtle.net", "Fox.ng", "Bear", "dog food", "Cat.com", "FUzzy", "1off", "www_test_site_com/long_name/stupid/foo.htm",
1133-
"._weird~yy%\":'test", "//WHYwhyWHY", "Xyz|zy", "foo:bar", "f🍕🍔🍟🌭d", "💎🙌", "some ノート", "笔录4u", "@u", "sane text", "Käsesoßenrührlöffel"];
1041+
"._weird~yy%\":'test", "//WHYwhyWHY", "Xyz|zy", "foo:bar", "f🍕🍔🍟🌭d", "💎🙌", "some ノート", "笔录4u", "@u", "sane text", "Käsesoßenrührlöffel",
1042+
"entropy", "👀", "mysite.com", "hax", "1336", "yo", "b", "mando", "Grogu", "zebra", "aws"];
11341043
let weights = [1; 21];
1135-
const TARGET_ENTRIES: usize = 15;
1044+
const TARGET_ENTRIES: usize = 12;
11361045
const TARGET_ENTRIES_PW: usize = 200;
11371046
// for each database, populate up to TARGET_ENTRIES
11381047
// as this is testing code, it's written a bit more fragile in terms of error handling (fail-panic, rather than fail-dialog)

0 commit comments

Comments
 (0)