deprecated mcaptcha add route

This commit is contained in:
realaravinth 2021-05-06 13:57:14 +05:30
parent b5a9c0d772
commit 30f457ca43
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
4 changed files with 3 additions and 66 deletions

View file

@ -140,7 +140,7 @@ mod tests {
}
register_and_signin(NAME, EMAIL, PASSWORD).await;
let (data, _, signin_resp, token_key) = add_token_util(NAME, PASSWORD).await;
let (data, _, signin_resp, token_key) = add_levels_util(NAME, PASSWORD).await;
let cookies = get_cookie!(signin_resp);
let mut app = get_app!(data).await;

View file

@ -26,7 +26,6 @@ use crate::Data;
pub mod routes {
pub struct MCaptcha {
pub add: &'static str,
pub delete: &'static str,
pub get_token: &'static str,
pub update_key: &'static str,
@ -35,7 +34,6 @@ pub mod routes {
impl MCaptcha {
pub const fn new() -> MCaptcha {
MCaptcha {
add: "/api/v1/mcaptcha/add",
update_key: "/api/v1/mcaptcha/update/key",
get_token: "/api/v1/mcaptcha/get",
delete: "/api/v1/mcaptcha/delete",
@ -48,12 +46,6 @@ pub fn services(cfg: &mut web::ServiceConfig) {
use crate::define_resource;
use crate::V1_API_ROUTES;
define_resource!(
cfg,
V1_API_ROUTES.mcaptcha.add,
Methods::ProtectPost,
add_mcaptcha
);
define_resource!(
cfg,
V1_API_ROUTES.mcaptcha.update_key,
@ -139,15 +131,6 @@ pub async fn add_mcaptcha_util(
Ok(resp)
}
// TODO deprecate this
async fn add_mcaptcha(data: web::Data<Data>, id: Identity) -> ServiceResult<impl Responder> {
let duration = 30;
let description = "dummy";
let resp = add_mcaptcha_util(duration, description, &data, &id).await?;
Ok(HttpResponse::Ok().json(resp))
}
async fn update_token(
payload: web::Json<MCaptchaDetails>,
data: web::Data<Data>,
@ -275,7 +258,7 @@ mod tests {
// 1. add mcaptcha token
register_and_signin(NAME, EMAIL, PASSWORD).await;
let (data, _, signin_resp, token_key) = add_token_util(NAME, PASSWORD).await;
let (data, _, signin_resp, token_key) = add_levels_util(NAME, PASSWORD).await;
let cookies = get_cookie!(signin_resp);
let mut app = get_app!(data).await;
@ -303,7 +286,7 @@ mod tests {
// 1. add mcaptcha token
register_and_signin(NAME, EMAIL, PASSWORD).await;
let (data, _, signin_resp, token_key) = add_token_util(NAME, PASSWORD).await;
let (data, _, signin_resp, token_key) = add_levels_util(NAME, PASSWORD).await;
let cookies = get_cookie!(signin_resp);
let mut app = get_app!(data).await;

View file

@ -23,7 +23,6 @@ use url::Url;
#[derive(Debug, Clone, Deserialize)]
pub struct Server {
// TODO yet to be configured
pub allow_registration: bool,
pub port: u32,
pub domain: String,
@ -43,15 +42,6 @@ impl Server {
pub fn get_ip(&self) -> String {
format!("{}:{}", self.ip, self.port)
}
//fn check_url_prefix(&mut self) {
// if let Some(prefix) = self.url_prefix.clone() {
// self.url_prefix = Some(prefix.trim().into());
// if prefix.trim().is_empty() {
// self.url_prefix = None;
// }
// }
//}
}
#[derive(Debug, Clone, Deserialize)]
@ -67,10 +57,6 @@ struct DatabaseBuilder {
impl DatabaseBuilder {
#[cfg(not(tarpaulin_include))]
fn extract_database_url(url: &Url) -> Self {
// if url.scheme() != "postgres" || url.scheme() != "postgresql" {
// panic!("URL must be postgres://url, url found: {}", url.scheme());
// } else {
debug!("Databse name: {}", url.path());
let mut path = url.path().split("/");
path.next();
@ -114,7 +100,6 @@ impl Settings {
// merging default config from file
s.merge(File::with_name("./config/default.toml"))?;
// TODO change PLACEHOLDER to app name
s.merge(Environment::with_prefix("GUARD"))?;
check_url(&s);

View file

@ -112,37 +112,6 @@ pub async fn signin<'a>(name: &'a str, password: &str) -> (data::Data, Login, Se
(data, creds, signin_resp)
}
pub async fn add_token_util(
name: &str,
password: &str,
) -> (data::Data, Login, ServiceResponse, MCaptchaDetails) {
let (data, creds, signin_resp) = signin(name, password).await;
let cookies = get_cookie!(signin_resp);
let mut app = get_app!(data).await;
// // 1. add mcaptcha token
// let domain = MCaptchaID {
// name: token_name.into(),
// };
let add_token_resp = test::call_service(
&mut app,
post_request!(ROUTES.mcaptcha.add)
.cookie(cookies.clone())
.to_request(),
)
.await;
// let status = add_token_resp.status();
// let txt: errortoresponse = test::read_body_json(add_token_resp).await;
// println!("{:?}", txt.error);
//
assert_eq!(add_token_resp.status(), StatusCode::OK);
let token_key: MCaptchaDetails = test::read_body_json(add_token_resp).await;
// assert_eq!(status, StatusCode::OK);
(data, creds, signin_resp, token_key)
}
/// pub duplicate test
pub async fn bad_post_req_test<T: Serialize>(
name: &str,