Skip to content

Commit 5ae6834

Browse files
authored
Merge pull request #116 from jku/client-readme-update
Rewrite the Client CLI documentation
2 parents a14e257 + b97f045 commit 5ae6834

File tree

3 files changed

+106
-51
lines changed

3 files changed

+106
-51
lines changed

CLIENT-CLI.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The conformance test suite provides a GitHub action that can be used to test a T
2222
There are two required steps:
2323

2424
1. Include an executable in the client project that implements the client-under-test
25-
[CLI protocol](clients/README.md).
25+
[CLI protocol](CLIENT-CLI.md).
2626
2. Use the `theupdateframework/tuf-conformance` action in your test workflow:
2727
```yaml
2828
jobs:

clients/README.md

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,4 @@
1-
# Client interface
2-
3-
Clients must implement the following command-line interface:
4-
5-
`init`: Initialises the clients local trusted metadata. It has the following command-line arguments:
6-
- `--metadata-dir`, Required: The localpath where the client stores metadata.
7-
- `--trusted-root`, Required: The initial root. The conformance tests generate this.
8-
9-
`refresh`: Updates the local metadata from the repository.
10-
- `--metadata-dir`, Required: The localpath where the client stores metadata.
11-
- `--metadata-url`, Required: The URL to the repository. The test suite takes care of passing the URL to the local repository.
12-
13-
`download`: Downloads a target file.
14-
- `--metadata-dir`, Required: The localpath where the client stores metadata.
15-
- `--metadata-url`, Required: The URL to the repository. The test suite takes care of passing the URL to the local repository.
16-
- `--target-name`: The name of the target from the `targets.json` metadata.
17-
- `--target-base-url`: Base URL to download the target file from. Clients are expected to concatenate `--target-base-url` with `--target-name`.
18-
- `--target-dir`: The directory in which the client stores downloaded files.
19-
20-
## Integrating a client
21-
22-
The conformance tests implements a `ClientRunner` class which represents the client in the conformance test suite. The goal of the `ClientRunner` is to carry out high-level tasks, for example:
23-
24-
1. Update local metadata
25-
2. Download target file
26-
3. Check that the local metadata is what we expect
27-
4. Check that a downloaded target file is the one we expected.
28-
29-
Some of these tasks are mere assertions against the local metadata. Others require `ClientRunner` to interact with the remote repository. When the `ClientRunner` needs to interact with the repository, it does so through a client wrapper. A client wrapper is a layer between the TUF-conformance test suite and a TUF client implementation. The client wrapper's goal is to invoke the client implementation we want to test. Client wrappers are responsible for:
30-
31-
1. receiving the parameters from the conformance test-suite
32-
2. invoking the client implementation in a correct manner with the parameters from the test-suite.
33-
34-
We can illustrate the behavior as such:
35-
36-
![Test suite clients workflow](../media/conformance-test-client-workflow.png)
37-
38-
In a conformance test, a `ClientRunner` instructs the client wrapper to fetch the latest metadata. The client wrapper invokes the client implementation - for example python-tuf or go-tuf. The client implementation interacts with the test repository; the client implementation also stores the metadata. The conformance test can then interact directly with the local metadata and verify that it is correct.
39-
40-
## Where should clients run their tests?
41-
42-
The intention is that TUF client implementations that want to use the test suite will include wrappers like this in their source code, and will run the test suite in their CI systems.
43-
44-
This project may then also run the test suite using the wrappers from the TUF implementations, but the intention is that this repository would not have to e.g. maintain dependency lists for the client wrappers.
45-
46-
That said, some wrappers are included for now:
47-
* We will likely tweak the "wrapper API" while we build the initial test suite: while this goes on, it makes
48-
sense to keep the wrappers here
49-
* We do need something to test the test suite itself
50-
* There is no easy way to run the test suite in a TUF implementation CI yet
1+
This directory contains test clients for the test suite. They are implementations of the
2+
client-under-test [CLI protocol](../CLIENT-CLI.md) and are intended to help the development
3+
of the test suite itself and to act as examples for actual client-under-test
4+
implementations.

0 commit comments

Comments
 (0)