package gateway import ( "net/http" "strings" "testing" "git.yeij.top/AskaEth/Cyrene_v2/internal/auth" ) // TestAdminMissingStoreWritesHonest501 locks the B5 red line for the endpoints // whose backing store does not exist yet: they must answer 501 not_implemented // with an explanatory message, never a fabricated success. User creation has no // user table/login to persist into, and IoT has no scenario/rule model or store. func TestAdminMissingStoreWritesHonest501(t *testing.T) { t.Parallel() srv, ts, jwt := buildEnv(t, cfgDefault(), Deps{}) _ = srv tok := signAny(t, jwt, "acct", auth.RoleOwner) cases := []string{ "/api/v1/admin/users", "/api/v1/admin/iot/scenarios", "/api/v1/admin/iot/rules", } for _, path := range cases { resp, body := doReq(t, http.MethodPost, ts.URL+path, map[string]any{"name": "x"}, tok) if resp.StatusCode != http.StatusNotImplemented { t.Fatalf("%s status = %d, want 501 (body=%s)", path, resp.StatusCode, body) } wantErrorShape(t, body) if !strings.Contains(string(body), "not_implemented") { t.Fatalf("%s body = %s, want not_implemented code", path, body) } } }