Skip to main content

Language Configuration

Some language-specific environment configuration may be necessary but you should not need to modify your application code to use proxymock.

If you want the full language-specific first-success path, start here:

  • Java — Java demo app
  • Kotlin — Kotlin demo app
  • .NET — .NET demo app
  • Node.js — Node.js demo app
  • Go — Go demo app
  • Python — Python demo app
  • Ruby — Ruby demo app
  • PHP — PHP demo app
  • Rust — Rust demo app
  • C++ — C++ demo app

Configuring the Proxy​

As the name implies, proxymock is a proxy which works by routing traffic from your application through proxymock before it goes to the final destination.

warning

Proxy support depends on the client library. Some clients ignore environment variables or require explicit proxy settings. Check your client configuration and confirm that a request appears in the recording.

Record inbound traffic by setting the --app-port flag and making requests to port 4143 instead of your application's port.

When to use --map​

Use --map when your client ignores proxy environment variables or when it is easier to point the client at a different host and port than configure proxy support.

Pick your recording mode like this:

  • HTTP, HTTPS, or gRPC clients that honor proxy environment variables: set HTTP_PROXY, HTTPS_PROXY, and grpc_proxy
  • Clients that support SOCKS: set ALL_PROXY
  • Clients that ignore proxy environment variables or use raw TCP protocols such as Redis: use proxymock record --map

Examples on this page follow the casing conventions commonly used by each runtime. Many proxy-aware clients accept uppercase and lowercase variants. The proxymock CLI overview shows proxy variables, and the proxymock CLI reference covers flags and syntax.

--map tells proxymock to listen on a local port and forward traffic to the real backend. Then point your application at the mapped port instead of the real service.

For example, to record Redis traffic, start proxymock with a port mapping and point your app at that mapped port:

proxymock record --out ./proxymock --map 56379=127.0.0.1:6379
export REDIS_ADDR=127.0.0.1:56379
./my-app

If the backend protocol matters, you can also include it explicitly:

proxymock record --map 65432=postgres://localhost:5432
proxymock record --map 1443=https://httpbin.org:443

For more examples, see the Redis mocking guide, MongoDB guide, MySQL guide, PostgreSQL guide, SQL Server guide, Oracle guide, and Kafka guide.

Go respects proxy environment variables.

export HTTP_PROXY=http://localhost:4140
export HTTPS_PROXY=http://localhost:4140
export NO_PROXY=localhost,127.0.0.1

Use the SOCKS proxy to capture database traffic:

export ALL_PROXY=socks5://localhost:4140

Decrypting TLS​

proxymock attempts to automatically configure TLS on the desktop so manual configuration is only necessary in special environments like CI/CD or when TLS decryption does not work out of the box.

Configure TLS trust in the environment that runs your HTTPS client. Clients that use the Windows certificate store need the Windows certificate store steps below.

export SSL_CERT_FILE="${HOME}/.speedscale/certs/tls.crt"

Go reads the SSL_CERT_FILE environment variable on Linux to locate trusted root certificates. This environment variable will be automatically populated by the Speedscale operator. Go 1.27 and later also reads it on macOS and Windows. Earlier versions use the keychain on macOS and the Windows certificate store on Windows.

Windows certificate store​

Native Windows clients that validate certificates with the Windows certificate store ignore SSL_CERT_FILE. These include .NET, SQL Server drivers, Go before 1.27, Rust with native-tls, and the curl.exe that ships with Windows. Trust the proxymock CA in the Windows certificate store instead. Node.js, Python requests, and Java keep their own trust settings, described in the tabs above.

On a Windows desktop, proxymock init offers to add the CA to your user's Trusted Root Certification Authorities store. Confirm the Windows Security Warning dialog and no further setup is needed. Use the steps below if you declined the dialog, passed --no-cert-install, set up a headless machine, or need trust for another account or the whole machine.

Apply trust to the runtime that opens the HTTPS connection. If the test calls your app and your app calls the dependency, configure trust for your app's account or Windows environment.

  1. Locate the public CA, tls.crt, from the proxymock instance serving the mock. The default Windows path is %USERPROFILE%\.speedscale\certs\tls.crt. Run proxymock admin certs if you need to generate the CA. Share only the public certificate with your endpoint administrator and keep tls.key on the mock host.

  2. Choose the trust store approved by your endpoint administrator. For machine-level trust, have them deploy the CA to Local Computer > Trusted Root Certification Authorities. For an approved manual install, run the following from elevated PowerShell with the actual path to the public certificate.

    certutil.exe -addstore Root "C:\path\to\tls.crt"

    For per-user trust, run this from regular PowerShell as the user running the HTTPS client. It does not need administrator rights. Windows shows a confirmation dialog, so it fails in headless sessions. For unattended jobs, have your administrator provision trust for the account or environment where the client runs.

    certutil.exe -user -addstore Root "$env:USERPROFILE\.speedscale\certs\tls.crt"
  3. To verify mocking, start proxymock with your recording and disable passthrough. The example assumes proxymock and the client are running on the same Windows host.

    proxymock mock --in .\proxymock\recorded-<timestamp> --out .\proxymock\mock-results --no-passthrough

    Replace recorded-<timestamp> with the directory proxymock record created. Route the client through proxymock in the session that launches it. For clients that read proxy environment variables, set HTTPS_PROXY, using the configured proxy address if you changed the default listener. The language pages cover clients that need other proxy settings, such as .NET Framework.

    $env:HTTPS_PROXY = "http://127.0.0.1:4140"

    Run a request that exercises the mocked dependency with TLS validation enabled. Confirm the expected response and check the mock output for match=HIT and zero passthrough. An unmatched request returns HTTP 404.

  4. When the trust is no longer needed, have the certificate owner remove the CA from the trust store by its exact thumbprint. certutil.exe -dump "C:\path\to\tls.crt" prints the thumbprint as Cert Hash(sha1). For the machine store, run this from elevated PowerShell:

    certutil.exe -delstore Root <thumbprint>

    For the per-user store, run this from regular PowerShell as that user:

    certutil.exe -user -delstore Root <thumbprint>

See Microsoft's Windows certificate store guide and certutil reference.

Loading search...