ljayic asked again for routing groups through /v1/magpie/admin/. They are
served now as the other routes are, by the app's own handlers behind the
same guard (gateway/admin.go, by path prefix, nothing new there):
- GET routing-groups: the Routing page's /api/groups answer.
- GET routing-groups/{id}: one group as that list has it, by its id or the
ref agents pick it by (group/<id>, auto/<model>); 404 for none.
- POST routing-groups/create: the page's save, refused with 409 when the
id is a group's already (save would write over it).
- POST routing-groups/update: the page's save over the group as it is,
the fields sent put over its own, so one field changes alone; 404 for no
such group; "from" renames, as the page's editor does.
- POST routing-groups/{save,delete,copy,switch,arrange,pick,defaults,
template,share,import,show}: the page's actions as they are.
Members, combos (a group in a group) and each member's account
("provider/model#<account>") go through provider.SaveGroup, so what the
page refuses the API refuses: an account the provider has none of, an
account on a group, an empty group, a bad id, deleting a group a combo
holds. Not served: "found" and "skip" (the found-groups switches, which
move the agents set to a found group, rewriting this computer's agents).
Run (mica; mote was at load 62 with a GUI suite): go test -count=1
-run 'TestAdmin|Group' ./internal/gui ok; go vet ./internal/gui and
GOOS=windows go vet ./internal/gui ok; gofmt -l empty.
Red on the old admin.go (origin/main's, with the new tests): both new
tests 404. Broken by hand, each red in TestAdminAPIRoutingGroups: create's
409 check off (create over team served), update's merge off (a name-only
update refused as an empty group), "found" added to the actions (served).
Tests: TestAdminAPIRoutingGroups (create, combo, 409, four refusals the
page makes, get by id and ref, update keeps fields, member change, rename
carried into the combo, switch, arrange, found/skip 404, delete refused in
a combo then both at once, no provider key told);
TestAdminAPIRoutingGroupsGuarded (through gateway.New().Front(): no key
401 from loopback and the network, a key that may not manage 403 from
both, a local key from the network and through a proxy 403, Origin 403,
five routes each, nothing made; then local from loopback and any from the
network 200).
Not tried: the full suite (both boxes had a GUI suite running; it runs
before the push), a Linux vet of gui (needs WebKitGTK; wsl-run before
the push), a real request from a second computer.