From 834f98b1e2db5da816f0d72fd71ae90a3dc7cc53 Mon Sep 17 00:00:00 2001 From: Giga <52905881+giga-a@users.noreply.github.com> Date: Wed, 1 Jan 2025 22:22:20 -0800 Subject: [PATCH] Add files via upload --- tests/test_elastic_server.py | 2 +- tests/test_telnet_server.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_elastic_server.py b/tests/test_elastic_server.py index 951f135..0300dc9 100644 --- a/tests/test_elastic_server.py +++ b/tests/test_elastic_server.py @@ -31,7 +31,7 @@ def test_elastic_server(server_logs): basic_auth=(USERNAME, PASSWORD), verify_certs=False, ) - elastic.search(index="test", body={}, size=99) + elastic.search(index="test", body={'size':99}) logs = load_logs_from_file(server_logs) diff --git a/tests/test_telnet_server.py b/tests/test_telnet_server.py index d353fdf..9e3fca1 100644 --- a/tests/test_telnet_server.py +++ b/tests/test_telnet_server.py @@ -1,8 +1,7 @@ from __future__ import annotations -from telnetlib import Telnet - import pytest +from socket import socket from honeypots import QTelnetServer from .utils import ( @@ -13,6 +12,7 @@ PASSWORD, USERNAME, wait_for_server, + connect_to ) PORT = "50023" @@ -23,17 +23,17 @@ [{"server": QTelnetServer, "port": PORT}], indirect=True, ) + def test_telnet_server(server_logs): - with wait_for_server(PORT): - telnet_client = Telnet(IP, int(PORT)) - telnet_client.read_until(b"login: ") - telnet_client.write(USERNAME.encode() + b"\n") - telnet_client.read_until(b"Password: ") - telnet_client.write(PASSWORD.encode() + b"\n") + with wait_for_server(PORT), connect_to(IP, PORT) as connection: + data, _ = connection.recvfrom(10000) + connection.send(USERNAME.encode() + b"\n") + data, _ = connection.recvfrom(10000) + connection.send(PASSWORD.encode() + b"\n") logs = load_logs_from_file(server_logs) assert len(logs) == 2 - connect, login = logs - assert_connect_is_logged(connect, PORT) - assert_login_is_logged(login) + connect_, login = logs + assert_connect_is_logged(connect_, PORT) + assert_login_is_logged(login) \ No newline at end of file