Files
magpie/internal/agent/flowdown_bob_test.go
T
yetone 7dbfc9f2fe usage: FlowDown and Bob are clients drawn with their own app icons (shannnnnks on X)
Their requests were unnamed in Usage and Routing. FlowDown (wiki.qaq.flow)
sets no User-Agent in its sources (checked Lakr233/FlowDown), so the system's
"FlowDown/<build> CFNetwork/..." is what arrives; Bob (com.hezongyidev.Bob) is
closed source and is matched the same way, by "bob/". Icons are the apps' own
App Store icons at 64px, as color SVGs wrapping the PNG, so app.js's size
budget is untouched.

Run: TestFlowDownAndBobAreClients (agent), see push notes for the rest.
Not tried: real traffic from Bob (its UA is the CFNetwork default for its
executable name, not captured); FlowDown/Bob are not wired as agents, since
neither reads a config file magpie can write.
2026-11-12 22:24:45 +08:00

34 lines
1019 B
Go

package agent
import (
"os"
"path/filepath"
"slices"
"testing"
"github.com/yetone/magpie/internal/usage"
)
// shannnnnks on X asked for FlowDown's and Bob's icons: their requests
// carry the system networking's User-Agent, naming the app first, and are
// drawn with the app's own icon.
func TestFlowDownAndBobAreClients(t *testing.T) {
for ua, want := range map[string]string{
"FlowDown/1234 CFNetwork/1568.100.1 Darwin/24.0.0": "flowdown",
"Bob/2.0.1 CFNetwork/1568.100.1 Darwin/24.0.0": "bob",
"Bobby/1.0": "Bobby",
} {
if got := usage.AgentOf(ua); got != want {
t.Errorf("%q: %q, want %q", ua, got, want)
}
}
for _, id := range []string{"flowdown", "bob"} {
if !slices.ContainsFunc(Clients(), func(a *Agent) bool { return a.ID == id && a.Icon == id+"-color" }) {
t.Errorf("%s isn't a client the Usage views draw", id)
}
if _, err := os.Stat(filepath.Join("..", "gui", "assets", "icons", id+"-color.svg")); err != nil {
t.Errorf("%s has no icon file: %v", id, err)
}
}
}