Skip to content

Commit

Permalink
Add a status code to the IdentityProviderException
Browse files Browse the repository at this point in the history
Previously this exception would always have `0` as the status code,
making it impossible to know what was the status of the response that
caused that exception.
  • Loading branch information
LiquidPL authored and mstefan21 committed Oct 24, 2023
1 parent fdd159f commit 1b690b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Provider/Keycloak.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ protected function checkResponse(ResponseInterface $response, $data)
if (isset($data['error_description'])) {
$error .= ': '.$data['error_description'];
}
throw new IdentityProviderException($error, 0, $data);
throw new IdentityProviderException($error, $response->getStatusCode(), $data);
}
}

Expand Down
4 changes: 3 additions & 1 deletion test/src/Provider/KeycloakTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,9 @@ public function testErrorResponse()
->andReturn($accessTokenResponseStream);
$response
->shouldReceive('getHeader')
->andReturn(['content-type' => 'json']);
$response
->shouldReceive('getStatusCode')
->andReturn(401);

$client = m::mock('GuzzleHttp\ClientInterface');
$client
Expand Down

0 comments on commit 1b690b7

Please sign in to comment.