File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ Add a unit test for ensuring associated refresh tokens are erased when a device is delted.
Original file line number Diff line number Diff line change @@ -449,6 +449,33 @@ def test_on_federation_query_user_devices_appservice(self) -> None:
449449 ],
450450 )
451451
452+ def test_delete_device_removes_refresh_tokens (self ) -> None :
453+ """Deleting a device should also purge any refresh tokens for it."""
454+ self ._record_users ()
455+
456+ self .get_success (
457+ self .store .add_refresh_token_to_user (
458+ user_id = user1 ,
459+ token = "refresh_token" ,
460+ device_id = "abc" ,
461+ expiry_ts = None ,
462+ ultimate_session_expiry_ts = None ,
463+ )
464+ )
465+
466+ self .get_success (self .handler .delete_devices (user1 , ["abc" ]))
467+
468+ remaining_refresh_token = self .get_success (
469+ self .store .db_pool .simple_select_one (
470+ table = "refresh_tokens" ,
471+ keyvalues = {"user_id" : user1 , "device_id" : "abc" },
472+ retcols = ("id" ,),
473+ desc = "get_refresh_token_for_device" ,
474+ allow_none = True ,
475+ )
476+ )
477+ self .assertIsNone (remaining_refresh_token )
478+
452479
453480class DehydrationTestCase (unittest .HomeserverTestCase ):
454481 servlets = [
You can’t perform that action at this time.
0 commit comments