diff --git a/db/db-core/src/lib.rs b/db/db-core/src/lib.rs index 2a84bcef..434ee86d 100644 --- a/db/db-core/src/lib.rs +++ b/db/db-core/src/lib.rs @@ -137,6 +137,13 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase { /// create new captcha async fn create_captcha(&self, username: &str, p: &CreateCaptcha) -> DBResult<()>; + /// update captcha metadata; doesn't change captcha key + async fn update_captcha_metadata( + &self, + username: &str, + p: &CreateCaptcha, + ) -> DBResult<()>; + /// Add levels to captcha async fn add_captcha_levels( &self, diff --git a/db/db-core/src/tests.rs b/db/db-core/src/tests.rs index dcf45e21..761feb2f 100644 --- a/db/db-core/src/tests.rs +++ b/db/db-core/src/tests.rs @@ -142,6 +142,12 @@ pub async fn database_works<'a, T: MCDatabase>( // delete captcha levels db.delete_captcha_levels(p.username, c.key).await.unwrap(); + // update captcha; set description = username and duration *= duration; + let mut c2 = c.clone(); + c2.duration *= c2.duration; + c2.description = p.username; + db.update_captcha_metadata(p.username, &c2).await.unwrap(); + // delete captcha db.delete_captcha(p.username, c.key).await.unwrap(); assert!(!db.captcha_exists(Some(p.username), c.key).await.unwrap());