feat: implement license platform business flows and delivery tooling
Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation. Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
36
backend/internal/httpapi/keyring_http_test.go
Normal file
36
backend/internal/httpapi/keyring_http_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestKeyringHTTPAndFileBoundary(t *testing.T) {
|
||||
if _, err := LoadKeyring("relative.json", ""); err == nil {
|
||||
t.Fatal("relative ring accepted")
|
||||
}
|
||||
for _, enabled := range []bool{false, true} {
|
||||
router := NewOperationalRouter(NewOperations(slog.New(slog.NewTextHandler(io.Discard, nil))))
|
||||
var ring *Keyring
|
||||
if enabled {
|
||||
ring = &Keyring{Current: "test", Keys: []VerificationKey{{KeyID: "test", PublicKeyPEM: "public-only", Revoked: false}}}
|
||||
}
|
||||
RegisterBusinessWithKeyring(router, &sql.DB{}, "", ring)
|
||||
response := httptest.NewRecorder()
|
||||
router.ServeHTTP(response, httptest.NewRequest("GET", "/api/v1/activation/keyring", nil))
|
||||
expected := 404
|
||||
if enabled {
|
||||
expected = 200
|
||||
}
|
||||
if response.Code != expected {
|
||||
t.Fatal(response.Code)
|
||||
}
|
||||
if strings.Contains(response.Body.String(), "PRIVATE KEY") {
|
||||
t.Fatal("private key disclosure")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user