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 ¶
New returns a server implementing every defect from brief §7:
- Observation?code — ignored
- Patient?birthdate — rejected (400)
- Patient?name — ignored (partial)
- Condition?_include=Condition:subject — rejected
- Encounter paging — next link 404s on hop 2
- Procedure paging — hop 3 repeats hop 2's entries
- Observation?_count — ignored (always 20)
- MedicationRequest/read — 500
- Patient?_lastUpdated — ignored
- AllergyIntolerance — search returns 0 entries (untested, not a lie)
- Immunization?date — honoured only under Prefer: handling=strict
- DiagnosticReport?based-on — not in kweli's path table; must still classify via the nonsense-only query
func NewTruthful ¶
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.