Release Please / Release Please (push) Skipped
Release / GoReleaser (push) Skipped
Tests / Secret scan (gitleaks) (push) Skipped
Tests / Test (Go 1.25) (push) Skipped
Tests / Test (Go stable) (push) Skipped
Tests / Secret scan (gitleaks) (pull_request) Successful in 4s
Tests / Test (Go 1.25) (pull_request) Successful in 59s
Tests / Test (Go stable) (pull_request) Successful in 1m7s
Showroom-safe: the tree no longer carries internal hosts, IPs, ports, personal names, client domains or client file names. Behaviour is unchanged and now supplied per deployment. - catalog: hardcoded mail-org / project classifiers become a YAML-driven Classifier (OO_CATALOG_CONFIG or --config); neutral default classifies nothing as work. New catalog/classify.go + example + tests. - storage_fallback: drop the baked-in MinIO endpoint IP; require MINIO_ENDPOINT (+ keys) from the env. - kontolink: build DocEditor links from $ONLYOFFICE_URL instead of a hardcoded portal host; kontoblatt: no client file id in the output name. - oo: load .env CLI-wide (bootstrap.LoadEnv in execute) so non-authenticating commands (catalog scans) also see config. - genericize comments/docs/fixtures (AGENTS, README, .env.example, crm-associations, catalog tests, ES/pdfattach tests, mails).
65 lines
2.2 KiB
Go
65 lines
2.2 KiB
Go
package catalog
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestClassifierRules(t *testing.T) {
|
|
cl := &Classifier{
|
|
WorkRemotes: []string{"git.internal.example"},
|
|
WorkNames: []string{"acme"},
|
|
MailOrgs: []MailRule{
|
|
{Domain: "acme.example", Org: "Acme", Zone: "hot", Role: "work"},
|
|
{Suffix: ".gov.example", Org: "Public", Zone: "warm", Role: "work"},
|
|
},
|
|
}
|
|
if role, zone := cl.ClassifyProject("acme-app", "git@git.internal.example:team/acme-app.git"); role != "work" || zone != "hot" {
|
|
t.Fatalf("remote: %s/%s", role, zone)
|
|
}
|
|
if role, zone := cl.ClassifyProject("acme-demo", ""); role != "work" || zone != "warm" {
|
|
t.Fatalf("name: %s/%s", role, zone)
|
|
}
|
|
if role, zone := cl.ClassifyProject("experiment-x", ""); role != "experiment" || zone != "cold" {
|
|
t.Fatalf("experiment: %s/%s", role, zone)
|
|
}
|
|
if org, zone, role := cl.ClassifyMail("", "bob@acme.example"); org != "Acme" || zone != "hot" || role != "work" {
|
|
t.Fatalf("mail: %s/%s/%s", org, zone, role)
|
|
}
|
|
if org, _, _ := cl.ClassifyMail("X", "x@team.gov.example"); org != "Public" {
|
|
t.Fatalf("suffix: %s", org)
|
|
}
|
|
if org, zone, role := cl.ClassifyMail("", "someone@unknown.example"); org != "" || zone != "private" || role != "unknown" {
|
|
t.Fatalf("neutral: %s/%s/%s", org, zone, role)
|
|
}
|
|
}
|
|
|
|
func TestLoadClassifier(t *testing.T) {
|
|
dir := t.TempDir()
|
|
path := filepath.Join(dir, "classify.yaml")
|
|
if err := os.WriteFile(path, []byte("work_names:\n - acme\nmail_orgs:\n - domain: acme.example\n org: Acme\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
cl, err := LoadClassifier(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if role, _ := cl.ClassifyProject("acme-app", ""); role != "work" {
|
|
t.Fatalf("role=%s", role)
|
|
}
|
|
if org, zone, _ := cl.ClassifyMail("", "a@acme.example"); org != "Acme" || zone != "hot" {
|
|
t.Fatalf("org=%s zone=%s", org, zone)
|
|
}
|
|
|
|
t.Setenv("OO_CATALOG_CONFIG", path)
|
|
if envCl, err := LoadClassifierFromEnv(); err != nil || envCl == nil || len(envCl.WorkNames) == 0 {
|
|
t.Fatalf("env: %+v %v", envCl, err)
|
|
}
|
|
t.Setenv("OO_CATALOG_CONFIG", "")
|
|
neutral, err := LoadClassifierFromEnv()
|
|
if err != nil || len(neutral.WorkNames) != 0 || len(neutral.MailOrgs) != 0 {
|
|
t.Fatalf("neutral: %+v %v", neutral, err)
|
|
}
|
|
}
|