# Clients and versions

Anything that talks to a wall other than its own page is a client of [The API](https://qkvm.com/docs/the-api):
a script with a token, a monitoring system, a program of its own that shows the wall. This
is what such a program goes by, so that it keeps working from one version of qKVM to the
next, and says the same things the page says.

- **Ask `GET /healthz` first.** It needs no sign-in. `api` lists the versions of the
  interface this qKVM speaks: a program written against `v1` uses it where it is listed and,
  where it is not, says so plainly (one of the two has to be updated) and sends nothing
  else. `locked` says that the wall reaches no device until somebody has signed in.
- **Within `v1` nothing is taken away** and nothing is given another meaning; fields,
  requests, states, codes and words are added. A program takes what it knows from an answer
  and leaves the rest. A state, a code or a word it has not met is one that was added since:
  a code is shown as a problem, with the sentence the wall sent for it; a word in `can` is
  left out.
- **What a machine can do comes from the wall**, in `can`, never from its kind: see
  [The API](https://qkvm.com/docs/the-api). A new kind of device brings new words, and a program that goes by
  `can` shows the right buttons for it without having heard of it.
- **The words are one file.** `words.json`, in the source at `qkvm/static/words.json` and
  served by every wall at `/static/words.json`, holds the states and what the page says for
  each (`states`; and `server_states`, for a server, whose "no signal" is "powered off"), a
  device's trouble by its code and the state a tile shows it under (`codes`), every code the
  wall refuses a request with and the statuses it comes with (`refusals`), the kinds of
  device and their names (`kinds`), and the words of `can` with a label for each. The page
  reads it as it starts; another program is built from it, or checked against it when it is
  built, so that no two programs call one thing by two names. A test of qKVM's own fails when
  the page or a driver uses a word the file does not have.
- **What the page does beyond this** (setting a wall up, its settings, accounts, the
  browsers told the alerts by Web Push, updates) is the page's own, listed at the end of
  [The API](https://qkvm.com/docs/the-api): a program leaves that to the page, in a browser.

### Checking a wall

`qkvm.conformance` holds a running wall to the promise of [The API](https://qkvm.com/docs/the-api) as a program
meets it: every promised read, what each answer holds and the kind of each value, the
refusals and their codes, the headers. It reads only. It sends nothing but GET, and so adds,
changes and presses nothing, and opens no live line and no console; it asks each machine it
reads for its history and one picture, as a tile of the page does, and with an operator's
token what its KVM can wake. One machine of each kind is read, or every one with
`--every-machine`; `--no-pictures` asks for no picture.

```
python -P -m qkvm.conformance https://192.168.1.20:8787 --token-file token.txt --cafile cert.pem
```

- **The token** is one for a script ([Scripts and wall screens](https://qkvm.com/docs/scripts-and-wall-screens)),
  a viewer's or an operator's, alone on the one line of a file of its own. It is sent to that
  wall and nowhere else, and never written out. A token for the machines it may look at is
  enough.
- **The wall's certificate.** One that a public authority vouches for needs nothing more.
  The one qKVM made itself is given with `--cafile` (`tls/cert.pem` in the wall's data folder,
  copied to where the check runs), and the wall is reached by an address the certificate is
  for: one qKVM listens on. There is no way to check without verifying it, since the token
  would go to whoever answers. Over plain HTTP, the check says that the token crossed the
  network unencrypted.
- **Behind a proxy that signs people in** (a wall started with `--sso-header`), check the
  wall's own address: through the proxy, `GET /api/v1/session` signs in whoever the proxy
  names.
- **What it says:** a line for each thing it looked at, `ok`, `FAIL` (what is not as
  promised, by the field and its kind, never its value), `note` or `skip`, and at the end how
  many of each. It exits 0 where the wall answered everything as promised, 1 where it did not,
  and 2 where it could not check: the wall out of reach, its certificate not trusted, the
  token not taken, the wall locked (started with `--locked-start`, and nobody has signed in
  since), or older than 0.2.0.
- **Versions.** It holds the wall to the promise as the copy of qKVM it is run from has it,
  and to no more than the wall's own version promised: a request or a field promised since a
  later version is not asked of it (`skip`), nor a code of its words that every request or
  device may answer with since a later one; a field, a code or a word the wall added
  since is a `note`. `--strict` makes those failures and expects all of it whatever the wall's
  version: for a wall of the very same version, as qKVM's own tests run it against a wall with
  a stand-in of every kind of machine.
- **For a program's own tests** (the Desktop App's joint test with a wall, a phone app's):
  run the check from the version of qKVM the program was written against (`pip install
  qkvm==0.4.0` in an environment of its own is enough; it needs no wall of its own), against a
  wall of every version the program is to work with, set up with machines and a token for a
  script, and stop the release on any exit code but 0. A newer wall has to pass whole; against
  an older one, what is skipped is what the program cannot ask there.
