ponymail-mcp: add unit tests and CI#5
Merged
rbowen merged 1 commit intoapache:rbowen-ponymail-mcpfrom Apr 27, 2026
Merged
Conversation
The mcp/ponymail-mcp package shipped without tests or CI. This adds both, using only built-in Node tooling so the dependency tree stays unchanged. - restrictions.test.js: 15 unit tests covering pattern grammar (prefix@, @Domain, prefix@domain), env-var parsing edge cases (none, empty, mixed case, whitespace), case-insensitive input matching, restrictionFor/restrictionForAddress/isRestricted/ restrictionError/listRestrictions, and falsy-input tolerance. Each test that exercises a different env spawns a child node process and re-imports restrictions.js, since RESTRICTED is captured at module load. - auth.test.js: 8 unit tests for the session-persistence helpers (loadSession, clearSession). Each test runs in a child process with HOME pointed at a temporary directory so the on-disk session.json is fully isolated. Covers: missing file, fresh cookie, expired cookie, missing-timestamp behaviour, malformed JSON, missing cookie field, and clearSession idempotency. The interactive performLogin() flow (browser, local HTTP server, network validation) is out of scope for unit tests. - package.json: adds `npm test` script using node:test with the spec reporter, and declares engines.node: >=20 (uses node:test built-in runner; no new deps). - .github/workflows/ponymail-mcp-tests.yml: runs the suite on push/PR (path-filtered to mcp/ponymail-mcp/) on Node 20 and 22. Hardened: top-level `permissions: {}` (deny-all) with per-job contents: read, third-party actions pinned to commit SHAs with version comments, actions/checkout sets persist-credentials: false, 10-minute job timeout. Generated-by: Claude Code (Claude Opus 4.7)
a514ccb to
face465
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Targets PR #2's branch (
apache:rbowen-ponymail-mcp). The package shipped without tests or CI — this adds both, using only built-in Node tooling so the dependency tree stays unchanged.mcp/ponymail-mcp/restrictions.test.js— 15 unit tests covering pattern grammar (prefix@,@domain,prefix@domain), env-var parsing edge cases (none,"", mixed case, whitespace), case-insensitive input matching, every public export (restrictionFor/restrictionForAddress/isRestricted/restrictionError/listRestrictions), and falsy-input tolerance.mcp/ponymail-mcp/auth.test.js— 8 unit tests for the session-persistence helpers (loadSession,clearSession). Each test runs in a child process withHOMEpointed at a temp directory so the on-disksession.jsonis fully isolated. Covers: missing file, fresh cookie, expired cookie, missing-timestamp behaviour, malformed JSON, missing cookie field, andclearSessionidempotency. The interactiveperformLogin()flow is out of scope for unit tests (browser, local HTTP server, network validation).mcp/ponymail-mcp/package.json— addsnpm testscript usingnode:testwith the spec reporter, and declaresengines.node: >=20..github/workflows/ponymail-mcp-tests.yml— runs the suite on push/PR (path-filtered tomcp/ponymail-mcp/**) on Node 20 and 22.Workflow hardening
permissions: {}(deny-all) with per-jobcontents: read.actions/checkoutsetspersist-credentials: false.Why a child-process per test
restrictions.jscapturesPONYMAIL_RESTRICTED_LISTSat module load, andauth.jscomputesSESSION_FILEfromos.homedir()at module load. Tests need different env per case, so each spawns a fresh node process. Slow (~24ms per test) but unambiguous.Notes for downstream PRs
PR #3 (built on top of this branch) already adds tests for the allowlist mechanism it introduces; if this lands first, PR #3 will need a one-line rebase to merge the
package.jsontestscript. Happy to handle that rebase.Test plan
cd mcp/ponymail-mcp && npm install && npm testpasses locally (23/23)🤖 Generated with Claude Code