|
| 1 | +# tuf-conformance client-under-test CLI |
| 2 | + |
| 3 | +Before a TUF client can be tested with the tuf-conformance test suite, an executable must be provided |
| 4 | +that implements this CLI protocol. There are three required commands: `init`, `refresh` and `download`. |
| 5 | + |
| 6 | +## Commands |
| 7 | + |
| 8 | +### Init command |
| 9 | + |
| 10 | +Initialize the clients local trusted metadata. |
| 11 | + |
| 12 | +`<client> --metadata-dir <METADATA_DIR> init <TRUSTED_ROOT>` |
| 13 | + |
| 14 | +where |
| 15 | +- `METADATA_DIR` is a directory where the client is expected to store metadata it considers valid |
| 16 | +- `TRUSTED_ROOT` is a file that contains initial root.json content |
| 17 | + |
| 18 | +Client must initialize with the given trusted root (this may involve simply copying the |
| 19 | +trusted root into `METADATA_DIR`: no checks are expected). No requests should be made to the repository at this point. |
| 20 | +Client must use exit code 0 if the initialization succeeded and exit code 1 otherwise. |
| 21 | + |
| 22 | +This command will be called only once for a specific test. |
| 23 | + |
| 24 | +**Example** |
| 25 | + |
| 26 | +`my-tuf-client --metadata-dir /tmp/metadata init ./initial_root.json` |
| 27 | + |
| 28 | + |
| 29 | +### Refresh command |
| 30 | + |
| 31 | +Update local metadata from the repository. |
| 32 | + |
| 33 | +`<client> --metadata-dir <METADATA_DIR> --metadata-url <METADATA_URL> refresh` |
| 34 | + |
| 35 | +where |
| 36 | +- `METADATA_DIR` is a directory where the client is expected to read and write trusted local metadata |
| 37 | +- `METADATA_URL` is a URL to the repository metadata store |
| 38 | + |
| 39 | +Client must update its top-level metadata according to the TUF client workflow. Client must use exit code |
| 40 | +0 if the refresh succeeded fully and exit code 1 if any part of the refresh failed. |
| 41 | + |
| 42 | +Client must use non-versioned filenames for metadata in `METADATA_DIR` (so "root.json" instead of "1.root.json"). |
| 43 | + |
| 44 | +This command may be called multiple times in a test. |
| 45 | + |
| 46 | +**Example** |
| 47 | + |
| 48 | +``` |
| 49 | +my-tuf-client \ |
| 50 | + --metadata-dir /tmp/metadata \ |
| 51 | + --metadata-url http://localhost:8888/test-repo/metadata \ |
| 52 | + refresh` |
| 53 | +``` |
| 54 | + |
| 55 | + |
| 56 | +### Download command |
| 57 | + |
| 58 | +Download an artifact from repository, store it in local disk. |
| 59 | + |
| 60 | +`<client> --metadata-dir <METADATA_DIR> --metadata-url <METADATA_URL> --target-name <TARGET_PATH> --target-base-url <TARGET_URL> --target-dir <TARGET_DIR> download` |
| 61 | + |
| 62 | +where |
| 63 | +- `METADATA_DIR` is a directory where the client is expected to store metadata it considers valid |
| 64 | +- `METADATA_URL` is a URL to the repository metadata store |
| 65 | +- `TARGET_PATH` is the TUF targetpath of the artifact that should be downloaded |
| 66 | +- `TARGET_URL` is the base URL for repository target store |
| 67 | +- `TARGET_DIR`: is a directory where the client should store downloaded and verified files |
| 68 | + |
| 69 | +Client must download the given artifact (targetpath) according to TUF client workflow, and store it in |
| 70 | +given targets directory. Client must ensure that metadata is up-to-date before downloading artifacts |
| 71 | +(see _Refresh command_ for rules on metadata storage in `METADATA_DIR`). |
| 72 | +Client must use exit code 0 if the download succeeded fully and exit code 1 if any part of |
| 73 | +the download failed. |
| 74 | + |
| 75 | +Client may use any filename or directory structure it wants within `TARGET_DIR`: The expectation is that if a |
| 76 | +targetpath is downloaded twice it is stored with the same filename (even if the content changed). |
| 77 | + |
| 78 | +This command may be called multiple times in a test. |
| 79 | + |
| 80 | +**Example** |
| 81 | + |
| 82 | +``` |
| 83 | +my-tuf-client \ |
| 84 | + --metadata-dir /tmp/metadata \ |
| 85 | + --metadata-url http://localhost:8888/test-repo/metadata \ |
| 86 | + --target-name path/to/artifact.txt \ |
| 87 | + --target-base-url http://localhost:8888/test-repo/targets \ |
| 88 | + --target-dir /tmp/targets |
| 89 | + download |
| 90 | +``` |
| 91 | + |
| 92 | +## What does the test suite measure? |
| 93 | + |
| 94 | +The test suite has limited visibility into client decisions so uses various signals to measure conformance: |
| 95 | +* Client command success/failure |
| 96 | +* The metadata the client considers trusted (`METADATA_DIR`) |
| 97 | +* The artifacts the client downloads (`TARGET_DIR`) |
| 98 | +* The HTTP requests made by the client to the repository |
| 99 | + |
| 100 | +Sometimes test suite expectations are not strictly part of TUF specification: As an example the test suite expects |
| 101 | +a specific sequence of metadata HTTP requests to assert that the client handled delegations correctly. |
0 commit comments