Intercept
Stoobly Intercept CLI - Questions & Answers
The intercept CLI allows you to dynamically configure the stoobly-agent after it's already running with stoobly-agent run. This enables you to change modes, policies, and strategies without restarting the agent.
Getting Started with Intercept
Q: What is the intercept feature?
A: Intercept is a feature that allows the stoobly-agent proxy to capture, modify, and control HTTP requests in real-time. You can enable/disable it and configure its behavior while the agent is running.
Example:
# Start the agent
stoobly-agent run
# In another terminal, enable intercept
stoobly-agent intercept enableQ: How do I check the current intercept configuration?
A: Use the intercept show command to display the current mode, policy, strategy, and status.
Example:
stoobly-agent intercept show
# Output: Mock with policy: 'found', strategy: 'None', enabledEnabling and Disabling Intercept
Q: How do I enable intercept mode?
A: Use stoobly-agent intercept enable to activate request interception on a running agent.
Example:
Q: How do I disable intercept mode?
A: Use stoobly-agent intercept disable to deactivate request interception without stopping the agent.
Example:
Q: Can I enable intercept when starting the agent?
A: Yes, use the --intercept flag when running the agent to enable it at startup.
Example:
Configuring Intercept Modes
Q: What intercept modes are available?
A: There are four intercept modes: mock, record, replay, and test (test requires remote features enabled).
Example:
Q: How do I switch from record mode to mock mode?
A: Use the intercept configure --mode command to change modes while the agent is running.
Example:
Q: What happens when I change the intercept mode?
A: When you change modes, intercept is automatically disabled, the mode is updated, and you need to re-enable intercept for the new mode to take effect.
Example:
Mock Mode Configuration
Q: What is mock mode?
A: Mock mode serves previously recorded responses instead of making real HTTP requests, useful for testing without external dependencies.
Example:
Q: What policies are available for mock mode?
A: Mock mode supports two policies: all (mock all requests) and found (only mock requests with recorded responses).
Example:
Q: How do I configure mock mode to only serve recorded responses?
A: Set the mock policy to found to only mock requests that have matching recorded responses.
Example:
Record Mode Configuration
Q: What is record mode?
A: Record mode captures HTTP requests and responses as they pass through the proxy, storing them for later replay or mocking.
Example:
Q: What policies are available for record mode?
A: Record mode supports four policies: all, api, found, and not_found.
Example:
Q: What recording strategies are available?
A: Record mode supports two strategies: full (capture complete request/response) and minimal (capture only essential data).
Example:
Q: What recording orders are available?
A: Record mode supports two orders: append (add new records) and overwrite (replace existing records).
Example:
Q: How do I configure record mode to only capture new requests?
A: Set the record policy to not_found to only record requests that haven't been captured before.
Example:
Q: How do I configure record mode to overwrite existing recordings?
A: Set the record order to overwrite to replace existing recordings with new captures.
Example:
Replay Mode Configuration
Q: What is replay mode?
A: Replay mode re-executes previously recorded requests, useful for testing and debugging.
Example:
Q: What policies are available for replay mode?
A: Replay mode currently supports the all policy to replay all intercepted requests.
Example:
Test Mode Configuration
Q: What is test mode?
A: Test mode validates responses against expected results, useful for automated testing and contract validation.
Example:
Q: What policies are available for test mode?
A: Test mode supports the found policy to only test requests with recorded responses.
Example:
Q: What test strategies are available?
A: Test mode supports four strategies: contract, custom, diff, and fuzzy.
Example:
Q: How do I set up contract testing?
A: Configure test mode with the contract strategy to validate responses against defined schemas.
Example:
Advanced Configuration
Q: Can I configure multiple options at once?
A: Yes, you can combine mode, policy, strategy, and order options in a single command.
Example:
Q: How do I configure intercept for a specific scenario?
A: First configure the mode and settings, then enable intercept. Use lifecycle hooks for scenario-specific logic.
Example:
Workflow Examples
Q: How do I set up a record-then-mock workflow?
A: Start by recording requests, then switch to mock mode to replay them.
Example:
Q: How do I set up continuous recording with overwrite?
A: Configure record mode with overwrite order to always capture the latest responses.
Example:
Q: How do I set up automated testing with validation?
A: Configure test mode with your preferred validation strategy.
Example:
Troubleshooting
Q: What happens if I try to set an invalid policy for a mode?
A: The command will fail with an error message showing valid policies for that mode.
Example:
Q: Why does intercept get disabled when I change modes?
A: Changing modes requires reconfiguring the proxy behavior, so intercept is automatically disabled. You need to re-enable it after changing modes.
Example:
Q: How do I verify my intercept configuration is working?
A: Use intercept show to check the current configuration and status.
Example:
Q: Can I configure intercept before enabling it?
A: Yes, you can configure all settings first, then enable intercept to apply them.
Example:
Quick Reference
Q: What's a quick reference for common intercept commands?
A: Here are the most frequently used intercept commands:
Example:
Integration with Other Features
Q: How does intercept work with scenarios?
A: Intercept can be configured to work with specific scenarios for organized request management.
Example:
Q: Can I use intercept with lifecycle hooks?
A: Yes, intercept works seamlessly with lifecycle hooks for custom request/response processing.
Example:
Last updated
Was this helpful?