// SPDX-FileCopyrightText: 2026 Echolot contributors // SPDX-License-Identifier: GPL-3.0-or-later package store import "testing" // The empty account must never match. Devices nobody has signed in on are not a group — they are // unrelated devices that share the absence of an owner — and treating that as an account would // let any anonymous device read every other anonymous device's runs. func TestTheEmptyAccountIsNotAGroup(t *testing.T) { s, err := Open(t.TempDir()) if err != nil { t.Fatal(err) } for _, id := range []string{"anon-1", "anon-2"} { s.data.Devices = append(s.data.Devices, Device{ID: id}) } s.data.Devices = append(s.data.Devices, Device{ID: "mine-1", AccountID: "iss#me"}, Device{ID: "mine-2", AccountID: "iss#me"}, Device{ID: "theirs", AccountID: "iss#them"}) if got := s.DeviceIDsForAccount(""); len(got) != 0 { t.Fatalf("the empty account matched %v", got) } if got := s.DeviceIDsForAccount("iss#me"); len(got) != 2 { t.Fatalf("account has %v, want both of its devices", got) } if got := s.DeviceIDsForAccount("iss#them"); len(got) != 1 || got[0] != "theirs" { t.Fatalf("wrong devices for the other account: %v", got) } }