// Copyright (C) 2026 Dcntrlized // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . package authmgmt import ( "os" "strings" "testing" ) // TestSchemeIsAlwaysPlaintext locks the rev-9 transport decision: every // satellite peer edge (manifest fetch, action routing) is plaintext HTTP on the // single :8080 listener. A future https/peer-port regression must fail here. func TestSchemeIsAlwaysPlaintext(t *testing.T) { if got := Scheme(); got != "http" { t.Fatalf("Scheme() = %q, want %q", got, "http") } } // TestConfigTokenMintsForService exercises the contract-named mint helper // (rev 9 ยง17.3.6) end to end against a temp data root: it must create the // dedicated config-signing keypair, return a 3-segment JWS bound to the target // service, and expose a public key whose kid matches the token header. func TestConfigTokenMintsForService(t *testing.T) { dir := t.TempDir() t.Setenv("DCNTRLIZED_INSTALL_DIR", dir) token, err := ConfigToken("calendar") if err != nil { t.Fatalf("ConfigToken: %v", err) } parts := strings.Split(token, ".") if len(parts) != 3 { t.Fatalf("token has %d segments, want 3", len(parts)) } for _, name := range []string{"config-signing.key", "config-signing.pub"} { if _, err := os.Stat(dir + "/maestro/" + name); err != nil { t.Fatalf("expected %s to exist: %v", name, err) } } }