Skip to content

Commit

Permalink
fix: pass auth http handler to update metadata call (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
yash30201 authored Apr 22, 2024
1 parent cc102eb commit 6e04a50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/CredentialsWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function getAuthorizationHeaderCallback($audience = null)

// Call updateMetadata to take advantage of self-signed JWTs
if ($this->credentialsFetcher instanceof UpdateMetadataInterface) {
return $this->credentialsFetcher->updateMetadata([], $audience);
return $this->credentialsFetcher->updateMetadata([], $audience, $this->authHttpHandler);
}

// In case a custom fetcher is provided (unlikely) which doesn't
Expand Down
5 changes: 3 additions & 2 deletions tests/Tests/Unit/CredentialsWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ public function getBearerStringData()
*/
public function testGetAuthorizationHeaderCallback($fetcher, $expectedCallbackResponse)
{
$credentialsWrapper = new CredentialsWrapper($fetcher);
$httpHandler = function () {};
$credentialsWrapper = new CredentialsWrapper($fetcher, $httpHandler);
$callback = $credentialsWrapper->getAuthorizationHeaderCallback('audience');
$actualResponse = $callback();
$this->assertSame($expectedCallbackResponse, $actualResponse);
Expand All @@ -385,7 +386,7 @@ public function getAuthorizationHeaderCallbackData()
'access_token' => 123,
'expires_at' => time() - 1
]);
$expiredFetcher->updateMetadata(Argument::any(), 'audience')
$expiredFetcher->updateMetadata(Argument::any(), 'audience', Argument::type('callable'))
->willReturn(['authorization' => ['Bearer 456']]);
$expiredInvalidFetcher = $this->prophesize(FetchAuthTokenInterface::class);
$expiredInvalidFetcher->getLastReceivedToken()
Expand Down

0 comments on commit 6e04a50

Please sign in to comment.