brave-intl / bat-go

Pass "go", collect 200 BAT
Mozilla Public License 2.0
41 stars 31 forks source link

feat: delete tlv2 creds with req_id matching item_id #2524

Closed pavelbrm closed 1 month ago

pavelbrm commented 2 months ago

Summary

This PR builds on #2522, and updates the delete credentials endpoint to only delete TLV2 credentials that have a request id that matches the item id.

Type of Change

Tested Environments

Before Requesting Review

Manual Test Plan

github-actions[bot] commented 1 month ago

[puLL-Merge] - brave-intl/bat-go@2524

Description

This PR makes various changes to the SKUs service, including:

Changes ### Changes `services/grant/cmd/grant.go` - Updates call to `skus.InitService` to pass the new `skuOrderItemRepo` dependency `services/skus/controllers.go` - `CreateOrderCreds` and `createItemCreds` now return specific `404 Not Found` error if order is not found, `409 Conflict` if creds already exist, or `400 Bad Request` for other errors - `DeleteOrderCreds` renamed to unexported `deleteOrderCreds` - `deleteOrderCreds` updated to return specific errors - `499 Client Closed Request`, `404 Not Found` if order not found, `400 Bad Request` if order has no items or other errors - Minor formatting changes `services/skus/controllers_test.go` - Updates test setup to initialize the new `orderItemRepo` dependency - Minor test updates `services/skus/credentials.go` - `CreateOrderItemCredentials` now uses new `getOrderFull` helper to retrieve order with items - `DeleteOrderCreds` updated to use a transaction, new `getOrderFullTx` helper, and new `tlv2Repo.DeleteLegacy` method `services/skus/datastore.go` - `GetOrder` marked as deprecated in favor of `orderRepo.Get` or new `getOrderFull` helper - `DeleteTimeLimitedV2OrderCredsByOrderTx` marked as deprecated in favor of `tlv2Repo.DeleteLegacy` `services/skus/service.go` - Adds `orderItemRepo` field to `Service` struct - `InitService` updated to take `orderItemRepo` dependency - Adds `getOrderFull` and `getOrderFullTx` helper methods `services/skus/storage/repository/tlv2.go` - Adds new `DeleteLegacy` method for deleting legacy tlv2 order creds `services/skus/storage/repository/tlv2_test.go` - Adds test for new `DeleteLegacy` method

Security Hotspots