Commit graph

11 commits

Author SHA1 Message Date
Jussi Kukkonen
f569754f5e tests: Fix a bug in RepoSimulator signer lookup 2021-10-13 15:59:56 +03:00
Jussi Kukkonen
1846e28ca3 tests: Test ngclient with unusual rolenames
Add support for adding delegated targets into RepositorySimulator.
Make the metadata URL parsing in RepositorySimulator more robust.

Add a test to make sure "../a" won't trick ngclient into creating the
metadata file outside the metadata cache.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-10-13 15:59:01 +03:00
Martin Vrachev
717eef9bb5 Repo simulator: make delegates() to all_targets()
Modify RepositorySimulator function delegates() to all_targets(), so
that all targets can be traversed and updated with one cycle when
calling update_snapshot() (which is the only use case for now for
delegates()).

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2021-10-13 10:40:29 +03:00
Martin Vrachev
f1f76d259f Repository_simulator: add a flag to compute hashes
Add an option to calculate the hashes and length for timestamp/snapshot
meta.
This will help to cover more use cases with the repository simulator.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2021-10-13 10:40:29 +03:00
Jussi Kukkonen
59b0b99ba3 tests: Improve the docs on RepositorySimulator
The handling of consistent snapshot was not very clear: try to make
it more obvious what is supported and what is not.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-09-24 13:41:52 +03:00
Jussi Kukkonen
1fb4204c26 tests: Add target support to RepositorySimulator
* Add very simple targets support into simulator
* Add documentation for the simulator
* Add an example targets test

This might need to be tweaked and/or extended as we add tests but the
implementation should give a good indication of how to extend it.

As an example, non-consistent targets are not yet supported, but
making fetch() check for the consistent_snapshot state and respond
accordingly should be easy.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-09-24 13:41:52 +03:00
Martin Vrachev
bf12e7565f Metadata API: change meta type in Timestamp
In Timestamp, the only valid "meta" value is the dictionary representing
meta information for the snapshot file. This makes the API unnecessarily
complicated and requires validation that only information about snapshot
is available inside "meta".
Together with the python-tuf maintainers, we decided that snapshot meta
information will not be represented by a "meta" dictionary but instead
by a MetaFile instance and with this it will diverge from the
specification.
Additionally, to prevent confusion, I will rename the "meta" attribute
to "snapshot_meta" as this attribute will be related only to meta
information about snapshot.

This decision is coherent with ADR9 and the rationale
behind it is to provide easier, safer, and direct access to the
snapshot meta information.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2021-09-20 14:09:38 +03:00
Jussi Kukkonen
ad813a5d0d tests: Add type checks suggested by mypy
also black fixes.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-09-10 09:59:03 +03:00
Jussi Kukkonen
87c200d014 tests: Add state dumping into RepositorySimulator
if state dumping is enabled with e.g.
    python3 test_updater_with_simulator.py --dump
The repository state can be dumped at will.

Modify the test so it dumps the state on every updater refresh if
--dump is set.

Add a root modifying case to test_refresh()

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-09-10 09:59:03 +03:00
Jussi Kukkonen
d64730b1e6 tests: RepositorySimulator: Add special handling for roots
We need to store past versions of root: that means an explicit
publish step (publish_root()) is required. It stores a serialization of
current root as a new version: fetch() then serves only these
serialized root versions.

Add a few tests demonstrating how to create root versions and change
signatures.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-09-10 09:59:03 +03:00
Jussi Kukkonen
4e5980e89d tests: Start testing ngclient with repo simulator
Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-09-10 09:59:03 +03:00