Files
Paul NicolasandGitHub 04517d36e0 fix(connectors): fix webhook idempotency key and tests (#445)
* feat(workflows): handle webhook idempotency in a different way

* feat(adyen): add verify webhook and fix tests

* fix(atlar): ensure plugin functions are tested

* fix(bankingcircle): ensure plugin functions are tested

* feat(column): add verify webhook method and fix tests

* fix(currencycloud): ensure plugin functions are tested

* fix(generic): ensure plugin functions are tested

* feat(mangopay): add verify webhook method and fix tests

* fix(modulr): ensure plugin functions are tested

* fix(moneycorp): ensure plugin functions are tested

* fix(stripe): ensure plugin functions are tested

* feat(wise): add verify webhook method and fix tests

* fix dirty

* fix postgres idempotency key

* fix wrong go libs version

* fix coderabbitai

* webhooks failing verification should stop temporal workflow
2025-05-14 15:27:14 +00:00

75 lines
1.8 KiB
Go

package stripe
import (
"encoding/json"
"fmt"
"github.com/formancehq/payments/internal/connectors/plugins/public/stripe/client"
"github.com/formancehq/payments/internal/models"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
stripesdk "github.com/stripe/stripe-go/v79"
gomock "go.uber.org/mock/gomock"
)
var _ = Describe("Stripe Plugin Accounts", func() {
var (
ctrl *gomock.Controller
m *client.MockClient
plg models.Plugin
)
BeforeEach(func() {
ctrl = gomock.NewController(GinkgoT())
m = client.NewMockClient(ctrl)
plg = &Plugin{client: m}
})
AfterEach(func() {
ctrl.Finish()
})
Context("fetch next accounts", func() {
var (
pageSize int
sampleAccounts []*stripesdk.Account
)
BeforeEach(func() {
pageSize = 20
sampleAccounts = make([]*stripesdk.Account, 0)
for i := 0; i < pageSize-1; i++ {
sampleAccounts = append(sampleAccounts, &stripesdk.Account{
ID: fmt.Sprintf("some-reference-%d", i),
})
}
})
It("fetches next accounts", func(ctx SpecContext) {
req := models.FetchNextAccountsRequest{
State: json.RawMessage(`{}`),
PageSize: pageSize,
}
// pageSize passed to client is less when we generate a root account
m.EXPECT().GetAccounts(gomock.Any(), gomock.Any(), int64(pageSize-1)).Return(
sampleAccounts,
client.Timeline{LatestID: sampleAccounts[len(sampleAccounts)-1].ID},
true,
nil,
)
res, err := plg.FetchNextAccounts(ctx, req)
Expect(err).To(BeNil())
Expect(res.HasMore).To(BeTrue())
Expect(res.Accounts).To(HaveLen(req.PageSize))
Expect(res.Accounts[0].Reference).To(Equal("root"))
var state accountsState
err = json.Unmarshal(res.NewState, &state)
Expect(err).To(BeNil())
Expect(state.Timeline.LatestID).To(Equal(res.Accounts[len(res.Accounts)-1].Reference))
})
})
})