mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-13 19:15:39 +00:00
chore: rust fmpt
This commit is contained in:
@@ -17,8 +17,6 @@
|
|||||||
//! Test utilities
|
//! Test utilities
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub async fn database_works<'a, T: MCDatabase>(
|
pub async fn database_works<'a, T: MCDatabase>(db: &T) {
|
||||||
db: &T,
|
|
||||||
) {
|
|
||||||
unimplemented!("database tests");
|
unimplemented!("database tests");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ use db_core::dev::*;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use sqlx::postgres::PgPoolOptions;
|
use sqlx::postgres::PgPoolOptions;
|
||||||
use sqlx::PgPool;
|
|
||||||
use sqlx::types::time::OffsetDateTime;
|
use sqlx::types::time::OffsetDateTime;
|
||||||
|
use sqlx::PgPool;
|
||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ pub fn handle_embedded_file(path: &str) -> HttpResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[my_codegen::get(path = "DOCS.assets")]
|
#[my_codegen::get(path = "DOCS.assets")]
|
||||||
async fn dist(path: web::Path<String>) -> impl Responder {
|
async fn dist(path: web::Path<String>) -> impl Responder {
|
||||||
handle_embedded_file(&path)
|
handle_embedded_file(&path)
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ impl Settings {
|
|||||||
pub fn new() -> Result<Self, ConfigError> {
|
pub fn new() -> Result<Self, ConfigError> {
|
||||||
let mut s = Config::new();
|
let mut s = Config::new();
|
||||||
|
|
||||||
|
|
||||||
const CURRENT_DIR: &str = "./config/default.toml";
|
const CURRENT_DIR: &str = "./config/default.toml";
|
||||||
const ETC: &str = "/etc/mcaptcha/config.toml";
|
const ETC: &str = "/etc/mcaptcha/config.toml";
|
||||||
|
|
||||||
@@ -163,8 +162,6 @@ impl Settings {
|
|||||||
s.set("database.pool", 2.to_string())
|
s.set("database.pool", 2.to_string())
|
||||||
.expect("Couldn't set database pool count");
|
.expect("Couldn't set database pool count");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
match s.try_into() {
|
match s.try_into() {
|
||||||
Ok(val) => Ok(val),
|
Ok(val) => Ok(val),
|
||||||
Err(e) => Err(ConfigError::Message(format!("\n\nError: {}. If it says missing fields, then please refer to https://github.com/mCaptcha/mcaptcha#configuration to learn more about how mcaptcha reads configuration\n\n", e))),
|
Err(e) => Err(ConfigError::Message(format!("\n\nError: {}. If it says missing fields, then please refer to https://github.com/mCaptcha/mcaptcha#configuration to learn more about how mcaptcha reads configuration\n\n", e))),
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ fn handle_assets(path: &str) -> HttpResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[get("/assets/{_:.*}")]
|
#[get("/assets/{_:.*}")]
|
||||||
pub async fn static_files(path: web::Path<String>) -> impl Responder {
|
pub async fn static_files(path: web::Path<String>) -> impl Responder {
|
||||||
handle_assets(&path)
|
handle_assets(&path)
|
||||||
@@ -131,7 +130,6 @@ fn handle_favicons(path: &str) -> HttpResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[get("/{file}")]
|
#[get("/{file}")]
|
||||||
pub async fn favicons(path: web::Path<String>) -> impl Responder {
|
pub async fn favicons(path: web::Path<String>) -> impl Responder {
|
||||||
debug!("searching favicons");
|
debug!("searching favicons");
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::ServiceResponse, error::ResponseError, http::StatusCode,
|
body::{BoxBody, EitherBody},
|
||||||
body::{EitherBody, BoxBody},
|
dev::ServiceResponse,
|
||||||
|
error::ResponseError,
|
||||||
|
http::StatusCode,
|
||||||
middleware as actix_middleware,
|
middleware as actix_middleware,
|
||||||
};
|
};
|
||||||
use libmcaptcha::defense::Level;
|
use libmcaptcha::defense::Level;
|
||||||
@@ -110,7 +112,10 @@ pub async fn register(name: &str, email: &str, password: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// signin util
|
/// signin util
|
||||||
pub async fn signin(name: &str, password: &str) -> (Arc<Data>, Login, ServiceResponse<EitherBody<BoxBody>>) {
|
pub async fn signin(
|
||||||
|
name: &str,
|
||||||
|
password: &str,
|
||||||
|
) -> (Arc<Data>, Login, ServiceResponse<EitherBody<BoxBody>>) {
|
||||||
let data = Data::new().await;
|
let data = Data::new().await;
|
||||||
let app = get_app!(data.clone()).await;
|
let app = get_app!(data.clone()).await;
|
||||||
|
|
||||||
@@ -173,7 +178,12 @@ pub fn get_level_data() -> CreateCaptcha {
|
|||||||
pub async fn add_levels_util(
|
pub async fn add_levels_util(
|
||||||
name: &str,
|
name: &str,
|
||||||
password: &str,
|
password: &str,
|
||||||
) -> (Arc<data::Data>, Login, ServiceResponse<EitherBody<BoxBody>>, MCaptchaDetails) {
|
) -> (
|
||||||
|
Arc<data::Data>,
|
||||||
|
Login,
|
||||||
|
ServiceResponse<EitherBody<BoxBody>>,
|
||||||
|
MCaptchaDetails,
|
||||||
|
) {
|
||||||
let (data, creds, signin_resp) = signin(name, password).await;
|
let (data, creds, signin_resp) = signin(name, password).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|||||||
Reference in New Issue
Block a user