Files
zeekay 7d727874d5 chore: rebrand Formance Payments -> Hanzo Payments (hanzo-fi)
- go.mod module path + all self-imports: github.com/formancehq/payments -> github.com/hanzo-fi/payments
  (1590 .go files / 3152 refs; 20 modules: root, pkg/client, pkg/domain, 18 ce/plugins).
  External dep kept: formancehq/go-libs.
- plugins: each ce/plugins/* consumed a *published* pkg/domain; added local
  'replace .../pkg/domain => ../../../pkg/domain' (consistent with root) so every
  standalone plugin module builds in-monorepo. compile-plugin.sh MOD var rebranded too.
- branding: README, LICENSE (dual MIT+EE; upstream copyright retained + Hanzo added),
  goreleaser (release images -> registry.hanzo.ai/hanzo-fi, OCI labels, homepage),
  proto go_package, renovate, speakeasy gen.yaml, connector-template *.gotpl.
- CI: removed Numary/Formance workflows + composite action; added canonical hanzo.yml +
  cicd.yml (hanzoai/ci, gated HANZO_CI_ENABLED) + secretless ci.yml (go build/vet).
- kept as data/compat keys: wire capability enums ALLOW_FORMANCE_*, generated SDK type
  client.Formance, domain field FormanceRedirectURL, OTEL_SERVICE_NAME, upstream base image.
- verified: go build ./... (default + -tags ee) + all 20 nested modules green.
2026-07-05 13:08:55 -07:00

207 lines
5.4 KiB
Go

package column
import (
"errors"
"net/http"
"net/http/httptest"
"time"
"github.com/hanzo-fi/payments/ce/plugins/column/client"
"github.com/hanzo-fi/payments/pkg/domain/models"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"go.uber.org/mock/gomock"
)
var _ = Describe("Column Plugin Uninstall", func() {
var (
plg models.Plugin
ctrl *gomock.Controller
mockHTTPClient *client.MockHTTPClient
now time.Time
ts *httptest.Server
)
BeforeEach(func() {
now = time.Now().UTC()
ctrl = gomock.NewController(GinkgoT())
ts = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte(`{"webhook_urls": []}`))
Expect(err).To(BeNil())
}))
mockHTTPClient = client.NewMockHTTPClient(ctrl)
c := client.New("test", "aseplye", ts.URL)
c.SetHttpClient(mockHTTPClient)
plg = &Plugin{
client: c,
}
})
AfterEach(func() {
ctrl.Finish()
})
Context("uninstalling connector", func() {
It("should handle empty webhooks list", func(ctx SpecContext) {
mockHTTPClient.EXPECT().Do(
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).Return(
200,
nil,
).SetArg(
2,
client.ListWebhookResponseWrapper[[]*client.EventSubscription]{
WebhookEndpoints: []*client.EventSubscription{},
},
)
resp, err := plg.Uninstall(ctx, models.UninstallRequest{
ConnectorID: "test-connector",
})
Expect(err).To(BeNil())
Expect(resp).To(Equal(models.UninstallResponse{}))
})
It("should handle webhook list event error", func(ctx SpecContext) {
mockHTTPClient.EXPECT().Do(
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).Return(
500,
errors.New("list failed"),
)
resp, err := plg.Uninstall(ctx, models.UninstallRequest{
ConnectorID: "test-connector",
})
Expect(err).To(MatchError("failed to list web hooks: list failed : "))
Expect(resp).To(Equal(models.UninstallResponse{}))
})
It("should handle webhook deletion error", func(ctx SpecContext) {
mockHTTPClient.EXPECT().Do(
gomock.Any(),
NewRequestMatcher("limit=100"),
gomock.Any(),
gomock.Any(),
).Return(
200,
nil,
).SetArg(
2,
client.ListWebhookResponseWrapper[[]*client.EventSubscription]{
WebhookEndpoints: []*client.EventSubscription{
{
ID: "webhook-2",
URL: ts.URL + "/test-connector/webhook",
CreatedAt: now.Add(-time.Duration(5) * time.Minute).UTC().Format(time.RFC3339),
UpdatedAt: now.Add(-time.Duration(5) * time.Minute).UTC().Format(time.RFC3339),
Description: "description",
EnabledEvents: []string{"book.transfer.completed"},
Secret: "secret",
IsDisabled: false,
},
},
},
)
mockHTTPClient.EXPECT().Do(
gomock.Any(),
NewRequestMatcher("limit=100&starting_after=webhook-2"),
gomock.Any(),
gomock.Any(),
).Return(
200,
nil,
).SetArg(
2,
client.ListWebhookResponseWrapper[[]*client.EventSubscription]{
WebhookEndpoints: []*client.EventSubscription{},
},
)
mockHTTPClient.EXPECT().Do(
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).Return(
200,
errors.New("deletion failed"),
)
resp, err := plg.Uninstall(ctx, models.UninstallRequest{
ConnectorID: "test-connector",
})
Expect(err).To(MatchError("failed to delete web hooks: deletion failed : "))
Expect(resp).To(Equal(models.UninstallResponse{}))
})
It("should successfully uninstall and delete webhooks", func(ctx SpecContext) {
mockHTTPClient.EXPECT().Do(
gomock.Any(),
NewRequestMatcher("limit=100"),
gomock.Any(),
gomock.Any(),
).Return(
200,
nil,
).SetArg(2, client.ListWebhookResponseWrapper[[]*client.EventSubscription]{
WebhookEndpoints: []*client.EventSubscription{
{
ID: "webhook-1",
URL: "https://example.com/test-connector/webhook",
CreatedAt: now.Add(-time.Duration(5) * time.Minute).UTC().Format(time.RFC3339),
UpdatedAt: now.Add(-time.Duration(5) * time.Minute).UTC().Format(time.RFC3339),
Description: "description",
EnabledEvents: []string{"book.transfer.completed"},
Secret: "secret",
IsDisabled: false,
},
{
ID: "webhook-2",
URL: "https://example.com/other-connector/webhook",
CreatedAt: now.Add(-time.Duration(5) * time.Minute).UTC().Format(time.RFC3339),
UpdatedAt: now.Add(-time.Duration(5) * time.Minute).UTC().Format(time.RFC3339),
Description: "description",
EnabledEvents: []string{"book.transfer.completed"},
Secret: "secret",
IsDisabled: false,
},
},
})
mockHTTPClient.EXPECT().Do(
gomock.Any(),
NewRequestMatcher("limit=100&starting_after=webhook-2"),
gomock.Any(),
gomock.Any(),
).Return(
200,
nil,
).SetArg(2, client.ListWebhookResponseWrapper[[]*client.EventSubscription]{
WebhookEndpoints: []*client.EventSubscription{},
})
mockHTTPClient.EXPECT().Do(
gomock.Any(),
gomock.Any(),
gomock.Any(),
gomock.Any(),
).Return(
200,
nil,
)
resp, err := plg.Uninstall(ctx, models.UninstallRequest{
ConnectorID: "test-connector",
})
Expect(err).To(BeNil())
Expect(resp).To(Equal(models.UninstallResponse{}))
})
})
})