@@ -285,17 +285,15 @@ impl AuthorizationGrant {
285
285
286
286
#[ cfg( test) ]
287
287
mod tests {
288
- use rand:: thread_rng ;
288
+ use rand:: SeedableRng ;
289
289
290
290
use super :: * ;
291
+ use crate :: clock:: { Clock , MockClock } ;
291
292
292
293
#[ test]
293
294
fn no_login_hint ( ) {
294
- #[ allow( clippy:: disallowed_methods) ]
295
- let mut rng = thread_rng ( ) ;
296
-
297
- #[ allow( clippy:: disallowed_methods) ]
298
- let now = Utc :: now ( ) ;
295
+ let now = MockClock :: default ( ) . now ( ) ;
296
+ let mut rng = rand_chacha:: ChaChaRng :: seed_from_u64 ( 42 ) ;
299
297
300
298
let grant = AuthorizationGrant {
301
299
login_hint : None ,
@@ -309,11 +307,8 @@ mod tests {
309
307
310
308
#[ test]
311
309
fn valid_login_hint ( ) {
312
- #[ allow( clippy:: disallowed_methods) ]
313
- let mut rng = thread_rng ( ) ;
314
-
315
- #[ allow( clippy:: disallowed_methods) ]
316
- let now = Utc :: now ( ) ;
310
+ let now = MockClock :: default ( ) . now ( ) ;
311
+ let mut rng = rand_chacha:: ChaChaRng :: seed_from_u64 ( 42 ) ;
317
312
318
313
let grant = AuthorizationGrant {
319
314
login_hint : Some ( String :: from ( "mxid:@example-user:example.com" ) ) ,
@@ -327,11 +322,8 @@ mod tests {
327
322
328
323
#[ test]
329
324
fn valid_login_hint_with_email ( ) {
330
- #[ allow( clippy:: disallowed_methods) ]
331
- let mut rng = thread_rng ( ) ;
332
-
333
- #[ allow( clippy:: disallowed_methods) ]
334
- let now = Utc :: now ( ) ;
325
+ let now = MockClock :: default ( ) . now ( ) ;
326
+ let mut rng = rand_chacha:: ChaChaRng :: seed_from_u64 ( 42 ) ;
335
327
336
328
let grant = AuthorizationGrant {
337
329
login_hint : Some ( String :: from ( "example@user" ) ) ,
@@ -345,11 +337,8 @@ mod tests {
345
337
346
338
#[ test]
347
339
fn invalid_login_hint ( ) {
348
- #[ allow( clippy:: disallowed_methods) ]
349
- let mut rng = thread_rng ( ) ;
350
-
351
- #[ allow( clippy:: disallowed_methods) ]
352
- let now = Utc :: now ( ) ;
340
+ let now = MockClock :: default ( ) . now ( ) ;
341
+ let mut rng = rand_chacha:: ChaChaRng :: seed_from_u64 ( 42 ) ;
353
342
354
343
let grant = AuthorizationGrant {
355
344
login_hint : Some ( String :: from ( "example-user" ) ) ,
@@ -363,11 +352,8 @@ mod tests {
363
352
364
353
#[ test]
365
354
fn valid_login_hint_for_wrong_homeserver ( ) {
366
- #[ allow( clippy:: disallowed_methods) ]
367
- let mut rng = thread_rng ( ) ;
368
-
369
- #[ allow( clippy:: disallowed_methods) ]
370
- let now = Utc :: now ( ) ;
355
+ let now = MockClock :: default ( ) . now ( ) ;
356
+ let mut rng = rand_chacha:: ChaChaRng :: seed_from_u64 ( 42 ) ;
371
357
372
358
let grant = AuthorizationGrant {
373
359
login_hint : Some ( String :: from ( "mxid:@example-user:matrix.org" ) ) ,
@@ -381,11 +367,8 @@ mod tests {
381
367
382
368
#[ test]
383
369
fn unknown_login_hint_type ( ) {
384
- #[ allow( clippy:: disallowed_methods) ]
385
- let mut rng = thread_rng ( ) ;
386
-
387
- #[ allow( clippy:: disallowed_methods) ]
388
- let now = Utc :: now ( ) ;
370
+ let now = MockClock :: default ( ) . now ( ) ;
371
+ let mut rng = rand_chacha:: ChaChaRng :: seed_from_u64 ( 42 ) ;
389
372
390
373
let grant = AuthorizationGrant {
391
374
login_hint : Some ( String :: from ( "something:anything" ) ) ,
0 commit comments