diff --git a/src/Downloading/GithubPackageReleaseAssets.php b/src/Downloading/GithubPackageReleaseAssets.php index 8eb891c..38075bf 100644 --- a/src/Downloading/GithubPackageReleaseAssets.php +++ b/src/Downloading/GithubPackageReleaseAssets.php @@ -77,13 +77,14 @@ private function getReleaseAssetsForPackage( Assert::notNull($package->downloadUrl()); try { - $decodedRepsonse = $httpDownloader->get( + $authOptions = $authHelper->addAuthenticationOptions([], $this->githubApiBaseUrl, $package->downloadUrl()); + $decodedRepsonse = $httpDownloader->get( $this->githubApiBaseUrl . '/repos/' . $package->githubOrgAndRepository() . '/releases/tags/' . $package->version(), [ 'retry-auth-failure' => true, 'http' => [ 'method' => 'GET', - 'header' => $authHelper->addAuthenticationHeader([], $this->githubApiBaseUrl, $package->downloadUrl()), + 'header' => $authOptions['http']['header'], ], ], )->decodeJson(); diff --git a/src/SelfManage/Update/FetchPieReleaseFromGitHub.php b/src/SelfManage/Update/FetchPieReleaseFromGitHub.php index e56ce9e..f047543 100644 --- a/src/SelfManage/Update/FetchPieReleaseFromGitHub.php +++ b/src/SelfManage/Update/FetchPieReleaseFromGitHub.php @@ -34,13 +34,14 @@ public function latestReleaseMetadata(): ReleaseMetadata { $url = $this->githubApiBaseUrl . self::PIE_LATEST_RELEASE_URL; - $decodedRepsonse = $this->httpDownloader->get( + $authOptions = $this->authHelper->addAuthenticationOptions([], $this->githubApiBaseUrl, $url); + $decodedRepsonse = $this->httpDownloader->get( $url, [ 'retry-auth-failure' => true, 'http' => [ 'method' => 'GET', - 'header' => $this->authHelper->addAuthenticationHeader([], $this->githubApiBaseUrl, $url), + 'header' => $authOptions['http']['header'], ], ], )->decodeJson(); @@ -78,13 +79,14 @@ static function (array $asset): bool { public function downloadContent(ReleaseMetadata $releaseMetadata): BinaryFile { + $authOptions = $this->authHelper->addAuthenticationOptions([], $this->githubApiBaseUrl, $releaseMetadata->downloadUrl); $pharContent = $this->httpDownloader->get( $releaseMetadata->downloadUrl, [ 'retry-auth-failure' => true, 'http' => [ 'method' => 'GET', - 'header' => $this->authHelper->addAuthenticationHeader([], $this->githubApiBaseUrl, $releaseMetadata->downloadUrl), + 'header' => $authOptions['http']['header'], ], ], )->getBody(); diff --git a/src/SelfManage/Verify/FallbackVerificationUsingOpenSsl.php b/src/SelfManage/Verify/FallbackVerificationUsingOpenSsl.php index aca1f7c..3631aa7 100644 --- a/src/SelfManage/Verify/FallbackVerificationUsingOpenSsl.php +++ b/src/SelfManage/Verify/FallbackVerificationUsingOpenSsl.php @@ -282,13 +282,14 @@ private function downloadAttestations(ReleaseMetadata $releaseMetadata, BinaryFi $attestationUrl = $this->githubApiBaseUrl . '/orgs/php/attestations/sha256:' . $pharFilename->checksum; try { - $decodedJson = $this->httpDownloader->get( + $authOptions = $this->authHelper->addAuthenticationOptions([], $this->githubApiBaseUrl, $attestationUrl); + $decodedJson = $this->httpDownloader->get( $attestationUrl, [ 'retry-auth-failure' => true, 'http' => [ 'method' => 'GET', - 'header' => $this->authHelper->addAuthenticationHeader([], $this->githubApiBaseUrl, $attestationUrl), + 'header' => $authOptions['http']['header'], ], ], )->decodeJson(); diff --git a/test/unit/SelfManage/Update/FetchPieReleaseFromGitHubTest.php b/test/unit/SelfManage/Update/FetchPieReleaseFromGitHubTest.php index 5af96f3..c1f582b 100644 --- a/test/unit/SelfManage/Update/FetchPieReleaseFromGitHubTest.php +++ b/test/unit/SelfManage/Update/FetchPieReleaseFromGitHubTest.php @@ -29,8 +29,8 @@ public function testLatestReleaseMetadata(): void $url = self::TEST_GITHUB_URL . '/repos/php/pie/releases/latest'; $authHelper - ->method('addAuthenticationHeader') - ->willReturn(['Authorization: Bearer fake-token']); + ->method('addAuthenticationOptions') + ->willReturn(['http' => ['header' => ['Authorization: Bearer fake-token']]]); $httpDownloader->expects(self::once()) ->method('get') ->with( @@ -84,8 +84,8 @@ public function testDownloadContent(): void $authHelper = $this->createMock(AuthHelper::class); $authHelper - ->method('addAuthenticationHeader') - ->willReturn(['Authorization: Bearer fake-token']); + ->method('addAuthenticationOptions') + ->willReturn(['http' => ['header' => ['Authorization: Bearer fake-token']]]); $httpDownloader->expects(self::once()) ->method('get') ->with( diff --git a/test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php b/test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php index cf820c1..ab5b2a7 100644 --- a/test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php +++ b/test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php @@ -135,8 +135,8 @@ private function mockAttestationResponse(string $digestInUrl, string $dsseEnvelo { $url = self::TEST_GITHUB_URL . '/orgs/php/attestations/sha256:' . $digestInUrl; $this->authHelper - ->method('addAuthenticationHeader') - ->willReturn(['Authorization: Bearer fake-token']); + ->method('addAuthenticationOptions') + ->willReturn(['http' => ['header' => ['Authorization: Bearer fake-token']]]); $this->httpDownloader->expects(self::once()) ->method('get') ->with( @@ -267,8 +267,8 @@ public function testFailedToVerifyBecauseDigestNotFoundOnGitHub(): void $transportException->setStatusCode(404); $this->authHelper - ->method('addAuthenticationHeader') - ->willReturn(['Authorization: Bearer fake-token']); + ->method('addAuthenticationOptions') + ->willReturn(['http' => ['header' => ['Authorization: Bearer fake-token']]]); $this->httpDownloader->expects(self::once()) ->method('get') ->willThrowException($transportException);