Security Architecture

A function that enforces refund limits calls an external payment API. The pipeline must verify the limit logic on every commit, in seconds, without reaching the live API. What is the BEST approach?

Show the answer

Correct answerA. Unit tests with the payment client replaced by a stub

AWhy this is right: A stub stands in for the API, isolating the function so the test is fast and independent of external services.

BWhy not this: A full regression replay is broad and slow, and does not isolate the refund-limit function.

CWhy not this: Calling a sandbox tests the real interaction and depends on the network, so it is neither isolated nor fast.

DWhy not this: A canary exposes production users to the change and happens after build and test stages.

A unit test isolates the function and replaces its external dependency with a test double, so it runs fast and needs no network. Sandbox integration tests depend on the external service and are slower, so they do not meet the speed and isolation constraints.