fix(site): 精简站点配置,移除名称/Banner/相关链接 (#15)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
608afb88ea
commit
460cfdc78a
8 files changed
+24
-238
No files matched your search
@@ -13,12 +13,9 @@ from app.core.config import get_settings
|
||||
from app.services.html_filter import filter_html
|
||||
|
||||
_PUBLIC_KEYS = {
|
||||
"siteName",
|
||||
"logoUrl",
|
||||
"bannerUrls",
|
||||
"icpText",
|
||||
"policeText",
|
||||
"friendLinks",
|
||||
"linkCirea",
|
||||
"linkHousing",
|
||||
}
|
||||
@@ -224,7 +221,7 @@ def test_admin_content_requires_login(api_client):
|
||||
("get", "/api/admin/files/1", None),
|
||||
("get", "/api/admin/site-settings", None),
|
||||
("get", "/api/admin/sensitive-words", None),
|
||||
("put", "/api/admin/site-settings", {"site_name": "x"}),
|
||||
("put", "/api/admin/site-settings", {"icp_text": "x"}),
|
||||
("post", "/api/admin/sensitive-words", {"word": "x"}),
|
||||
("post", "/api/admin/content/preview-filter", {"html": "<p>a</p>"}),
|
||||
("delete", "/api/admin/sensitive-words/1", None),
|
||||
@@ -309,8 +306,6 @@ def test_public_settings_hide_login_lock(ready_client):
|
||||
assert isinstance(original["login_max_failures"], int)
|
||||
assert isinstance(original["login_lock_minutes"], int)
|
||||
assert isinstance(original["logoUrl"], str)
|
||||
assert isinstance(original["bannerUrls"], list)
|
||||
link = {"name": "示例链接", "url": "https://example.com/gsrea"}
|
||||
try:
|
||||
rejected = ready_client.put(
|
||||
"/api/admin/site-settings",
|
||||
@@ -318,12 +313,17 @@ def test_public_settings_hide_login_lock(ready_client):
|
||||
headers=headers,
|
||||
)
|
||||
assert rejected.status_code == 400
|
||||
unknown = ready_client.put(
|
||||
"/api/admin/site-settings",
|
||||
json={"site_name": "甘肃价协测试站点"},
|
||||
headers=headers,
|
||||
)
|
||||
assert unknown.status_code == 400
|
||||
saved = ready_client.put(
|
||||
"/api/admin/site-settings",
|
||||
json={
|
||||
"site_name": "甘肃价协测试站点",
|
||||
"icp_text": "陇ICP备测试号",
|
||||
"friend_links": [link],
|
||||
"link_cirea": "https://example.com/cirea",
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
@@ -332,11 +332,9 @@ def test_public_settings_hide_login_lock(ready_client):
|
||||
assert response.status_code == 200, response.text
|
||||
body = response.json()
|
||||
assert set(body) == _PUBLIC_KEYS
|
||||
assert body["siteName"] == "甘肃价协测试站点"
|
||||
assert body["icpText"] == "陇ICP备测试号"
|
||||
assert body["friendLinks"] == [link]
|
||||
assert body["linkCirea"] == "https://example.com/cirea"
|
||||
assert isinstance(body["logoUrl"], str)
|
||||
assert isinstance(body["bannerUrls"], list)
|
||||
text = response.text
|
||||
assert "login_max_failures" not in text
|
||||
assert "login_lock_minutes" not in text
|
||||
@@ -344,13 +342,15 @@ def test_public_settings_hide_login_lock(ready_client):
|
||||
assert "loginLockMinutes" not in text
|
||||
assert "upload_max_bytes" not in text
|
||||
assert "uploadMaxBytes" not in text
|
||||
assert "siteName" not in text
|
||||
assert "bannerUrls" not in text
|
||||
assert "friendLinks" not in text
|
||||
finally:
|
||||
ready_client.put(
|
||||
"/api/admin/site-settings",
|
||||
json={
|
||||
"site_name": original["site_name"],
|
||||
"icp_text": original["icp_text"],
|
||||
"friend_links": original["friend_links"],
|
||||
"link_cirea": original["link_cirea"],
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user