allow load_accounts to take encryption passkey

This commit is contained in:
Carson McManus 2021-08-14 23:45:17 -04:00
parent dc18f3a7ab
commit c98ff1c914
2 changed files with 4 additions and 4 deletions

View file

@ -84,7 +84,7 @@ impl Manifest {
return Ok(manifest); return Ok(manifest);
} }
pub fn load_accounts(&mut self) -> anyhow::Result<()> { pub fn load_accounts(&mut self, passkey: Option<&str>) -> anyhow::Result<()> {
for entry in &mut self.entries { for entry in &mut self.entries {
let path = Path::new(&self.folder).join(&entry.filename); let path = Path::new(&self.folder).join(&entry.filename);
debug!("loading account: {:?}", path); debug!("loading account: {:?}", path);
@ -187,7 +187,7 @@ mod tests {
let mut loaded_manifest = Manifest::load(manifest_path.as_path()).unwrap(); let mut loaded_manifest = Manifest::load(manifest_path.as_path()).unwrap();
assert_eq!(loaded_manifest.entries.len(), 1); assert_eq!(loaded_manifest.entries.len(), 1);
assert_eq!(loaded_manifest.entries[0].filename, "asdf1234.maFile"); assert_eq!(loaded_manifest.entries[0].filename, "asdf1234.maFile");
assert!(matches!(loaded_manifest.load_accounts(), Ok(_))); assert!(matches!(loaded_manifest.load_accounts(None), Ok(_)));
assert_eq!( assert_eq!(
loaded_manifest.entries.len(), loaded_manifest.entries.len(),
loaded_manifest.accounts.len() loaded_manifest.accounts.len()
@ -257,7 +257,7 @@ mod tests {
assert!(matches!(result, Ok(_))); assert!(matches!(result, Ok(_)));
let mut manifest = result.unwrap(); let mut manifest = result.unwrap();
assert!(matches!(manifest.entries.last().unwrap().encryption, None)); assert!(matches!(manifest.entries.last().unwrap().encryption, None));
assert!(matches!(manifest.load_accounts(), Ok(_))); assert!(matches!(manifest.load_accounts(None), Ok(_)));
assert_eq!( assert_eq!(
manifest.entries.last().unwrap().account_name, manifest.entries.last().unwrap().account_name,
manifest manifest

View file

@ -173,7 +173,7 @@ fn main() {
} }
manifest manifest
.load_accounts() .load_accounts(matches.value_of("passkey"))
.expect("Failed to load accounts in manifest"); .expect("Failed to load accounts in manifest");
if matches.is_present("setup") { if matches.is_present("setup") {