mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2024-11-23 09:55:57 +03:00
feat: def interface to del traffic pattern
This commit is contained in:
parent
2dd18897b0
commit
5270ced600
2 changed files with 18 additions and 0 deletions
|
@ -201,6 +201,13 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
|
||||||
username: &str,
|
username: &str,
|
||||||
captcha_key: &str,
|
captcha_key: &str,
|
||||||
) -> DBResult<TrafficPattern>;
|
) -> DBResult<TrafficPattern>;
|
||||||
|
|
||||||
|
/// Delete traffic configuration
|
||||||
|
async fn delete_traffic_pattern(
|
||||||
|
&self,
|
||||||
|
username: &str,
|
||||||
|
captcha_key: &str,
|
||||||
|
) -> DBResult<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Serialize, Deserialize, Clone, Debug)]
|
#[derive(Default, PartialEq, Serialize, Deserialize, Clone, Debug)]
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
//! Test utilities
|
//! Test utilities
|
||||||
|
use crate::errors::*;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
/// test all database functions
|
/// test all database functions
|
||||||
|
@ -147,6 +148,16 @@ pub async fn database_works<'a, T: MCDatabase>(
|
||||||
tp
|
tp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// delete traffic pattern
|
||||||
|
db.delete_traffic_pattern(p.username, c.key).await.unwrap();
|
||||||
|
assert!(
|
||||||
|
matches!(
|
||||||
|
db.get_traffic_pattern(p.username, c.key).await,
|
||||||
|
Err(DBError::TrafficPatternNotFound)
|
||||||
|
),
|
||||||
|
"deletion successful; traffic pattern no longer exists"
|
||||||
|
);
|
||||||
|
|
||||||
// add captcha levels
|
// add captcha levels
|
||||||
db.add_captcha_levels(p.username, c.key, l).await.unwrap();
|
db.add_captcha_levels(p.username, c.key, l).await.unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue