mirror of
https://github.com/D-Modem/login.git
synced 2026-11-28 20:38:06 -08:00
All of modemmenu was one package main in the repository's root. It is
now one module with the program and the pieces it is made of apart:
cmd/modemmenu/ the program (the login, the menu, access, limits,
the selections, -serve, AutoPPP, drop files, the
auth socket's server)
internal/config/ modemmenu.conf's sections and keys, {name} templates
internal/term/ the caller's line, terminal detection, PETSCII
internal/auth/ the backends and password changes
internal/telnet/ the telnet client of mode = telnet items
authd/ the auth socket's protocol and a client, for a BBS
to import (bbs's internal/menuauth is a copy of it)
samples/ the .conf, .users, .pam and .service samples
make builds ./cmd/modemmenu and installs the samples from samples/; the
docs, confref and the site's reference follow. The tests are where
their code is, none lost. TestSampleHasEveryKey now reads the keys of
internal/ too (and the exported Get, Bool...: it would have found none).
.gitignore's "modemmenu" ignored cmd/modemmenu/ as well: it is
/modemmenu now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRbjf74j8oq9R3PXhA
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
// Copyright (C) 2026 D-Modem Authors
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"regexp"
|
|
"sort"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestSampleHasEveryKey: each key the code reads is in
|
|
// samples/modemmenu.conf.sample, so it has help there and a line in the
|
|
// configuration reference (go run ./tools/confref makes docs/reference.md
|
|
// from the sample).
|
|
func TestSampleHasEveryKey(t *testing.T) {
|
|
sample, err := os.ReadFile("../../samples/modemmenu.conf.sample")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
inSample := map[string]bool{}
|
|
for _, m := range regexp.MustCompile(`(?m)^;?\s*([a-z][a-z0-9_]*)\s*=`).FindAllSubmatch(sample, -1) {
|
|
inSample[string(m[1])] = true
|
|
}
|
|
re := regexp.MustCompile(`(\w+)\.(?:Get|Has|Bool|Int|Duration|Durations)\("([a-z0-9_]+)"`)
|
|
// this command's and its packages' (internal/auth reads [file], [ldap]...)
|
|
files, _ := filepath.Glob("*.go")
|
|
more, _ := filepath.Glob("../../internal/*/*.go")
|
|
files = append(files, more...)
|
|
var missing []string
|
|
for _, f := range files {
|
|
if strings.HasSuffix(f, "_test.go") {
|
|
continue
|
|
}
|
|
src, err := os.ReadFile(f)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, m := range re.FindAllStringSubmatch(string(src), -1) {
|
|
if m[1] == "flag" {
|
|
continue // the command line's
|
|
}
|
|
if !inSample[m[2]] {
|
|
missing = append(missing, f+": "+m[2])
|
|
inSample[m[2]] = true
|
|
}
|
|
}
|
|
}
|
|
sort.Strings(missing)
|
|
for _, m := range missing {
|
|
t.Errorf("not in modemmenu.conf.sample: %s", m)
|
|
}
|
|
}
|