From 44e3e5553a4eb525b0c692673c3dc5a19d8ad2a7 Mon Sep 17 00:00:00 2001 From: Maximiliano Sandoval Date: Fri, 15 Dec 2023 21:58:48 +0100 Subject: [PATCH] Update tests --- README.md | 6 +++--- client/examples/basic.rs | 2 +- client/examples/basic_2.rs | 2 +- client/examples/dbus_service.rs | 2 +- client/src/dbus/mod.rs | 2 +- client/src/portal/api/mod.rs | 8 ++++---- client/src/portal/mod.rs | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a47cd8b3a..d8a4b61cb 100644 --- a/README.md +++ b/README.md @@ -43,12 +43,12 @@ async fn run() -> oo7::Result<()> { // Find a stored secret let items = keyring - .search_items(HashMap::from([("attribute", "attribute_value")])) + .search_items(&HashMap::from([("attribute", "attribute_value")])) .await?; // Delete a stored secret keyring - .delete(HashMap::from([("attribute", "attribute_value")])) + .delete(&HashMap::from([("attribute", "attribute_value")])) .await?; // Unlock the collection if the Secret Service is used @@ -82,7 +82,7 @@ fn main() { let items = KEYRING .get() .unwrap() - .search_items(HashMap::from([("attribute", "attribute_value")])) + .search_items(&HashMap::from([("attribute", "attribute_value")])) .await; }); } diff --git a/client/examples/basic.rs b/client/examples/basic.rs index 330ffc6f3..c351fdd71 100644 --- a/client/examples/basic.rs +++ b/client/examples/basic.rs @@ -15,7 +15,7 @@ async fn main() -> oo7::Result<()> { .await?; let items = keyring - .search_items(HashMap::from([("attr", "value")])) + .search_items(&HashMap::from([("attr", "value")])) .await?; for item in items { diff --git a/client/examples/basic_2.rs b/client/examples/basic_2.rs index c21e15d77..30469a816 100644 --- a/client/examples/basic_2.rs +++ b/client/examples/basic_2.rs @@ -24,7 +24,7 @@ async fn main() -> oo7::Result<()> { let items = KEYRING .get() .unwrap() - .search_items(HashMap::from([("attr", "value")])) + .search_items(&HashMap::from([("attr", "value")])) .await?; for item in items { diff --git a/client/examples/dbus_service.rs b/client/examples/dbus_service.rs index 637ac39d2..770e4041e 100644 --- a/client/examples/dbus_service.rs +++ b/client/examples/dbus_service.rs @@ -9,7 +9,7 @@ async fn main() -> oo7::Result<()> { let mut attributes = HashMap::new(); attributes.insert("type", "token"); let collection = service.default_collection().await?; - let items = collection.search_items(attributes).await?; + let items = collection.search_items(&attributes).await?; for item in items { println!("{}", item.label().await?); println!("{}", item.is_locked().await?); diff --git a/client/src/dbus/mod.rs b/client/src/dbus/mod.rs index 382cc9068..a659587fb 100644 --- a/client/src/dbus/mod.rs +++ b/client/src/dbus/mod.rs @@ -24,7 +24,7 @@ //! .await?; //! //! // Retrieve it later thanks to it attributes -//! let items = collection.search_items(attributes).await?; +//! let items = collection.search_items(&attributes).await?; //! let item = items.first().unwrap(); //! assert_eq!(*item.secret().await?, b"password"); //! diff --git a/client/src/portal/api/mod.rs b/client/src/portal/api/mod.rs index 79ea8eb9a..334866f9a 100644 --- a/client/src/portal/api/mod.rs +++ b/client/src/portal/api/mod.rs @@ -330,11 +330,11 @@ mod tests { .items .push(Item::new(String::from("Label"), needle.clone(), b"MyPassword").encrypt(&key)?); - assert_eq!(keyring.search_items(needle.clone(), &key)?.len(), 1); + assert_eq!(keyring.search_items(&needle, &key)?.len(), 1); - keyring.remove_items(needle.clone(), &key)?; + keyring.remove_items(&needle, &key)?; - assert_eq!(keyring.search_items(needle, &key)?.len(), 0); + assert_eq!(keyring.search_items(&needle, &key)?.len(), 0); Ok(()) } @@ -360,7 +360,7 @@ mod tests { let loaded_keyring = Keyring::try_from(blob.as_slice())?; let loaded_items = - loaded_keyring.search_items(HashMap::from([("my-tag", "my tag value")]), &key)?; + loaded_keyring.search_items(&HashMap::from([("my-tag", "my tag value")]), &key)?; assert_eq!(*loaded_items[0].secret(), "A Password".as_bytes()); diff --git a/client/src/portal/mod.rs b/client/src/portal/mod.rs index ecb160049..483056a4f 100644 --- a/client/src/portal/mod.rs +++ b/client/src/portal/mod.rs @@ -17,12 +17,12 @@ //! .await?; //! //! let items = keyring -//! .search_items(HashMap::from([("account", "alice")])) +//! .search_items(&HashMap::from([("account", "alice")])) //! .await?; //! assert_eq!(*items[0].secret(), b"My Password"); //! //! keyring -//! .delete(HashMap::from([("account", "alice")])) +//! .delete(&HashMap::from([("account", "alice")])) //! .await?; //! # Ok(()) //! # }