def connect(self): with self._socket_lock: if self._socket is not None: # Socket already established return self._open_socket_and_init_protocoll() # Perform the authenication handshake and get the part # with the agreed authentication data agreed_auth_part = self._auth_manager.perform_handshake() request = RequestMessage.new( self, RequestSegment( message_types.CONNECT, ( agreed_auth_part, ClientId( "pyhdb-%s@%s" % (os.getpid(), socket.getfqdn()) ), ConnectOptions(DEFAULT_CONNECTION_OPTIONS) ) ) ) reply = self.send_request(request, no_reconnect=True) for segment in reply.segments: for part in segment.parts: if part.kind == part_kinds.CONNECTOPTIONS: self.connect_options = part.options
def test_unpack_data(): client_id = ClientId.unpack_data(1, BytesIO(b"*****@*****.**")) assert client_id == "*****@*****.**"
def test_pack_data(): part = ClientId("*****@*****.**") arguments, payload = part.pack_data() assert arguments == 1 assert payload == "*****@*****.**".encode('cesu-8')
def test_pack_data(): part = ClientId("*****@*****.**") arguments, payload = part.pack_data(constants.MAX_SEGMENT_SIZE) assert arguments == 1 assert payload == "*****@*****.**".encode('cesu-8')