@andrewheberle/serverless-ssh-ca-testing

中文文档
0.30.0发布于 2026/11/07Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2276

Runs the Serverless SSH CA under Node.js or workerd for end-to-end tests of clients

原始使用文档
文档目录5 节
  1. Requirements
  2. Usage
  3. Configuration
  4. Log file
  5. Programmatic use

@andrewheberle/serverless-ssh-ca-testing

Runs the Serverless SSH CA for end-to-end tests of clients, such as ssh-ca-client.

The CA can be run under:

  • node: Node.js, using the package's Node.js helpers with an in-memory node:sqlite database
  • workerd: the Cloudflare Workers runtime, using the Wrangler test harness with a local D1 database and Secrets Store, as wrangler dev would

Nothing is persisted between runs.

This package is released with @andrewheberle/serverless-ssh-ca and uses whichever version of that package is installed alongside it. To test a client against an unreleased version of the CA, install a tarball from npm pack in its place.

Requirements

Node.js 24 or later.

Usage

npm install --save-dev @andrewheberle/serverless-ssh-ca @andrewheberle/serverless-ssh-ca-testing
npx serverless-ssh-ca-test-server [--runtime node|workerd] config.json

The runtime defaults to node. Clients that start the server from another language can run node node_modules/@andrewheberle/serverless-ssh-ca-testing/dist/cli.js, which avoids the platform-specific shims in node_modules/.bin.

The server exits when its standard input is closed, so it does not outlive the test that started it. If it cannot start, it writes the reason to standard error and exits with status 1.

Configuration

The configuration file is a JSON object:

PropertyDescription
private_keyThe CA private key in OpenSSH format
bindingsThe CA configuration, as the Workers vars (environment variables)
port_filePath the port is written to once the CA is listening on 127.0.0.1
log_filePath that log output from the CA and harness is appended to as JSON lines

The bindings are those documented for the CA, with every value as a string. Under workerd, Wrangler's working files are written to the directory containing the configuration file.

Log file

Each line of the log file is a JSON object with at least level and message. Lines logged by the CA are written as they are, and the harness adds lines whose message starts with harness:

  • {"level":"info","message":"harness request","method":...,"url":...,"status":...} for every request, where url is the path and query. When status is 400 or more, body holds the response body, so a test can check why a request was rejected.
  • {"level":"error","message":"harness ...",...} for a fault, meaning the CA or harness failed rather than rejected a request. Some faults, such as a failure to record an issued certificate, are only visible in the log, so tests should fail if any of these lines appear. A CA log line that indicates a fault is followed by a line with the message harness fault and the original line in line.

Under workerd, the CA's output is copied to the log file every 100ms, so a request may be logged shortly after its response is received.

Programmatic use

import { startTestServer } from "@andrewheberle/serverless-ssh-ca-testing"

const server = await startTestServer("node", "config.json")
// make requests to http://127.0.0.1:${server.port}
await server.close()

Under node the CA's console output is redirected to the log file until the server is closed.

版本与发布记录

@andrewheberle/serverless-ssh-ca-testing 共发布 17 个版本,首次发布于 2026/10/09;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.30.0latest2026/11/07今天
0.29.02026/11/07今天
0.28.12026/11/07今天
0.28.02026/11/061 天前
0.27.02026/11/061 天前
0.26.02026/11/052 天前

关于 @andrewheberle/serverless-ssh-ca-testing 的常见问题

@andrewheberle/serverless-ssh-ca-testing 是什么?

Runs the Serverless SSH CA under Node.js or workerd for end-to-end tests of clients

如何安装 @andrewheberle/serverless-ssh-ca-testing?

在项目目录运行 npm install @andrewheberle/serverless-ssh-ca-testing,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@andrewheberle/serverless-ssh-ca(>=0.20.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 serverless-ssh-ca-test-server,可以用 npx serverless-ssh-ca-test-server 直接运行。

@andrewheberle/serverless-ssh-ca-testing 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@andrewheberle/serverless-ssh-ca-testing 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@andrewheberle/serverless-ssh-ca-testing 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@andrewheberle/serverless-ssh-ca-testing 可以商用吗?

@andrewheberle/serverless-ssh-ca-testing 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@andrewheberle/serverless-ssh-ca-testing 的下载量有多少?

根据 npm 官方下载统计,@andrewheberle/serverless-ssh-ca-testing 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,276 次,日均约 76 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@andrewheberle/serverless-ssh-ca-testing 还在维护吗?

最新版本 0.30.0 发布于 2026/11/07(今天);至今共发布 17 个版本,其中过去 12 个月发布了 17 个;首次发布于 2026/10/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。