testserver

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testserver is the acceptance-test fixture from brief §7: an httptest.Server serving a synthetic R4 CapabilityStatement and synthetic resources, with twelve deliberately planted lies. NewTruthful serves the same shape of data with every one of those lies fixed, as the "zero lies" control.

Data is generated deterministically (see data.go) — no randomness, so tests never flake.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *httptest.Server

New returns a server implementing every defect from brief §7:

  1. Observation?code — ignored
  2. Patient?birthdate — rejected (400)
  3. Patient?name — ignored (partial)
  4. Condition?_include=Condition:subject — rejected
  5. Encounter paging — next link 404s on hop 2
  6. Procedure paging — hop 3 repeats hop 2's entries
  7. Observation?_count — ignored (always 20)
  8. MedicationRequest/read — 500
  9. Patient?_lastUpdated — ignored
  10. AllergyIntolerance — search returns 0 entries (untested, not a lie)
  11. Immunization?date — honoured only under Prefer: handling=strict
  12. DiagnosticReport?based-on — not in kweli's path table; must still classify via the nonsense-only query

func NewTruthful

func NewTruthful() *httptest.Server

NewTruthful serves the same resource shapes with every defect above fixed — the "zero lies" control from brief §7.

Types

type SMARTStats

type SMARTStats struct {
	// contains filtered or unexported fields
}

SMARTStats exposes counters from a NewSMARTProtected fixture — tests use TokenCalls to confirm kweli's TokenSource actually caches (i.e. doesn't re-exchange for every FHIR request in a run).

func NewSMARTProtected

func NewSMARTProtected(pub *rsa.PublicKey, clientID string, tokenTTL time.Duration) (*httptest.Server, SMARTStats)

NewSMARTProtected returns an httptest.Server requiring a valid SMART Backend Services access token on every FHIR request:

  • GET /metadata (public) — declares the oauth-uris security extension pointing at this server's own /token endpoint.
  • GET /.well-known/smart-configuration (public) — same token_endpoint, via the modern discovery mechanism.
  • POST /token — verifies a private_key_jwt client assertion (RS384, matching iss/sub/aud/kid, signed by pub) for clientID, and issues a short-lived opaque bearer token.
  • GET /Patient — 401 without a valid, unexpired token from /token; 200 with a small Bundle otherwise.

tokenTTL controls how long an issued access token lives — pass something well above kweli's TokenSource refresh skew (30s) to test caching, or well below it to force a refresh on every call.

func (SMARTStats) TokenCalls

func (st SMARTStats) TokenCalls() int

TokenCalls returns how many times /token has been hit so far.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL