MCPcopy Create free account
hub / github.com/chatmail/core / test_check_passphrase

Function test_check_passphrase

src/sql/sql_tests.rs:211–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

209
210#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
211async 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)]
244async fn test_sql_change_passphrase() -> Result<()> {

Callers

nothing calls this directly

Calls 4

cloneMethod · 0.80
check_passphraseMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected