Expand description
Stateful fake TR-064 server, built from recorded fixtures. Used by tests only: every write test runs against it, never against a real device.
Sim::start serves a Fixture on the loopback interface: the device
description and the service descriptions without authentication, and
the action calls with HTTP Digest authentication.
- Calls are checked against the service description: an unknown action fails with UPnP error 401, missing or unknown arguments with 402, and values that don’t fit the data type or the allowed values with 600. Like the devices, it doesn’t check the allowed range.
- Getters answer as recorded. Getters with an index answer the recorded entry, or 713 if there is none.
- Every argument refers to a state variable. Calls of other actions, like
SetEnable, write their input arguments into these variables, and the getters that read the same variables answer with the new values. - Paths to list documents, like the one
X_AVM-DE_GetHostListPathreturns, hold a session ID, and the documents are served for it. - The web interface has a session login,
/login_sid.lua, with a PBKDF2 challenge, and serves the documents of the REST API, like/api/v0/smarthome/overview, for the open session. - Tests can inject UPnP errors, delays, discarded writes and a locked login, and read the requests the server got.
use fritz_sim::{Fixture, Injection, Sim};
let sim = Sim::start(Fixture::bundled("fritzbox-7690/8.25")?).await?;
let client = sim.client().build()?;
let description = client.description().await?;
let wlan = description.service("WLANConfiguration1")?;
client.call(wlan, "SetEnable", &[("NewEnable", "0")]).await?;
assert_eq!(sim.state("WLANConfiguration1", "Enable").as_deref(), Some("0"));
sim.inject(Injection::fault("WLANConfiguration1", "SetEnable", 866));
assert!(client.call(wlan, "SetEnable", &[("NewEnable", "1")]).await.is_err());Structs§
- Fixture
- A device as recorded in a fixture directory:
- Options
- How the simulator listens and whom it lets in.
- Request
- A request the simulator got.
- Sim
- A running simulator. It stops when dropped.
Enums§
- Answer
- A recorded answer to an action call.
- Error
- Why a fixture cannot be loaded.
- Injection
- A change to how the simulator behaves, until cleared.