Class HttpContractRecorder
java.lang.Object
com.shaft.tools.io.internal.HttpContractRecorder
Thread-local HTTP contract recorder, validator, and browser replay rule factory.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final recordstatic final record -
Method Summary
Modifier and TypeMethodDescriptionstatic List<BrowserNetworkInterceptionRule> browserReplayRules(String contractFilePath) Builds browser replay rules from a recorded contract.static voidclear()Clears current-thread recording and validation state without writing files.static voidhandleApiExchange(io.restassured.specification.FilterableRequestSpecification requestSpec, io.restassured.response.Response response) Records or validates a SHAFT API HTTP exchange when a contract mode is active.static voidhandleBrowserExchange(org.openqa.selenium.remote.http.HttpRequest request, org.openqa.selenium.remote.http.HttpResponse response, String failureReason) Records or validates a browser HTTP exchange when a contract mode is active.static booleanReturns whether browser interception must actively fetch responses for contract work.static booleanisSensitiveKey(String key) Reports whether a request/response/header/query/JSON-body key is configured as sensitive (seeshaft.contract.sensitiveKeys).static booleanisVolatileKey(String key) Reports whether a request/response/header/query/JSON-body key is configured as volatile (seeshaft.contract.volatileKeys).static booleanisVolatileValue(String rawValue) Reports whether a raw string value looks volatile (a UUID or an ISO-8601 instant), regardless of its key name.static voidstartAssertMode(String contractFilePath, String... urlContains) Starts hard-assert contract validation for current-thread browser and SHAFT API traffic.static voidstartRecording(String contractFilePath, String... urlContains) Starts recording current-thread browser and SHAFT API HTTP traffic.static voidstartVerifyMode(String contractFilePath, String... urlContains) Starts soft-verify contract validation for current-thread browser and SHAFT API traffic.static voidWrites the current recording session and clears it.static voidClears current-thread validation mode.
-
Method Details
-
startRecording
-
stopRecording
public static void stopRecording()Writes the current recording session and clears it. -
startAssertMode
-
startVerifyMode
-
stopValidation
public static void stopValidation()Clears current-thread validation mode. -
clear
public static void clear()Clears current-thread recording and validation state without writing files. -
isBrowserContractModeActive
public static boolean isBrowserContractModeActive()Returns whether browser interception must actively fetch responses for contract work.- Returns:
- true when recording or validation is active
-
handleBrowserExchange
public static void handleBrowserExchange(org.openqa.selenium.remote.http.HttpRequest request, org.openqa.selenium.remote.http.HttpResponse response, String failureReason) Records or validates a browser HTTP exchange when a contract mode is active.- Parameters:
request- browser requestresponse- browser responsefailureReason- optional failure reason
-
handleApiExchange
public static void handleApiExchange(io.restassured.specification.FilterableRequestSpecification requestSpec, io.restassured.response.Response response) Records or validates a SHAFT API HTTP exchange when a contract mode is active.- Parameters:
requestSpec- REST Assured request specresponse- REST Assured response
-
browserReplayRules
Builds browser replay rules from a recorded contract.- Parameters:
contractFilePath- source JSON contract path- Returns:
- replay rules that return recorded responses
-
isSensitiveKey
Reports whether a request/response/header/query/JSON-body key is configured as sensitive (seeshaft.contract.sensitiveKeys). Exposed for reuse by other contract-aware consumers (e.g.com.shaft.capture.generate.api.ResponseNormalizer) that need the exact same sensitive-key detection this class uses for contract redaction.- Parameters:
key- request/response/header/query/JSON-body key- Returns:
truewhen the key matches a configured sensitive fragment
-
isVolatileKey
Reports whether a request/response/header/query/JSON-body key is configured as volatile (seeshaft.contract.volatileKeys). Exposed for reuse by other contract-aware consumers that need the exact same volatile-key detection this class uses for contract normalization.- Parameters:
key- request/response/header/query/JSON-body key- Returns:
truewhen the key matches a configured volatile name
-
isVolatileValue
Reports whether a raw string value looks volatile (a UUID or an ISO-8601 instant), regardless of its key name. Exposed for reuse by other contract-aware consumers.- Parameters:
rawValue- candidate value- Returns:
truewhen the value matches a UUID or a parseableInstant
-