From eba5602bff6f3a4853515c340a8b580e8a8b207c Mon Sep 17 00:00:00 2001 From: Christopher Gervais Date: Mon, 28 Oct 2024 14:48:06 -0400 Subject: [PATCH] Relates to #121: Print messages when TUF is enabled and during operations. --- src/Plugin.php | 2 +- src/TufValidatedComposerRepository.php | 6 +++--- tests/ComposerCommandsTest.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index c8ba9dc..c3777aa 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -117,7 +117,7 @@ private function getRepositoryFromEvent(PreFileDownloadEvent|PostFileDownloadEve */ public function activate(Composer $composer, IOInterface $io): void { - $io->debug('TUF integration enabled.'); + $io->write('TUF integration enabled. This may impact performance.'); // By the time this plugin is activated, several repositories may have // already been instantiated, and we need to convert them to diff --git a/src/TufValidatedComposerRepository.php b/src/TufValidatedComposerRepository.php index 1d34429..22e4e78 100644 --- a/src/TufValidatedComposerRepository.php +++ b/src/TufValidatedComposerRepository.php @@ -71,7 +71,7 @@ public function __construct(array $repoConfig, IOInterface $io, Config $config, $loader = new SizeCheckingLoader($loader); $this->updater = new ComposerCompatibleUpdater($loader, $storage); - $io->info("[TUF] Packages from $url are verified by TUF. This may impact performance."); + $io->write("[TUF] Packages from $url are verified by TUF."); $io->debug("[TUF] Metadata source: $metadataUrl"); } else { // @todo Usability assessment. Should we output this for other repo types, or not at all? @@ -253,7 +253,7 @@ public function validateComposerMetadata(string $url, Response $response): void $target = $this->getTargetFromUrl($url); $this->updater->verify($target, Utils::streamFor($response->getBody())); - $this->io->debug("[TUF] Target '$target' validated."); + $this->io->write("[TUF] Target '$target' validated."); } } @@ -284,7 +284,7 @@ public function validatePackage(PackageInterface $package, string $filename): vo $resource = Utils::tryFopen($filename, 'r'); $this->updater->verify($options['tuf']['target'], Utils::streamFor($resource)); - $this->io->debug("[TUF] Target '" . $options['tuf']['target'] . "' validated."); + $this->io->write("[TUF] Target '" . $options['tuf']['target'] . "' validated."); } } } diff --git a/tests/ComposerCommandsTest.php b/tests/ComposerCommandsTest.php index a9d3923..8b6e105 100644 --- a/tests/ComposerCommandsTest.php +++ b/tests/ComposerCommandsTest.php @@ -51,7 +51,7 @@ public function testRequireAndRemove(): void // debugging messages generated by the plugin, which will be logged to STDERR. $debug = $this->composer(['require', 'drupal/core-recommended', '--with-all-dependencies', '-vvv',]) ->getErrorOutput(); - $this->assertStringContainsString('TUF integration enabled.', $debug); + $this->assertStringContainsString('TUF integration enabled. This may impact performance.', $debug); $this->assertStringContainsString('[TUF] Root metadata for http://localhost:8080 loaded from ', $debug); $this->assertStringContainsString('[TUF] Packages from http://localhost:8080 are verified by TUF.', $debug); $this->assertStringContainsString('[TUF] Metadata source: http://localhost:8080/metadata/', $debug);