hafas-sim 1.0.0

Fake HAFAS ReST server built from trimmed RMV responses, for tests
Documentation
# hafas-sim

Fake HAFAS ReST server for tests, built from trimmed RMV responses. Part of
[rmv](https://github.com/udondan/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`.

```rust
use hafas_sim::{Failure, Injection, Sim, ACCESS_ID};

let sim = Sim::start().await;
sim.inject(Injection::Fail(Failure::status(503).retry_after(1).times(1)));
// 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 401 `API_AUTH`, in JSON
  for `format=json` and in XML otherwise. It never repeats the key it was
  sent.
- `journeyDetail` answers with the cancelled tram of
  `journeyDetail-cancelled.json` for `CANCELLED_JOURNEY` (2.39).
- Injections change the answers until `Sim::clear`: `Cancel` and `Delay` of a
  journey, `NoRealtime`, `ServerVersion`, another `Fixture` for a service,
  `Fail` (a status, or a HAFAS error like `API_QUOTA` in JSON or XML, with
  `Retry-After`, for one service, a number of times), `Slow` and
  `Malformed`.
- `Sim::requests` lists every request, with its path, query and
  `User-Agent`. A key other than `ACCESS_ID` is recorded as `REDACTED`.
- `Cancel` and `Delay` change only the journey asked for, not the
  alternatives listed in its `Freq`.

## 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).