fix(storage) `read` and `revoke` Id param
@@ -108,9 +108,6 @@ impl Storage {
pub fn read(&self, id: Id, pass: &str) -> String {
let client: Client<Provider> = deserialize_from_snapshot(&self.snapshot_path, pass);
- let id = Vec::from_base64(id).expect("couldn't convert the id to from base64");
- let id = Id::load(&id).expect("Couldn't build a new Id");
-
let record = client.read_record_by_id(id);
serialize_to_snapshot(&self.snapshot_path, pass, client);
@@ -122,9 +119,6 @@ impl Storage {
pub fn revoke(&self, id: Id, pass: &str) {
let client: Client<Provider> = deserialize_from_snapshot(&self.snapshot_path, pass);
- let id = Vec::from_base64(id).expect("couldn't convert the id to from base64");
- let id = Id::load(&id).expect("Couldn't build a new Id");
-
client.revoke_record_by_id(id);
serialize_to_snapshot(&self.snapshot_path, pass, client);
@@ -140,3 +134,18 @@ impl Storage {
serialize_to_snapshot(&self.snapshot_path, pass, client);
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::Storage;
+
+ #[test]
+ fn encrypt_value() {
+ let storage = Storage::default();
+ let value = "value_to_encrypt";
+ let id = storage.encrypt("", value, "password");
+
+ let read = storage.read(id, "password");
+ assert_eq!(read, value);
+ }
+}
