mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
// Copyright (c) 2014-present Hanzo AI, Inc.
|
|
// Licensed under MIT OR Apache-2.0. See LICENSE-MIT and LICENSE-APACHE.
|
|
|
|
package billing
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/zap-proto/zip"
|
|
)
|
|
|
|
// TestResolveWebhookOrgSessionlessDoesNotPanic is the regression guard for the
|
|
// webhook-ingress 500: resolveWebhookOrg ran middleware.GetOrganization —
|
|
// gin MustGet — on requests that never passed the auth-token group, so every
|
|
// signature-VALID provider delivery panicked ("key organization does not
|
|
// exist") after passing HMAC verification. Sessionless resolution must fall
|
|
// through to header/env/default lookup instead.
|
|
func TestResolveWebhookOrgSessionlessDoesNotPanic(t *testing.T) {
|
|
app := zip.New(zip.Config{DisableStartupMessage: true})
|
|
c := app.TestCtx("POST", "/v1/billing/webhooks/square")
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
t.Fatalf("resolveWebhookOrg panicked on a sessionless request: %v", r)
|
|
}
|
|
}()
|
|
// No "organization" key set — the sessionless webhook shape. The resolver
|
|
// may return nil here (no datastore in a bare test context); the contract
|
|
// under test is strictly "no panic", which the handler turns into an
|
|
// honest 503 rather than a recovered-panic 500.
|
|
_ = resolveWebhookOrg(c)
|
|
}
|