feat(server): add project sharing access control

This commit is contained in:
2026-07-10 14:46:18 +08:00
parent 60130b3d9b
commit 9d47cb9bbd
41 changed files with 3069 additions and 17 deletions
+36
View File
@@ -0,0 +1,36 @@
package errorx
import (
"context"
"net/http"
"testing"
sharingmodule "img_infinite_canvas/internal/modules/sharing"
)
func TestHandleShareInviteConflicts(t *testing.T) {
tests := []struct {
name string
err error
errorCode string
}{
{name: "self invite", err: sharingmodule.ErrSelfInvite, errorCode: "share.self_invite"},
{name: "member exists", err: sharingmodule.ErrMemberExists, errorCode: "share.member_exists"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
status, body := Handle(context.Background(), tt.err)
if status != http.StatusConflict {
t.Fatalf("expected status %d, got %d", http.StatusConflict, status)
}
payload, ok := body.(map[string]any)
if !ok {
t.Fatalf("expected map response, got %T", body)
}
if payload["errorCode"] != tt.errorCode {
t.Fatalf("expected error code %q, got %v", tt.errorCode, payload["errorCode"])
}
})
}
}