use std::time::Duration; use btlib::{ crypto::{CredStoreMut, Creds}, Epoch, Principaled, Result, }; pub trait CredStoreTestingExt: CredStoreMut { /// Generates new root credentials and issues the node credentials a writecap using them. The /// given password is used to secure the root credentials. fn provision(&self, root_password: &str) -> Result<()> { let root_creds = self.gen_root_creds(root_password)?; let mut node_creds = self.node_creds()?; let expires = Epoch::now() + Duration::from_secs(3600); let writecap = root_creds.issue_writecap(node_creds.principal(), &mut std::iter::empty(), expires)?; self.assign_node_writecap(&mut node_creds, writecap) } } impl CredStoreTestingExt for T {}