Software Testing Engineering / API & CONTRACT TESTING / TST-022

Provider Fault Matrix

Explore concept graph

Materi

Masalah: bank mungkin menerapkan debit sebelum koneksi timeout. Menganggap gagal lalu mengirim ulang bisa membuat debit duplikat.

Langkah pertama: bedakan definitive accepted, known rejection, temporary HTTP condition dan UNKNOWN outcome.

Peta konsep statis. Ikuti alur teks dari atas ke bawah.
POST /bank/debits
      |
  status and payload
      +-- 200 valid ACCEPTED -> SUCCESS (not settled)
      +-- 400 known rejection -> REJECTED
      +-- 429 / 503 ----------> RETRYABLE
      +-- timeout / reset ----> UNKNOWN
      +-- invalid JSON -------> UNKNOWN
                                  |
                            reconcile status
                                  |
                             no blind retry

HTTP fault matrix

Fault Mapping Safe action
200 accepted with valid JSON SUCCESS Store provider reference
400 INVALID_ACCOUNT REJECTED Do not retry
429 rate limit / 503 unavailable RETRYABLE Check status before retry
Delayed response beyond timeout UNKNOWN Query provider status
Socket reset after receiving request UNKNOWN Query provider status
Malformed JSON or unexpected amount type UNKNOWN Query provider status
Unknown rejection body or PENDING UNKNOWN Query provider status

Penting: label RETRYABLE hanya untuk keadaan HTTP sementara. Header Retry-After adalah informasi pacing dan tidak membuktikan debit belum terjadi. Client fixture tidak pernah menjalankan request debit kedua.

Konsep 1 / 3

Differentiate accepted and explicitly rejected debits from malformed provider success and rejection bodies.

An HTTP status alone cannot establish the provider's business result.

Mulai dari sini

List required accepted response fields.

Intuisi utama

Validated status plus stable business JSON gives a definite response; inconsistent JSON leaves UNKNOWN.

This lab defines 200 with result ACCEPTED, matching amount/currency and providerReference as SUCCESS meaning accepted by the educational stub, not settled funds. Only 400 with the known INVALID_ACCOUNT rejection is REJECTED. Malformed 200, 400 with unknown body and 200 PENDING map UNKNOWN.

Contoh bertahap

A local bank returns 200 but serializes amount as JSON number.

  1. Compare the 200 body with expected decimal-string amount and provider reference.

    Mengapa: Status 200 does not validate representation.

    Hasil yang diharapkan: A correct ACCEPTED response maps SUCCESS.

  2. Mutate amount to number, then inspect the classification.

    Mengapa: The caller must fail closed on invalid provider data.

    Hasil yang diharapkan: An invalid 200 maps UNKNOWN.

Konsep 2 / 3

Treat 429 and 503 as temporary provider conditions without automatically resending debit.

Blind payment retry can create duplicate debit effects when prior outcome is unknown.

Mulai dari sini

Write action CHECK_STATUS_BEFORE_RETRY for 429 and 503.

Intuisi utama

RETRYABLE describes recoverable HTTP conditions, not permission to replay a non-idempotent mutation.

429 Too Many Requests and 503 Service Unavailable may include Retry-After. The lab reads bounded numeric delay values for 429/503 and maps them RETRYABLE with action CHECK_STATUS_BEFORE_RETRY, without issuing another POST. An invalid delay is omitted instead of invented.

Contoh bertahap

A bank returns HTTP 429 Retry-After: 3 to a debit submission.

  1. Send exactly one request to the 429 stub and inspect the header.

    Mengapa: Observe real HTTP status and pacing metadata.

    Hasil yang diharapkan: RETRYABLE with retryAfterSeconds=3.

  2. Inspect the request counter and next action.

    Mengapa: Temporary status is not deduplication proof.

    Hasil yang diharapkan: Action checks status and no repeated debit is emitted.

Konsep 3 / 3

Classify timeout, socket reset and malformed JSON as UNKNOWN while guarding against duplicate debit.

A provider may apply a debit before its reply is lost, leaving the client without final evidence.

Mulai dari sini

Write the rule that post-dispatch transport failure implies UNKNOWN.

Intuisi utama

The provider's actual internal state can differ from the client's last observed HTTP result.

In the Node lab the server records an applied flag before delaying the HTTP reply beyond the timeout or resetting its socket. The client sees UNKNOWN and uses QUERY_PROVIDER_STATUS. Malformed JSON and invalid/missing business results are also UNKNOWN. The entire fixture sends each debit once, with no real bank, WireMock process, or ledger.

Contoh bertahap

The provider records a debit, destroys the socket, and the caller receives a transport failure.

  1. Record stub-side applied before closing the connection.

    Mengapa: This models the danger of post-dispatch failure.

    Hasil yang diharapkan: The stub records an applied debit even though the client receives no success body.

  2. Assert UNKNOWN and a single outbound request.

    Mengapa: No definite outcome can justify an automatic duplicate debit.

    Hasil yang diharapkan: One request, UNKNOWN response, zero blind retry.

Sumber primer

Sumber

Cross-domain connections

Curated relationships for this unit at G1. Proposed edges are suggestions, not prerequisites.

Concept connectionsG1 · 4 visible concepts · 4 curated links
100%

Dashed = proposed relationship; solid = reviewed connection. Only reviewed prerequisites constrain a learning path. Keyboard and text links remain available.