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:
37
backend/internal/httpapi/portal_test.go
Normal file
37
backend/internal/httpapi/portal_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPortalCredentialCookieBoundary(t *testing.T) {
|
||||
r := NewOperationalRouter(NewOperations(slog.New(slog.NewTextHandler(io.Discard, nil))))
|
||||
a := &BusinessAPI{}
|
||||
r.POST("/api/v1/portal/snapshot", a.portalSnapshot)
|
||||
for _, tc := range []struct {
|
||||
body, path, origin string
|
||||
want int
|
||||
}{
|
||||
{"{}", "/api/v1/portal/snapshot", "", 400},
|
||||
{`{"instance_id":"00000000-0000-4000-8000-000000000001","secret":"wrong"}`, "/api/v1/portal/snapshot", "", 403},
|
||||
{"{}", "/api/v1/portal/snapshot?customer_id=2", "", 400},
|
||||
{"{}", "/api/v1/portal/snapshot", "https://evil.test", 403},
|
||||
} {
|
||||
q := httptest.NewRequest("POST", tc.path, strings.NewReader(tc.body))
|
||||
q.Header.Set("Cookie", "lp_session=administrator-cookie")
|
||||
q.Header.Set("Content-Type", "application/json")
|
||||
q.Header.Set("Origin", tc.origin)
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, q)
|
||||
if w.Code != tc.want {
|
||||
t.Fatalf("status %d want %d", w.Code, tc.want)
|
||||
}
|
||||
if len(w.Result().Cookies()) != 0 {
|
||||
t.Fatal("portal issued cookie")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user