Repository navigation
cmd/nntp-fakeserver: the fake server as a process, configured by JSON - #14
Merged
Merged
Conversation
A standalone program for test suites in other languages (Python, shell, C): it reads a JSON
config, prints {addr, host, port, ca} when it listens, serves until stdin reaches end of
file, then prints a summary {lines, mismatches, articles, notes, accepted, counts,
tls_handshakes, tls_failed, server_names}. Modes: store, peer, script (the kit's) and raw (a
byte-exact script with split writes, RST, STARTTLS and inflate, generalised from pynntp's
fault server).
The config keys are the Go field names of fakeserver.Options, StoreOptions, PeerOptions,
Faults and StartTLSOptions, durations in milliseconds; the decoder walks the types, so a field
added to the kit works from JSON at once, and an unknown key is an error. The certificate is
tlscert.GenerateSelfSigned, written to a temp dir that is removed on exit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ode, config checks)
Summary: lines_b64, mismatches_b64 and articles_raw (base64, lossless for bytes that are not
UTF-8), max_open and closed; ready line: ca_pem. Store articles: HeadersB64 and BodyB64.
Raw mode: pauses use Conn.Sleep (bounded by Deadline, ended by Close), reads of expected lines
and writes have the Deadline, lines over 1 MiB, blocks over 16 MiB and 64 MiB per connection
close the connection with a note.
Config: Faults command keys must be upper case; empty {} and [] sections are fine in any mode;
StartTLS "Config": false switches STARTTLS off; []byte is base64; check() guards a renamed kit
field. A second SIGINT or SIGTERM during shutdown is no longer swallowed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…byte must be a string TestEveryKitFieldDecodes now builds nested samples (Split, Trailing); TestByteFaults checks their values and a Split + Trailing reply end to end. A []byte field takes a base64 string only (encoding/json would also take an array). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ames, usage keys) - A raw Sleep, Gap or SplitGap longer than Options.Deadline is a config error: Conn.Sleep ends every pause at the Deadline, so it was cut short without a note. The package doc says a client that stays silent longer than the Deadline before an expected line is cut off. - Base64 errors name their key (HeadersB64[0], BodyB64[0]), not Headers or Body. - -h lists the current ready and summary keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
go-while
added a commit
to go-while/pynntp
that referenced
this pull request
Nov 13, 2026
kit_config() renames the scenarios' short keys to the Go field names that nntp-testkit's cmd/nntp-fakeserver takes (an unknown key is an error), so the suite can run against the kit's program instead of its own server. With nntp-fakeserver (go-while/nntp-testkit#14): 219 passed, 9 xfailed, the same as with tests/faults/server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Item 4 of
survey-pynntp.md: the fake server as a program, so test suites in other languages can use the kit. It generalises pynntp's fault server (tests/faults/server/main.goin greenbender/pynntp#145, which drives 228 fault scenarios from Python) and leaves room for go-pugleaf's plannednntp-fakepeer(survey-go-pugleaf.mdsection 3): its peer mode isPeerOptionsfrom JSON.Usage
nntp-fakeserver [-listen host:port] config.json{"addr","host","port","ca"}.cais the PEM of a fresh self-signed certificate (tlscert.GenerateSelfSigned, tlscert, fakeserver: twins without testing.TB #9), valid for localhost, 127.0.0.1 and ::1. Clients verify implicit TLS and STARTTLS against it.{lines, mismatches, articles, notes, accepted, counts, tls_handshakes, tls_failed, server_names}, removes its temp dir and exits 0.The full description, with an example for each mode, is in the package doc. README is left for the release.
Config
Options,StoreOpts,Faults,PeerOptions,Script, …). The decoder walks the kit types by reflection, so a new kit field, such as theFaultsfields in the faults-bytes branch, works from JSON with no change here.TestEveryKitFieldDecodesfails if a new field has a shape it can't read.Options.Store.Options.TLS: truemeans implicit TLS with the program's certificate.StartTLS: {}(plus the knobsRefuse,HideCapability,AuthNeedsTLS,CloseAfterHandshake) offers STARTTLS with it.store: Store, StoreOpts and Faults.peer: PeerOptions.script:Options.Scriptasfakeserver.Step.raw: byte-exact scripts. Per step: an anchored regexp for the client line, an optional dot block, chunks asTextorB64withGap/Split/SplitGap, thenclose/rst/hang/starttls/inflate.starttlsusesConn.StartTLS. The kit's Script mode is text lines only, which is why raw stays a mode of its own.Testing
main_test.godrivesrun()in-process:starttlsthen a command over TLS,rst, pipelined plaintext after STARTTLS;gofmt -lempty,go vet ./...clean,go test -race -count=1 ./...passes in all packages, and-count=5passes for this package.ssl.create_default_context(cafile=ca)and a stdin pipe: TLS verified, summary withtls_handshakes: 1, temp dir gone after exit.Next on the pynntp side: #145 switches from its own server to this program.
🤖 Generated with Claude Code