Implement key_parameter conversion from/to rusqlite storage.
This implements conversion methods on top of basic
keyparameter implementation in aosp/1350725
Bug: 159722691, 159723797, 161798431
Test: atest --host keystore2_tests.
Change-Id: I1457ae4cf4336ebc5bff2645bca55ad285a4449c
diff --git a/keystore2/src/error.rs b/keystore2/src/error.rs
index e6443b7..a285bda 100644
--- a/keystore2/src/error.rs
+++ b/keystore2/src/error.rs
@@ -143,9 +143,9 @@
}
#[cfg(test)]
-mod tests {
+pub mod tests {
- use anyhow::{anyhow, Context};
+ use anyhow::{anyhow, Context, Result};
use super::aidl::ErrorCode;
use super::*;
@@ -284,4 +284,18 @@
);
Ok(())
}
+
+ //Helper function to test whether error cases are handled as expected.
+ pub fn check_result_contains_error_string<T>(result: Result<T>, expected_error_string: &str) {
+ let error_str = format!(
+ "{:#?}",
+ result.err().unwrap_or_else(|| panic!("Expected the error: {}", expected_error_string))
+ );
+ assert!(
+ error_str.contains(expected_error_string),
+ "The string \"{}\" should contain \"{}\"",
+ error_str,
+ expected_error_string
+ );
+ }
} // mod tests