Files
login/cmd/modemmenu/ldap_test.go
T
Claude 80d0fda167 Split the code into packages: cmd/modemmenu, internal/*, authd
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
2026-11-06 03:12:02 +00:00

38 lines
1.0 KiB
Go

// Copyright (C) 2026 D-Modem Authors
// SPDX-License-Identifier: AGPL-3.0-only
package main
import (
"os"
"path/filepath"
"strings"
"testing"
)
// MODEMMENU_TEST_LDAP, groups as in internal/auth's TestLDAPGroups: an
// item for sysops, through settings, a login by ldap
func TestLDAPItemGroups(t *testing.T) {
url := os.Getenv("MODEMMENU_TEST_LDAP")
if url == "" {
t.Skip("MODEMMENU_TEST_LDAP is not set")
}
dir := t.TempDir()
p := filepath.Join(dir, "c.conf")
os.WriteFile(p, []byte("[general]\nauth = ldap\n[ldap]\nurl = "+url+
"\nsearch_base = ou=people,dc=example,dc=com\ngroup_base = ou=groups,dc=example,dc=com\n"+
"[item ops]\ngroups = sysops\ncommand = true\n[item away]\ngroups = other\ncommand = true\n"), 0o600)
s, err := loadSettings(p)
if err != nil {
t.Fatal(err)
}
sess := &session{User: "lduser", Password: "ldpass", Auth: "ldap"}
var names []string
for _, it := range s.visible(sess) {
names = append(names, it.name)
}
if strings.Join(names, " ") != "ops" {
t.Errorf("lduser sees %v", names)
}
}