|
|
@@ -320,6 +320,51 @@ TEST_F(ApiFixture, SettingsGetMasksSecretForAdmin) {
|
|
|
EXPECT_TRUE(body.contains("default_embedding_model"));
|
|
|
}
|
|
|
|
|
|
+// 0.18.1: EVERY operational setting must survive the ROUTE, not only
|
|
|
+// Settings::fromJson. All four of these were added to the struct and to the GET
|
|
|
+// and NOT to the PUT handler, which is an explicit allow-list - so the route
|
|
|
+// answered 200 and silently discarded them, and a GET afterwards showed the
|
|
|
+// default. Nothing in the unit tests could see it, because they exercise
|
|
|
+// fromJson/toJson and never the handler; it was caught by a round-trip against
|
|
|
+// the built deb. This test exists so "a setting is not done until a test drives
|
|
|
+// its ROUTE" is enforced rather than remembered.
|
|
|
+//
|
|
|
+// It is also the falsifiable pairing: remove any one of the four lines from
|
|
|
+// handlers/settings.cpp and exactly this test goes red.
|
|
|
+TEST_F(ApiFixture, EveryOperationalSettingSurvivesThePutRoute) {
|
|
|
+ const nlohmann::json body{{"embedding_connect_cap_sec", 1},
|
|
|
+ {"vector_filter_scan_cap", 20000},
|
|
|
+ {"captcha_connect_timeout_sec", 3},
|
|
|
+ {"captcha_read_timeout_sec", 7}};
|
|
|
+ auto put = admin().Put("/api/v1/settings", body.dump(), "application/json");
|
|
|
+ ASSERT_TRUE(put);
|
|
|
+ ASSERT_EQ(put->status, 200);
|
|
|
+
|
|
|
+ auto get = admin().Get("/api/v1/settings");
|
|
|
+ ASSERT_TRUE(get);
|
|
|
+ ASSERT_EQ(get->status, 200);
|
|
|
+ auto g = nlohmann::json::parse(get->body);
|
|
|
+ EXPECT_EQ(g["embedding_connect_cap_sec"].get<uint32_t>(), 1u);
|
|
|
+ EXPECT_EQ(g["vector_filter_scan_cap"].get<uint32_t>(), 20000u);
|
|
|
+ EXPECT_EQ(g["captcha_connect_timeout_sec"].get<uint32_t>(), 3u);
|
|
|
+ EXPECT_EQ(g["captcha_read_timeout_sec"].get<uint32_t>(), 7u);
|
|
|
+
|
|
|
+ // A PUT REPLACES the document from the current snapshot, so the real risk
|
|
|
+ // is a neighbouring field being reset rather than the named one failing to
|
|
|
+ // move. Assert one that was never mentioned in the body.
|
|
|
+ EXPECT_EQ(g["embedding_read_timeout_sec"].get<uint32_t>(), 60u);
|
|
|
+
|
|
|
+ // 0 is "no absolute cap", not "no connect time", and it must round-trip as
|
|
|
+ // 0 rather than being coerced back to the default - otherwise an operator
|
|
|
+ // could not restore the pre-0.18.1 arithmetic at all.
|
|
|
+ auto zero = admin().Put("/api/v1/settings",
|
|
|
+ nlohmann::json{{"embedding_connect_cap_sec", 0}}.dump(), "application/json");
|
|
|
+ ASSERT_TRUE(zero);
|
|
|
+ ASSERT_EQ(zero->status, 200);
|
|
|
+ auto g2 = nlohmann::json::parse(admin().Get("/api/v1/settings")->body);
|
|
|
+ EXPECT_EQ(g2["embedding_connect_cap_sec"].get<uint32_t>(), 0u);
|
|
|
+}
|
|
|
+
|
|
|
// W9 Step 1a: PUT /api/v1/settings changes a field; non-admin gets 403
|
|
|
TEST_F(ApiFixture, SettingsPutChangesField) {
|
|
|
// Change default_embedding_model
|