async def test_refresh(): mock_bot_authenticator = AsyncMock() mock_bot_authenticator.retrieve_session_token.return_value = "session_token" mock_bot_authenticator.retrieve_key_manager_token.return_value = "km_token" auth_session = AuthSession(mock_bot_authenticator) await auth_session.refresh() assert await auth_session.session_token == "session_token" assert await auth_session.key_manager_token == "km_token"
async def test_bot_session(config): with patch("symphony.bdk.core.auth.bot_authenticator.create_signed_jwt", return_value="privateKey"): bot_authenticator = AsyncMock(BotAuthenticatorRsa) bot_authenticator.retrieve_session_token.return_value = "session_token" bot_authenticator.retrieve_key_manager_token.return_value = "km_token" bot_session = AuthSession(bot_authenticator) async with SymphonyBdk(config) as symphony_bdk: symphony_bdk._bot_session = bot_session auth_session = symphony_bdk.bot_session() assert auth_session is not None assert await auth_session.session_token == "session_token" assert await auth_session.key_manager_token == "km_token"
def _initialize_bot_services(self): self._bot_session = AuthSession(self._authenticator_factory.get_bot_authenticator()) self._service_factory = ServiceFactory(self._api_client_factory, self._bot_session, self._config) self._user_service = self._service_factory.get_user_service() self._message_service = self._service_factory.get_message_service() self._connection_service = self._service_factory.get_connection_service() self._stream_service = self._service_factory.get_stream_service() self._application_service = self._service_factory.get_application_service() self._signal_service = self._service_factory.get_signal_service() self._session_service = self._service_factory.get_session_service() self._datafeed_loop = self._service_factory.get_datafeed_loop() self._health_service = self._service_factory.get_health_service() self._presence_service = self._service_factory.get_presence_service() # creates ActivityRegistry that subscribes to DF Loop events self._activity_registry = ActivityRegistry(self._session_service) self._datafeed_loop.subscribe(self._activity_registry)
def fixture_auth_session(): auth_session = AuthSession(None) auth_session.session_token = "session_token" auth_session.key_manager_token = "km_token" return auth_session
def fixture_auth_session(): bot_session = AuthSession(None) bot_session.session_token = "session_token" bot_session.key_manager_token = "km_token" return bot_session
def fixture_service_factory(api_client_factory, config): factory = ServiceFactory(api_client_factory, AuthSession(None), config) return factory
def fixture_auth_session(): auth_session = AuthSession(None) auth_session.session_token = SESSION_TOKEN auth_session.key_manager_token = KM_TOKEN return auth_session