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.
34 lines
1019 B
Go
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)
|
|
}
|
|
}
|
|
}
|