def test_tiny_session_server(): """ Test the whole tiny session, from a server POV. """ packet_log = rdpcap("test/inputs/tiniest-session.pcap") syn, syn_ack = packet_log[:2] listener = MockListener() conn = TCPSocket(listener) conn.seq = syn_ack.seq conn.bind(syn.payload.dst, syn.dport) check_replay(listener, conn, packet_log)
def test_bind_handshake(): """ We can do a handshake when we're the server (someone else initiates the SYN). """ packet_log = rdpcap("test/inputs/tiniest-session.pcap") syn, syn_ack, ack, client_fin_ack, server_fin_ack, client_ack = packet_log listener = MockListener() conn = TCPSocket(listener) conn.seq = syn_ack.seq conn.bind(syn.payload.dst, syn.dport) listener.dispatch(syn) listener.dispatch(ack) assert len(listener.received_packets) == 1 assert conn.state == "ESTABLISHED" check_mostly_same(listener.received_packets[0], syn_ack)