56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Simple FTP Client Test Script
|
|
Tests the basic functionality of our FTP server
|
|
"""
|
|
|
|
import socket
|
|
import time
|
|
|
|
def test_ftp_server():
|
|
"""Test basic FTP server functionality"""
|
|
print("Testing FTP Server...")
|
|
|
|
try:
|
|
# Connect to FTP server
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
sock.connect(('127.0.0.1', 2121))
|
|
|
|
# Read welcome message
|
|
response = sock.recv(1024).decode('utf-8')
|
|
print(f"Server: {response.strip()}")
|
|
|
|
# Test USER command
|
|
sock.send(b'USER admin\r\n')
|
|
response = sock.recv(1024).decode('utf-8')
|
|
print(f"Server: {response.strip()}")
|
|
|
|
# Test PASS command
|
|
sock.send(b'PASS admin123\r\n')
|
|
response = sock.recv(1024).decode('utf-8')
|
|
print(f"Server: {response.strip()}")
|
|
|
|
# Test PWD command
|
|
sock.send(b'PWD\r\n')
|
|
response = sock.recv(1024).decode('utf-8')
|
|
print(f"Server: {response.strip()}")
|
|
|
|
# Test SYST command
|
|
sock.send(b'SYST\r\n')
|
|
response = sock.recv(1024).decode('utf-8')
|
|
print(f"Server: {response.strip()}")
|
|
|
|
# Test QUIT command
|
|
sock.send(b'QUIT\r\n')
|
|
response = sock.recv(1024).decode('utf-8')
|
|
print(f"Server: {response.strip()}")
|
|
|
|
sock.close()
|
|
print("✅ Basic FTP commands test passed!")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Test failed: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
test_ftp_server()
|