def test_serial(self): command = AuthenticateCommand(AuthenticateCommand.Request.SERIAL, 123456789) self.assertEqual( command.get(), array.array("B", b"\x44\x04\x01\x00\x15\xCD\x5B\x07"), )
def test_pairing(self): command = AuthenticateCommand( AuthenticateCommand.Request.PAIRING, 987654321, map(ord, 'hello')) self.assertEqual(command.get(), array.array('B', [0x44, 0x04, 0x02, 0x05, 0xb1, 0x68, 0xde, 0x3a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00]))
def test_pairing(self): command = AuthenticateCommand(AuthenticateCommand.Request.PAIRING, 987654321, map(ord, "hello")) self.assertEqual( command.get(), array.array( "B", b"\x44\x04\x02\x05\xB1\x68\xDE\x3A\x68\x65\x6C\x6C\x6F\x00\x00\x00" ), )
def runTest(self): command = AuthenticateCommand( AuthenticateCommand.Request.SERIAL, 123456789) self.assertEqual(command.get(), array.array('B', [0x44, 0x04, 0x01, 0x00, 0x15, 0xcd, 0x5b, 0x7])) command = AuthenticateCommand( AuthenticateCommand.Request.PAIRING, 987654321, map(ord, 'hello')) self.assertEqual(command.get(), array.array('B', [0x44, 0x04, 0x02, 0x05, 0xb1, 0x68, 0xde, 0x3a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00]))
def authentication_passkey(self, passkey): self._send_command(AuthenticateCommand( AuthenticateCommand.Request.PASSKEY_EXCHANGE, self._serial_number, passkey)) response = self._get_command() if response._get_argument("type") == AuthenticateResponse.Response.ACCEPT: return response.get_data_array() else: raise AntFSAuthenticationException("Passkey authentication failed", response._get_argument("type"))
def authentication_pair(self, friendly_name): data = array.array('B', map(ord, list(friendly_name))) self._send_command(AuthenticateCommand( AuthenticateCommand.Request.PAIRING, self._serial_number, data)) response = self._get_command(30) if response._get_argument("type") == AuthenticateResponse.Response.ACCEPT: return response.get_data_array() else: raise AntFSAuthenticationException("Pair authentication failed", response._get_argument("type"))
def authenticate_command(): command = AuthenticateCommand( AuthenticateCommand.Type.REQUEST_SERIAL, 123456789) assert command.get() == array.array('B', [0x44, 0x04, 0x01, 0x00, 0x15, 0xcd, 0x5b, 0x7]) command = AuthenticateCommand( AuthenticateCommand.Type.REQUEST_PAIRING, 987654321, map(ord, 'hello')) assert command.get() == array.array('B', [0x44, 0x04, 0x02, 0x05, 0xb1, 0x68, 0xde, 0x3a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00])
def runTest(self): command = AuthenticateCommand(AuthenticateCommand.Request.SERIAL, 123456789) self.assertEqual( command.get(), array.array('B', [0x44, 0x04, 0x01, 0x00, 0x15, 0xcd, 0x5b, 0x7])) command = AuthenticateCommand(AuthenticateCommand.Request.PAIRING, 987654321, map(ord, 'hello')) self.assertEqual( command.get(), array.array('B', [ 0x44, 0x04, 0x02, 0x05, 0xb1, 0x68, 0xde, 0x3a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00 ]))
def authentication_serial(self): self._send_command( AuthenticateCommand(AuthenticateCommand.Request.SERIAL, self._serial_number)) response = self._get_command() return (response.get_serial(), response.get_data_string())
def test_serial(self): command = AuthenticateCommand( AuthenticateCommand.Request.SERIAL, 123456789) self.assertEqual(command.get(), array.array('B', [0x44, 0x04, 0x01, 0x00, 0x15, 0xcd, 0x5b, 0x7]))
def test_serial(self): command = AuthenticateCommand(AuthenticateCommand.Request.SERIAL, 123456789) self.assertEqual( command.get(), array.array('B', [0x44, 0x04, 0x01, 0x00, 0x15, 0xcd, 0x5b, 0x7]))