Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add python-tuf v3.0.0 support #515

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/python_interop/python_interop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (InteropSuite) TestGoClientPythonGenerated(c *C) {
// start file server
cwd, err := os.Getwd()
c.Assert(err, IsNil)
testDataDir := filepath.Join(cwd, "testdata", "python-tuf-v2.0.0")
testDataDir := filepath.Join(cwd, "testdata", "python-tuf-v3.0.0")
addr, cleanup := startFileServer(c, testDataDir)
defer cleanup()

Expand Down Expand Up @@ -145,7 +145,7 @@ func (InteropSuite) TestPythonClientGoGenerated(c *C) {
c.Assert(os.WriteFile(filepath.Join(currDir, "root.json"), rootJSON, 0644), IsNil)

args := []string{
filepath.Join(cwd, "testdata", "python-tuf-v2.0.0", "client.py"),
filepath.Join(cwd, "testdata", "python-tuf-v3.0.0", "client.py"),
"--repo=http://" + addr + "/" + name,
}
for path := range files {
Expand Down Expand Up @@ -204,7 +204,7 @@ func (InteropSuite) TestPythonClientGoGeneratedNullDelegations(c *C) {
c.Assert(os.WriteFile(filepath.Join(currDir, "root.json"), rootJSON, 0644), IsNil)

args := []string{
filepath.Join(cwd, "testdata", "python-tuf-v2.0.0", "client.py"),
filepath.Join(cwd, "testdata", "python-tuf-v3.0.0", "client.py"),
"--repo=http://" + addr + "/" + name,
}
for path := range files {
Expand Down
2 changes: 1 addition & 1 deletion client/python_interop/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PYTHON_TUF=python-tuf-v2.0.0
PYTHON_TUF=python-tuf-v3.0.0

all:
docker build -t tuf-gen ./$(PYTHON_TUF)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.10

RUN apt-get update && apt-get install -y libsodium-dev tree
RUN pip install -U pip && pip install 'securesystemslib[crypto,pynacl]==0.25.0' 'tuf==v2.0.0'
RUN pip install -U pip && pip install 'securesystemslib[crypto,pynacl]==0.28.0' 'tuf==v3.0.0'

ADD generate.py generate.sh /
CMD /generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from typing import List
from pathlib import Path

import tuf.api

from tuf.ngclient import Updater


Expand All @@ -35,7 +33,8 @@ def update_client(repo: str, targets: List[str]):


def parse_arguments():
parser = argparse.ArgumentParser(description="Retrieve file from TUF repository.")
parser = argparse.ArgumentParser(
description="Retrieve file from TUF repository.")

parser.add_argument(
"-r",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
from pathlib import Path
from typing import Dict

import securesystemslib.util

from securesystemslib.keys import generate_ed25519_key
from securesystemslib.signer import SSlibSigner
from securesystemslib.signer import SSlibSigner, SSlibKey
from tuf.api.metadata import (
Key,
Metadata,
MetaFile,
Role,
Expand All @@ -43,11 +40,14 @@ def make_targets(target_dir: Path, consistent_snapshot: bool) -> Dict[str, Targe
for target in (Path("file1.txt"), Path("dir/file2.txt")):
target_fspath = target_dir / target
target_fspath.parent.mkdir(parents=True, exist_ok=True)
target_fspath.write_text(target.name) # file contents are the file name
target_file_info = TargetFile.from_file(str(target), str(target_fspath))
# file contents are the file name
target_fspath.write_text(target.name)
target_file_info = TargetFile.from_file(
str(target), str(target_fspath))
if consistent_snapshot:
digest = next(iter(target_file_info.hashes.values()))
shutil.move(target_fspath, target_fspath.parent / f"{digest}.{target.name}")
shutil.move(target_fspath, target_fspath.parent /
f"{digest}.{target.name}")
targets[str(target)] = target_file_info
return targets

Expand Down Expand Up @@ -93,9 +93,10 @@ def make_test_repo(repo_dir: Path, consistent_snapshot: bool):
spec_version=SPEC_VERSION,
expires=EXPIRY,
keys={
key["keyid"]: Key.from_securesystemslib_key(key) for key in keys.values()
key["keyid"]: SSlibKey.from_securesystemslib_key(key) for key in keys.values()
},
roles={role: Role([key["keyid"]], threshold=1) for role, key in keys.items()},
roles={role: Role([key["keyid"]], threshold=1)
for role, key in keys.items()},
consistent_snapshot=consistent_snapshot,
)
roles["root"] = Metadata[Root](root_metadata, {})
Expand Down
Loading