Files
ResolveSpec/pkg/security/lookup/deps_test.go
T
Hein c9fa8c60f2 refactor(security): move all database access into pkg/security/lookup
pkg/security no longer contains SQL. Every provider calls a store interface
from lookup, implemented by a procedure backend (Postgres stored procedures,
the default there) and a direct backend (dialect-driven SQL for postgres,
sqlite, mysql and mssql with configurable table and column names).

- add sectypes, lookup, lookup/{dialect,procedure,direct,backends,ddl,conformance}
- split totp and providers sub packages out of the core package
- replace SQLNames/TableNames/QueryMode with lookup.Config (see breaking_changes.md)
- direct backend now covers column/row security and API-key login
- move txsettings SQL to lookup.ApplyTxSettings; remove password.go
- move schema scripts under lookup/, add reference DDL per dialect
- add a shared conformance suite; run it on sqlite, and on Postgres in a
  podman/docker container (RESOLVESPEC_TEST_CONTAINERS=1)
- fix procedure schema bugs found on real Postgres: duplicate p_data
  parameter, JSON null arrays, expires_at timezone casts, passkey list
  GROUP BY, missing resolvespec_passkey_login; accept zone-less timestamps
2026-10-01 13:19:44 +02:00

35 lines
1.1 KiB
Go

package lookup_test
import (
"os/exec"
"strings"
"testing"
)
// lookup and its backends sit above sectypes and below security: they must not import the
// core package (security imports lookup) or any sibling sub package.
func TestNoUpwardImports(t *testing.T) {
for _, pkg := range []string{".", "./procedure", "./direct", "./conformance"} {
checkNoUpwardImports(t, pkg)
}
}
func checkNoUpwardImports(t *testing.T, pkg string) {
t.Helper()
out, err := exec.Command("go", "list", "-deps", "-f", "{{.ImportPath}}", pkg).Output()
if err != nil {
t.Skipf("go list unavailable: %v", err)
}
for _, p := range strings.Fields(string(out)) {
if strings.Contains(p, "uptrace/bun") || strings.Contains(p, "gorm.io") {
t.Errorf("%s must not depend on an ORM, found %s", pkg, p)
}
if !strings.Contains(p, "/pkg/security") || strings.HasSuffix(p, "/lookup") ||
strings.HasSuffix(p, "/sectypes") || strings.HasSuffix(p, "/lookup/dialect") ||
strings.HasSuffix(p, "/lookup/procedure") || strings.HasSuffix(p, "/lookup/direct") || strings.HasSuffix(p, "/lookup/conformance") {
continue
}
t.Errorf("%s must not import %s", pkg, p)
}
}