Update secrets
Update RSS / update (push) Successful in 5m14s

This commit is contained in:
2026-08-29 15:11:13 +08:00
parent 530a356468
commit e19f4bf49c
4 changed files with 78 additions and 9 deletions
+23 -1
View File
@@ -3,10 +3,11 @@ from pathlib import Path
import sys
import unittest
import xml.etree.ElementTree as ET
from urllib.parse import parse_qs, urlsplit
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from merge import FeedItem, build_rss, sort_and_limit
from merge import FeedItem, add_rsshub_access_key, build_rss, redact_secret, sort_and_limit
def item(title, link, hour, description=""):
@@ -22,6 +23,27 @@ def item(title, link, hour, description=""):
class MergeTests(unittest.TestCase):
def test_adds_rsshub_key_and_preserves_existing_query(self):
result = add_rsshub_access_key(
"https://rsshub.yuzhen.pub/github/trending/daily?language=python&key=old",
"new key&value",
)
query = parse_qs(urlsplit(result).query)
self.assertEqual(query, {"language": ["python"], "key": ["new key&value"]})
upgraded = add_rsshub_access_key("http://rsshub.yuzhen.pub/feed", "secret")
self.assertEqual(urlsplit(upgraded).scheme, "https")
def test_does_not_add_key_to_other_hosts(self):
url = "https://example.com/feed.xml?category=tech"
self.assertEqual(add_rsshub_access_key(url, "secret"), url)
def test_redacts_raw_and_encoded_key(self):
message = "raw=a b&encoded=a+b&percent=a%20b"
self.assertNotIn("a b", redact_secret(message, "a b"))
self.assertNotIn("a+b", redact_secret(message, "a b"))
self.assertNotIn("a%20b", redact_secret(message, "a b"))
def test_sorts_keeps_duplicates_and_limits(self):
values = [
item("Older", "https://example.com/old", 1),