Address #131 review: unknown link action is unknown, typed views, one share shape
Build image / build-and-push (push) Successful in 13s

- public_link checks the action before the confirmation gate, so an unknown
  action is told so instead of being asked to confirm nothing in particular
  (the 4/4 finding).
- linkView is a struct like shareView; toShareView builds the five share
  results, and a fresh share is read back so it carries the person's name
  like every other path.
- PublicShareURL trims a trailing slash off a hand-built base URL.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
2026-08-23 02:21:04 -04:00
co-authored by Claude Fable 5
parent f985c264f8
commit 608ef7c58e
3 changed files with 56 additions and 32 deletions
+8 -5
View File
@@ -1066,8 +1066,8 @@ func TestSharingToolsAskFirst(t *testing.T) {
Note string `json:"note"`
}
mustCall("share_garden", map[string]any{"gardenId": g.ID, "email": "[email protected]", "role": "editor", "confirmed": true}, &shared)
if shared.Share.Role != domain.RoleEditor || shared.Share.Email != "[email protected]" {
t.Errorf("share = %+v, want sam as editor", shared)
if shared.Share.Role != domain.RoleEditor || shared.Share.Email != "[email protected]" || shared.Share.DisplayName != "Sam" {
t.Errorf("share = %+v, want Sam as editor, named", shared)
}
mustCall("share_garden", map[string]any{"gardenId": g.ID, "email": "[email protected]", "role": "viewer", "confirmed": true}, &shared)
if shared.Share.Role != domain.RoleViewer || !strings.Contains(shared.Note, "now viewer") {
@@ -1081,11 +1081,11 @@ func TestSharingToolsAskFirst(t *testing.T) {
refused("share_garden", map[string]any{"gardenId": g.ID, "email": "[email protected]", "role": "owner", "confirmed": true})
var listed struct {
Shares []shareView `json:"shares"`
PublicLink map[string]any `json:"publicLink"`
Shares []shareView `json:"shares"`
PublicLink linkView `json:"publicLink"`
}
mustCall("list_shares", map[string]any{"gardenId": g.ID}, &listed)
if len(listed.Shares) != 1 || listed.Shares[0].Email != "[email protected]" || listed.Shares[0].Role != domain.RoleViewer || listed.PublicLink["enabled"] != false {
if len(listed.Shares) != 1 || listed.Shares[0].Email != "[email protected]" || listed.Shares[0].Role != domain.RoleViewer || listed.PublicLink.Enabled {
t.Errorf("list_shares = %+v", listed)
}
// Not the owner: Sam can see the garden but can't manage its sharing.
@@ -1135,6 +1135,9 @@ func TestSharingToolsAskFirst(t *testing.T) {
t.Error("the link is still on after disable")
}
refused("public_link", map[string]any{"gardenId": g.ID, "action": "share", "confirmed": true}, "get, enable, rotate or disable")
// An unknown action is unknown whether or not it was confirmed — not a
// request to confirm nothing in particular.
refused("public_link", map[string]any{"gardenId": g.ID, "action": "share"}, "get, enable, rotate or disable")
// --- delete_planting: gone from every view, but in the history — undoable.
bed, err := svc.CreateObject(ctx, owner, g.ID, service.ObjectInput{Kind: domain.KindBed, Name: "Bed", XCM: 500, YCM: 500, WidthCM: 200, HeightCM: 200})