test-gap-client
v1.0.0
Published
CLI tool for testing Gap proxy header injection
Readme
test-gap-client
A simple CLI tool to verify Gap proxy header injection is working correctly.
Prerequisites
- Gap installed and running
- Node.js 18+
Install
git clone https://github.com/mikekelly/test-gap-client.git
cd test-gap-client
npm installSetup
1. Install the test-gap plugin
gap plugin install mikekelly/test-gap2. Configure credentials
The test-gap plugin requires two credentials:
gap credential set mikekelly/test-gap apiKey
# Enter a test value, e.g., "foobar"
gap credential set mikekelly/test-gap clientId
# Enter a test value, e.g., "bazqux"3. Create an agent token
gap token create test-agent
# Note the token (e.g., gap_19bfb04eb35)Usage
npx ~/code/test-gap-client --gap-token <your-token>Or with a custom proxy URL:
npx ~/code/test-gap-client --gap-token <your-token> --proxy-url https://localhost:9443Expected Output
If everything is configured correctly, you should see the echo server response with injected headers:
{
"headers": {
"Host": "echo.free.beeceptor.com",
"User-Agent": "test-gap-client/1.0.0",
"Via": "1.1 Caddy",
"X-Api-Key": "foobar",
"X-Client-Id": "bazqux",
"Accept-Encoding": "gzip"
}
}The X-Api-Key and X-Client-Id headers are injected by the Gap proxy via the test-gap plugin.
How it works
- The client connects to the Gap proxy (default:
https://localhost:9443) - Authenticates using
Proxy-Authorization: Bearer <token>header - Makes a request to
https://echo.free.beeceptor.comthrough the proxy - Gap matches the request to the
mikekelly/test-gapplugin (which matchesecho.free.beeceptor.com) - The plugin injects
X-Api-KeyandX-Client-Idheaders from stored credentials - The echo server returns all headers, proving injection worked
Troubleshooting
"Could not load Gap CA" - Make sure Gap has been run at least once. The CA is exported to ~/Library/Application Support/gap/ca.crt on first run.
"Missing Proxy-Authorization header" - Ensure you're passing --gap-token with a valid token.
No injected headers - Verify the plugin is installed (gap plugin list) and credentials are configured (gap credential list mikekelly/test-gap).
