47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
|
|
import requests
|
||
|
|
import json
|
||
|
|
|
||
|
|
# 测试设置API
|
||
|
|
def test_settings_api():
|
||
|
|
base_url = "http://127.0.0.1:5000"
|
||
|
|
|
||
|
|
# 测试保存基本设置
|
||
|
|
settings_data = {
|
||
|
|
"site_name": "测试系统名称",
|
||
|
|
"admin_email": "admin@test.com",
|
||
|
|
"max_failed_attempts": 10,
|
||
|
|
"lockout_minutes": 15,
|
||
|
|
"max_unbind_times": 5,
|
||
|
|
"auth_secret_key": "test-secret-key"
|
||
|
|
}
|
||
|
|
|
||
|
|
print("测试保存基本设置...")
|
||
|
|
response = requests.post(
|
||
|
|
f"{base_url}/api/v1/settings",
|
||
|
|
headers={"Content-Type": "application/json"},
|
||
|
|
json=settings_data
|
||
|
|
)
|
||
|
|
|
||
|
|
print(f"状态码: {response.status_code}")
|
||
|
|
print(f"响应: {response.json()}")
|
||
|
|
|
||
|
|
# 测试保存卡密设置
|
||
|
|
license_settings = {
|
||
|
|
"license_key_length": 20,
|
||
|
|
"license_key_prefix": "TEST",
|
||
|
|
"trial_prefix": "TEST_TRIAL_",
|
||
|
|
"offline_cache_days": 14
|
||
|
|
}
|
||
|
|
|
||
|
|
print("\n测试保存卡密设置...")
|
||
|
|
response = requests.post(
|
||
|
|
f"{base_url}/api/v1/settings",
|
||
|
|
headers={"Content-Type": "application/json"},
|
||
|
|
json=license_settings
|
||
|
|
)
|
||
|
|
|
||
|
|
print(f"状态码: {response.status_code}")
|
||
|
|
print(f"响应: {response.json()}")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
test_settings_api()
|