()
| 209 | |
| 210 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)] |
| 211 | async fn test_check_passphrase() -> Result<()> { |
| 212 | use tempfile::tempdir; |
| 213 | |
| 214 | // The context is used only for logging. |
| 215 | let t = TestContext::new().await; |
| 216 | |
| 217 | // Create a separate empty database for testing. |
| 218 | let dir = tempdir()?; |
| 219 | let dbfile = dir.path().join("testdb.sqlite"); |
| 220 | let sql = Sql::new(dbfile.clone()); |
| 221 | |
| 222 | sql.check_passphrase("foo".to_string()).await?; |
| 223 | sql.open(&t, "foo".to_string()) |
| 224 | .await |
| 225 | .context("failed to open the database first time")?; |
| 226 | sql.close().await; |
| 227 | |
| 228 | // Reopen the database |
| 229 | let sql = Sql::new(dbfile); |
| 230 | |
| 231 | // Test that we can't open encrypted database without a passphrase. |
| 232 | assert!(sql.open(&t, "".to_string()).await.is_err()); |
| 233 | |
| 234 | // Now open the database with passpharse, it should succeed. |
| 235 | sql.check_passphrase("foo".to_string()).await?; |
| 236 | sql.open(&t, "foo".to_string()) |
| 237 | .await |
| 238 | .context("failed to open the database second time")?; |
| 239 | |
| 240 | Ok(()) |
| 241 | } |
| 242 | |
| 243 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)] |
| 244 | async fn test_sql_change_passphrase() -> Result<()> { |
nothing calls this directly
no test coverage detected