mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
chore: use local app ctx
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub mod v1;
|
pub mod v1;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ pub mod tests {
|
|||||||
const PASSWORD: &str = "longpassword2";
|
const PASSWORD: &str = "longpassword2";
|
||||||
const EMAIL: &str = "updatepassuser@a.com";
|
const EMAIL: &str = "updatepassuser@a.com";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{HttpResponse, Responder};
|
use actix_web::{HttpResponse, Responder};
|
||||||
use db_core::prelude::*;
|
use db_core::prelude::*;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub async fn uname_email_exists_works() {
|
|||||||
const NAME: &str = "testuserexists";
|
const NAME: &str = "testuserexists";
|
||||||
const PASSWORD: &str = "longpassword2";
|
const PASSWORD: &str = "longpassword2";
|
||||||
const EMAIL: &str = "testuserexists@a.com2";
|
const EMAIL: &str = "testuserexists@a.com2";
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ pub async fn email_udpate_password_validation_del_userworks() {
|
|||||||
const NAME2: &str = "eupdauser";
|
const NAME2: &str = "eupdauser";
|
||||||
const EMAIL2: &str = "eupdauser@a.com";
|
const EMAIL2: &str = "eupdauser@a.com";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
delete_user(data, NAME2).await;
|
delete_user(data, NAME2).await;
|
||||||
@@ -206,7 +206,7 @@ pub async fn username_update_works() {
|
|||||||
const NAME2: &str = "terstusrtds";
|
const NAME2: &str = "terstusrtds";
|
||||||
const NAME_CHANGE: &str = "terstusrtdsxx";
|
const NAME_CHANGE: &str = "terstusrtdsxx";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
futures::join!(
|
futures::join!(
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ pub mod runners {
|
|||||||
payload: &Register,
|
payload: &Register,
|
||||||
data: &AppData,
|
data: &AppData,
|
||||||
) -> ServiceResult<()> {
|
) -> ServiceResult<()> {
|
||||||
if !crate::SETTINGS.allow_registration {
|
if !data.settings.allow_registration {
|
||||||
return Err(ServiceError::ClosedForRegistration);
|
return Err(ServiceError::ClosedForRegistration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,13 +121,11 @@ async fn create(
|
|||||||
let username = id.identity().unwrap();
|
let username = id.identity().unwrap();
|
||||||
let payload = payload.into_inner();
|
let payload = payload.into_inner();
|
||||||
let pattern = (&payload).into();
|
let pattern = (&payload).into();
|
||||||
let levels = calculate(
|
let levels =
|
||||||
&pattern,
|
calculate(&pattern, &data.settings.captcha.default_difficulty_strategy)?;
|
||||||
&crate::SETTINGS.captcha.default_difficulty_strategy,
|
|
||||||
)?;
|
|
||||||
let msg = CreateCaptcha {
|
let msg = CreateCaptcha {
|
||||||
levels,
|
levels,
|
||||||
duration: crate::SETTINGS.captcha.default_difficulty_strategy.duration,
|
duration: data.settings.captcha.default_difficulty_strategy.duration,
|
||||||
description: payload.description,
|
description: payload.description,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -156,14 +154,12 @@ async fn update(
|
|||||||
let username = id.identity().unwrap();
|
let username = id.identity().unwrap();
|
||||||
let payload = payload.into_inner();
|
let payload = payload.into_inner();
|
||||||
let pattern = (&payload.pattern).into();
|
let pattern = (&payload.pattern).into();
|
||||||
let levels = calculate(
|
let levels =
|
||||||
&pattern,
|
calculate(&pattern, &data.settings.captcha.default_difficulty_strategy)?;
|
||||||
&crate::SETTINGS.captcha.default_difficulty_strategy,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let msg = UpdateCaptcha {
|
let msg = UpdateCaptcha {
|
||||||
levels,
|
levels,
|
||||||
duration: crate::SETTINGS.captcha.default_difficulty_strategy.duration,
|
duration: data.settings.captcha.default_difficulty_strategy.duration,
|
||||||
description: payload.pattern.description,
|
description: payload.pattern.description,
|
||||||
key: payload.key,
|
key: payload.key,
|
||||||
};
|
};
|
||||||
@@ -201,6 +197,7 @@ pub mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn easy_configuration_works() {
|
fn easy_configuration_works() {
|
||||||
const NAME: &str = "defaultuserconfgworks";
|
const NAME: &str = "defaultuserconfgworks";
|
||||||
|
let settings = crate::tests::get_settings();
|
||||||
|
|
||||||
let mut payload = TrafficPattern {
|
let mut payload = TrafficPattern {
|
||||||
avg_traffic: 100_000,
|
avg_traffic: 100_000,
|
||||||
@@ -208,7 +205,7 @@ pub mod tests {
|
|||||||
broke_my_site_traffic: Some(10_000_000),
|
broke_my_site_traffic: Some(10_000_000),
|
||||||
};
|
};
|
||||||
|
|
||||||
let strategy = &crate::SETTINGS.captcha.default_difficulty_strategy;
|
let strategy = &settings.captcha.default_difficulty_strategy;
|
||||||
let l1 = LevelBuilder::default()
|
let l1 = LevelBuilder::default()
|
||||||
.difficulty_factor(strategy.avg_traffic_difficulty)
|
.difficulty_factor(strategy.avg_traffic_difficulty)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@@ -273,7 +270,7 @@ pub mod tests {
|
|||||||
const NAME: &str = "defaultuserconfgworks";
|
const NAME: &str = "defaultuserconfgworks";
|
||||||
const PASSWORD: &str = "longpassworddomain";
|
const PASSWORD: &str = "longpassworddomain";
|
||||||
const EMAIL: &str = "defaultuserconfgworks@a.com";
|
const EMAIL: &str = "defaultuserconfgworks@a.com";
|
||||||
let data = crate::data::Data::new().await;
|
let data = crate::tests::get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
@@ -292,7 +289,7 @@ pub mod tests {
|
|||||||
|
|
||||||
let default_levels = calculate(
|
let default_levels = calculate(
|
||||||
&(&payload).into(),
|
&(&payload).into(),
|
||||||
&crate::SETTINGS.captcha.default_difficulty_strategy,
|
&data.settings.captcha.default_difficulty_strategy,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -331,7 +328,7 @@ pub mod tests {
|
|||||||
|
|
||||||
let updated_default_values = calculate(
|
let updated_default_values = calculate(
|
||||||
&(&update_pattern).into(),
|
&(&update_pattern).into(),
|
||||||
&crate::SETTINGS.captcha.default_difficulty_strategy,
|
&data.settings.captcha.default_difficulty_strategy,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ pub async fn level_routes_work() {
|
|||||||
const NAME: &str = "testuserlevelroutes";
|
const NAME: &str = "testuserlevelroutes";
|
||||||
const PASSWORD: &str = "longpassworddomain";
|
const PASSWORD: &str = "longpassworddomain";
|
||||||
const EMAIL: &str = "testuserlevelrouts@a.com";
|
const EMAIL: &str = "testuserlevelrouts@a.com";
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ mod tests {
|
|||||||
const NAME: &str = "updateusermcaptcha";
|
const NAME: &str = "updateusermcaptcha";
|
||||||
const PASSWORD: &str = "longpassworddomain";
|
const PASSWORD: &str = "longpassworddomain";
|
||||||
const EMAIL: &str = "testupdateusermcaptcha@a.com";
|
const EMAIL: &str = "testupdateusermcaptcha@a.com";
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
use derive_builder::Builder;
|
use derive_builder::Builder;
|
||||||
@@ -79,7 +79,7 @@ async fn health(data: AppData) -> impl Responder {
|
|||||||
|
|
||||||
if let SystemGroup::Redis(_) = data.captcha {
|
if let SystemGroup::Redis(_) = data.captcha {
|
||||||
if let Ok(r) = Redis::new(RedisConfig::Single(
|
if let Ok(r) = Redis::new(RedisConfig::Single(
|
||||||
crate::SETTINGS.redis.as_ref().unwrap().url.clone(),
|
data.settings.redis.as_ref().unwrap().url.clone(),
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@@ -123,7 +123,7 @@ pub mod tests {
|
|||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
pub async fn health_works() {
|
pub async fn health_works() {
|
||||||
println!("{}", V1_API_ROUTES.meta.health);
|
println!("{}", V1_API_ROUTES.meta.health);
|
||||||
let data = crate::data::Data::new().await;
|
let data = crate::tests::get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_auth_middleware::Authentication;
|
use actix_auth_middleware::Authentication;
|
||||||
use actix_web::web::ServiceConfig;
|
use actix_web::web::ServiceConfig;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
@@ -73,7 +73,7 @@ pub mod tests {
|
|||||||
const EMAIL1: &str = "testnotification1@a.com";
|
const EMAIL1: &str = "testnotification1@a.com";
|
||||||
const EMAIL2: &str = "testnotification2@a.com";
|
const EMAIL2: &str = "testnotification2@a.com";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
delete_user(data, NAME1).await;
|
delete_user(data, NAME1).await;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{HttpResponse, Responder};
|
use actix_web::{HttpResponse, Responder};
|
||||||
@@ -95,7 +95,7 @@ pub mod tests {
|
|||||||
const HEADING: &str = "testing notifications get";
|
const HEADING: &str = "testing notifications get";
|
||||||
const MESSAGE: &str = "testing notifications get message";
|
const MESSAGE: &str = "testing notifications get message";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
delete_user(data, NAME1).await;
|
delete_user(data, NAME1).await;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
@@ -68,7 +68,7 @@ pub mod tests {
|
|||||||
const EMAIL2: &str = "testnotification222@a.com";
|
const EMAIL2: &str = "testnotification222@a.com";
|
||||||
const HEADING: &str = "testing notifications get";
|
const HEADING: &str = "testing notifications get";
|
||||||
const MESSAGE: &str = "testing notifications get message";
|
const MESSAGE: &str = "testing notifications get message";
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
delete_user(data, NAME1).await;
|
delete_user(data, NAME1).await;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub mod add;
|
pub mod add;
|
||||||
pub mod get;
|
pub mod get;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//use actix::prelude::*;
|
//use actix::prelude::*;
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
@@ -155,7 +155,7 @@ pub mod tests {
|
|||||||
const PASSWORD: &str = "testingpas";
|
const PASSWORD: &str = "testingpas";
|
||||||
const EMAIL: &str = "randomuser@a.com";
|
const EMAIL: &str = "randomuser@a.com";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_web::web;
|
use actix_web::web;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
//! PoW Verification module
|
//! PoW Verification module
|
||||||
|
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
@@ -64,7 +64,7 @@ pub mod tests {
|
|||||||
const NAME: &str = "powverifyusr";
|
const NAME: &str = "powverifyusr";
|
||||||
const PASSWORD: &str = "testingpas";
|
const PASSWORD: &str = "testingpas";
|
||||||
const EMAIL: &str = "verifyuser@a.com";
|
const EMAIL: &str = "verifyuser@a.com";
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
//! PoW success token module
|
//! PoW success token module
|
||||||
|
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
@@ -72,7 +72,7 @@ pub mod tests {
|
|||||||
const VERIFY_TOKEN_URL: &str = "/api/v1/pow/siteverify";
|
const VERIFY_TOKEN_URL: &str = "/api/v1/pow/siteverify";
|
||||||
// const UPDATE_URL: &str = "/api/v1/mcaptcha/domain/token/duration/update";
|
// const UPDATE_URL: &str = "/api/v1/mcaptcha/domain/token/duration/update";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use actix_auth_middleware::GetLoginRoute;
|
use actix_auth_middleware::GetLoginRoute;
|
||||||
|
|
||||||
use super::account::routes::Account;
|
use super::account::routes::Account;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ pub async fn auth_works() {
|
|||||||
const PASSWORD: &str = "longpassword";
|
const PASSWORD: &str = "longpassword";
|
||||||
const EMAIL: &str = "testuser1@a.com";
|
const EMAIL: &str = "testuser1@a.com";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
@@ -147,7 +147,7 @@ pub async fn serverside_password_validation_works() {
|
|||||||
const NAME: &str = "testuser542";
|
const NAME: &str = "testuser542";
|
||||||
const PASSWORD: &str = "longpassword2";
|
const PASSWORD: &str = "longpassword2";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod auth;
|
mod auth;
|
||||||
mod protected;
|
mod protected;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
@@ -27,7 +27,7 @@ async fn protected_routes_work() {
|
|||||||
const NAME: &str = "testuser619";
|
const NAME: &str = "testuser619";
|
||||||
const PASSWORD: &str = "longpassword2";
|
const PASSWORD: &str = "longpassword2";
|
||||||
const EMAIL: &str = "testuser119@a.com2";
|
const EMAIL: &str = "testuser119@a.com2";
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
|
|
||||||
let _post_protected_urls = [
|
let _post_protected_urls = [
|
||||||
|
|||||||
44
src/data.rs
44
src/data.rs
@@ -46,7 +46,8 @@ use sqlx::PgPool;
|
|||||||
use db_core::MCDatabase;
|
use db_core::MCDatabase;
|
||||||
|
|
||||||
use crate::errors::ServiceResult;
|
use crate::errors::ServiceResult;
|
||||||
use crate::SETTINGS;
|
//use crate::SETTINGS;
|
||||||
|
use crate::settings::Settings;
|
||||||
|
|
||||||
macro_rules! enum_system_actor {
|
macro_rules! enum_system_actor {
|
||||||
($name:ident, $type:ident) => {
|
($name:ident, $type:ident) => {
|
||||||
@@ -105,9 +106,13 @@ impl SystemGroup {
|
|||||||
// utility function to remove captcha
|
// utility function to remove captcha
|
||||||
enum_system_actor!(remove, RemoveCaptcha);
|
enum_system_actor!(remove, RemoveCaptcha);
|
||||||
|
|
||||||
fn new_system<A: Save, B: MasterTrait>(m: Addr<B>, c: Addr<A>) -> System<A, B> {
|
fn new_system<A: Save, B: MasterTrait>(
|
||||||
|
s: &Settings,
|
||||||
|
m: Addr<B>,
|
||||||
|
c: Addr<A>,
|
||||||
|
) -> System<A, B> {
|
||||||
let pow = PoWConfigBuilder::default()
|
let pow = PoWConfigBuilder::default()
|
||||||
.salt(SETTINGS.captcha.salt.clone())
|
.salt(s.captcha.salt.clone())
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -116,8 +121,8 @@ impl SystemGroup {
|
|||||||
|
|
||||||
// read settings, if Redis is configured then produce a Redis mCaptcha cache
|
// read settings, if Redis is configured then produce a Redis mCaptcha cache
|
||||||
// based SystemGroup
|
// based SystemGroup
|
||||||
async fn new() -> Self {
|
async fn new(s: &Settings) -> Self {
|
||||||
match &SETTINGS.redis {
|
match &s.redis {
|
||||||
Some(val) => {
|
Some(val) => {
|
||||||
let master = RedisMaster::new(RedisConfig::Single(val.url.clone()))
|
let master = RedisMaster::new(RedisConfig::Single(val.url.clone()))
|
||||||
.await
|
.await
|
||||||
@@ -127,14 +132,14 @@ impl SystemGroup {
|
|||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.start();
|
.start();
|
||||||
let captcha = Self::new_system(master, cache);
|
let captcha = Self::new_system(s, master, cache);
|
||||||
|
|
||||||
SystemGroup::Redis(captcha)
|
SystemGroup::Redis(captcha)
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let master = EmbeddedMaster::new(SETTINGS.captcha.gc).start();
|
let master = EmbeddedMaster::new(s.captcha.gc).start();
|
||||||
let cache = HashCache::default().start();
|
let cache = HashCache::default().start();
|
||||||
let captcha = Self::new_system(master, cache);
|
let captcha = Self::new_system(s, master, cache);
|
||||||
|
|
||||||
SystemGroup::Embedded(captcha)
|
SystemGroup::Embedded(captcha)
|
||||||
}
|
}
|
||||||
@@ -154,6 +159,9 @@ pub struct Data {
|
|||||||
pub captcha: SystemGroup,
|
pub captcha: SystemGroup,
|
||||||
/// email client
|
/// email client
|
||||||
pub mailer: Option<Mailer>,
|
pub mailer: Option<Mailer>,
|
||||||
|
|
||||||
|
/// app settings
|
||||||
|
pub settings: Settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Data {
|
impl Data {
|
||||||
@@ -168,7 +176,7 @@ impl Data {
|
|||||||
}
|
}
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
/// create new instance of app data
|
/// create new instance of app data
|
||||||
pub async fn new() -> Arc<Self> {
|
pub async fn new(s: &Settings) -> Arc<Self> {
|
||||||
let creds = Self::get_creds();
|
let creds = Self::get_creds();
|
||||||
let c = creds.clone();
|
let c = creds.clone();
|
||||||
|
|
||||||
@@ -180,17 +188,16 @@ impl Data {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let db = PgPoolOptions::new()
|
let db = PgPoolOptions::new()
|
||||||
.max_connections(SETTINGS.database.pool)
|
.max_connections(s.database.pool)
|
||||||
.connect(&SETTINGS.database.url)
|
.connect(&s.database.url)
|
||||||
.await
|
.await
|
||||||
.expect("Unable to form database pool");
|
.expect("Unable to form database pool");
|
||||||
|
|
||||||
let settings = &SETTINGS;
|
let pool = s.database.pool;
|
||||||
let pool = settings.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,
|
||||||
url: settings.database.url.clone(),
|
url: s.database.url.clone(),
|
||||||
});
|
});
|
||||||
let dblib = connection_options.connect().await.unwrap();
|
let dblib = connection_options.connect().await.unwrap();
|
||||||
dblib.migrate().await.unwrap();
|
dblib.migrate().await.unwrap();
|
||||||
@@ -199,8 +206,9 @@ impl Data {
|
|||||||
creds,
|
creds,
|
||||||
db,
|
db,
|
||||||
dblib: Box::new(dblib),
|
dblib: Box::new(dblib),
|
||||||
captcha: SystemGroup::new().await,
|
captcha: SystemGroup::new(s).await,
|
||||||
mailer: Self::get_mailer(),
|
mailer: Self::get_mailer(s),
|
||||||
|
settings: s.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
@@ -209,8 +217,8 @@ impl Data {
|
|||||||
Arc::new(data)
|
Arc::new(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_mailer() -> Option<Mailer> {
|
fn get_mailer(s: &Settings) -> Option<Mailer> {
|
||||||
if let Some(smtp) = SETTINGS.smtp.as_ref() {
|
if let Some(smtp) = s.smtp.as_ref() {
|
||||||
let creds =
|
let creds =
|
||||||
Credentials::new(smtp.username.to_string(), smtp.password.to_string()); // "smtp_username".to_string(), "smtp_password".to_string());
|
Credentials::new(smtp.username.to_string(), smtp.password.to_string()); // "smtp_username".to_string(), "smtp_password".to_string());
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ mod tests {
|
|||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn demo_account_works() {
|
async fn demo_account_works() {
|
||||||
let data_inner = crate::data::Data::new().await;
|
let data_inner = get_data().await;
|
||||||
let data_inner = &data_inner;
|
let data_inner = &data_inner;
|
||||||
let data = AppData::new(data_inner.clone());
|
let data = AppData::new(data_inner.clone());
|
||||||
crate::tests::delete_user(data_inner, DEMO_USER).await;
|
crate::tests::delete_user(data_inner, DEMO_USER).await;
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub mod verification;
|
pub mod verification;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
//! Email operations: verification, notification, etc
|
//! Email operations: verification, notification, etc
|
||||||
use lettre::{
|
use lettre::{
|
||||||
message::{header, MultiPart, SinglePart},
|
message::{header, MultiPart, SinglePart},
|
||||||
@@ -44,7 +44,7 @@ async fn verification(
|
|||||||
to: &str,
|
to: &str,
|
||||||
verification_link: &str,
|
verification_link: &str,
|
||||||
) -> ServiceResult<()> {
|
) -> ServiceResult<()> {
|
||||||
if let Some(smtp) = SETTINGS.smtp.as_ref() {
|
if let Some(smtp) = data.settings.smtp.as_ref() {
|
||||||
let from = format!("mCaptcha Admin <{}>", smtp.from);
|
let from = format!("mCaptcha Admin <{}>", smtp.from);
|
||||||
let reply_to = format!("mCaptcha Admin <{}>", smtp.reply);
|
let reply_to = format!("mCaptcha Admin <{}>", smtp.reply);
|
||||||
const SUBJECT: &str = "[mCaptcha] Please verify your email";
|
const SUBJECT: &str = "[mCaptcha] Please verify your email";
|
||||||
@@ -64,7 +64,7 @@ Admin
|
|||||||
instance: {}
|
instance: {}
|
||||||
project website: {}",
|
project website: {}",
|
||||||
verification_link,
|
verification_link,
|
||||||
SETTINGS.server.domain,
|
&data.settings.server.domain,
|
||||||
crate::PKG_HOMEPAGE
|
crate::PKG_HOMEPAGE
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -105,7 +105,8 @@ mod tests {
|
|||||||
async fn email_verification_works() {
|
async fn email_verification_works() {
|
||||||
const TO_ADDR: &str = "Hello <realaravinth@localhost>";
|
const TO_ADDR: &str = "Hello <realaravinth@localhost>";
|
||||||
const VERIFICATION_LINK: &str = "https://localhost";
|
const VERIFICATION_LINK: &str = "https://localhost";
|
||||||
let data = Data::new().await;
|
let data = crate::tests::get_data().await;
|
||||||
|
let settings = &data.settings;
|
||||||
verification(&data, TO_ADDR, VERIFICATION_LINK)
|
verification(&data, TO_ADDR, VERIFICATION_LINK)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -118,7 +119,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let data: serde_json::Value = resp.json().await.unwrap();
|
let data: serde_json::Value = resp.json().await.unwrap();
|
||||||
let data = &data[0];
|
let data = &data[0];
|
||||||
let smtp = SETTINGS.smtp.as_ref().unwrap();
|
let smtp = settings.smtp.as_ref().unwrap();
|
||||||
|
|
||||||
let from_addr = &data["headers"]["from"];
|
let from_addr = &data["headers"]["from"];
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
|
|
||||||
|
|||||||
20
src/main.rs
20
src/main.rs
@@ -110,12 +110,13 @@ async fn main() -> std::io::Result<()> {
|
|||||||
PKG_NAME, PKG_DESCRIPTION, PKG_HOMEPAGE, VERSION, GIT_COMMIT_HASH
|
PKG_NAME, PKG_DESCRIPTION, PKG_HOMEPAGE, VERSION, GIT_COMMIT_HASH
|
||||||
);
|
);
|
||||||
|
|
||||||
let data = Data::new().await;
|
let settings = Settings::new().unwrap();
|
||||||
|
let data = Data::new(&settings).await;
|
||||||
let data = actix_web::web::Data::new(data);
|
let data = actix_web::web::Data::new(data);
|
||||||
|
|
||||||
let mut demo_user: Option<DemoUser> = None;
|
let mut demo_user: Option<DemoUser> = None;
|
||||||
|
|
||||||
if SETTINGS.allow_demo && SETTINGS.allow_registration {
|
if settings.allow_demo && settings.allow_registration {
|
||||||
demo_user = Some(
|
demo_user = Some(
|
||||||
DemoUser::spawn(data.clone(), Duration::from_secs(60 * 30))
|
DemoUser::spawn(data.clone(), Duration::from_secs(60 * 30))
|
||||||
.await
|
.await
|
||||||
@@ -123,7 +124,8 @@ async fn main() -> std::io::Result<()> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Starting server on: http://{}", SETTINGS.server.get_ip());
|
let ip = settings.server.get_ip();
|
||||||
|
println!("Starting server on: http://{ip}");
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
@@ -132,7 +134,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
actix_middleware::DefaultHeaders::new()
|
actix_middleware::DefaultHeaders::new()
|
||||||
.add(("Permissions-Policy", "interest-cohort=()")),
|
.add(("Permissions-Policy", "interest-cohort=()")),
|
||||||
)
|
)
|
||||||
.wrap(get_identity_service())
|
.wrap(get_identity_service(&settings))
|
||||||
.wrap(actix_middleware::Compress::default())
|
.wrap(actix_middleware::Compress::default())
|
||||||
.app_data(data.clone())
|
.app_data(data.clone())
|
||||||
.wrap(actix_middleware::NormalizePath::new(
|
.wrap(actix_middleware::NormalizePath::new(
|
||||||
@@ -141,7 +143,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.configure(routes::services)
|
.configure(routes::services)
|
||||||
.app_data(get_json_err())
|
.app_data(get_json_err())
|
||||||
})
|
})
|
||||||
.bind(SETTINGS.server.get_ip())
|
.bind(&ip)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.run()
|
.run()
|
||||||
.await?;
|
.await?;
|
||||||
@@ -161,14 +163,16 @@ pub fn get_json_err() -> JsonConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(tarpaulin_include))]
|
#[cfg(not(tarpaulin_include))]
|
||||||
pub fn get_identity_service() -> IdentityService<CookieIdentityPolicy> {
|
pub fn get_identity_service(
|
||||||
let cookie_secret = &SETTINGS.server.cookie_secret;
|
settings: &Settings,
|
||||||
|
) -> IdentityService<CookieIdentityPolicy> {
|
||||||
|
let cookie_secret = &settings.server.cookie_secret;
|
||||||
IdentityService::new(
|
IdentityService::new(
|
||||||
CookieIdentityPolicy::new(cookie_secret.as_bytes())
|
CookieIdentityPolicy::new(cookie_secret.as_bytes())
|
||||||
.name("Authorization")
|
.name("Authorization")
|
||||||
//TODO change cookie age
|
//TODO change cookie age
|
||||||
.max_age_secs(216000)
|
.max_age_secs(216000)
|
||||||
.domain(&SETTINGS.server.domain)
|
.domain(&settings.server.domain)
|
||||||
.secure(false),
|
.secure(false),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_web::{HttpResponse, Responder};
|
use actix_web::{HttpResponse, Responder};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pub mod login;
|
pub mod login;
|
||||||
pub mod register;
|
pub mod register;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_web::{HttpResponse, Responder};
|
use actix_web::{HttpResponse, Responder};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use actix_auth_middleware::Authentication;
|
use actix_auth_middleware::Authentication;
|
||||||
use actix_web::web::ServiceConfig;
|
use actix_web::web::ServiceConfig;
|
||||||
@@ -51,7 +52,7 @@ mod tests {
|
|||||||
const PASSWORD: &str = "longpassword";
|
const PASSWORD: &str = "longpassword";
|
||||||
const EMAIL: &str = "templateuser@a.com";
|
const EMAIL: &str = "templateuser@a.com";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_web::{HttpResponse, Responder};
|
use actix_web::{HttpResponse, Responder};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_web::{web, HttpResponse, Responder};
|
use actix_web::{web, HttpResponse, Responder};
|
||||||
use my_codegen::get;
|
use my_codegen::get;
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ mod test {
|
|||||||
const NAME: &str = "editsitekeyuser";
|
const NAME: &str = "editsitekeyuser";
|
||||||
const PASSWORD: &str = "longpassworddomain";
|
const PASSWORD: &str = "longpassworddomain";
|
||||||
const EMAIL: &str = "editsitekeyuser@a.com";
|
const EMAIL: &str = "editsitekeyuser@a.com";
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ mod test {
|
|||||||
const PASSWORD: &str = "longpassworddomain";
|
const PASSWORD: &str = "longpassworddomain";
|
||||||
const EMAIL: &str = "listsitekeyuser@a.com";
|
const EMAIL: &str = "listsitekeyuser@a.com";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use actix_web::{HttpResponse, Responder};
|
use actix_web::{HttpResponse, Responder};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod add;
|
mod add;
|
||||||
mod delete;
|
mod delete;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ mod test {
|
|||||||
const PASSWORD: &str = "longpassworddomain";
|
const PASSWORD: &str = "longpassworddomain";
|
||||||
const EMAIL: &str = "viewsitekeyuser@a.com";
|
const EMAIL: &str = "viewsitekeyuser@a.com";
|
||||||
|
|
||||||
let data = crate::data::Data::new().await;
|
let data = get_data().await;
|
||||||
let data = &data;
|
let data = &data;
|
||||||
delete_user(data, NAME).await;
|
delete_user(data, NAME).await;
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use actix_auth_middleware::GetLoginRoute;
|
use actix_auth_middleware::GetLoginRoute;
|
||||||
|
|
||||||
use super::auth::routes::Auth;
|
use super::auth::routes::Auth;
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
body::{BoxBody, EitherBody},
|
body::{BoxBody, EitherBody},
|
||||||
@@ -17,6 +34,15 @@ use crate::api::v1::ROUTES;
|
|||||||
use crate::errors::*;
|
use crate::errors::*;
|
||||||
use crate::ArcData;
|
use crate::ArcData;
|
||||||
|
|
||||||
|
pub fn get_settings() -> Settings {
|
||||||
|
Settings::new().unwrap()
|
||||||
|
}
|
||||||
|
pub async fn get_data() -> ArcData {
|
||||||
|
let settings = get_settings();
|
||||||
|
let data = Data::new(&settings).await;
|
||||||
|
data
|
||||||
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! get_cookie {
|
macro_rules! get_cookie {
|
||||||
($resp:expr) => {
|
($resp:expr) => {
|
||||||
@@ -50,7 +76,7 @@ macro_rules! get_app {
|
|||||||
() => {
|
() => {
|
||||||
test::init_service(
|
test::init_service(
|
||||||
App::new()
|
App::new()
|
||||||
.wrap(get_identity_service())
|
// .wrap(get_identity_service(&$data.settings))
|
||||||
.wrap(actix_middleware::NormalizePath::new(
|
.wrap(actix_middleware::NormalizePath::new(
|
||||||
actix_middleware::TrailingSlash::Trim,
|
actix_middleware::TrailingSlash::Trim,
|
||||||
))
|
))
|
||||||
@@ -60,7 +86,7 @@ macro_rules! get_app {
|
|||||||
($data:expr) => {
|
($data:expr) => {
|
||||||
test::init_service(
|
test::init_service(
|
||||||
App::new()
|
App::new()
|
||||||
.wrap(get_identity_service())
|
.wrap(get_identity_service(&$data.settings))
|
||||||
.wrap(actix_middleware::NormalizePath::new(
|
.wrap(actix_middleware::NormalizePath::new(
|
||||||
actix_middleware::TrailingSlash::Trim,
|
actix_middleware::TrailingSlash::Trim,
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in New Issue
Block a user