mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-06-02 20:26:39 +00:00
chore: cleanup and addressing clippy lints
This commit is contained in:
parent
d7fd23f565
commit
629c841e2d
@ -160,7 +160,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
db.create_notification(an).await.unwrap();
|
db.create_notification(an).await.unwrap();
|
||||||
|
|
||||||
// 2. Get notifications
|
// 2. Get notifications
|
||||||
let notifications = db.get_all_unread_notifications(&an.to).await.unwrap();
|
let notifications = db.get_all_unread_notifications(an.to).await.unwrap();
|
||||||
assert_eq!(notifications.len(), 2);
|
assert_eq!(notifications.len(), 2);
|
||||||
assert_eq!(notifications[0].heading.as_ref().unwrap(), an.heading);
|
assert_eq!(notifications[0].heading.as_ref().unwrap(), an.heading);
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ pub async fn database_works<'a, T: MCDatabase>(
|
|||||||
db.mark_notification_read(an.to, notifications[0].id.unwrap())
|
db.mark_notification_read(an.to, notifications[0].id.unwrap())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let new_notifications = db.get_all_unread_notifications(&an.to).await.unwrap();
|
let new_notifications = db.get_all_unread_notifications(an.to).await.unwrap();
|
||||||
assert_eq!(new_notifications.len(), 1);
|
assert_eq!(new_notifications.len(), 1);
|
||||||
|
|
||||||
// create captcha
|
// create captcha
|
||||||
|
@ -59,7 +59,7 @@ async fn everyting_works() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const add_notification: AddNotification = AddNotification {
|
const ADD_NOTIFICATION: AddNotification = AddNotification {
|
||||||
from: NAME,
|
from: NAME,
|
||||||
to: NAME,
|
to: NAME,
|
||||||
message: MESSAGE,
|
message: MESSAGE,
|
||||||
@ -84,5 +84,5 @@ async fn everyting_works() {
|
|||||||
key: CAPTCHA_SECRET,
|
key: CAPTCHA_SECRET,
|
||||||
description: CAPTCHA_DESCRIPTION,
|
description: CAPTCHA_DESCRIPTION,
|
||||||
};
|
};
|
||||||
database_works(&db, &p, &c, &LEVELS, &TRAFFIC_PATTERN, &add_notification).await;
|
database_works(&db, &p, &c, &LEVELS, &TRAFFIC_PATTERN, &ADD_NOTIFICATION).await;
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,7 @@ async fn set_username(
|
|||||||
|
|
||||||
let processed_uname = data.creds.username(&payload.username)?;
|
let processed_uname = data.creds.username(&payload.username)?;
|
||||||
|
|
||||||
data.db
|
data.db.update_username(&username, &processed_uname).await?;
|
||||||
.update_username(&username, &processed_uname)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
id.forget();
|
id.forget();
|
||||||
id.remember(processed_uname);
|
id.remember(processed_uname);
|
||||||
|
@ -166,9 +166,7 @@ async fn update(
|
|||||||
|
|
||||||
update_captcha_runner(&msg, &data, &username).await?;
|
update_captcha_runner(&msg, &data, &username).await?;
|
||||||
|
|
||||||
data.db
|
data.db.delete_traffic_pattern(&username, &msg.key).await?;
|
||||||
.delete_traffic_pattern(&username, &msg.key)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
data.db
|
data.db
|
||||||
.add_traffic_pattern(&username, &msg.key, &pattern)
|
.add_traffic_pattern(&username, &msg.key, &pattern)
|
||||||
@ -196,7 +194,6 @@ pub mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn easy_configuration_works() {
|
fn easy_configuration_works() {
|
||||||
const NAME: &str = "defaultuserconfgworks";
|
|
||||||
let settings = crate::tests::get_settings();
|
let settings = crate::tests::get_settings();
|
||||||
|
|
||||||
let mut payload = TrafficPattern {
|
let mut payload = TrafficPattern {
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
|
|
||||||
use libmcaptcha::defense::Level;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::create::MCaptchaDetails;
|
use super::create::MCaptchaDetails;
|
||||||
|
@ -101,7 +101,7 @@ pub async fn get_config(
|
|||||||
async fn init_mcaptcha(data: &AppData, key: &str) -> ServiceResult<()> {
|
async fn init_mcaptcha(data: &AppData, key: &str) -> ServiceResult<()> {
|
||||||
// get levels
|
// get levels
|
||||||
let levels = data.db.get_captcha_levels(None, key).await?;
|
let levels = data.db.get_captcha_levels(None, key).await?;
|
||||||
let duration = data.db.get_captcha_cooldown(&key).await?;
|
let duration = data.db.get_captcha_cooldown(key).await?;
|
||||||
|
|
||||||
// build defense
|
// build defense
|
||||||
let mut defense = DefenseBuilder::default();
|
let mut defense = DefenseBuilder::default();
|
||||||
|
@ -185,7 +185,7 @@ impl Data {
|
|||||||
log::info!("Initialized credential manager");
|
log::info!("Initialized credential manager");
|
||||||
});
|
});
|
||||||
|
|
||||||
let pool = s.database.pool;
|
let pool = s.database.pool;
|
||||||
let pool_options = PgPoolOptions::new().max_connections(pool);
|
let pool_options = PgPoolOptions::new().max_connections(pool);
|
||||||
let connection_options = ConnectionOptions::Fresh(Fresh {
|
let connection_options = ConnectionOptions::Fresh(Fresh {
|
||||||
pool_options,
|
pool_options,
|
||||||
|
@ -23,7 +23,6 @@ use sailfish::TemplateOnce;
|
|||||||
|
|
||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
use crate::Data;
|
use crate::Data;
|
||||||
use crate::SETTINGS;
|
|
||||||
|
|
||||||
const PAGE: &str = "Login";
|
const PAGE: &str = "Login";
|
||||||
|
|
||||||
|
@ -240,21 +240,6 @@ impl From<CaptchaError> for ServiceError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[cfg(not(tarpaulin_include))]
|
|
||||||
//impl From<sqlx::Error> for ServiceError {
|
|
||||||
// #[cfg(not(tarpaulin_include))]
|
|
||||||
// fn from(e: sqlx::Error) -> Self {
|
|
||||||
// use sqlx::error::Error;
|
|
||||||
// use std::borrow::Cow;
|
|
||||||
// if let Error::Database(err) = e {
|
|
||||||
// if err.code() == Some(Cow::from("23505")) {
|
|
||||||
// return ServiceError::UsernameTaken;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ServiceError::InternalServerError
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
impl From<SmtpError> for ServiceError {
|
impl From<SmtpError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
@ -294,14 +279,6 @@ pub enum PageError {
|
|||||||
ServiceError(ServiceError),
|
ServiceError(ServiceError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<sqlx::Error> for PageError {
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(_: sqlx::Error) -> Self {
|
|
||||||
PageError::InternalServerError
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
impl From<ServiceError> for PageError {
|
impl From<ServiceError> for PageError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
|
@ -20,7 +20,6 @@ use lazy_static::lazy_static;
|
|||||||
use my_codegen::get;
|
use my_codegen::get;
|
||||||
use sailfish::TemplateOnce;
|
use sailfish::TemplateOnce;
|
||||||
|
|
||||||
use crate::api::v1::RedirectQuery;
|
|
||||||
use crate::PAGES;
|
use crate::PAGES;
|
||||||
|
|
||||||
#[derive(Clone, TemplateOnce)]
|
#[derive(Clone, TemplateOnce)]
|
||||||
|
12
src/stats.rs
12
src/stats.rs
@ -50,12 +50,12 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Box<dyn CloneStats> {
|
//impl Clone for Box<dyn CloneStats> {
|
||||||
fn clone(&self) -> Self {
|
// fn clone(&self) -> Self {
|
||||||
self.clone()
|
// Box::clone(self)
|
||||||
//(*self).clone_stats()
|
// //(*self).clone_stats()
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)]
|
||||||
pub struct CaptchaStats {
|
pub struct CaptchaStats {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user