From 546f0c204731028f7c42297dbae184400eecfc77 Mon Sep 17 00:00:00 2001 From: fl0l0u Date: Fri, 30 Oct 2026 10:45:00 +0000 Subject: [PATCH] config: pin the empty --api-key refusal with a test d773992 restored the refusal 33108e4 had silently taken back, so the behavior is main's again. What no branch carried was a test. The hunk was written once, merged, and deleted by a stale rebase with nothing noticing until an audit read the parser; an empty --api-key value -- a unit file whose $RADIANCE_API_KEY was never set -- must stay a startup error, so a config_test case says so, and the next silent overwrite trips a test instead of an audit. --- tests/config_test.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/config_test.cpp b/tests/config_test.cpp index 1546eb39..7aea8d94 100644 --- a/tests/config_test.cpp +++ b/tests/config_test.cpp @@ -91,6 +91,17 @@ TEST(a_retired_flag_is_refused) { CHECK_EQ(parse({ "--kv-host-cache-mib", "4096" }, &c), RAD_E_INVAL); } +/* An empty key is no key: --api-key "" -- or --api-key "$UNSET_VAR" in a unit file whose variable + * was typo'd -- must not start a server that looks guarded on its command line and answers every + * route keyless. The shipped compose files fail closed on ${RADIANCE_API_KEY:?}; this is the + * refusal for every other way the binary meets an empty value. */ +TEST(an_empty_api_key_is_refused) { + CHECK_EQ(parse_fresh({ "--api-key", "" }), RAD_E_INVAL); + Config c; + CHECK_EQ(parse({ "--api-key", "k" }, &c), 0); + CHECK(c.api_key == "k"); +} + /* A flag written last with no argument is refused rather than reading past argv. */ TEST(a_flag_missing_its_argument_is_refused_rather_than_read_past) { Config c;