hafas-sim
Fake HAFAS ReST server for tests, built from trimmed RMV responses. Part of rmv.
It listens on loopback and serves dialect version 2.39 below /hapi/ and
2.52 below /hapi/latest/, like the RMV server. The services are
location.name, location.nearbystops, departureBoard, arrivalBoard,
trip, journeyDetail and recon.
use ;
let sim = start.await;
sim.inject;
// Point the client under test at sim.base_url() with ACCESS_ID.
// Every request it got: sim.requests()
Answers
- The key is
ACCESS_ID. Without a key the sim answers 400 with the XML error of the server; with another key it answers 401API_AUTH, in JSON forformat=jsonand in XML otherwise. It never repeats the key it was sent. journeyDetailanswers with the cancelled tram ofjourneyDetail-cancelled.jsonforCANCELLED_JOURNEY(2.39).- Injections change the answers until
Sim::clear:CancelandDelayof a journey,NoRealtime,ServerVersion, anotherFixturefor a service,Fail(a status, or a HAFAS error likeAPI_QUOTAin JSON or XML, withRetry-After, for one service, a number of times),SlowandMalformed. Sim::requestslists every request, with its path, query andUser-Agent. A key other thanACCESS_IDis recorded asREDACTED.CancelandDelaychange only the journey asked for, not the alternatives listed in itsFreq.
Fixtures
fixtures/2.39/ and fixtures/2.52/ hold small responses, trimmed with
scripts/fixture-trim.py from a few requests made by hand. They must never
contain an access key.
Program
cargo run -p hafas-sim -- [PORT] prints the base URLs and serves until
standard input ends (Ctrl-D).