Why Testing Matters
- ✅ Catch configuration or logic bugs early
- ✅ Ensure plugin behavior across multiple request scenarios
- ✅ Validate rejection, continuation, or halting logic
- ✅ Prevent regressions during future changes
- ✅ Gain confidence before shipping your plugin
Project Structure for Plugin Tests
Place your tests alongside your plugin inside thepkg/plugins/<your_plugin>/
folder.
What to Test
Here are key areas to focus on when testing your plugin:-
✅ Configuration Validation
Ensure your plugin handles missing or invalid configuration properly using
ValidateConfig()
. -
✅ Correct Behavior per Stage
Test how the plugin behaves when executed at each stage (
pre_request
,post_request
, etc.). - ✅ Edge Cases Simulate missing headers, empty bodies, or malformed inputs and ensure your plugin responds appropriately.
- ✅ Error Handling Confirm that errors are returned clearly and that the plugin fails gracefully.
-
✅ Custom Settings
Use a variety of
settings
inputs to test conditional logic or behavior toggles in your plugin.
Example: Using the Plugin in Gateway Configuration
Once your custom plugin is tested and registered, you can activate it in the gateway configuration with acurl
command like the following: