Files
bbs/internal/server/infoconfig_test.go
T
Claude d61601320a Chat, node messages and paging the sysop; finger and gopher servers
Chat rooms for callers on any node (C on the text menu, Chat on a 3270):
/join, /me, /who, /rooms, /msg, the last lines of a room for who comes
in, a flood limit.  A line to one node, from who's online or /msg.
Paging the sysop (S): sysops online and not /busy are told, the caller
waits in a private room, /answer joins it; with no sysop on, page_command
runs (no shell) and the caller may leave a message.  On the text BBS,
lines from other nodes show at whatever prompt the caller is at, above
what they type; on a 3270, on the next screen's message line, and the
chat screen refreshes on Enter or PF5.

[finger] (RFC 1288): who is on and who a user is, no addresses, no
forwarding.  [gopher] (RFC 1436): about, who's online, and the message
and file areas the sysop opens to it (none by default; bbs check warns),
selectors naming records, not paths.

Also: the TN3270 handoff set the caller's Via while who's online could
read it (a data race the new test found); it is set under the lock now.

Tested: the chat hub; two text callers chatting and paging; s3270 chatting
with a text caller; finger with the finger program, gopher with curl.
Wiki pages Chat-and-Paging and Finger-and-Gopher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
2026-10-11 02:20:13 +00:00

56 lines
1.6 KiB
Go

package server
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestInfoConfig(t *testing.T) {
load := func(body string) (*Config, error) {
p := filepath.Join(t.TempDir(), "bbs.conf")
os.WriteFile(p, []byte("[listen telnet]\ntype = telnet\naddress = :2300\n"+body), 0600)
return Load(p)
}
c, err := load(`
[general]
page_command = /usr/local/bin/notify 'BBS page' {user} {reason}
[finger]
users = no
[gopher]
address = :7070
hostname = bbs.example.org
areas = general,announce*
files = yes
`)
if err != nil {
t.Fatal(err)
}
if strings.Join(c.Settings.PageCommand, "|") != "/usr/local/bin/notify|BBS page|{user}|{reason}" {
t.Errorf("page command %q", c.Settings.PageCommand)
}
if c.Finger.Address != ":79" || !c.Finger.Online || c.Finger.Users {
t.Errorf("finger %+v", c.Finger)
}
if g := c.Gopher; g.Host != "bbs.example.org" || g.Port != 7070 || g.Areas != "general,announce*" || !g.Files {
t.Errorf("gopher %+v", g)
}
if !strings.Contains(strings.Join(c.Warnings, "\n"), "[gopher] shows message or file areas to anyone") {
t.Errorf("no warning: %v", c.Warnings)
}
c, err = load("[gopher]\n")
if err != nil || c.Gopher.Port != 70 || c.Gopher.Areas != "" || c.Gopher.Files {
t.Errorf("defaults %+v %v", c.Gopher, err)
}
for body, want := range map[string]string{
"[finger]\naddress = 79\n": "[finger] address",
"[gopher]\nport = 0\n": "[gopher]",
"[general]\npage_command = 'x\n": "page_command",
} {
if _, err := load(body); err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("%q: %v", body, err)
}
}
}