Files
Reims-Go/internal/plugin/broker_log_test.go
T
千川白浪andClaude Opus 5.5 3e5b0d7e6c feat(plugin): open settings panels from the settings button, merge plugin logs into the app log (#182)
- The settings button now also appears for plugins that only contribute a
  settings.plugin panel; the panel opens in the settings dialog beside the
  declarative form instead of the bottom of the Plugins page.
- Plugin stderr and non-routine audit entries are mirrored to the app log as
  plugin:<id>, rate limited per plugin; the per-plugin log window is removed.
- The installed-plugin security scan button is removed; the scan verdict shows
  in the permissions tooltip. The pre-install archive scan is unchanged.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 12:01:51 +08:00

34 lines
1.0 KiB
Go

package plugin
import (
"os"
"strings"
"testing"
)
func TestAuditMirrorsPluginOutputToAppLog(t *testing.T) {
layout := NewPluginsLayout(t.TempDir())
broker := NewBroker(layout, nil, func(s string) string { return strings.ReplaceAll(s, "secret", "***") })
var got []string
broker.SetLogger(func(source, line string) { got = append(got, source+" "+line) })
broker.Audit("vendor.demo", "STDERR", "secret one\r\n12:00:00 [host] two")
broker.Audit("vendor.demo", "HOST_API", "host/vm.list")
want := "plugin:vendor.demo [STDERR] *** one 12:00:00 [host] two"
if len(got) != 1 || got[0] != want {
t.Fatalf("app log = %q, want only %q", got, want)
}
file, err := os.ReadFile(layout.LogPath("vendor.demo"))
if err != nil || !strings.Contains(string(file), "host/vm.list") {
t.Fatalf("audit file must keep routine entries: %q, %v", file, err)
}
for range 2 * hostCallsPerSecond {
broker.Audit("vendor.demo", "STDERR", "spam")
}
if len(got) >= 2*hostCallsPerSecond {
t.Fatalf("%d lines reached the app log; spam must be limited", len(got))
}
}