mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
The repositories moved from Neo-Desktop to the D-Modem GitHub organisation: D-Modem-RE is now D-Modem/D-Modem, pico-serial is D-Modem/hardware, modemmenu (PBX-Modem) is D-Modem/menu, bbs-sec is D-Modem/bbs and go3270-sec is D-Modem/go3270. Update links, module paths, submodule URLs and source-location strings to match. Copyright notices still name Neo-Desktop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRUwD2JJ5d6fgHmpVTw
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package server
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/D-Modem/bbs/internal/mrc"
|
|
)
|
|
|
|
// TestMRCConfig: [mrc] takes the BBS's name and sysop, has a default
|
|
// address, and refuses a bad address, prefix, requirement or tls.
|
|
func TestMRCConfig(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]\nname = My BBS\nsysop = Sid\n[mrc]\ntls = yes\naddress = mrc.bottomlessabyss.net:5001\n")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m := c.MRC
|
|
if m == nil || !m.TLS || m.Prefix != "mrc-" || m.Sysop != "Sid" || m.Description != "My BBS" {
|
|
t.Errorf("mrc %+v", m)
|
|
}
|
|
if c, _ := load("[mrc]\n"); c.MRC.Address != mrc.DefaultAddress {
|
|
t.Errorf("default address %q", c.MRC.Address)
|
|
}
|
|
for body, want := range map[string]string{
|
|
"[mrc]\naddress = nowhere\n": "address",
|
|
"[mrc]\nprefix = MRC_\n": "prefix",
|
|
"[mrc]\nrequire = 999\n": "require",
|
|
"[mrc]\ntls = maybe\n": "tls",
|
|
} {
|
|
if _, err := load(body); err == nil || !strings.Contains(err.Error(), want) {
|
|
t.Errorf("%q: %v", body, err)
|
|
}
|
|
}
|
|
}
|