- server: relay storing signed objects (PUT/GET), per-IP rate limiting, per-subject quota (1000), one-response-per-request, pagination, /v1/healthz /v1/readyz /v1/metrics - verify: signature-verifying trust evaluator; every object is checked via env.Verify(), approvals via VerifyApprovalResponse, revocations via VerifyRevocationOf; k-of-n approval quorum - docs: TRUST-MODEL.md and API.md describing issuer-anchored signatures and the endpoint/status-code contract - tests: server, verify, and ratelimit packages
42 lines
961 B
Go
42 lines
961 B
Go
package server_test
|
|
|
|
import (
|
|
"go/parser"
|
|
"go/token"
|
|
"os"
|
|
"path/filepath"
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
// TestServerDoesNotImportSigner enforces INV-1 structurally: the relay never
|
|
// links the client-only signing package, so a server compromise cannot forge.
|
|
func TestServerDoesNotImportSigner(t *testing.T) {
|
|
dir := "."
|
|
entries, err := os.ReadDir(dir)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, e := range entries {
|
|
if e.IsDir() || filepath.Ext(e.Name()) != ".go" {
|
|
continue
|
|
}
|
|
if e.Name()[len(e.Name())-8:] == "_test.go" {
|
|
continue
|
|
}
|
|
fset := token.NewFileSet()
|
|
f, err := parser.ParseFile(fset, e.Name(), nil, parser.ImportsOnly)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, imp := range f.Imports {
|
|
p, err := strconv.Unquote(imp.Path.Value)
|
|
if err != nil {
|
|
continue
|
|
}
|
|
if p == "git.n1ko.dev/Niko/niko_trust/internal/identity/signer" {
|
|
t.Errorf("%s imports the signer package, violating INV-1", e.Name())
|
|
}
|
|
}
|
|
}
|
|
}
|