@@ -470,13 +470,45 @@ class WhoamiTestCase(unittest.HomeserverTestCase):
470
470
register .register_servlets ,
471
471
]
472
472
473
+ def default_config (self ):
474
+ config = super ().default_config ()
475
+ config ["allow_guest_access" ] = True
476
+ return config
477
+
473
478
def test_GET_whoami (self ):
474
479
device_id = "wouldgohere"
475
480
user_id = self .register_user ("kermit" , "test" )
476
481
tok = self .login ("kermit" , "test" , device_id = device_id )
477
482
478
- whoami = self .whoami (tok )
479
- self .assertEqual (whoami , {"user_id" : user_id , "device_id" : device_id })
483
+ whoami = self ._whoami (tok )
484
+ self .assertEqual (
485
+ whoami ,
486
+ {
487
+ "user_id" : user_id ,
488
+ "device_id" : device_id ,
489
+ # Unstable until MSC3069 enters spec
490
+ "org.matrix.msc3069.is_guest" : False ,
491
+ },
492
+ )
493
+
494
+ def test_GET_whoami_guests (self ):
495
+ channel = self .make_request (
496
+ b"POST" , b"/_matrix/client/r0/register?kind=guest" , b"{}"
497
+ )
498
+ tok = channel .json_body ["access_token" ]
499
+ user_id = channel .json_body ["user_id" ]
500
+ device_id = channel .json_body ["device_id" ]
501
+
502
+ whoami = self ._whoami (tok )
503
+ self .assertEqual (
504
+ whoami ,
505
+ {
506
+ "user_id" : user_id ,
507
+ "device_id" : device_id ,
508
+ # Unstable until MSC3069 enters spec
509
+ "org.matrix.msc3069.is_guest" : True ,
510
+ },
511
+ )
480
512
481
513
def test_GET_whoami_appservices (self ):
482
514
user_id = "@as:test"
@@ -491,11 +523,18 @@ def test_GET_whoami_appservices(self):
491
523
)
492
524
self .hs .get_datastore ().services_cache .append (appservice )
493
525
494
- whoami = self .whoami (as_token )
495
- self .assertEqual (whoami , {"user_id" : user_id })
526
+ whoami = self ._whoami (as_token )
527
+ self .assertEqual (
528
+ whoami ,
529
+ {
530
+ "user_id" : user_id ,
531
+ # Unstable until MSC3069 enters spec
532
+ "org.matrix.msc3069.is_guest" : False ,
533
+ },
534
+ )
496
535
self .assertFalse (hasattr (whoami , "device_id" ))
497
536
498
- def whoami (self , tok ):
537
+ def _whoami (self , tok ):
499
538
channel = self .make_request ("GET" , "account/whoami" , {}, access_token = tok )
500
539
self .assertEqual (channel .code , 200 )
501
540
return channel .json_body
0 commit comments