File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,25 @@ fn persistent_session_user() {
21
21
assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
22
22
}
23
23
24
+ #[ test]
25
+ fn persistent_session_revoked_after_logout ( ) {
26
+ let ( app, _) = TestApp :: init ( ) . empty ( ) ;
27
+ let user = app. db_new_user ( "user1" ) . with_session ( ) ;
28
+ let request = user. request_builder ( Method :: GET , URL ) ;
29
+ let response: Response < Body > = user. run ( request) ;
30
+ assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
31
+
32
+ // Logout
33
+ let request = user. request_builder ( Method :: DELETE , "/api/private/session" ) ;
34
+ let response: Response < Body > = user. run ( request) ;
35
+ assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
36
+
37
+ // Now this request should fail since we logged out.
38
+ let request = user. request_builder ( Method :: GET , URL ) ;
39
+ let response: Response < Body > = user. run ( request) ;
40
+ assert_eq ! ( response. status( ) , StatusCode :: FORBIDDEN ) ;
41
+ }
42
+
24
43
#[ test]
25
44
fn incorrect_session_is_forbidden ( ) {
26
45
let ( _, anon) = TestApp :: init ( ) . empty ( ) ;
You can’t perform that action at this time.
0 commit comments