refactor: ponytail-audit — drop the EffectiveRole delegating wrapper 🧹
It only called EffectiveMember and dropped one return; its sole prod caller (the push gate) discarded that return anyway. Inline it: the gate calls EffectiveMember directly and the test now targets the real method. Kept blobstore.Store (single impl, but the documented M9 S3/R2 seam) and control.Daemon (single impl, but breaks the daemon->control import cycle).
This commit is contained in:
parent
82307bd366
commit
05ebdeea77
3 changed files with 6 additions and 13 deletions
|
|
@ -395,13 +395,6 @@ type Member struct {
|
|||
CanReshare bool
|
||||
}
|
||||
|
||||
// EffectiveRole returns a device's role on a share and whether the share is in
|
||||
// explicit-ACL mode. Thin wrapper over EffectiveMember for the push write gate.
|
||||
func (d *DB) EffectiveRole(deviceID, share string) (role int, explicit bool, err error) {
|
||||
role, _, explicit, err = d.EffectiveMember(deviceID, share)
|
||||
return role, explicit, err
|
||||
}
|
||||
|
||||
// EffectiveMember returns a device's role, its reshare (+s) right, and whether
|
||||
// the share is in explicit-ACL mode. In legacy mode (the v1 default — no member
|
||||
// grants) every known device is an implicit RoleOwner with reshare, so v1 behavior
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ func TestRolesLegacyAndExplicit(t *testing.T) {
|
|||
|
||||
// Legacy: both devices are implicit owners (v1 behavior preserved).
|
||||
for _, dev := range []string{"devA", "devB"} {
|
||||
role, explicit, err := db.EffectiveRole(dev, "proj")
|
||||
role, _, explicit, err := db.EffectiveMember(dev, "proj")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -403,7 +403,7 @@ func TestRolesLegacyAndExplicit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
// An unknown device gets nothing, even in legacy mode.
|
||||
if role, _, _ := db.EffectiveRole("ghost", "proj"); role != 0 {
|
||||
if role, _, _, _ := db.EffectiveMember("ghost", "proj"); role != 0 {
|
||||
t.Fatalf("unknown device role = %d, want 0", role)
|
||||
}
|
||||
|
||||
|
|
@ -428,7 +428,7 @@ func TestRolesLegacyAndExplicit(t *testing.T) {
|
|||
dev string
|
||||
want int
|
||||
}{{"devA", RoleOwner}, {"devB", RoleEditor}} {
|
||||
role, explicit, err := db.EffectiveRole(tc.dev, "proj")
|
||||
role, _, explicit, err := db.EffectiveMember(tc.dev, "proj")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -441,7 +441,7 @@ func TestRolesLegacyAndExplicit(t *testing.T) {
|
|||
if err := db.SetMember("proj", "bob", RoleViewer, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if role, _, _ := db.EffectiveRole("devB", "proj"); role >= RoleEditor {
|
||||
if role, _, _, _ := db.EffectiveMember("devB", "proj"); role >= RoleEditor {
|
||||
t.Fatalf("demoted devB role = %d, want < editor(%d)", role, RoleEditor)
|
||||
}
|
||||
|
||||
|
|
@ -449,7 +449,7 @@ func TestRolesLegacyAndExplicit(t *testing.T) {
|
|||
if err := db.RemoveMember("proj", "bob"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if role, explicit, _ := db.EffectiveRole("devB", "proj"); role != 0 || !explicit {
|
||||
if role, _, explicit, _ := db.EffectiveMember("devB", "proj"); role != 0 || !explicit {
|
||||
t.Fatalf("removed devB role=%d explicit=%v, want 0/true (deny-by-default)", role, explicit)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ func (s *Server) handlePush(w http.ResponseWriter, r *http.Request, deviceID str
|
|||
writeErr(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
role, _, err := s.db.EffectiveRole(deviceID, req.Share)
|
||||
role, _, _, err := s.db.EffectiveMember(deviceID, req.Share)
|
||||
if err != nil {
|
||||
writeErr(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue