features/commands/initialize.local.featureRunning behat features/commands/initialize.local.feature results in:
@rugged @commands-local @initialize
Feature: Command to initialize Rugged TUF repository locally.
In order to host TUF metadata
As an administrator
I need to initialize a TUF repo locally.
Background:
Given I reset Rugged
And local Rugged directories exist
Scenario: The 'initialize' Rugged command exists.
When I try to run "sudo sudo -u rugged rugged initialize --help"
Then I should not get:
"""
Error: No such command 'initialize'.
"""
And I should get:
"""
Usage: rugged initialize [OPTIONS]
Initialize a new TUF repository.
Options:
--local Generate keys locally, rather than delegating to the root worker.
--help Show this message and exit.
"""
Scenario: Initialize repository locally.
When I run the Rugged command "rugged generate-keys --local"
When I run the Rugged command "rugged --debug initialize --local"
Then I should get:
"""
Initializing new TUF repository at /var/rugged/tuf_repo.
TUF repository initialized.
"""
And the "/var/rugged/tuf_repo/targets" directory should exist
When I run the Rugged command "rugged logs --local --limit=0"
Then I should get:
"""
Initializing new TUF repository locally.
Initializing new TUF repository at /var/rugged/tuf_repo.
Instantiated repository.
Signed 'targets' metadata with 'targets' key.
Wrote 'targets' metadata to file '/var/rugged/tuf_repo/metadata/targets.json'.
Signed 'snapshot' metadata with 'snapshot' key.
Wrote 'snapshot' metadata to file '/var/rugged/tuf_repo/metadata/snapshot.json'.
Signed 'timestamp' metadata with 'timestamp' key.
Wrote 'timestamp' metadata to file '/var/rugged/tuf_repo/metadata/timestamp.json'.
Signed 'root' metadata with 'root' key.
Signed 'root' metadata with 'root1' key.
Wrote 'root' metadata to file '/var/rugged/tuf_repo/metadata/1.root.json'.
TUF repository initialized.
"""
When I try to run the Rugged command "rugged logs --worker=root-worker --limit=0"
Then I should not get:
"""
Received 'initialize' task.
Initializing new TUF repository at /var/rugged/tuf_repo.
/var/rugged/tuf_repo
TUF repository initialized.
"""
When I run "ls /var/rugged/tuf_repo"
Then I should get:
"""
metadata
targets
"""
And I should not get:
"""
Permission denied
"""
When I run "ls /var/rugged/tuf_repo/metadata"
Then I should get:
"""
1.root.json
"""
When I run the Rugged command "rugged validate metadata"
Then I should get:
"""
Metadata for the 'root' role is valid.
Metadata for the 'timestamp' role is valid.
Metadata for the 'snapshot' role is valid.
Metadata for the 'targets' role is valid.
"""
And I should not get:
"""
error: Metadata for the 'root' role is not valid.
error: Metadata for the 'timestamp' role is not valid.
error: Metadata for the 'snapshot' role is not valid.
error: Metadata for the 'targets' role is not valid.
"""
Scenario: Fail gracefully on initialization errors.
Given I run "sudo chmod 000 /var/rugged/tuf_repo"
When I fail to run the Rugged command "rugged --debug initialize --local"
Then I should get:
"""
error: Failed to initialize repository at /var/rugged/tuf_repo.
Failed to initialize TUF repository. Check the logs for more detailed error reporting.
"""
And I should not get:
"""
TUF repository initialized.
"""
When I run the Rugged command "rugged logs --local --limit=0"
Then I should get:
"""
Initializing new TUF repository locally.
Initializing new TUF repository at /var/rugged/tuf_repo.
RuggedStorageError: The repository could not create the needed directories.
RuggedStorageError thrown in __init__: The repository could not create the needed directories.
Failed to instantiate repository.
RuggedRepositoryError: The repository could not load a repository at the given path.
RuggedRepositoryError thrown in init_repo: The repository could not load a repository at the given path.
Failed to initialize repository at /var/rugged/tuf_repo.
"""
And I should not get:
"""
TUF repository initialized.
"""
Scenario: Fail gracefully on metadata errors.
Given I run the Rugged command "rugged generate-keys --local --role=root"
And I run the Rugged command "rugged generate-keys --local --role=snapshot"
And I run the Rugged command "rugged generate-keys --local --role=timestamp"
When I fail to run the Rugged command "rugged --debug initialize --local"
Then I should get:
"""
debug: Setting 'snapshot' signature threshold to 1.
error: Failed to instantiate repository.
debug: RuggedRepositoryError: The repository could not load a repository at the given path.
error: RuggedRepositoryError thrown in init_repo: The repository could not load a repository at the given path.
error: Failed to initialize repository at /var/rugged/tuf_repo.
Failed to initialize TUF repository. Check the logs for more detailed error reporting.
"""
And I should not get:
"""
TUF repository initialized.
"""
When I run the Rugged command "rugged logs --local --limit=0"
Then I should get:
"""
Initializing new TUF repository locally.
Initializing new TUF repository at /var/rugged/tuf_repo.
Failed to instantiate repository.
RuggedRepositoryError: The repository could not load a repository at the given path.
Failed to initialize repository at /var/rugged/tuf_repo.
"""
And I should not get:
"""
TUF repository initialized.
"""
4 scenarios (4 passed)
43 steps (43 passed)