示例#1
0
    async def logon(self):
        """
        Log on to the FIX server using the provided credentials.
        """
        logger.info(f"{self.name}: Logging in...")

        logon_msg = admin.LogonMessage(self.username,
                                       self.password,
                                       heartbeat_int=self.heartbeat_int)

        self.reset_seq_nums = not self.pipeline.apps[
            ClientSessionApp.name].is_resumed
        if self.reset_seq_nums:
            logon_msg.ResetSeqNumFlag = True

        if self.test_mode is True:
            logon_msg.TestMessageIndicator = True

        logger.info(f"{self.name}: Logging in with: {logon_msg:t}...")
        # Don't need to block while we send logon message
        asyncio.create_task(self.send(logon_msg))

        await self.logged_in_event.wait()

        logger.info(f"Successfully logged on!")
示例#2
0
    async def test_on_logon_raises_exception_on_wrong_reset_sequence_number_response(
            self, base_pipeline):
        with pytest.raises(SessionError):
            logon_msg = admin.LogonMessage("", "")
            logon_msg.ResetSeqNumFlag = False

            auth_app = AuthenticationApp(base_pipeline)
            await auth_app.on_logon(logon_msg)
示例#3
0
    async def test_on_logon_raises_exception_on_wrong_heartbeat_response(
            self, base_pipeline):
        with pytest.raises(SessionError):
            logon_msg = admin.LogonMessage("", "", heartbeat_int=60)
            logon_msg.ResetSeqNumFlag = True

            auth_app = AuthenticationApp(base_pipeline)
            await auth_app.on_logon(logon_msg)
示例#4
0
    async def test_on_logon_sets_default_test_message_indicator_to_false(
            self, base_pipeline):
        logon_msg = admin.LogonMessage("", "")
        logon_msg.ResetSeqNumFlag = True

        auth_app = AuthenticationApp(base_pipeline)
        await auth_app.on_logon(logon_msg)

        assert auth_app.test_mode is False
示例#5
0
def logon_message():
    """Sample logon message"""
    message = admin.LogonMessage("USERNAME", "PASSWORD")

    message.MsgSeqNum = "1"
    message.SenderCompID = "SENDER"
    message.SendingTime = "20181206-10:24:27.018"
    message.TargetCompID = "TARGET"
    message.ResetSeqNumFlag = "Y"

    return message