1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

Add test helpers for handlers and use them

Also expands the test coverage of the revoke handler.
This commit is contained in:
Quentin Gliech
2023-02-21 11:44:52 +01:00
parent a6cd4412c1
commit 64ce271d08
5 changed files with 561 additions and 162 deletions

View File

@ -18,7 +18,7 @@
//! [`SystemClock`] which uses the system time, and a [`MockClock`], which can
//! be used and freely manipulated in tests.
use std::sync::atomic::AtomicI64;
use std::sync::{atomic::AtomicI64, Arc};
use chrono::{DateTime, TimeZone, Utc};
@ -28,6 +28,12 @@ pub trait Clock: Sync {
fn now(&self) -> DateTime<Utc>;
}
impl<C: Clock + Send + ?Sized> Clock for Arc<C> {
fn now(&self) -> DateTime<Utc> {
(**self).now()
}
}
impl<C: Clock + ?Sized> Clock for Box<C> {
fn now(&self) -> DateTime<Utc> {
(**self).now()