Skip to content
Security
Agent

testing

<!-- Agent-consumed file. Keep terse, unambiguous, machine-parseable. -->

From plugin
jwx
2.4k9 skills9 agents

Claude Code

> /plugin marketplace add lestrrat-go/jwx
> /plugin install jwx-dev-v4@jwx-v4

Agent definition

testing.md

<!-- Agent-consumed file. Keep terse, unambiguous, machine-parseable. -->

Testing

Running Tests

make test              # All tests, race detector
make smoke             # Short/smoke tests only
make cover             # Coverage report
make lint              # golangci-lint

Test Script

`scripts/test.sh` iterates over these modules:

  • `.` (main)
  • `./cmd/jwx`

All run with `-race` flag. Coverage excludes `internal/jose`, `internal/jwxtest`, `internal/cmd`.

Environment variables:

  • `TESTOPTS` — extra `go test` flags (e.g., `-run TestFoo`)
  • `MODE` — `cover` (add coverage), `short` (add `-short`)

Package Test Conventions

  • Test package: `{pkg}_test` (external test package)
  • Assertion library: `github.com/stretchr/testify/require` — NEVER use `assert`
  • Test functions use `t.Run()` for subtests

Test Data

  • `jwk/testdata/rs256.jwk` — RSA JWK fixture
  • Test keys generated at runtime via `internal/jwxtest` helpers

Build Tags for Tests

No feature build tags in v4. Optional features (signature algorithms, base64 backend) are activated via side-effect imports of [extension modules](../docs/10-extensions.md).

The only build tags in the tree are Go-version constraints, and tests never set them; the toolchain selects the files. Two groups exist: the json/v2 sentinel shim (`internal/json/skipfunc_pre_go127.go` / `skipfunc_go127.go`), and native ML-DSA (`jwa/signature_go127_gen.go`, `jwk/mldsa.go`, `jws/mldsa.go` plus their tests, all `//go:build go1.27`).

ML-DSA coverage therefore runs only on Go 1.27: `jwa/mldsa_test.go`, `jwa/signature_go127_gen_test.go` (generated; DO NOT EDIT), `jwk/mldsa_test.go` (import/export, JWK round-trip, thumbprint, and known-answer vectors pinned from a fixed seed), `jws/mldsa_test.go` (sign/verify, parameter-set confusion, signer-opts handling), and `jws/mldsa_fuzz_test.go`. On Go 1.26 these files do not compile in, so the suite is silently smaller — check the toolchain before concluding ML-DSA is untested.

Go 1.27

Both Go 1.26 and Go 1.27 build and pass from the same source. Go 1.26 needs `GOEXPERIMENT=jsonv2`; Go 1.27 ships `encoding/json/v2` in the standard library and must NOT set it. The Makefile probes the toolchain and rewrites `GOEXPERIMENT` to match, adding `jsonv2` on Go 1.26 and stripping it on Go 1.27, so `make` handles this either way even when the variable is already exported. Go 1.27 does still require `-vet=off`:

make test-cmd TESTOPTS=-vet=off   # Go 1.27

`go.mod` declares `go 1.26.10`, so under Go 1.27 vet's `stdversion` analyzer rejects every file that uses `encoding/json/v2` or `jsontext` (`requires go1.27 or later (file is go1.26)`). `go vet ./...` and `make lint` fail on Go 1.27 for the same reason. Use Go 1.26 for vet and lint until `go.mod` moves to 1.27.

`.github/workflows/ci.yml` covers both: the `Test` job uses the go.mod toolchain with vet enabled, and `Test (Go 1.27)` runs the same suite with vet disabled. Every other workflow takes its toolchain from `go.mod`.

Each of those two jobs also asserts the experiment its toolchain expects, via `make print-goexperiment`. `Test` requires `jsonv2` and `Test (Go 1.27)` requires the empty string, so a broken probe cannot quietly flip either one. When `go.mod` moves to 1.27, the `Test` job's expectation becomes the empty string and `Test (Go 1.27)` goes away with the rest of the shim.

Fuzz Tests

make fuzz              # All fuzz targets (default 30s each)
make fuzz-jwt          # FuzzParse, FuzzSignAndParse
make fuzz-jws          # FuzzParse, FuzzSignAndVerify
make fuzz-jwe          # FuzzParse, FuzzEncryptAndDecrypt
make fuzz-jwk          # FuzzParseKey, FuzzParse, FuzzParseKeyRoundtrip
make fuzz-json         # FuzzFieldProbe (internal/json header probe)
FUZZTIME=5m make fuzz  # Override fuzz duration

`jws/mldsa_fuzz_test.go` adds `FuzzMLDSASignAndVerify` and `FuzzMLDSAJWKRoundTrip`. Neither is wired into `make fuzz-jws`, because both are `//go:build go1.27` and naming a missing target would break `make fuzz` on Go 1.26. Run them directly on a Go 1.27 toolchain:

go test ./jws/ -run "^$" -fuzz FuzzMLDSASignAndVerify -fuzztime 30s

Their `f.Add` seeds still execute during a normal `go test` run on Go 1.27, so the seed corpus is covered by `make test` there. Wire both into `make fuzz-jws` once `go.mod` moves to 1.27.

Test Helpers (internal/jwxtest)

Key generation helpers for tests:

  • RSA, ECDSA, Ed25519, symmetric key generation
  • JWT/JWS/JWE/JWK operation helpers

Header probe verification

`internal/json/probe_test.go` covers owned input, escaped names/values, first-wins duplicate handling, syntax-error pointers, standard float rounding, integer precision/overflow, array typing, and full-input validation. `FuzzFieldProbe` checks agreement with jsontext validation (duplicates allowed) and that probe access never modifies the caller's input.

Read more
@lestrrat-go
Ships withjwx

Go module implementing various JWx (JWA/JWE/JWK/JWS/JWT, otherwise known as JOSE) technologies. If you are using this module in your product or your company, please add your product and/or company name in the Wiki! It really helps keeping up our motivation.

2.4k2 skills9 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
2.4k
Star history of lestrrat-go/jwx on GitHub, a chart by star-history.com

Other agents on jwx.

companion-template-sync

companion-template-syn…

Agent

Pull newest GitHub Actions versions from companion repos back into `.companions/templates/`. Dependabot updates each companion…

@lestrrat-go@lestrrat-goInstall Agent
companions

companions

Agent

Extension modules under `github.com/jwx-go/*` (asmbase64, compsig, ed448, es256k, examples, jwkfetch, jwxfilter, jwxmigrate,…

@lestrrat-go@lestrrat-goInstall Agent
internals

internals

Agent

<!-- Agent-consumed file. Keep terse, unambiguous, machine-parseable. -->

@lestrrat-go@lestrrat-goInstall Agent
packages

packages

Agent

<!-- Agent-consumed file. Keep terse, unambiguous, machine-parseable. -->

@lestrrat-go@lestrrat-goInstall Agent

More agents from other plugins.

dependency-review

dependency-review

Agent

<!-- SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. --> <!--…

@nvidia@nvidiaInstall Agent
0-preflight

0-preflight

Agent

Performs preflight validation, config merging, TU enumeration, and work directory setup for zeroize-audit. Produces…

skills9d8.2k
@trailofbits@trailofbitsInstall Agent
autopilot

autopilot

Agent

Autonomous hunt loop agent. Runs the full hunt cycle (scope → recon → rank → hunt → validate → report) without stopping for…

@awarexone@awarexoneInstall Agent
autopilot

autopilot

Agent

Autonomous hunt loop agent. Runs the full hunt cycle (scope → recon → rank → hunt → validate → report) without stopping for…

@shuvonsec@shuvonsecInstall Agent

Questions about testing.

Which coding agents can use testing?
testing installs in Claude Code and Cursor: each loads subagents from .claude/agents, so copy the file there. Flowy's auto-invocation runs in Claude Code only.