Skip to content

Add mock HTTP server tests for request actors#100

Merged
SeanTAllen merged 1 commit intomainfrom
sean/mock-http-server-tests
Mar 3, 2026
Merged

Add mock HTTP server tests for request actors#100
SeanTAllen merged 1 commit intomainfrom
sean/mock-http-server-tests

Conversation

@SeanTAllen
Copy link
Copy Markdown
Member

The request actors were the largest untested area in the library. They make real HTTPS connections via courier/lori, so testing them requires a mock HTTP server with SSL support.

This adds an optional ssl_ctx field to Credentials that lets request actors use a custom SSL context instead of the hardcoded SSLContextFactory. Defaults to None, so existing callers are unaffected. The mock server follows lori's own SSL test pattern: a TCPListenerActor that accepts connections and dispatches to ssl_server connection actors, with a responder lambda that generates HTTP responses.

13 tests cover all four request actor types: JsonRequester (GET success/failure, POST success, redirect following, parse error), NoContentRequester (DELETE success/failure), CheckRequester (204/404/other), and LinkedJsonRequester (with/without Link header, failure).

Design: #98

@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Mar 3, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Mar 3, 2026
@SeanTAllen SeanTAllen removed the changelog - added Automatically add "Added" CHANGELOG entry on merge label Mar 3, 2026
The request actors (JsonRequester, NoContentRequester, CheckRequester,
LinkedJsonRequester) were the largest untested area. Testing them requires
a mock HTTPS server since they make real connections via courier/lori.

Adds an optional `ssl_ctx` field to `Credentials` so request actors can
use a custom SSL context instead of the default system CA store. This
allows tests to use self-signed certificates. The field defaults to None,
preserving existing behavior for all callers.

The mock server follows lori's own SSL test pattern: a TCPListenerActor
that accepts connections and dispatches to ssl_server connection actors,
with a responder lambda that generates HTTP responses from raw requests.

13 tests cover all four request actor types:
- JsonRequester: GET success, GET failure, POST success, GET redirect,
  GET parse error
- NoContentRequester: DELETE success, DELETE failure
- CheckRequester: 204 (true), 404 (false), other status (failure)
- LinkedJsonRequester: with Link header, without Link header, failure

Design: #98
@SeanTAllen SeanTAllen force-pushed the sean/mock-http-server-tests branch from 7b51f98 to b63e6d0 Compare March 3, 2026 16:40
@SeanTAllen SeanTAllen merged commit 157f293 into main Mar 3, 2026
3 checks passed
@SeanTAllen SeanTAllen deleted the sean/mock-http-server-tests branch March 3, 2026 16:40
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants