actix_permissions/tests/
mod.rs1mod test_permission;
2mod test_service;
3#[cfg(test)]
4mod stubs {
5 use crate::permission::Permission;
6 use actix_web::{web, HttpRequest};
7 use serde::Deserialize;
8 use std::future::Future;
9 use std::pin::Pin;
10
11 #[derive(Deserialize, Debug, Clone)]
12 pub struct MyStatus {
13 status: bool,
14 }
15
16 pub async fn always_true(
17 _req: HttpRequest,
18 status: web::Query<MyStatus>,
19 ) -> actix_web::Result<bool> {
20 Ok(status.status)
21 }
22
23 #[derive(Deserialize, Debug, Clone)]
24 pub struct PermissionStruct;
25 impl Permission<web::Query<MyStatus>> for PermissionStruct {
26 type Future = Pin<Box<dyn Future<Output = actix_web::Result<bool>>>>;
27
28 fn call(&self, _req: HttpRequest, args: web::Query<MyStatus>) -> Self::Future {
29 Box::pin(async move { Ok(args.status) })
30 }
31 }
32}