Exemplo n.º 1
0
 async def get_user_devices_info(self, user_id: UserID = None) -> List[DeviceInfo]:
     """
     Raises:
         BackendConnectionError
     """
     user_id = user_id or self.device.user_id
     try:
         user_certif, revoked_user_certif, device_certifs = await self._remote_devices_manager.get_user_and_devices(
             user_id, no_cache=True
         )
     except RemoteDevicesManagerBackendOfflineError as exc:
         raise BackendNotAvailable(str(exc)) from exc
     except RemoteDevicesManagerNotFoundError as exc:
         raise BackendNotFoundError(str(exc)) from exc
     except RemoteDevicesManagerError as exc:
         # TODO: we should be using our own kind of exception instead of borowing BackendConnectionError...
         raise BackendConnectionError(
             f"Error while fetching user {user_id} certificates"
         ) from exc
     results = []
     for device_certif in device_certifs:
         results.append(
             DeviceInfo(
                 device_id=device_certif.device_id,
                 device_label=device_certif.device_label,
                 created_on=device_certif.timestamp,
             )
         )
     return results
Exemplo n.º 2
0
 async def get_user_info(self, user_id: UserID) -> UserInfo:
     """
     Raises:
         BackendConnectionError
     """
     try:
         user_certif, revoked_user_certif = await self._remote_devices_manager.get_user(user_id)
     except RemoteDevicesManagerBackendOfflineError as exc:
         raise BackendNotAvailable(str(exc)) from exc
     except RemoteDevicesManagerNotFoundError as exc:
         raise BackendNotFoundError(str(exc)) from exc
     except RemoteDevicesManagerError as exc:
         # TODO: we should be using our own kind of exception instead of borowing BackendConnectionError...
         raise BackendConnectionError(
             f"Error while fetching user {user_id} certificates"
         ) from exc
     return UserInfo(
         user_id=user_certif.user_id,
         human_handle=user_certif.human_handle,
         profile=user_certif.profile,
         revoked_on=revoked_user_certif.timestamp if revoked_user_certif else None,
         created_on=user_certif.timestamp,
     )
Exemplo n.º 3
0
 async def mocked_backend_block_create(*args, **kwargs):
     await vanilla_backend_block_create(*args, **kwargs)
     raise BackendNotAvailable()