Skip to content

Commit

Permalink
Merge pull request #2684 from jku/update-tuf-conformance-to-1.0
Browse files Browse the repository at this point in the history
Update tuf conformance to 1.0
  • Loading branch information
jku committed Sep 17, 2024
2 parents 8b53382 + 9b2a931 commit 8b25782
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
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"

0 comments on commit 8b25782

Please sign in to comment.