mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 12:35:13 +00:00
fix(api): redact error replies, lock segment url lookups, refuse unresolvable proxy hosts and recheck job proxies at start
This commit is contained in:
@@ -293,3 +293,23 @@ def test_a_system_exit_stays_a_service_error_whatever_its_cause_names() -> None:
|
||||
raise SystemExit(1) from e
|
||||
except SystemExit as exit_:
|
||||
assert categorize_exception(exit_).error_code == APIErrorCode.SERVICE_ERROR
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"error",
|
||||
[
|
||||
APIError(
|
||||
APIErrorCode.SERVICE_ERROR,
|
||||
"Licence request failed: 403 Client Error: Forbidden for url: https://lic.example.com/wv?token=s3cr3t&kid=1",
|
||||
),
|
||||
RuntimeError("Failed to initialize service: 403 for url: https://lic.example.com/wv?token=s3cr3t&kid=1"),
|
||||
],
|
||||
ids=["api-error", "exception"],
|
||||
)
|
||||
def test_the_reply_masks_a_secret_in_the_error_text(error: Exception) -> None:
|
||||
"""A service exception names the URL it failed on, and a server-account login puts the operator's token there."""
|
||||
resp = build_error_response(error)
|
||||
body = _body(resp)
|
||||
assert "s3cr3t" not in body["message"]
|
||||
assert "s3cr3t" not in resp["error"]["message"]
|
||||
assert "https://lic.example.com/wv?token=***&kid=1" in body["message"]
|
||||
|
||||
Reference in New Issue
Block a user