Skip to content

ATS-COM-ORD-013Provide purchased rights and account for their use: Capability Test Specification

Markdown

ATS-COM-ORD-013

Provide purchased rights and account for their use: Capability Test Specification

Markdown
  • DocumentProposed

KindAcceptance test setProduct areaCommerceModuleCustomer purchases, purchased benefits and vendor stockRevision2

Read atservices-commerce c8b66a98macroservice-libraries 54536a44react-console baf6dae3

Coverage

  • Rule covered
  • Transition gap: FND-COM-ORD-070
  • Validation gap: FND-COM-ORD-070
  • Permission gap: FND-COM-ORD-070
  • Edge covered
  • Failure covered
  • Boundary gap: FND-COM-ORD-070
  • Concurrency covered
  • Invariant gap: FND-COM-ORD-070
  • Interaction covered

Test Scenarios

15 scenarios proving CAP-COM-ORD-013; 13 bound to an existing test.

01 Grant delivery reads the frozen purchasetransitionapitest
Proves
BR-CAP-COM-ORD-013-01
Preconditions
An e-book purchase contains an entitlement specification.
Steps
[ { "do": "Place, pay and deliver its grant obligation.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#placed the e-book with a plan of the register’s own kind and the download specification frozen on the line" } ]
Expected
The purchase retains the specification and the completed obligation identifies its grant record.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#placed the e-book with a plan of the register’s own kind and the download specification frozen on the line
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation to the register: completed, with the grant as its record
Source
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#placed the e-book with a plan of the register’s own kind and the download specification frozen on the line
02 Copies do not multiply a specified grant limitruleapitest
Proves
BR-CAP-COM-ORD-013-02
Preconditions
Three copies each carry the purchase-level two-download declaration.
Steps
[ { "do": "Place and fulfil the purchase, then consume its right.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE download right of two uses for the three copies, not six" } ]
Expected
One two-use grant exists, without a six-use multiplication.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE download right of two uses for the three copies, not six
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and refuses the third 409 insufficient_entitlement
Source
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE download right of two uses for the three copies, not six
03 Holder resolution honors recipient or buyer selectionedgeunittest
Proves
BR-CAP-COM-ORD-013-03
Preconditions
Inputs name a recipient, omit one or explicitly choose the buyer.
Steps
[ { "do": "Resolve the holder for each specification.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/unit/register/grant-specification.spec.js#gives the grant to the line’s recipient, to the buyer when the line names none, and to the buyer when the spec says so" } ]
Expected
The results select the recipient, buyer fallback or explicit buyer respectively.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/unit/register/grant-specification.spec.js#gives the grant to the line’s recipient, to the buyer when the line names none, and to the buyer when the spec says so
Source
services-commerce:modules/entitlements/tests/unit/register/grant-specification.spec.js#gives the grant to the line’s recipient, to the buyer when the line names none, and to the buyer when the spec says so
04 A missing grant specification fails permanentlyfailureapinegativetest
Proves
BR-CAP-COM-ORD-013-04
Preconditions
A grant obligation references purchase details without a readable specification.
Steps
[ { "do": "Process the obligation.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/integration/services/register/grant-handler.integration.spec.js#fails the obligation of a purchase that names no specification, not retryable, with obligation_failed raised" } ]
Expected
The obligation fails non-retryably, creates no right and raises obligation_failed.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/integration/services/register/grant-handler.integration.spec.js#fails the obligation of a purchase that names no specification, not retryable, with obligation_failed raised
Source
services-commerce:modules/entitlements/tests/integration/services/register/grant-handler.integration.spec.js#fails the obligation of a purchase that names no specification, not retryable, with obligation_failed raised
05 Consumption replay does not spend an extra useinvariantapitest
Proves
BR-CAP-COM-ORD-013-05
Preconditions
A download right has two available uses.
Steps
[ { "do": "Download, replay the first request, make the second request and attempt a third.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and consumes one use per Idempotency-Key (the retry free), then refuses the third 409 insufficient_entitlement" } ]
Expected
Only two uses are consumed and the final independent request receives insufficient_entitlement.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and consumes one use per Idempotency-Key (the retry free), then refuses the third 409 insufficient_entitlement
Source
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and consumes one use per Idempotency-Key (the retry free), then refuses the third 409 insufficient_entitlement
06 Restoration returns one consumed use with audit evidencetransitionapitest
Proves
BR-CAP-COM-ORD-013-06
Preconditions
Both uses on a grant are consumed.
Steps
[ { "do": "Restore the first use, replay that request, try another key and consume again.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an intervention: the log row, the history, the audit event), replays under the same key, refuses the same use under another" } ]
Expected
The restoration has intervention, history and audit records; replay is free and a duplicate restoration is refused.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an intervention: the log row, the history, the audit event), replays under the same key, refuses the same use under another
Source
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an intervention: the log row, the history, the audit event), replays under the same key, refuses the same use under another
07 Manual interventions retain source and reasonpermissionapitest
Proves
BR-CAP-COM-ORD-013-07
Preconditions
Staff can grant rights to a contact without a sale and can revoke a purchased right.
Steps
[ { "do": "Grant, revoke, retry revocation and submit an invalid window.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#writes a manual grant with no order, line or obligation, the window stated, the reason in its notes" } ]
Expected
The manual source and reason remain, used quantities survive revocation, repetition is refused and the invalid window returns 400.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#writes a manual grant with no order, line or obligation, the window stated, the reason in its notes
services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#revokes it whatever its source, with the intervention and the revocation on the order’s history
services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#refuses a window that ends before it starts, writing neither the grant nor the intervention
Source
services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#writes a manual grant with no order, line or obligation, the window stated, the reason in its notes
08 Cancellation revocation prevents further downloadinteractionapinegativetest
Proves
BR-CAP-COM-ORD-013-08
Preconditions
A purchased e-book right remains linked to its line.
Steps
[ { "do": "Invoke cancellation revocation and attempt download.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant with the reason, refuses the download 409 entitlement_not_active, and writes the history" } ]
Expected
The grant is revoked with its reason, use history stays and the download returns entitlement_not_active.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant with the reason, refuses the download 409 entitlement_not_active, and writes the history
Source
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant with the reason, refuses the download 409 entitlement_not_active, and writes the history
09 Expiry processing affects only elapsed windowstransitionapitest
Proves
BR-CAP-COM-ORD-013-09
Preconditions
Grants include expired, live, unbounded and revoked fixtures.
Steps
[ { "do": "Run expiry processing and repeat it.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires the lapsed grants of both tenants, oldest expiry first, and counts what it did" } ]
Expected
Only active elapsed-window grants change, with no repeated expiry write.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires the lapsed grants of both tenants, oldest expiry first, and counts what it did
services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#leaves a grant inside its window, one with no window and a revoked one alone
Source
services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires the lapsed grants of both tenants, oldest expiry first, and counts what it did
10 Rights access separates holders from staff readerspermissionapinegativetest
Proves
BR-CAP-COM-ORD-013-10
Preconditions
The fixtures provide a holder, another member and a console reader.
Steps
[ { "do": "Read by holder and order and attempt restoration.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a stranger nothing of the member’s, and refuses the member’s grant by id 403" } ]
Expected
The authorized reads succeed, another member cannot reach the right and restoration requires staff authority.
Data
Use the controlled records and transports established by the cited tests.
Bound to
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a stranger nothing of the member’s, and refuses the member’s grant by id 403
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#lets a console reader read the member’s grants by holder and by order, and refuses them the restore
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#refuses a portal member the restore, and a restore with no Idempotency-Key 400
Source
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a stranger nothing of the member’s, and refuses the member’s grant by id 403
11 Revocation immediately removes eligibility and consumption accessinteractionapitest
Proves
BR-CAP-COM-ORD-013-12
Preconditions
A manually granted right is visible to eligibility and has unused allowance.
Steps
[ { "do": "Revoke the right and read eligibility and consumption before an expiry pass.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#takes it out of the Eligibility view and the consume function at once" } ]
Expected
The right is absent from eligibility and cannot be consumed.
Data
Use an isolated workspace with the records and responses named in the preconditions.
Bound to
Source
services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#takes it out of the Eligibility view and the consume function at once
12 Competing consumers cannot overspend the remaining allowanceconcurrencyapitest
Proves
BR-CAP-COM-ORD-013-05 INV-DOM-COM-ORD-004-02
Preconditions
A finite grant has two uses left and two database connections each request both.
Steps
[ { "do": "Hold the first draw while the second waits, then commit the first.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and consumes one use per Idempotency-Key (the retry free), then refuses the third 409 insufficient_entitlement" } ]
Expected
The first owns the two uses and the second is refused with no extra use rows.
Data
Use an isolated workspace with the records and responses named in the preconditions.
Bound to
services-commerce:modules/entitlements/tests/integration/services/persistence/entitlements.integration.spec.js#refuses the second once the first committed, and the ledger holds exactly the first’s uses
Source
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and consumes one use per Idempotency-Key (the retry free), then refuses the third 409 insufficient_entitlement
13 Enforcement restoration distinguishes an elapsed granttransitionapitest
Proves
BR-CAP-COM-ORD-013-09 INV-DOM-COM-ORD-004-04
Preconditions
Line grants carry enforcement and unrelated revocation reasons, including an elapsed window.
Steps
[ { "do": "Reinstate only the enforcement-revoked grants.", "provenance": "test", "source": "services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires the lapsed grants of both tenants, oldest expiry first, and counts what it did" } ]
Expected
The eligible enforcement grant becomes active, its elapsed counterpart becomes expired and the unrelated revocation remains.
Data
Use an isolated workspace with the records and responses named in the preconditions.
Bound to
services-commerce:modules/entitlements/tests/integration/services/persistence/entitlements.integration.spec.js#reinstates only what the named reason revoked, and expires a reinstated grant whose window has passed
Source
services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires the lapsed grants of both tenants, oldest expiry first, and counts what it did
14 Cancellation revokes the purchased right without removing use historyinteractionapinegativeproposed
Proves
BR-CAP-COM-ORD-013-08 BR-CAP-COM-ORD-014-04
Preconditions
A completed purchased grant has one recorded use.
Steps
[ { "do": "Cancel its line and retry the buyer’s download.", "provenance": "proposed", "source": [ "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant with the reason, refuses the download 409 entitlement_not_active, and writes the history", "services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the participant’s cancel, which settles the document completed and runs the refund after the domain (ADR-13)" ] } ]
Expected
The grant is revoked, the original use remains and the download is refused.
Data
Use an isolated workspace with the records and responses named in the preconditions.
Source
services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant with the reason, refuses the download 409 entitlement_not_active, and writes the history,services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the participant’s cancel, which settles the document completed and runs the refund after the domain (ADR-13)
15 A purchased grant can be used before a cancellation revokes itinteractionapiproposed
Proves
BR-CAP-COM-ORD-013-01 BR-CAP-COM-ORD-012-01 BR-CAP-COM-ORD-014-01
Preconditions
An application freezes a finite grant on a purchased line.
Steps
[ { "do": "Deliver the grant, consume once, restore that use and cancel the line.", "provenance": "proposed", "source": [ "services-commerce:modules/entitlements/services/register/grant-handler.ts", "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation to the register: completed, with the grant as its record", "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and refuses the third 409 insufficient_entitlement", "services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an intervention: the log row, the history, the audit event), replays under the same key, refuses the same use under another", "services-commerce:modules/fulfillment/services/register/intervention-audit.ts", "services-commerce:modules/entitlements/services/register/revocation.ts", "services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts" ] } ]
Expected
History retains the use and restoration while later consumption is refused after cancellation.
Data
Use an isolated workspace with the records and responses named in the preconditions.
Source
services-commerce:modules/entitlements/services/register/grant-handler.ts,services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation to the register: completed, with the grant as its record,services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and refuses the third 409 insufficient_entitlement,services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an intervention: the log row, the history, the audit event), replays under the same key, refuses the same use under another,services-commerce:modules/fulfillment/services/register/intervention-audit.ts,services-commerce:modules/entitlements/services/register/revocation.ts,services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts

The Markdown files under specs/ in rhythmsoftware/rhythm-v2-docs are the canonical source of truth. This reader is a generated, read-only projection of them.