Commit graph

87 commits

Author SHA1 Message Date
Jussi Kukkonen
166434d844 tests: Remove unused test files
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2025-01-17 11:11:26 +02:00
Jussi Kukkonen
416c34c6fc tests: Remove unused file
test_updater_ng.py is a little archaic (as it uses the static test
repository content from ye olden days). This commit does not change that
but removes an extra file in client cache dir: it is now quite confusing
as it looks a bit like intermediate root caching but is just an unused
file.

This has the nice side effect that tests now longer need to workaround
this extra file.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2025-01-17 11:11:26 +02:00
Jussi Kukkonen
28a031f039 tests: Remove aggregate_tests.py
This was essentially unused now (originally it was used to
randomize the test order).

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2024-12-11 10:11:49 +02:00
Jussi Kukkonen
38f309bbbf WIP: Update to new securesystemslib API
* API changes covered:
  * keys and interface modules removed
  * SSlibSigner removed
  * CryptoSigner added: this replaces the removed functionality
  * DSSE "signatures" container type changed
* Currently pins a securesystemslib main branch commit:
  this shoudl be reverted before merging, when securesystemslib
  has made a release
* tests/generated_data/generate_md.py was simplified
* Encrypted test keys in tests/repository_data/keystore were replaced
  with the unencrypted PEM versions of the same keys
* The public test keys in tests/repository_data/keystore were removed
  as they were not used anymore

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2024-04-25 14:27:54 +03:00
Lukas Puehringer
438518f68c tests: remove unused and obsolete test metadata
- metadata.staged: related to a removed tutorial and outdated deployment
  recommendation
- project: related to the removed developer_tool (#1790)
- map.json: related to TAP4, which is not supported by python-tuf

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2023-10-11 15:09:09 +02:00
Lukas Puehringer
16192902ce test: drop legacy test metadata generation scripts
Remove metadata generation scripts based on legacy
repository/developer tools, which will be removed in subsequent
commits.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2022-01-26 14:52:04 +01:00
Martin Vrachev
22fe1e69e4 Rename old test files by adding old suffix
Rename test files testing the old code by adding an "old" suffix.
This is done, so we can easily exclude them from linting.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2021-12-09 16:44:25 +02:00
Martin Vrachev
d3d2f57f3a Test files: bump expiration date and resign
Our newly added metadata files in the
tests/repository_data/fishy_rolenames/metadata directory have an expiry
date until "2021-10-22T11:21:56Z" and today while running the tests on
develop branch I recived this error:
ExpiredMetadataError("Metadata X expired on Fri Oct 22 11:21:56 2021")
when running the tests in tests/test_updater.py file and more precisly
the TestUpdaterRolenames.test_unusual_rolenames() test.

That's why I decided to bump the expiration date to a random time in
the future (October 22-nd 2050) and I had to resign all of the metadata
files.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2021-10-23 18:39:22 +03:00
Jussi Kukkonen
b2b2f21f99 tests: Make sure legacy client copes with unusual rolenames
Make sure rolenames like "../a" won't trick ngclient into creating the
metadata file outside the metadata cache.

The test data was semi-manually created with RepositorySimulator:
this test code could use RepositorySimulator directly instead (like the
ngclient tests do) but that would require some more infrastructural
work.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-10-13 15:59:56 +03:00
Joshua Lock
3dc5594242 Update links to account for repository rename
We have renamed the repository from tuf->python-tuf

Signed-off-by: Joshua Lock <jlock@vmware.com>
2021-09-01 11:15:33 +01:00
samuelgregorovic
112575d987 updated docs and comments
Updated/removed documented commands and comments which were referencing Python2. Also updated links to documentation referencing Python2 docs (unchanged where needed)

Signed-off-by: Samuel Gregorovic <samuelgregorovic@gmail.com>
Signed-off-by: samuelgregorovic <samuelgregorovic@gmail.com>
2021-07-14 10:37:08 +03:00
Jussi Kukkonen
271d5b7810 Metadata API: verify_delegate: refactor
* Rename arguments so connection between the role name and the
  metadata is stronger.
* Also add a comment on the list comprehension + next() trick.
* Add return value annotation
* Raise early if delegations is None to make the flow more obvious
  (and modify test case so we have coverage for the new case)

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-07-08 20:16:42 +03:00
Velichka Atanasova
06c8fb8cd3 Add a test for the 'ecdsa' key type
Changes tests/repository_data/keystore/root_key3* to be an ecdsa key,
created and encrypted with the generate_ecdsa_key and
encrypt_key methods of securesystemslib.keys.
The test_updater_root_rotation_integration.py test
tests both repotool and updater.

Signed-off-by: Velichka Atanasova <avelichka@vmware.com>
2021-06-21 16:32:49 +03:00
Martin Vrachev
5d9a6f6598 Tests: Queue replace tmp files, OS port creation
These changes can be summarized with the following bullets:
- Delegate generation of ports used for the tests to the OS
- Use thread-safe Queue for processes communication
instead of temporary files
- Remove all instances of port generation or hardcoded ports
- Make test_slow_retrieval.py fully conform with TestServerProcess

Delegate generation of ports used for the tests to the OS is much
better than if we manually generate them, because there is always
a chance that the port we have randomly pick turns out to be taken.
By giving 0 to the port argument we ask the OS to give us
an arbitrary unused port.

Use thread-safe Queue for processes communication instead of temporary
files became a necessity because of findings made by Jussi Kukkonen.
With the latest changes made in pr 1192 we were rapidly reading
from the temporary files and Jussi found that it happened rarely
the successful message "bind succeded..." to be corrupted.
It seems, this is a thread issue related to the thread redirecting
the subprocess stdout to the temp file and our thread rapidly
reading from the file.
By using a thread-safe Queue we eliminate this possibility.
For reference read:
https://github.com/theupdateframework/tuf/issues/1196

Lastly, test_slow_retrieval.py and slow_retrieval.py were refactored.
Until now, slow_retrieval.py couldn't use the TestServerProcess class
from utils.py for a port generation because of a bug related to
httpd.handle_request().
Now, when we use httpd.serve_forever() we can refactor both of those
files and fully conform with TestServerProcess.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2020-11-13 14:01:57 +02:00
Lukas Puehringer
ff8819577b Adopt sslib keygen interface encryption changes
secure-systems-lab/securesystemslib#288 changes the key generation
interface functions in such a way that it is clear if a call opens
a blocking prompt, or writes the key unencrypted. To do this two
functions are added per key type:
 - `generate_and_write_*_keypair_with_prompt`
 - `generate_and_write_unencrypted_*_keypair`

The default `generate_and_write_*_keypair` function now only allows
encrypted keys and only using a passed password. This respects the
principle of secure defaults and least surprise.

sslib#288 furthermore adds a protected
`_generate_and_write_*_keypair`, which is not exposed publicly
because it does not encrypt by default, but is more flexible and
thus convenient e.g. to consume all arguments from a key generation
command line tool such as 'repo.py'.

This commit adds the new public functions to the tuf namespace and
adopts their usage accordingly.

NOTE regarding repo.py:
This commit does not fix any problematic password behavior of
'repo.py' like default passwords, etc. (see #881). It only adopts
the sslib#288 changes to maintain the current behvior, plus
removing one glaringly obsolete password prompt.

NOTE regarding key import:
The securesystemslib private key import functions were also changed
to no longer auto-prompt for decryption passwords , TUF, however,
only exposes custom wrappers (see repository_lib) that do
auto-prompt. sslib#288 changes to the prompt texts are nevertheless
propagated to tuf and reflected in this commit.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2020-11-11 10:27:56 +01:00
Joshua Lock
4487a98020 Remove redundant test logic
Support for compressed files was removed in tuf v0.10.x leaving behind
some vestiges like the test logic in test_repository_lib, which is
duplicated below and carries a redundant comment, and setting compression
on in generate_project_data.py

Signed-off-by: Joshua Lock <jlock@vmware.com>
2020-05-12 22:16:38 +01:00
Joshua Lock
3720b2358e Re-generate repository and client test metadata
Re-generate metadata to adopt the change that root.json is no longer
listed in snapshot.json

```
 # Remove repository and client data
cd tests/repository_data && rm -rf repository client
 # Generate metadata
python generate.py
 # Duplicate metadata files
cp -r client/test_repository1 client/test_repository2
 # Recover non-signed file
git checkout client/map.json
```

Signed-off-by: Joshua Lock <jlock@vmware.com>
2020-03-11 11:35:37 +00:00
Joshua Lock
4bd9b5ef6b Improve determinism of test repository generator
One of the created target files has its file permissions encoded in the
targets metadata via the custom attribute of the add_target() function.
On Linux-based OS the umask value of the environment the script is run
in can result in different octal permissions for the created file, i.e.
on Fedora the default umask is 0002 (default permissions 664) whereas
on Debian/Ubuntu the default umask is 0022 (default permissions 644).

Explicitly chown 'file1' to octal permissions 644 so that the generated
data has the same custom attributes for targets regardless of which
Linux host they are generated on.

Signed-off-by: Joshua Lock <jlock@vmware.com>
2020-03-11 11:35:37 +00:00
Joshua Lock
a134db0a43 Update test repository data generator
* Fix the path referenced in the Purpose
* Change add_target() calls to pass file paths relative to targets dir

Signed-off-by: Joshua Lock <jlock@vmware.com>
2020-03-11 11:35:37 +00:00
Lukas Puehringer
250a3f32a6 Add two ed25519 key pairs for updater tests
This commit also updates the key loader helper in
test_updater_root_rotation_integration.py to load
the new keys too.

The keys were created (at the root of the repository) like
so:

```
from tuf import repository_tool
repository_tool.generate_and_write_ed25519_keypair(
    "tests/repository_data/keystore/root_key2", "password")
repository_tool.generate_and_write_ed25519_keypair(
    "tests/repository_data/keystore/root_key3", "password")

```

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2019-10-07 11:59:40 +02:00
Lukas Puehringer
5d2898a13c Remove obsolete 'interposition' from docs
The interposition sub-package was removed in #537.
This commits removes obsolete mentions of 'interposition' from code
comments and documentation.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2019-09-24 14:31:54 +02:00
Lukas Puehringer
2e21950c74 Re-generate projects test metadata
Re-generate metadata to adopt spec version format change, using
`generate_project_data.py`:

```
cd tests/repository_data && rm -rf project
python generate_project_data.py
```

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2019-09-16 15:43:39 +02:00
Lukas Puehringer
af1a21b05a Re-generate repository and client test metadata
Re-generate metadata to adopt spec version format change, using
`generate.py` plus some working around (see script below):

```
 # QUICKFIX: Patch add_target to pass file paths relative to targets dir
git apply - <<EOF
diff --git a/tests/repository_data/generate.py b/tests/repository_data/generate.py
index 6c263575..699ed00f 100755
--- a/tests/repository_data/generate.py
+++ b/tests/repository_data/generate.py
@@ -119,12 +119,11 @@ if not options.dry_run:
 # about the target (i.e., file permissions in octal format.)
 octal_file_permissions = oct(os.stat(target1_filepath).st_mode)[4:]
 file_permissions = {'file_permissions': octal_file_permissions}
-repository.targets.add_target(target1_filepath, file_permissions)
-repository.targets.add_target(target2_filepath)
+repository.targets.add_target('file1.txt', file_permissions)
+repository.targets.add_target('file2.txt')

-repository.targets.delegate('role1', [delegation_public],
-    [os.path.basename(target3_filepath)])
-repository.targets('role1').add_target(target3_filepath)
+repository.targets.delegate('role1', [delegation_public], ['file3.txt'])
+repository.targets('role1').add_target('file3.txt')
 repository.targets('role1').load_signing_key(delegation_private)

 repository.targets('role1').delegate('role2', [delegation_public], [])
EOF

 # Remove repository and client data
cd repository_data && rm -rf repository client
 # Generate metadata
python generate.py
 # Duplicate metadata files
cp -r client/test_repository1 client/test_repository2
 # Recover non-signed file
git checkout client/map.json
```

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2019-09-16 15:43:39 +02:00
chentanjun
efbe0a3489 fix-up the the -> the
Signed-off-by: chentanjun <2799194073@qq.com>
2019-09-01 22:53:02 +08:00
Vladimir Diaz
a434652143
Edit test repo scripts to exclude target files with leading os.sep
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-06 11:08:45 -04:00
Vladimir Diaz
f460f46ef6
Add new repo data that excludes paths with a leading os.sep
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-06 11:06:30 -04:00
Vladimir Diaz
67af7a0da6
Add first draft of README for unit tests
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-14 11:57:59 -05:00
Vladimir Diaz
ec95a0d30f
Resolve conflicts
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:53:57 -05:00
Vladimir Diaz
60912e2280
Tweak map file to improve test coverage
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:32:49 -05:00
Vladimir Diaz
ade2b777fe
Modify repository names in map.json
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:31:53 -05:00
Vladimir Diaz
ee0ef5d4c5
Add second local repository dir (for map file)
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:31:46 -05:00
Vladimir Diaz
57313fbf6e
Fix map.json
The map file contains invalid elements.  Format map JSON similar to metadata for readability

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:31:07 -05:00
Vladimir Diaz
1c8e9e4404
Add the missing 'threshold' attribute to map.json
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:30:44 -05:00
Vladimir Diaz
c53449c086
Add working copy of map.json
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:27:19 -05:00
Vladimir Diaz
b38858b0c9
Minor edits to MultiRepoUpdater and map.json
Incorrect variable names, expand comments, etc.

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:26:54 -05:00
Vladimir Diaz
28421ae2df
Add map.json (needed for testing TAP 4 behavior)
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-12-08 16:26:44 -05:00
Vladimir Diaz
25ccb769b5
Add copyright and license to unit test scripts
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-11-30 13:26:44 -05:00
Vladimir Diaz
c897a43238
Add valid developer_tool.py metadata 2017-08-29 09:54:31 -04:00
Vladimir Diaz
d4f6362dcf
Add metadata that contains 'spec_version' 2017-08-28 15:12:57 -04:00
Vladimir Diaz
924b97d1d7
Resolve conflicts 2017-08-28 13:07:54 -04:00
Vladimir Diaz
419569c6d6
Re-generate metadata that doesn't reference compressed metadata 2017-08-25 17:26:02 -04:00
Vladimir Diaz
33721556ed
Do not generate compressed top-level repository data 2017-08-25 15:59:08 -04:00
Vladimir Diaz
bcf43e63a2
Edit metadata and code for developer_tool.py 2017-08-23 12:47:20 -04:00
Vladimir Diaz
3933232efc
Add new metadata that includes the signing scheme 2017-08-23 10:57:34 -04:00
Vladimir Diaz
4cc7c17232
Test that root.json.gz can be loaded 2017-07-13 14:40:52 -04:00
Vladimir Diaz
639818a529
Add new project metadata that uses lowercase _type entries 2017-07-12 15:04:06 -04:00
Vladimir Diaz
41954acc5b
Remove obsolete backup files (used by developer tool) 2017-07-12 15:00:39 -04:00
Vladimir Diaz
25e23d4910
Import correct key files in generate_project_data.py 2017-07-12 14:59:02 -04:00
Vladimir Diaz
6e26c31f70
Add metadata where _type = lowercase 2017-07-12 14:56:01 -04:00
Vladimir Diaz
f6d0d07a0e
Add missing root.json.gz metadata 2017-07-11 10:19:32 -04:00