Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 513913c

Browse files
authored
Expose the registered device ID from the register_appservice_user test helper. (#11615)
1 parent 3f72c2a commit 513913c

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

changelog.d/11615.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expose the registered device ID from the `register_appservice_user` test helper.

tests/handlers/test_user_directory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ def test_excludes_appservices_user(self) -> None:
169169
# Register an AS user.
170170
user = self.register_user("user", "pass")
171171
token = self.login(user, "pass")
172-
as_user = self.register_appservice_user("as_user_potato", self.appservice.token)
172+
as_user, _ = self.register_appservice_user(
173+
"as_user_potato", self.appservice.token
174+
)
173175

174176
# Join the AS user to rooms owned by the normal user.
175177
public, private = self._create_rooms_and_inject_memberships(
@@ -388,7 +390,7 @@ def test_handle_local_profile_change_with_deactivated_user(self) -> None:
388390

389391
def test_handle_local_profile_change_with_appservice_user(self) -> None:
390392
# create user
391-
as_user_id = self.register_appservice_user(
393+
as_user_id, _ = self.register_appservice_user(
392394
"as_user_alice", self.appservice.token
393395
)
394396

tests/rest/client/test_room_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None:
8989
self.clock = clock
9090
self.storage = hs.get_storage()
9191

92-
self.virtual_user_id = self.register_appservice_user(
92+
self.virtual_user_id, _ = self.register_appservice_user(
9393
"as_user_potato", self.appservice.token
9494
)
9595

tests/storage/test_user_directory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ def test_population_excludes_appservice_user(self) -> None:
341341
# Register an AS user.
342342
user = self.register_user("user", "pass")
343343
token = self.login(user, "pass")
344-
as_user = self.register_appservice_user("as_user_potato", self.appservice.token)
344+
as_user, _ = self.register_appservice_user(
345+
"as_user_potato", self.appservice.token
346+
)
345347

346348
# Join the AS user to rooms owned by the normal user.
347349
public, private = self._create_rooms_and_inject_memberships(

tests/unittest.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,18 +620,19 @@ def register_appservice_user(
620620
self,
621621
username: str,
622622
appservice_token: str,
623-
) -> str:
623+
) -> Tuple[str, str]:
624624
"""Register an appservice user as an application service.
625625
Requires the client-facing registration API be registered.
626626
627627
Args:
628628
username: the user to be registered by an application service.
629-
Should be a full username, i.e. ""@localpart:hostname" as opposed to just "localpart"
629+
Should NOT be a full username, i.e. just "localpart" as opposed to "@localpart:hostname"
630630
appservice_token: the acccess token for that application service.
631631
632632
Raises: if the request to '/register' does not return 200 OK.
633633
634-
Returns: the MXID of the new user.
634+
Returns:
635+
The MXID of the new user, the device ID of the new user's first device.
635636
"""
636637
channel = self.make_request(
637638
"POST",
@@ -643,7 +644,7 @@ def register_appservice_user(
643644
access_token=appservice_token,
644645
)
645646
self.assertEqual(channel.code, 200, channel.json_body)
646-
return channel.json_body["user_id"]
647+
return channel.json_body["user_id"], channel.json_body["device_id"]
647648

648649
def login(
649650
self,

0 commit comments

Comments
 (0)