mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-11-23 22:15:46 +00:00
fix: remove tarpaulin annotations
This commit is contained in:
parent
5c29c2e71e
commit
a05f8ec6f0
@ -8,7 +8,6 @@ use std::env;
|
|||||||
use sqlx::postgres::PgPoolOptions;
|
use sqlx::postgres::PgPoolOptions;
|
||||||
use sqlx::mysql::MySqlPoolOptions;
|
use sqlx::mysql::MySqlPoolOptions;
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
#[actix_rt::main]
|
#[actix_rt::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
//TODO featuregate sqlite and postgres
|
//TODO featuregate sqlite and postgres
|
||||||
|
|||||||
@ -188,7 +188,6 @@ impl Data {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
/// create new instance of app data
|
/// create new instance of app data
|
||||||
pub async fn new(s: &Settings, survey_secrets: SecretsStore) -> Arc<Self> {
|
pub async fn new(s: &Settings, survey_secrets: SecretsStore) -> Arc<Self> {
|
||||||
let creds = Self::get_creds();
|
let creds = Self::get_creds();
|
||||||
|
|||||||
@ -40,7 +40,6 @@ impl std::cmp::PartialEq for SmtpErrorWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Display, PartialEq, Error)]
|
#[derive(Debug, Display, PartialEq, Error)]
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub enum ServiceError {
|
pub enum ServiceError {
|
||||||
#[display(fmt = "internal server error")]
|
#[display(fmt = "internal server error")]
|
||||||
InternalServerError,
|
InternalServerError,
|
||||||
@ -114,14 +113,11 @@ pub enum ServiceError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub struct ErrorToResponse {
|
pub struct ErrorToResponse {
|
||||||
pub error: String,
|
pub error: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl ResponseError for ServiceError {
|
impl ResponseError for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn error_response(&self) -> HttpResponse {
|
fn error_response(&self) -> HttpResponse {
|
||||||
HttpResponseBuilder::new(self.status_code())
|
HttpResponseBuilder::new(self.status_code())
|
||||||
.append_header((header::CONTENT_TYPE, "application/json; charset=UTF-8"))
|
.append_header((header::CONTENT_TYPE, "application/json; charset=UTF-8"))
|
||||||
@ -133,7 +129,6 @@ impl ResponseError for ServiceError {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn status_code(&self) -> StatusCode {
|
fn status_code(&self) -> StatusCode {
|
||||||
match self {
|
match self {
|
||||||
ServiceError::ClosedForRegistration => StatusCode::FORBIDDEN,
|
ServiceError::ClosedForRegistration => StatusCode::FORBIDDEN,
|
||||||
@ -177,7 +172,6 @@ impl ResponseError for ServiceError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<CredsError> for ServiceError {
|
impl From<CredsError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: CredsError) -> ServiceError {
|
fn from(e: CredsError) -> ServiceError {
|
||||||
match e {
|
match e {
|
||||||
CredsError::UsernameCaseMappedError => ServiceError::UsernameCaseMappedError,
|
CredsError::UsernameCaseMappedError => ServiceError::UsernameCaseMappedError,
|
||||||
@ -192,7 +186,6 @@ impl From<CredsError> for ServiceError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<DBError> for ServiceError {
|
impl From<DBError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: DBError) -> ServiceError {
|
fn from(e: DBError) -> ServiceError {
|
||||||
println!("from conversin: {}", e);
|
println!("from conversin: {}", e);
|
||||||
match e {
|
match e {
|
||||||
@ -208,57 +201,46 @@ impl From<DBError> for ServiceError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<ValidationErrors> for ServiceError {
|
impl From<ValidationErrors> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(_: ValidationErrors) -> ServiceError {
|
fn from(_: ValidationErrors) -> ServiceError {
|
||||||
ServiceError::NotAnEmail
|
ServiceError::NotAnEmail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseError> for ServiceError {
|
impl From<ParseError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(_: ParseError) -> ServiceError {
|
fn from(_: ParseError) -> ServiceError {
|
||||||
ServiceError::NotAUrl
|
ServiceError::NotAUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<CaptchaError> for ServiceError {
|
impl From<CaptchaError> for ServiceError {
|
||||||
fn from(e: CaptchaError) -> ServiceError {
|
fn from(e: CaptchaError) -> ServiceError {
|
||||||
ServiceError::CaptchaError(e)
|
ServiceError::CaptchaError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<SmtpError> for ServiceError {
|
impl From<SmtpError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: SmtpError) -> Self {
|
fn from(e: SmtpError) -> Self {
|
||||||
ServiceError::UnableToSendEmail(SmtpErrorWrapper(e))
|
ServiceError::UnableToSendEmail(SmtpErrorWrapper(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<RecvError> for ServiceError {
|
impl From<RecvError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: RecvError) -> Self {
|
fn from(e: RecvError) -> Self {
|
||||||
log::error!("{:?}", e);
|
log::error!("{:?}", e);
|
||||||
ServiceError::InternalServerError
|
ServiceError::InternalServerError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<MailboxError> for ServiceError {
|
impl From<MailboxError> for ServiceError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: MailboxError) -> Self {
|
fn from(e: MailboxError) -> Self {
|
||||||
log::error!("{:?}", e);
|
log::error!("{:?}", e);
|
||||||
ServiceError::InternalServerError
|
ServiceError::InternalServerError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub type ServiceResult<V> = std::result::Result<V, ServiceError>;
|
pub type ServiceResult<V> = std::result::Result<V, ServiceError>;
|
||||||
|
|
||||||
#[derive(Debug, Display, PartialEq, Error)]
|
#[derive(Debug, Display, PartialEq, Error)]
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub enum PageError {
|
pub enum PageError {
|
||||||
#[display(fmt = "Something weng wrong: Internal server error")]
|
#[display(fmt = "Something weng wrong: Internal server error")]
|
||||||
InternalServerError,
|
InternalServerError,
|
||||||
@ -267,17 +249,13 @@ pub enum PageError {
|
|||||||
ServiceError(ServiceError),
|
ServiceError(ServiceError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<ServiceError> for PageError {
|
impl From<ServiceError> for PageError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: ServiceError) -> Self {
|
fn from(e: ServiceError) -> Self {
|
||||||
PageError::ServiceError(e)
|
PageError::ServiceError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl From<DBError> for PageError {
|
impl From<DBError> for PageError {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn from(e: DBError) -> Self {
|
fn from(e: DBError) -> Self {
|
||||||
let se: ServiceError = e.into();
|
let se: ServiceError = e.into();
|
||||||
se.into()
|
se.into()
|
||||||
@ -297,7 +275,6 @@ impl ResponseError for PageError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
fn status_code(&self) -> StatusCode {
|
fn status_code(&self) -> StatusCode {
|
||||||
match self {
|
match self {
|
||||||
PageError::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR,
|
PageError::InternalServerError => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
@ -306,7 +283,6 @@ impl ResponseError for PageError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub type PageResult<V> = std::result::Result<V, PageError>;
|
pub type PageResult<V> = std::result::Result<V, PageError>;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@ -92,7 +92,6 @@ pub const CACHE_AGE: u32 = 604800;
|
|||||||
pub type ArcData = Arc<crate::data::Data>;
|
pub type ArcData = Arc<crate::data::Data>;
|
||||||
pub type AppData = actix_web::web::Data<ArcData>;
|
pub type AppData = actix_web::web::Data<ArcData>;
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@ -185,7 +184,6 @@ async fn main() -> std::io::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub fn get_json_err() -> JsonConfig {
|
pub fn get_json_err() -> JsonConfig {
|
||||||
JsonConfig::default().error_handler(|err, _| {
|
JsonConfig::default().error_handler(|err, _| {
|
||||||
//debug!("JSON deserialization error: {:?}", &err);
|
//debug!("JSON deserialization error: {:?}", &err);
|
||||||
@ -193,7 +191,6 @@ pub fn get_json_err() -> JsonConfig {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub fn get_identity_service(
|
pub fn get_identity_service(
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
) -> IdentityService<CookieIdentityPolicy> {
|
) -> IdentityService<CookieIdentityPolicy> {
|
||||||
|
|||||||
@ -25,7 +25,6 @@ pub fn get_middleware() -> Authentication<routes::Routes> {
|
|||||||
Authentication::with_identity(routes::ROUTES)
|
Authentication::with_identity(routes::ROUTES)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
|
|||||||
@ -56,7 +56,6 @@ pub struct Smtp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Server {
|
impl Server {
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
pub fn get_ip(&self) -> String {
|
pub fn get_ip(&self) -> String {
|
||||||
format!("{}:{}", self.ip, self.port)
|
format!("{}:{}", self.ip, self.port)
|
||||||
}
|
}
|
||||||
@ -205,7 +204,6 @@ const DEPRECATED_ENV_VARS: [(&str, &str); 23] = [
|
|||||||
("smtp.port", "MCAPTCHA_SMTP_PORT"),
|
("smtp.port", "MCAPTCHA_SMTP_PORT"),
|
||||||
];
|
];
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
pub fn new() -> Result<Self, ConfigError> {
|
pub fn new() -> Result<Self, ConfigError> {
|
||||||
let mut s = Config::builder();
|
let mut s = Config::builder();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user