diff --git a/services/skus/controllers.go b/services/skus/controllers.go index 5901a2a12..8a5af61b1 100644 --- a/services/skus/controllers.go +++ b/services/skus/controllers.go @@ -122,7 +122,6 @@ func Router( cr.Method(http.MethodGet, "/items/{itemID}/batches/{requestID}", metricsMwr("GetOrderCredsByID", getOrderCredsByID(svc, false))) cr.Method(http.MethodPut, "/items/{itemID}/batches/{requestID}", metricsMwr("CreateOrderItemCreds", createItemCreds(svc))) - cr.Method(http.MethodDelete, "/items/{itemID}/batches/{requestID}", metricsMwr("DeleteOrderItemCreds", authMwr(deleteItemCreds(svc)))) }) return r @@ -604,47 +603,6 @@ func CreateOrderCreds(svc *Service) handlers.AppHandler { } } -// deleteItemCreds handles requests for deleting credentials for an item. -func deleteItemCreds(svc *Service) handlers.AppHandler { - return func(w http.ResponseWriter, r *http.Request) *handlers.AppError { - ctx := r.Context() - lg := logging.Logger(ctx, "skus").With().Str("func", "deleteItemCreds").Logger() - - orderID, err := uuid.FromString(chi.URLParamFromCtx(ctx, "orderID")) - if err != nil { - lg.Error().Err(err).Msg("failed to validate order id") - return handlers.ValidationError("request url parameter", map[string]interface{}{ - "orderID": err.Error(), - }) - } - - reqID, err := uuid.FromString(chi.URLParamFromCtx(ctx, "reqID")) - if err != nil { - lg.Error().Err(err).Msg("failed to validate request id") - return handlers.ValidationError("request url parameter", map[string]interface{}{ - "itemID": err.Error(), - }) - } - - isSigned := r.URL.Query().Get("isSigned") == "true" - - if err := svc.DeleteOrderCreds(ctx, orderID, reqID, isSigned); err != nil { - lg.Error().Err(err).Msg("failed to delete the order credentials") - - switch { - case errors.Is(err, model.ErrOrderNotFound), errors.Is(err, ErrOrderHasNoItems): - return handlers.WrapError(err, "order or item not found", http.StatusNotFound) - case errors.Is(err, errExceededMaxActiveOrderCreds): - return handlers.WrapError(err, errExceededMaxActiveOrderCreds.Error(), http.StatusUnprocessableEntity) - default: - return handlers.WrapError(err, "error deleting credentials", http.StatusInternalServerError) - } - } - - return handlers.RenderContent(ctx, nil, w, http.StatusOK) - } -} - // createItemCredsRequest includes the blinded credentials to be signed. type createItemCredsRequest struct { BlindedCreds []string `json:"blindedCreds" valid:"base64"` @@ -750,7 +708,7 @@ func DeleteOrderCreds(service *Service) handlers.AppHandler { } isSigned := r.URL.Query().Get("isSigned") == "true" - if err := service.DeleteOrderCreds(ctx, id, uuid.Nil, isSigned); err != nil { + if err := service.DeleteOrderCreds(ctx, id, isSigned); err != nil { return handlers.WrapError(err, "Error deleting credentials", http.StatusBadRequest) } diff --git a/services/skus/credentials.go b/services/skus/credentials.go index cdb37fbc4..c17a8b1a2 100644 --- a/services/skus/credentials.go +++ b/services/skus/credentials.go @@ -44,8 +44,6 @@ var ( errItemDoesNotExist model.Error = "order item does not exist for order" errCredsAlreadySubmitted model.Error = "credentials already submitted" - errExceededMaxActiveOrderCreds model.Error = "maximum active order credentials exceeded" - defaultExpiresAt = time.Now().Add(17532 * time.Hour) // 2 years retryPolicy = retrypolicy.DefaultRetry dontRetryCodes = map[int]struct{}{ @@ -690,7 +688,7 @@ func (s *SigningOrderResultErrorHandler) Handle(ctx context.Context, message kaf // - create repos for credentials; // - move the corresponding methods there; // - make those methods work on per-item basis. -func (s *Service) DeleteOrderCreds(ctx context.Context, orderID uuid.UUID, reqID uuid.UUID, isSigned bool) error { +func (s *Service) DeleteOrderCreds(ctx context.Context, orderID uuid.UUID, isSigned bool) error { order, err := s.Datastore.GetOrder(orderID) if err != nil { return err @@ -722,7 +720,7 @@ func (s *Service) DeleteOrderCreds(ctx context.Context, orderID uuid.UUID, reqID } if doTlv2 { - if err := s.deleteTLV2(ctx, tx, order, reqID, time.Now()); err != nil { + if err := s.Datastore.DeleteTimeLimitedV2OrderCredsByOrderTx(ctx, tx, orderID); err != nil { return fmt.Errorf("error deleting time limited v2 order creds: %w", err) } } @@ -738,34 +736,6 @@ func (s *Service) DeleteOrderCreds(ctx context.Context, orderID uuid.UUID, reqID return nil } -// maxTLV2ActiveItemCreds is the max number of credentials an item is allowed to have in the given day -const maxTLV2ActiveOrderCreds = 10 - -func (s *Service) deleteTLV2(ctx context.Context, dbi sqlx.ExtContext, order *model.Order, reqID uuid.UUID, now time.Time) error { - - // Pass the request id as an "item id", which will allow for legacy credentials to be deleted. - // Otherwise, do not delete said credentials for multiple device support. - if !uuid.Equal(reqID, uuid.Nil) { - // check if we already have N active credentials on this item for the current day - activeCreds, err := s.Datastore.GetCountActiveOrderCreds(ctx, dbi, order.ID, now) - if err != nil { - return fmt.Errorf("failed to get count of active order credentials: %w", err) - } - if activeCreds > maxTLV2ActiveOrderCreds { - return errExceededMaxActiveOrderCreds - } - return s.Datastore.DeleteTimeLimitedV2OrderCredsByOrderTx(ctx, dbi, order.ID, reqID) - } - - itemIDs := make([]uuid.UUID, 0, len(order.Items)) - // Legacy, delete all items. - for i := range order.Items { - itemIDs = append(itemIDs, order.Items[i].ID) - } - - return s.Datastore.DeleteTimeLimitedV2OrderCredsByOrderTx(ctx, dbi, order.ID, itemIDs...) -} - // checkNumBlindedCreds checks the number of submitted blinded credentials. // // The number of submitted credentials must not exceed: diff --git a/services/skus/credentials_noint_test.go b/services/skus/credentials_noint_test.go deleted file mode 100644 index 20a2cbac7..000000000 --- a/services/skus/credentials_noint_test.go +++ /dev/null @@ -1,110 +0,0 @@ -package skus - -import ( - "context" - "testing" - "time" - - "github.com/golang/mock/gomock" - uuid "github.com/satori/go.uuid" - should "github.com/stretchr/testify/assert" - must "github.com/stretchr/testify/require" - - "github.com/brave-intl/bat-go/services/skus/model" -) - -func TestService_DeleteTLV2(t *testing.T) { - type tcGiven struct { - ord *model.Order - reqID uuid.UUID - } - - type tcExpected struct { - args []gomock.Matcher - err error - } - - type testCase struct { - name string - given tcGiven - exp tcExpected - } - - now := time.Now() - - tests := []testCase{ - { - name: "request_id_specified", - given: tcGiven{ - ord: &model.Order{ID: uuid.Must(uuid.FromString("a6b72f11-c886-49ee-b4f4-913eaa0984ae"))}, - reqID: uuid.Must(uuid.FromString("d10cf2ae-30d8-4ada-965c-11c582968f26")), - }, - exp: tcExpected{ - args: []gomock.Matcher{ - gomock.Eq(context.Background()), - gomock.Nil(), // dbi - gomock.Eq(uuid.Must(uuid.FromString("a6b72f11-c886-49ee-b4f4-913eaa0984ae"))), - gomock.Eq([]uuid.UUID{uuid.Must(uuid.FromString("d10cf2ae-30d8-4ada-965c-11c582968f26"))}), - gomock.Eq(now), - }, - }, - }, - - { - name: "request_id_nil", - given: tcGiven{ - ord: &model.Order{ - ID: uuid.Must(uuid.FromString("d7b4f524-ebe3-48c1-b60d-d6f548b25aae")), - Items: []model.OrderItem{ - {ID: uuid.Must(uuid.FromString("3882ec99-73fb-476b-b176-1f4b40a9b767"))}, - {ID: uuid.Must(uuid.FromString("ed437d36-182b-460f-8213-2ce3d4bb5c93"))}, - {ID: uuid.Must(uuid.FromString("d3e62075-996f-4bed-bbc7-f6cd324b83e0"))}, - }, - }, - reqID: uuid.Nil, - }, - exp: tcExpected{ - args: []gomock.Matcher{ - gomock.Eq(context.Background()), - gomock.Nil(), // dbi - gomock.Eq(uuid.Must(uuid.FromString("d7b4f524-ebe3-48c1-b60d-d6f548b25aae"))), - gomock.Eq([]uuid.UUID{ - uuid.Must(uuid.FromString("3882ec99-73fb-476b-b176-1f4b40a9b767")), - uuid.Must(uuid.FromString("ed437d36-182b-460f-8213-2ce3d4bb5c93")), - uuid.Must(uuid.FromString("d3e62075-996f-4bed-bbc7-f6cd324b83e0")), - }), - gomock.Eq(now), - }, - }, - }, - } - - for i := range tests { - tc := tests[i] - - t.Run(tc.name, func(t *testing.T) { - must.Equal(t, 5, len(tc.exp.args)) - - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - ds := NewMockDatastore(ctrl) - - svc := &Service{Datastore: ds} - - ctx := context.Background() - if tc.given.reqID != uuid.Nil { - ds.EXPECT().GetCountActiveOrderCreds( - tc.exp.args[0], tc.exp.args[1], tc.exp.args[2], tc.exp.args[4], - ).Return(0, nil) - } - - ds.EXPECT().DeleteTimeLimitedV2OrderCredsByOrderTx( - tc.exp.args[0], tc.exp.args[1], tc.exp.args[2], tc.exp.args[3], - ).Return(nil) - - actual := svc.deleteTLV2(ctx, nil, tc.given.ord, tc.given.reqID, now) - should.Equal(t, tc.exp.err, actual) - }) - } -} diff --git a/services/skus/datastore.go b/services/skus/datastore.go index c2b8c2a5c..67937c96b 100644 --- a/services/skus/datastore.go +++ b/services/skus/datastore.go @@ -83,9 +83,8 @@ type Datastore interface { AreTimeLimitedV2CredsSubmitted(ctx context.Context, blindedCreds ...string) (bool, error) GetTimeLimitedV2OrderCredsByOrder(orderID uuid.UUID) (*TimeLimitedV2Creds, error) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID, itemID, reqID uuid.UUID) (*TimeLimitedV2Creds, error) - DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, dbi sqlx.ExtContext, orderID uuid.UUID, itemIDs ...uuid.UUID) error + DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) error GetTimeLimitedV2OrderCredsByOrderItem(itemID uuid.UUID) (*TimeLimitedV2Creds, error) - GetCountActiveOrderCreds(ctx context.Context, dbi sqlx.ExtContext, orderID uuid.UUID, now time.Time) (int, error) InsertTimeLimitedV2OrderCredsTx(ctx context.Context, tx *sqlx.Tx, tlv2 TimeAwareSubIssuedCreds) error InsertSigningOrderRequestOutbox(ctx context.Context, requestID uuid.UUID, orderID uuid.UUID, itemID uuid.UUID, signingOrderRequest SigningOrderRequest) error GetSigningOrderRequestOutboxByRequestID(ctx context.Context, dbi sqlx.QueryerContext, reqID uuid.UUID) (*SigningOrderRequestOutbox, error) @@ -797,20 +796,11 @@ func (pg *Postgres) DeleteSingleUseOrderCredsByOrderTx(ctx context.Context, tx * // DeleteTimeLimitedV2OrderCredsByOrderTx performs a hard delete for all time limited v2 order // credentials for a given OrderID. -func (pg *Postgres) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, dbi sqlx.ExtContext, orderID uuid.UUID, itemIDs ...uuid.UUID) error { - // Legacy, if the request id matches the item id on the tlv2 creds, we actually want to delete the record. - // Otherwise we will keep these credentials here for multiple device refresh capabilities. - const q = "DELETE FROM time_limited_v2_order_creds WHERE order_id = ? AND item_id in (?)" - query, args, err := sqlx.In(q, orderID, itemIDs) +func (pg *Postgres) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) error { + _, err := tx.ExecContext(ctx, `delete from time_limited_v2_order_creds where order_id = $1`, orderID) if err != nil { - return fmt.Errorf("error creating delete query for order with item ids: %w", err) - } - - query = dbi.Rebind(query) - if _, err := dbi.ExecContext(ctx, query, args...); err != nil { return fmt.Errorf("error deleting time limited v2 order creds: %w", err) } - return nil } @@ -1036,19 +1026,6 @@ func (pg *Postgres) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, o return result, nil } -// GetCountActiveOrderCreds returns the count of order creds currently active on an order. -func (pg *Postgres) GetCountActiveOrderCreds(ctx context.Context, dbi sqlx.ExtContext, orderID uuid.UUID, now time.Time) (int, error) { - const q = `SELECT COUNT(1) FROM time_limited_v2_order_creds - WHERE order_id = $1 AND valid_from < $2 AND valid_to > $2 GROUP BY request_id` - - var activeCredCount int - if err := sqlx.GetContext(ctx, dbi, &activeCredCount, q, orderID, now); err != nil { - return 0, fmt.Errorf("error getting active credential count: %w", err) - } - - return activeCredCount, nil -} - // GetTimeLimitedV2OrderCredsByOrderItem returns all the order credentials for a single order item. func (pg *Postgres) GetTimeLimitedV2OrderCredsByOrderItem(itemID uuid.UUID) (*TimeLimitedV2Creds, error) { query := ` diff --git a/services/skus/datastore_test.go b/services/skus/datastore_test.go index cc39cfda6..6ff26089c 100644 --- a/services/skus/datastore_test.go +++ b/services/skus/datastore_test.go @@ -151,25 +151,6 @@ func (suite *PostgresTestSuite) TestGetOrderByExternalID() { } } -func (suite *PostgresTestSuite) TestCountActiveOrderCreds_Success() { - env := os.Getenv("ENV") - ctx := context.WithValue(context.Background(), appctx.EnvironmentCTXKey, env) - - ctx = context.WithValue(ctx, appctx.WhitelistSKUsCTXKey, []string{ - devBraveFirewallVPNPremiumTimeLimited, - devBraveSearchPremiumYearTimeLimited, - }) - - creds := suite.createTimeLimitedV2OrderCreds(suite.T(), ctx, devBraveFirewallVPNPremiumTimeLimited, devBraveSearchPremiumYearTimeLimited) - - actual, err := suite.storage.GetCountActiveOrderCreds(ctx, suite.storage.RawDB(), creds[0].OrderID, time.Now()) - suite.Require().NoError(err) - - const expected = 2 - - suite.Assert().Equal(expected, actual) -} - func (suite *PostgresTestSuite) TestGetTimeLimitedV2OrderCredsByOrder_Success() { env := os.Getenv("ENV") ctx := context.WithValue(context.Background(), appctx.EnvironmentCTXKey, env) diff --git a/services/skus/instrumented_datastore.go b/services/skus/instrumented_datastore.go index 08462e645..f79130141 100644 --- a/services/skus/instrumented_datastore.go +++ b/services/skus/instrumented_datastore.go @@ -1,9 +1,9 @@ +package skus + // Code generated by gowrap. DO NOT EDIT. // template: ../../.prom-gowrap.tmpl // gowrap: http://github.com/hexdigest/gowrap -package skus - //go:generate gowrap gen -p github.com/brave-intl/bat-go/services/skus -i Datastore -t ../../.prom-gowrap.tmpl -o instrumented_datastore.go -l "" import ( @@ -227,7 +227,7 @@ func (_d DatastoreWithPrometheus) DeleteSingleUseOrderCredsByOrderTx(ctx context } // DeleteTimeLimitedV2OrderCredsByOrderTx implements Datastore -func (_d DatastoreWithPrometheus) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, dbi sqlx.ExtContext, orderID uuid.UUID, itemIDs ...uuid.UUID) (err error) { +func (_d DatastoreWithPrometheus) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID uuid.UUID) (err error) { _since := time.Now() defer func() { result := "ok" @@ -237,7 +237,7 @@ func (_d DatastoreWithPrometheus) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx con datastoreDurationSummaryVec.WithLabelValues(_d.instanceName, "DeleteTimeLimitedV2OrderCredsByOrderTx", result).Observe(time.Since(_since).Seconds()) }() - return _d.base.DeleteTimeLimitedV2OrderCredsByOrderTx(ctx, dbi, orderID, itemIDs...) + return _d.base.DeleteTimeLimitedV2OrderCredsByOrderTx(ctx, tx, orderID) } // ExternalIDExists implements Datastore @@ -254,20 +254,6 @@ func (_d DatastoreWithPrometheus) ExternalIDExists(ctx context.Context, s1 strin return _d.base.ExternalIDExists(ctx, s1) } -// GetCountActiveOrderCreds implements Datastore -func (_d DatastoreWithPrometheus) GetCountActiveOrderCreds(ctx context.Context, dbi sqlx.ExtContext, orderID uuid.UUID, now time.Time) (i1 int, err error) { - _since := time.Now() - defer func() { - result := "ok" - if err != nil { - result = "error" - } - - datastoreDurationSummaryVec.WithLabelValues(_d.instanceName, "GetCountActiveOrderCreds", result).Observe(time.Since(_since).Seconds()) - }() - return _d.base.GetCountActiveOrderCreds(ctx, dbi, orderID, now) -} - // GetIssuerByPublicKey implements Datastore func (_d DatastoreWithPrometheus) GetIssuerByPublicKey(publicKey string) (ip1 *Issuer, err error) { _since := time.Now() @@ -464,8 +450,8 @@ func (_d DatastoreWithPrometheus) GetSumForTransactions(orderID uuid.UUID) (d1 d return _d.base.GetSumForTransactions(orderID) } -// GetTLV2Creds implements Datastore -func (_d DatastoreWithPrometheus) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID uuid.UUID, itemID uuid.UUID, reqID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error) { +// GetTimeLimitedV2OrderCredsByOrder implements Datastore +func (_d DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrder(orderID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error) { _since := time.Now() defer func() { result := "ok" @@ -473,13 +459,13 @@ func (_d DatastoreWithPrometheus) GetTLV2Creds(ctx context.Context, dbi sqlx.Que result = "error" } - datastoreDurationSummaryVec.WithLabelValues(_d.instanceName, "GetTLV2Creds", result).Observe(time.Since(_since).Seconds()) + datastoreDurationSummaryVec.WithLabelValues(_d.instanceName, "GetTimeLimitedV2OrderCredsByOrder", result).Observe(time.Since(_since).Seconds()) }() - return _d.base.GetTLV2Creds(ctx, dbi, ordID, itemID, reqID) + return _d.base.GetTimeLimitedV2OrderCredsByOrder(orderID) } -// GetTimeLimitedV2OrderCredsByOrder implements Datastore -func (_d DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrder(orderID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error) { +// GetTimeLimitedV2OrderCredsByOrderItem implements Datastore +func (_d DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrderItem(itemID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error) { _since := time.Now() defer func() { result := "ok" @@ -487,13 +473,13 @@ func (_d DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrder(orderID uuid result = "error" } - datastoreDurationSummaryVec.WithLabelValues(_d.instanceName, "GetTimeLimitedV2OrderCredsByOrder", result).Observe(time.Since(_since).Seconds()) + datastoreDurationSummaryVec.WithLabelValues(_d.instanceName, "GetTimeLimitedV2OrderCredsByOrderItem", result).Observe(time.Since(_since).Seconds()) }() - return _d.base.GetTimeLimitedV2OrderCredsByOrder(orderID) + return _d.base.GetTimeLimitedV2OrderCredsByOrderItem(itemID) } -// GetTimeLimitedV2OrderCredsByOrderItem implements Datastore -func (_d DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrderItem(itemID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error) { +// GetTLV2Creds implements Datastore +func (_d DatastoreWithPrometheus) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID, itemID, reqID uuid.UUID) (tp1 *TimeLimitedV2Creds, err error) { _since := time.Now() defer func() { result := "ok" @@ -501,9 +487,9 @@ func (_d DatastoreWithPrometheus) GetTimeLimitedV2OrderCredsByOrderItem(itemID u result = "error" } - datastoreDurationSummaryVec.WithLabelValues(_d.instanceName, "GetTimeLimitedV2OrderCredsByOrderItem", result).Observe(time.Since(_since).Seconds()) + datastoreDurationSummaryVec.WithLabelValues(_d.instanceName, "GetTLV2Creds", result).Observe(time.Since(_since).Seconds()) }() - return _d.base.GetTimeLimitedV2OrderCredsByOrderItem(itemID) + return _d.base.GetTLV2Creds(ctx, dbi, ordID, itemID, reqID) } // GetTransaction implements Datastore diff --git a/services/skus/mockdatastore.go b/services/skus/mockdatastore.go index 182b80c95..9375051c8 100644 --- a/services/skus/mockdatastore.go +++ b/services/skus/mockdatastore.go @@ -9,7 +9,6 @@ import ( reflect "reflect" time "time" - datastore "github.com/brave-intl/bat-go/libs/datastore" inputs "github.com/brave-intl/bat-go/libs/inputs" model "github.com/brave-intl/bat-go/services/skus/model" v4 "github.com/golang-migrate/migrate/v4" @@ -165,18 +164,18 @@ func (mr *MockDatastoreMockRecorder) CreateKey(merchant, name, encryptedSecretKe } // CreateOrder mocks base method. -func (m *MockDatastore) CreateOrder(ctx context.Context, dbi sqlx.ExtContext, oreq *model.OrderNew, items []model.OrderItem) (*model.Order, error) { +func (m *MockDatastore) CreateOrder(ctx context.Context, dbi sqlx.ExtContext, req *model.OrderNew, items []model.OrderItem) (*model.Order, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateOrder", ctx, dbi, oreq, items) + ret := m.ctrl.Call(m, "CreateOrder", ctx, dbi, req, items) ret0, _ := ret[0].(*model.Order) ret1, _ := ret[1].(error) return ret0, ret1 } // CreateOrder indicates an expected call of CreateOrder. -func (mr *MockDatastoreMockRecorder) CreateOrder(ctx, dbi, oreq, items interface{}) *gomock.Call { +func (mr *MockDatastoreMockRecorder) CreateOrder(ctx, dbi, req, items interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrder", reflect.TypeOf((*MockDatastore)(nil).CreateOrder), ctx, dbi, oreq, items) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrder", reflect.TypeOf((*MockDatastore)(nil).CreateOrder), ctx, dbi, req, items) } // CreateTransaction mocks base method. @@ -238,22 +237,17 @@ func (mr *MockDatastoreMockRecorder) DeleteSingleUseOrderCredsByOrderTx(ctx, tx, } // DeleteTimeLimitedV2OrderCredsByOrderTx mocks base method. -func (m *MockDatastore) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, dbi sqlx.ExtContext, orderID go_uuid.UUID, itemIDs ...go_uuid.UUID) error { +func (m *MockDatastore) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx context.Context, tx *sqlx.Tx, orderID go_uuid.UUID) error { m.ctrl.T.Helper() - varargs := []interface{}{ctx, dbi, orderID} - for _, a := range itemIDs { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "DeleteTimeLimitedV2OrderCredsByOrderTx", varargs...) + ret := m.ctrl.Call(m, "DeleteTimeLimitedV2OrderCredsByOrderTx", ctx, tx, orderID) ret0, _ := ret[0].(error) return ret0 } // DeleteTimeLimitedV2OrderCredsByOrderTx indicates an expected call of DeleteTimeLimitedV2OrderCredsByOrderTx. -func (mr *MockDatastoreMockRecorder) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx, dbi, orderID interface{}, itemIDs ...interface{}) *gomock.Call { +func (mr *MockDatastoreMockRecorder) DeleteTimeLimitedV2OrderCredsByOrderTx(ctx, tx, orderID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, dbi, orderID}, itemIDs...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTimeLimitedV2OrderCredsByOrderTx", reflect.TypeOf((*MockDatastore)(nil).DeleteTimeLimitedV2OrderCredsByOrderTx), varargs...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTimeLimitedV2OrderCredsByOrderTx", reflect.TypeOf((*MockDatastore)(nil).DeleteTimeLimitedV2OrderCredsByOrderTx), ctx, tx, orderID) } // ExternalIDExists mocks base method. @@ -271,21 +265,6 @@ func (mr *MockDatastoreMockRecorder) ExternalIDExists(arg0, arg1 interface{}) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExternalIDExists", reflect.TypeOf((*MockDatastore)(nil).ExternalIDExists), arg0, arg1) } -// GetCountActiveOrderCreds mocks base method. -func (m *MockDatastore) GetCountActiveOrderCreds(ctx context.Context, dbi sqlx.ExtContext, orderID go_uuid.UUID, now time.Time) (int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCountActiveOrderCreds", ctx, dbi, orderID, now) - ret0, _ := ret[0].(int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCountActiveOrderCreds indicates an expected call of GetCountActiveOrderCreds. -func (mr *MockDatastoreMockRecorder) GetCountActiveOrderCreds(ctx, dbi, orderID, now interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCountActiveOrderCreds", reflect.TypeOf((*MockDatastore)(nil).GetCountActiveOrderCreds), ctx, dbi, orderID, now) -} - // GetIssuerByPublicKey mocks base method. func (m *MockDatastore) GetIssuerByPublicKey(publicKey string) (*Issuer, error) { m.ctrl.T.Helper() @@ -497,21 +476,6 @@ func (mr *MockDatastoreMockRecorder) GetSumForTransactions(orderID interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSumForTransactions", reflect.TypeOf((*MockDatastore)(nil).GetSumForTransactions), orderID) } -// GetTLV2Creds mocks base method. -func (m *MockDatastore) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID, itemID, reqID go_uuid.UUID) (*TimeLimitedV2Creds, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTLV2Creds", ctx, dbi, ordID, itemID, reqID) - ret0, _ := ret[0].(*TimeLimitedV2Creds) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTLV2Creds indicates an expected call of GetTLV2Creds. -func (mr *MockDatastoreMockRecorder) GetTLV2Creds(ctx, dbi, ordID, itemID, reqID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTLV2Creds", reflect.TypeOf((*MockDatastore)(nil).GetTLV2Creds), ctx, dbi, ordID, itemID, reqID) -} - // GetTimeLimitedV2OrderCredsByOrder mocks base method. func (m *MockDatastore) GetTimeLimitedV2OrderCredsByOrder(orderID go_uuid.UUID) (*TimeLimitedV2Creds, error) { m.ctrl.T.Helper() @@ -542,6 +506,21 @@ func (mr *MockDatastoreMockRecorder) GetTimeLimitedV2OrderCredsByOrderItem(itemI return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTimeLimitedV2OrderCredsByOrderItem", reflect.TypeOf((*MockDatastore)(nil).GetTimeLimitedV2OrderCredsByOrderItem), itemID) } +// GetTLV2Creds mocks base method. +func (m *MockDatastore) GetTLV2Creds(ctx context.Context, dbi sqlx.QueryerContext, ordID, itemID, reqID go_uuid.UUID) (*TimeLimitedV2Creds, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTLV2Creds", ctx, dbi, ordID, itemID, reqID) + ret0, _ := ret[0].(*TimeLimitedV2Creds) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTLV2Creds indicates an expected call of GetTLV2Creds. +func (mr *MockDatastoreMockRecorder) GetTLV2Creds(ctx, dbi, ordID, itemID, reqID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTLV2Creds", reflect.TypeOf((*MockDatastore)(nil).GetTLV2Creds), ctx, dbi, ordID, itemID, reqID) +} + // GetTransaction mocks base method. func (m *MockDatastore) GetTransaction(externalTransactionID string) (*Transaction, error) { m.ctrl.T.Helper() @@ -860,422 +839,3 @@ func (mr *MockDatastoreMockRecorder) UpdateTransaction(orderID, externalTransact mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateTransaction", reflect.TypeOf((*MockDatastore)(nil).UpdateTransaction), orderID, externalTransactionID, status, currency, kind, amount) } - -// MockorderStore is a mock of orderStore interface. -type MockorderStore struct { - ctrl *gomock.Controller - recorder *MockorderStoreMockRecorder -} - -// MockorderStoreMockRecorder is the mock recorder for MockorderStore. -type MockorderStoreMockRecorder struct { - mock *MockorderStore -} - -// NewMockorderStore creates a new mock instance. -func NewMockorderStore(ctrl *gomock.Controller) *MockorderStore { - mock := &MockorderStore{ctrl: ctrl} - mock.recorder = &MockorderStoreMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockorderStore) EXPECT() *MockorderStoreMockRecorder { - return m.recorder -} - -// AppendMetadata mocks base method. -func (m *MockorderStore) AppendMetadata(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, key, val string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AppendMetadata", ctx, dbi, id, key, val) - ret0, _ := ret[0].(error) - return ret0 -} - -// AppendMetadata indicates an expected call of AppendMetadata. -func (mr *MockorderStoreMockRecorder) AppendMetadata(ctx, dbi, id, key, val interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendMetadata", reflect.TypeOf((*MockorderStore)(nil).AppendMetadata), ctx, dbi, id, key, val) -} - -// AppendMetadataInt mocks base method. -func (m *MockorderStore) AppendMetadataInt(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, key string, val int) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AppendMetadataInt", ctx, dbi, id, key, val) - ret0, _ := ret[0].(error) - return ret0 -} - -// AppendMetadataInt indicates an expected call of AppendMetadataInt. -func (mr *MockorderStoreMockRecorder) AppendMetadataInt(ctx, dbi, id, key, val interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendMetadataInt", reflect.TypeOf((*MockorderStore)(nil).AppendMetadataInt), ctx, dbi, id, key, val) -} - -// AppendMetadataInt64 mocks base method. -func (m *MockorderStore) AppendMetadataInt64(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, key string, val int64) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AppendMetadataInt64", ctx, dbi, id, key, val) - ret0, _ := ret[0].(error) - return ret0 -} - -// AppendMetadataInt64 indicates an expected call of AppendMetadataInt64. -func (mr *MockorderStoreMockRecorder) AppendMetadataInt64(ctx, dbi, id, key, val interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppendMetadataInt64", reflect.TypeOf((*MockorderStore)(nil).AppendMetadataInt64), ctx, dbi, id, key, val) -} - -// Create mocks base method. -func (m *MockorderStore) Create(ctx context.Context, dbi sqlx.QueryerContext, oreq *model.OrderNew) (*model.Order, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, dbi, oreq) - ret0, _ := ret[0].(*model.Order) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Create indicates an expected call of Create. -func (mr *MockorderStoreMockRecorder) Create(ctx, dbi, oreq interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockorderStore)(nil).Create), ctx, dbi, oreq) -} - -// Get mocks base method. -func (m *MockorderStore) Get(ctx context.Context, dbi sqlx.QueryerContext, id go_uuid.UUID) (*model.Order, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, dbi, id) - ret0, _ := ret[0].(*model.Order) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockorderStoreMockRecorder) Get(ctx, dbi, id interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockorderStore)(nil).Get), ctx, dbi, id) -} - -// GetByExternalID mocks base method. -func (m *MockorderStore) GetByExternalID(ctx context.Context, dbi sqlx.QueryerContext, extID string) (*model.Order, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetByExternalID", ctx, dbi, extID) - ret0, _ := ret[0].(*model.Order) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetByExternalID indicates an expected call of GetByExternalID. -func (mr *MockorderStoreMockRecorder) GetByExternalID(ctx, dbi, extID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByExternalID", reflect.TypeOf((*MockorderStore)(nil).GetByExternalID), ctx, dbi, extID) -} - -// GetExpiredStripeCheckoutSessionID mocks base method. -func (m *MockorderStore) GetExpiredStripeCheckoutSessionID(ctx context.Context, dbi sqlx.QueryerContext, orderID go_uuid.UUID) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetExpiredStripeCheckoutSessionID", ctx, dbi, orderID) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetExpiredStripeCheckoutSessionID indicates an expected call of GetExpiredStripeCheckoutSessionID. -func (mr *MockorderStoreMockRecorder) GetExpiredStripeCheckoutSessionID(ctx, dbi, orderID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExpiredStripeCheckoutSessionID", reflect.TypeOf((*MockorderStore)(nil).GetExpiredStripeCheckoutSessionID), ctx, dbi, orderID) -} - -// GetExpiresAtAfterISOPeriod mocks base method. -func (m *MockorderStore) GetExpiresAtAfterISOPeriod(ctx context.Context, dbi sqlx.QueryerContext, id go_uuid.UUID) (time.Time, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetExpiresAtAfterISOPeriod", ctx, dbi, id) - ret0, _ := ret[0].(time.Time) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetExpiresAtAfterISOPeriod indicates an expected call of GetExpiresAtAfterISOPeriod. -func (mr *MockorderStoreMockRecorder) GetExpiresAtAfterISOPeriod(ctx, dbi, id interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetExpiresAtAfterISOPeriod", reflect.TypeOf((*MockorderStore)(nil).GetExpiresAtAfterISOPeriod), ctx, dbi, id) -} - -// GetMetadata mocks base method. -func (m *MockorderStore) GetMetadata(ctx context.Context, dbi sqlx.QueryerContext, id go_uuid.UUID) (datastore.Metadata, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetMetadata", ctx, dbi, id) - ret0, _ := ret[0].(datastore.Metadata) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetMetadata indicates an expected call of GetMetadata. -func (mr *MockorderStoreMockRecorder) GetMetadata(ctx, dbi, id interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMetadata", reflect.TypeOf((*MockorderStore)(nil).GetMetadata), ctx, dbi, id) -} - -// HasExternalID mocks base method. -func (m *MockorderStore) HasExternalID(ctx context.Context, dbi sqlx.QueryerContext, extID string) (bool, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HasExternalID", ctx, dbi, extID) - ret0, _ := ret[0].(bool) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// HasExternalID indicates an expected call of HasExternalID. -func (mr *MockorderStoreMockRecorder) HasExternalID(ctx, dbi, extID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasExternalID", reflect.TypeOf((*MockorderStore)(nil).HasExternalID), ctx, dbi, extID) -} - -// SetExpiresAt mocks base method. -func (m *MockorderStore) SetExpiresAt(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, when time.Time) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetExpiresAt", ctx, dbi, id, when) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetExpiresAt indicates an expected call of SetExpiresAt. -func (mr *MockorderStoreMockRecorder) SetExpiresAt(ctx, dbi, id, when interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetExpiresAt", reflect.TypeOf((*MockorderStore)(nil).SetExpiresAt), ctx, dbi, id, when) -} - -// SetLastPaidAt mocks base method. -func (m *MockorderStore) SetLastPaidAt(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, when time.Time) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetLastPaidAt", ctx, dbi, id, when) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetLastPaidAt indicates an expected call of SetLastPaidAt. -func (mr *MockorderStoreMockRecorder) SetLastPaidAt(ctx, dbi, id, when interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLastPaidAt", reflect.TypeOf((*MockorderStore)(nil).SetLastPaidAt), ctx, dbi, id, when) -} - -// SetStatus mocks base method. -func (m *MockorderStore) SetStatus(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, status string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetStatus", ctx, dbi, id, status) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetStatus indicates an expected call of SetStatus. -func (mr *MockorderStoreMockRecorder) SetStatus(ctx, dbi, id, status interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetStatus", reflect.TypeOf((*MockorderStore)(nil).SetStatus), ctx, dbi, id, status) -} - -// SetTrialDays mocks base method. -func (m *MockorderStore) SetTrialDays(ctx context.Context, dbi sqlx.QueryerContext, id go_uuid.UUID, ndays int64) (*model.Order, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetTrialDays", ctx, dbi, id, ndays) - ret0, _ := ret[0].(*model.Order) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// SetTrialDays indicates an expected call of SetTrialDays. -func (mr *MockorderStoreMockRecorder) SetTrialDays(ctx, dbi, id, ndays interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrialDays", reflect.TypeOf((*MockorderStore)(nil).SetTrialDays), ctx, dbi, id, ndays) -} - -// UpdateMetadata mocks base method. -func (m *MockorderStore) UpdateMetadata(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, data datastore.Metadata) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateMetadata", ctx, dbi, id, data) - ret0, _ := ret[0].(error) - return ret0 -} - -// UpdateMetadata indicates an expected call of UpdateMetadata. -func (mr *MockorderStoreMockRecorder) UpdateMetadata(ctx, dbi, id, data interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateMetadata", reflect.TypeOf((*MockorderStore)(nil).UpdateMetadata), ctx, dbi, id, data) -} - -// MockorderItemStore is a mock of orderItemStore interface. -type MockorderItemStore struct { - ctrl *gomock.Controller - recorder *MockorderItemStoreMockRecorder -} - -// MockorderItemStoreMockRecorder is the mock recorder for MockorderItemStore. -type MockorderItemStoreMockRecorder struct { - mock *MockorderItemStore -} - -// NewMockorderItemStore creates a new mock instance. -func NewMockorderItemStore(ctrl *gomock.Controller) *MockorderItemStore { - mock := &MockorderItemStore{ctrl: ctrl} - mock.recorder = &MockorderItemStoreMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockorderItemStore) EXPECT() *MockorderItemStoreMockRecorder { - return m.recorder -} - -// FindByOrderID mocks base method. -func (m *MockorderItemStore) FindByOrderID(ctx context.Context, dbi sqlx.QueryerContext, orderID go_uuid.UUID) ([]model.OrderItem, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FindByOrderID", ctx, dbi, orderID) - ret0, _ := ret[0].([]model.OrderItem) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// FindByOrderID indicates an expected call of FindByOrderID. -func (mr *MockorderItemStoreMockRecorder) FindByOrderID(ctx, dbi, orderID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByOrderID", reflect.TypeOf((*MockorderItemStore)(nil).FindByOrderID), ctx, dbi, orderID) -} - -// Get mocks base method. -func (m *MockorderItemStore) Get(ctx context.Context, dbi sqlx.QueryerContext, id go_uuid.UUID) (*model.OrderItem, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, dbi, id) - ret0, _ := ret[0].(*model.OrderItem) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockorderItemStoreMockRecorder) Get(ctx, dbi, id interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockorderItemStore)(nil).Get), ctx, dbi, id) -} - -// InsertMany mocks base method. -func (m *MockorderItemStore) InsertMany(ctx context.Context, dbi sqlx.ExtContext, items ...model.OrderItem) ([]model.OrderItem, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx, dbi} - for _, a := range items { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "InsertMany", varargs...) - ret0, _ := ret[0].([]model.OrderItem) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// InsertMany indicates an expected call of InsertMany. -func (mr *MockorderItemStoreMockRecorder) InsertMany(ctx, dbi interface{}, items ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, dbi}, items...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InsertMany", reflect.TypeOf((*MockorderItemStore)(nil).InsertMany), varargs...) -} - -// MockorderPayHistoryStore is a mock of orderPayHistoryStore interface. -type MockorderPayHistoryStore struct { - ctrl *gomock.Controller - recorder *MockorderPayHistoryStoreMockRecorder -} - -// MockorderPayHistoryStoreMockRecorder is the mock recorder for MockorderPayHistoryStore. -type MockorderPayHistoryStoreMockRecorder struct { - mock *MockorderPayHistoryStore -} - -// NewMockorderPayHistoryStore creates a new mock instance. -func NewMockorderPayHistoryStore(ctrl *gomock.Controller) *MockorderPayHistoryStore { - mock := &MockorderPayHistoryStore{ctrl: ctrl} - mock.recorder = &MockorderPayHistoryStoreMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockorderPayHistoryStore) EXPECT() *MockorderPayHistoryStoreMockRecorder { - return m.recorder -} - -// Insert mocks base method. -func (m *MockorderPayHistoryStore) Insert(ctx context.Context, dbi sqlx.ExecerContext, id go_uuid.UUID, when time.Time) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Insert", ctx, dbi, id, when) - ret0, _ := ret[0].(error) - return ret0 -} - -// Insert indicates an expected call of Insert. -func (mr *MockorderPayHistoryStoreMockRecorder) Insert(ctx, dbi, id, when interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Insert", reflect.TypeOf((*MockorderPayHistoryStore)(nil).Insert), ctx, dbi, id, when) -} - -// MockissuerStore is a mock of issuerStore interface. -type MockissuerStore struct { - ctrl *gomock.Controller - recorder *MockissuerStoreMockRecorder -} - -// MockissuerStoreMockRecorder is the mock recorder for MockissuerStore. -type MockissuerStoreMockRecorder struct { - mock *MockissuerStore -} - -// NewMockissuerStore creates a new mock instance. -func NewMockissuerStore(ctrl *gomock.Controller) *MockissuerStore { - mock := &MockissuerStore{ctrl: ctrl} - mock.recorder = &MockissuerStoreMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockissuerStore) EXPECT() *MockissuerStoreMockRecorder { - return m.recorder -} - -// Create mocks base method. -func (m *MockissuerStore) Create(ctx context.Context, dbi sqlx.QueryerContext, req model.IssuerNew) (*model.Issuer, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Create", ctx, dbi, req) - ret0, _ := ret[0].(*model.Issuer) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Create indicates an expected call of Create. -func (mr *MockissuerStoreMockRecorder) Create(ctx, dbi, req interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockissuerStore)(nil).Create), ctx, dbi, req) -} - -// GetByMerchID mocks base method. -func (m *MockissuerStore) GetByMerchID(ctx context.Context, dbi sqlx.QueryerContext, merchID string) (*model.Issuer, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetByMerchID", ctx, dbi, merchID) - ret0, _ := ret[0].(*model.Issuer) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetByMerchID indicates an expected call of GetByMerchID. -func (mr *MockissuerStoreMockRecorder) GetByMerchID(ctx, dbi, merchID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByMerchID", reflect.TypeOf((*MockissuerStore)(nil).GetByMerchID), ctx, dbi, merchID) -} - -// GetByPubKey mocks base method. -func (m *MockissuerStore) GetByPubKey(ctx context.Context, dbi sqlx.QueryerContext, pubKey string) (*model.Issuer, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetByPubKey", ctx, dbi, pubKey) - ret0, _ := ret[0].(*model.Issuer) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetByPubKey indicates an expected call of GetByPubKey. -func (mr *MockissuerStoreMockRecorder) GetByPubKey(ctx, dbi, pubKey interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByPubKey", reflect.TypeOf((*MockissuerStore)(nil).GetByPubKey), ctx, dbi, pubKey) -} diff --git a/services/skus/order.go b/services/skus/order.go index d64731b2e..2b60ede03 100644 --- a/services/skus/order.go +++ b/services/skus/order.go @@ -198,5 +198,5 @@ func (s *Service) RenewOrder(ctx context.Context, orderID uuid.UUID) error { return fmt.Errorf("failed to set order status to paid: %w", err) } - return s.DeleteOrderCreds(ctx, orderID, uuid.Nil, true) + return s.DeleteOrderCreds(ctx, orderID, true) }