Files
synapbus/internal/console/console_test.go
T
Algis DumbrisandClaude Opus 4.6 2575ce2626 feat: OAuth 2.1 with PKCE, MCP auth, dead letters, channel management, and UX polish
- Add OAuth 2.1 identity provider with PKCE S256 (ory/fosite)
- Add RFC 7591 dynamic client registration for MCP clients
- Add RFC 8414 OAuth metadata discovery endpoint
- Add branded OAuth login/authorize pages with SynapBus design
- Add SYNAPBUS_BASE_URL env var for remote/LAN deployments
- Add OAuth bearer token authentication for MCP connections
- Add dead letter queue with Web UI management page
- Add channel leave, member list, and improved channel management
- Add agent auth middleware for MCP-authenticated requests
- Add console printer for structured server startup output
- Hide human accounts from agent management UI
- Fix SSE through middleware (Flush/Unwrap support)
- Fix graceful shutdown by closing SSE clients before server stop
- Fix localhost/127.0.0.1 redirect URI normalization for OAuth
- Remove agent self-registration MCP tools (manage via Web UI only)
- Update README with OAuth setup guide and MCP client config example

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 12:54:02 +02:00

109 lines
2.6 KiB
Go

package console
import (
"bytes"
"strings"
"testing"
)
func TestSuccess(t *testing.T) {
var buf bytes.Buffer
p := NewWithWriter(&buf)
p.Success("SynapBus listening on :8900")
out := buf.String()
if !strings.Contains(out, "✓") {
t.Errorf("expected checkmark, got: %s", out)
}
if !strings.Contains(out, "SynapBus listening on :8900") {
t.Errorf("expected message, got: %s", out)
}
}
func TestArrow(t *testing.T) {
var buf bytes.Buffer
p := NewWithWriter(&buf)
p.Arrow("something happened")
out := buf.String()
if !strings.Contains(out, "→") {
t.Errorf("expected arrow, got: %s", out)
}
}
func TestAgentConnectedWithClient(t *testing.T) {
var buf bytes.Buffer
p := NewWithWriter(&buf)
p.AgentConnected("planner", "claude-code", "1.2.3")
out := buf.String()
if !strings.Contains(out, `"planner"`) {
t.Errorf("expected agent name, got: %s", out)
}
if !strings.Contains(out, "claude-code") {
t.Errorf("expected client name, got: %s", out)
}
if !strings.Contains(out, "1.2.3") {
t.Errorf("expected client version, got: %s", out)
}
}
func TestAgentConnectedWithoutClient(t *testing.T) {
var buf bytes.Buffer
p := NewWithWriter(&buf)
p.AgentConnected("coder", "", "")
out := buf.String()
if !strings.Contains(out, `"coder"`) {
t.Errorf("expected agent name, got: %s", out)
}
if strings.Contains(out, "(") {
t.Errorf("should not have parens without client info, got: %s", out)
}
}
func TestAgentDisconnected(t *testing.T) {
var buf bytes.Buffer
p := NewWithWriter(&buf)
p.AgentDisconnected("reviewer")
out := buf.String()
if !strings.Contains(out, "←") {
t.Errorf("expected left arrow, got: %s", out)
}
if !strings.Contains(out, `"reviewer"`) {
t.Errorf("expected agent name, got: %s", out)
}
}
func TestClientConnected(t *testing.T) {
var buf bytes.Buffer
p := NewWithWriter(&buf)
p.ClientConnected("mcp-inspector", "0.5.0")
out := buf.String()
if !strings.Contains(out, "Client connected") {
t.Errorf("expected client connected, got: %s", out)
}
if !strings.Contains(out, "mcp-inspector") {
t.Errorf("expected client name, got: %s", out)
}
}
func TestInfoAndWarn(t *testing.T) {
var buf bytes.Buffer
p := NewWithWriter(&buf)
p.Info("Waiting for agents...")
p.Warn("something")
out := buf.String()
if !strings.Contains(out, "Waiting for agents...") {
t.Errorf("expected info message, got: %s", out)
}
if !strings.Contains(out, "⚠") {
t.Errorf("expected warning symbol, got: %s", out)
}
}
func TestBlank(t *testing.T) {
var buf bytes.Buffer
p := NewWithWriter(&buf)
p.Blank()
if buf.String() != "\n" {
t.Errorf("expected blank line, got: %q", buf.String())
}
}