diff --git a/repository_service_tuf/cli/admin/ceremony.py b/repository_service_tuf/cli/admin/ceremony.py index 1cf777f7..ba5e9f7e 100644 --- a/repository_service_tuf/cli/admin/ceremony.py +++ b/repository_service_tuf/cli/admin/ceremony.py @@ -23,7 +23,6 @@ BootstrapSetup, Roles, RSTUFKey, - ServiceSettings, TUFManagement, _conform_rsa_key, get_key, @@ -236,12 +235,12 @@ Roles.TIMESTAMP: 1, Roles.BINS: 1, }, - services=ServiceSettings(), number_of_keys={Roles.ROOT: 2, Roles.TARGETS: 1}, threshold={ Roles.ROOT: 1, Roles.TARGETS: 1, }, + number_of_delegated_bins=256, root_keys={}, online_key=RSTUFKey(), ) @@ -270,7 +269,7 @@ def _configure_role_target(): with console.pager(links=True): console.print(markdown.Markdown(HASH_BINS_EXAMPLE), width=100) - setup.services.number_of_delegated_bins = prompt.IntPrompt.ask( + setup.number_of_delegated_bins = prompt.IntPrompt.ask( "\nChoose the number of delegated hash bin roles", default=256, choices=[str(2**i) for i in range(1, 15)], # choices must be str @@ -278,15 +277,6 @@ def _configure_role_target(): show_choices=True, ) - targets_base_url = click.prompt( - "\nWhat is the targets base URL? (i.e.: " - "https://www.example.com/downloads/)" - ) - if targets_base_url.endswith("/") is False: - targets_base_url = targets_base_url + "/" - - setup.services.targets_base_url = targets_base_url - def _configure_role_root(): setup.number_of_keys[Roles.ROOT] = prompt.IntPrompt.ask( @@ -544,15 +534,12 @@ def _add_row_keys_table(table: table.Table, key: RSTUFKey, storage: str): ) if role == Roles.TARGETS: - base_url = setup.services.targets_base_url role_table.add_row( ( - f"\n[white]Base URL:[/] [yellow]{base_url}[/]" - "\n" "\n[orange1]DELEGATIONS[/]" f"\n[aquamarine3]{role.value} -> bins[/]" "\nNumber of bins: " - f"[yellow]{setup.services.number_of_delegated_bins}[/]" + f"[yellow]{setup.number_of_delegated_bins}[/]" ), "", ) diff --git a/repository_service_tuf/helpers/tuf.py b/repository_service_tuf/helpers/tuf.py index 2a732b3f..8207e1cd 100644 --- a/repository_service_tuf/helpers/tuf.py +++ b/repository_service_tuf/helpers/tuf.py @@ -5,7 +5,7 @@ import base64 import copy import json -from dataclasses import asdict, dataclass, field +from dataclasses import dataclass, field from datetime import datetime, timedelta from enum import Enum from typing import Any, Dict, List, Literal, Optional, Tuple @@ -47,16 +47,6 @@ class Roles(Enum): BINS = "bins" -@dataclass -class ServiceSettings: - number_of_delegated_bins: int = 256 - targets_base_url: str = "" - targets_online_key: bool = True - - def to_dict(self): - return asdict(self) - - @dataclass class RSTUFKey: key: dict = field(default_factory=dict) @@ -81,17 +71,26 @@ def to_dict(self) -> Dict[str, Any]: @dataclass class BootstrapSetup: expiration: Dict[Roles, int] - services: ServiceSettings number_of_keys: Dict[Literal[Roles.ROOT, Roles.TARGETS], int] threshold: Dict[Literal[Roles.ROOT, Roles.TARGETS], int] + number_of_delegated_bins: int = 256 root_keys: Dict[str, RSTUFKey] = field(default_factory=Dict) online_key: RSTUFKey = field(default_factory=RSTUFKey) - def to_dict(self): - return { - "expiration": {k.value: v for k, v in self.expiration.items()}, - "services": self.services.to_dict(), - } + def to_dict(self) -> Dict[str, Any]: + result: Dict[str, Any] = {"roles": {}} + for role in Roles: + if role.value == BINS: + result["roles"][BINS] = { + "expiration": self.expiration[role], + "number_of_delegated_bins": self.number_of_delegated_bins, + } + else: + result["roles"][role.value] = { + "expiration": self.expiration[role], + } + + return result class MetadataInfo: diff --git a/tests/conftest.py b/tests/conftest.py index cdd08b59..4078e7a0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,7 +18,6 @@ MetadataInfo, Roles, RSTUFKey, - ServiceSettings, TUFManagement, ) @@ -46,12 +45,12 @@ def test_setup() -> BootstrapSetup: Roles.TIMESTAMP: 1, Roles.BINS: 1, }, - services=ServiceSettings(), number_of_keys={Roles.ROOT: 2, Roles.TARGETS: 1}, threshold={ Roles.ROOT: 1, Roles.TARGETS: 1, }, + number_of_delegated_bins=256, root_keys={}, online_key=RSTUFKey(), ) @@ -75,7 +74,6 @@ def test_inputs() -> Tuple[List[str], List[str], List[str], List[str]]: "", # What is the metadata expiration for the targets role?(Days) (365)? # noqa "y", # Show example? "16", # Choose the number of delegated hash bin roles - "http://www.example.com/repository", # What is the targets base URL "", # What is the metadata expiration for the snapshot role?(Days) (365)? # noqa "", # What is the metadata expiration for the timestamp role?(Days) (365)? # noqa "", # What is the metadata expiration for the bins role?(Days) (365)?