| 1 | package daemon |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "encoding/json" |
| 6 | "strings" |
| 7 | "testing" |
| 8 | ) |
| 9 | |
| 10 | // TestManagementGoldenInventory is intentionally a diagnostic inventory. It |
| 11 | // records source methods that still return unsupported after the complete |
| 12 | // tenant dispatcher has been constructed; package tests must not treat a |
| 13 | // static registry as implementation proof. |
| 14 | func TestManagementGoldenInventory(t *testing.T) { |
| 15 | params := map[string][]json.RawMessage{} |
| 16 | for _, method := range ManagementMethods() { |
| 17 | params[method] = nil |
| 18 | } |
| 19 | params["setpolicy" ] = []json.RawMessage{json.RawMessage(`{}` )} |
| 20 | params["setconnections" ] = []json.RawMessage{json.RawMessage(`[]` )} |
| 21 | params["deleteevent" ] = []json.RawMessage{json.RawMessage(`"` + strings.Repeat("0" , 64) + `"` )} |
| 22 | params["deleteblob" ] = []json.RawMessage{json.RawMessage(`"` + strings.Repeat("0" , 64) + `"` )} |
| 23 | params["deleterelay" ] = []json.RawMessage{json.RawMessage(`"main"` )} |
| 24 | params["forkrelay" ] = []json.RawMessage{json.RawMessage(`{"name":"fork-golden"}` )} |
| 25 | params["transferowner" ] = []json.RawMessage{json.RawMessage(`"` + strings.Repeat("1" , 64) + `"` )} |
| 26 | readMethods := map[string]bool{} |
| 27 | for _, method := range []string{"supportedmethods" , "listaudit" , "stats" , "getpolicy" , "listviews" , "listbannedpubkeys" , "listallowedpubkeys" , "listmembers" , "listpeople" , "listjoinrequests" , "listinvites" , "listclaims" , "listlisthistory" , "listeventsneedingmoderation" , "listblockedips" , "listreports" , "exportconfig" , "listblobs" , "listsites" , "listrecentevents" , "searchevents" , "listpins" , "storagestats" , "listretention" , "listallowedkinds" , "listblockedkinds" , "listpresets" , "listconnectiontemplates" , "listconnections" , "pullstatus" , "listjobs" , "deliverystatus" , "listdumps" , "listbackups" , "clearsuccession" , "successionstatus" , "listdomains" } { |
| 28 | readMethods[method] = true |
| 29 | } |
| 30 | for _, method := range ManagementMethods() { |
| 31 | t.Run(method, func(t *testing.T) { |
| 32 | _, tenant := testTenant(t) |
| 33 | _, err := tenant.Execute(context.Background(), tenant.Policy().Owner, method, params[method]) |
| 34 | if err != nil && strings.HasPrefix(err.Error(), "unsupported:" ) { |
| 35 | t.Errorf("missing %s: %v" , method, err) |
| 36 | } |
| 37 | if readMethods[method] && err != nil { |
| 38 | t.Errorf("read method %s failed: %v" , method, err) |
| 39 | } |
| 40 | }) |
| 41 | } |
| 42 | } |