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

Update tuf conformance to 1.0 #2684

Merged
merged 3 commits into from
Sep 17, 2024
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
22 changes: 2 additions & 20 deletions .github/scripts/conformance-client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import os
import shutil
import sys
from datetime import datetime, timedelta, timezone

from tuf.ngclient import Updater, UpdaterConfig
from tuf.ngclient import Updater


def init(metadata_dir: str, trusted_root: str) -> None:
Expand All @@ -21,23 +20,13 @@ def init(metadata_dir: str, trusted_root: str) -> None:
print(f"python-tuf test client: Initialized repository in {metadata_dir}")


def refresh(
metadata_url: str,
metadata_dir: str,
days_in_future: str,
max_root_rotations: int,
) -> None:
def refresh(metadata_url: str, metadata_dir: str) -> None:
"""Refresh local metadata from remote"""

updater = Updater(
metadata_dir,
metadata_url,
config=UpdaterConfig(max_root_rotations=int(max_root_rotations)),
)
if days_in_future != "0":
day_int = int(days_in_future)
day_in_future = datetime.now(timezone.utc) + timedelta(days=day_int)
updater._trusted_set.reference_time = day_in_future # noqa: SLF001
updater.refresh()
print(f"python-tuf test client: Refreshed metadata in {metadata_dir}")

Expand All @@ -56,7 +45,6 @@ def download_target(
metadata_url,
download_dir,
target_base_url,
config=UpdaterConfig(prefix_targets_with_hash=False),
)
target_info = updater.get_targetinfo(target_name)
if not target_info:
Expand All @@ -73,10 +61,6 @@ def main() -> int:
parser.add_argument("--target-name", required=False)
parser.add_argument("--target-dir", required=False)
parser.add_argument("--target-base-url", required=False)
parser.add_argument("--days-in-future", required=False, default="0")
parser.add_argument(
"--max-root-rotations", required=False, default=32, type=int
)

sub_command = parser.add_subparsers(dest="sub_command")
init_parser = sub_command.add_parser(
Expand Down Expand Up @@ -104,8 +88,6 @@ def main() -> int:
refresh(
command_args.metadata_url,
command_args.metadata_dir,
command_args.days_in_future,
command_args.max_root_rotations,
)
elif command_args.sub_command == "download":
download_target(
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
on:
# manual dispatch only while the conformance test suite is under rapid development
push:
branches:
- develop
pull_request:
workflow_dispatch:

permissions:
contents: read

name: Conformance test
jobs:
conformance:
Expand All @@ -11,6 +17,6 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Run test suite
uses: theupdateframework/tuf-conformance@main
uses: theupdateframework/tuf-conformance@5ae68349ec6b85ae443c110d967ac21807f1cdb7 # v1.0.0
with:
entrypoint: ".github/scripts/conformance-client.py"