Smail/test/tools/check_remote_status.py
smail def5b40d13
Some checks are pending
Security Checks / security (push) Waiting to run
test: 增加全量自动化端到端验收工具脚本套件
2026-09-12 01:11:56 +08:00

27 lines
931 B
Python

import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("47.108.78.12", port=22, username="root", password="10102442Lb!")
sftp = ssh.open_sftp()
with sftp.open("/tmp/test_api.py", "w") as f:
f.write("""import requests
s = requests.Session()
r = s.post('http://127.0.0.1/api/login', json={'account': 'xuans', 'password': '12345678'}, headers={'Content-Type': 'application/json'})
print('LOGIN:', r.status_code, r.text)
print('COOKIES:', s.cookies.get_dict())
r2 = s.get('http://127.0.0.1/api/v1/config/status')
print('CONFIG_STATUS:', r2.status_code, r2.text)
r3 = s.get('http://127.0.0.1/api/v1/config/section/ssl')
print('SSL_SECTION:', r3.status_code, r3.text)
""")
sftp.close()
stdin, stdout, stderr = ssh.exec_command("python3 /tmp/test_api.py")
print("STDOUT:\n", stdout.read().decode('utf-8'))
print("STDERR:\n", stderr.read().decode('utf-8'))
ssh.close()