mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-02-17 08:59:46 +03:00
feat: define interfaces for delete_captcha_levels and delete_captcha
This commit is contained in:
parent
0c1a82b4c5
commit
af46a3c54d
2 changed files with 20 additions and 0 deletions
|
@ -151,6 +151,16 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
|||
username: Option<&str>,
|
||||
captcha_key: &str,
|
||||
) -> DBResult<bool>;
|
||||
|
||||
/// Delete all levels of a captcha
|
||||
async fn delete_captcha_levels(
|
||||
&self,
|
||||
username: &str,
|
||||
captcha_key: &str,
|
||||
) -> DBResult<()>;
|
||||
|
||||
/// Delete captcha
|
||||
async fn delete_captcha(&self, username: &str, captcha_key: &str) -> DBResult<()>;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
|
|
|
@ -131,8 +131,18 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||
"user was with empty email but email is set; so email should exsit"
|
||||
);
|
||||
|
||||
// create captcha
|
||||
db.create_captcha(p.username, c).await.unwrap();
|
||||
assert!(db.captcha_exists(None, c.key).await.unwrap());
|
||||
assert!(db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
||||
|
||||
// add captcha levels
|
||||
db.add_captcha_levels(p.username, c.key, l).await.unwrap();
|
||||
|
||||
// delete captcha levels
|
||||
db.delete_captcha_levels(p.username, c.key).await.unwrap();
|
||||
|
||||
// delete captcha
|
||||
db.delete_captcha(p.username, c.key).await.unwrap();
|
||||
assert!(!db.captcha_exists(Some(p.username), c.key).await.unwrap());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue