Files
bbs/internal/server/fidoconfig_test.go
T
Claude 5502f207d2 FidoNet: AreaFix and FileFix, and echoes made when they come
A link with areafix = yes manages what it has here: netmail to AreaFix
(AreaMgr) or FileFix (FileMgr, AllFix) with its areafix_password as the
subject is answered, not delivered: +TAG, -TAG, patterns (+FSX_*), -ALL,
%LIST, %QUERY, %UNLINKED, %HELP, the answer back by netmail.  Such a
link carries the echoes it has linked (within echoes), kept in the
database; others carry their echoes as before.  Requests from systems
that are not links are dropped.

bbs fido areafix|filefix LINK COMMAND... asks a link's robot (our hub's),
with the password we share; bbs fido subs, link, unlink, filelink and
fileunlink show and set a link's by hand.  create = yes makes the area
for an echo a link sends that is not here (named by its tag).  The
store gains the subscriptions, and file areas' file echo tags and files'
origins, for TIC.

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

81 lines
2.7 KiB
Go

package server
import (
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/Neo-Desktop/bbs-sec/internal/archive"
)
func TestFidoConfig(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(`
[fido]
address = 21:1/200 2:5020/9999.1
[binkp]
[link hub]
address = 21:1/100
host = hub.example
password = secret
packet_password = PKT
echoes = FSX_*,!FSX_BOT
route = yes
poll = 3600
[link other]
address = 2:5020/1
packer = arj
host = nodelist
fileechoes = FSX*
areafix = yes
areafix_password = FIXME
tic_password = TIC
create = yes
[link third]
address = 2:5020/3
packer = none
`)
if err != nil {
t.Fatal(err)
}
f := c.Fido
if len(f.Addrs) != 2 || f.Addrs[1].Point != 1 || f.Dir != "fido" || c.Binkp.Address != ":24554" {
t.Fatalf("%+v %+v", f, c.Binkp)
}
hub := f.Links[0]
if hub.Host != "hub.example:24554" || hub.Packer != archive.ZIP || !hub.Route || hub.Poll != time.Hour || hub.PktPassword != "PKT" {
t.Fatalf("%+v", hub)
}
o := f.Links[1]
if o.Packer != archive.ARJ || o.Host != "nodelist" || o.FileEchoes != "FSX*" || !o.AreaFix || o.AreafixPassword != "FIXME" ||
o.TicPassword != "TIC" || !o.Create || hub.AreaFix || hub.Create || hub.FileEchoes != "" {
t.Fatalf("%+v", o)
}
if f.Links[2].Packer != "" || !strings.Contains(strings.Join(c.Warnings, "\n"), "[link other] has no password") {
t.Fatalf("%+v %v", f.Links[2], c.Warnings)
}
for body, want := range map[string]string{
"[fido]\n": "[fido] address",
"[fido]\naddress = 1:1/1\n[link x]\naddress = 1:1/2\nareafix = yes\n": "needs an areafix_password",
"[fido]\naddress = 1:1/1\n[link x]\naddress = 1:1/2\npacker = rar\n": "packer",
"[fido]\naddress = 21:1\n": "not an FTN address",
"[link x]\naddress = 1:1/1\n": "need a [fido] section",
"[fido]\naddress = 1:1/1\n[link x]\n": "address",
"[fido]\naddress = 1:1/1\n[link x]\naddress = 1:1/1\n": "our own address",
"[fido]\naddress = 1:1/1\n[link a]\naddress = 1:1/2\nroute = yes\n[link b]\naddress = 1:1/3\nroute = yes\n": "more than one",
"[fido]\naddress = 1:1/1\n[link a]\naddress = 1:1/2\n[link b]\naddress = 1:1/2\n": "has the address of",
"[fido]\naddress = 1:1/1\n[link a]\naddress = 1:1/2\npacket_password = 123456789\n": "8 characters",
"[fido]\naddress = 1:1/1\ncharset = koi8\n": "charset",
} {
if _, err := load(body); err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("%q: %v, want %q", body, err, want)
}
}
}