fix: 拒绝过短密钥,并把对外端口只留在本机
This commit is contained in:
@@ -14,6 +14,18 @@ from euniv.encrypt import (
|
||||
)
|
||||
|
||||
|
||||
def test_short_secret_is_rejected(monkeypatch) -> None:
|
||||
from euniv.crypto import require_secret
|
||||
|
||||
monkeypatch.setenv("EUNIV_SECRET_KEY", "too-short")
|
||||
try:
|
||||
require_secret()
|
||||
except RuntimeError as exc:
|
||||
assert "32" in str(exc)
|
||||
else:
|
||||
raise AssertionError("过短的密钥应当被拒绝")
|
||||
|
||||
|
||||
def test_encrypt_payload_wraps_progress_json_as_string() -> None:
|
||||
body = '{"knowledgeId":"abc","end":false}'
|
||||
assert encrypt_payload(body) == b'{"body":"{\\"knowledgeId\\":\\"abc\\",\\"end\\":false}"}'
|
||||
|
||||
Reference in New Issue
Block a user