Skip to content

Commit

Permalink
bug #1267 Fix wrongly silenced signing failure (chalasr)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.x branch.

Discussion
----------

Fix wrongly silenced signing failure

Thanks `@backendtea` for the patch!

Commits
-------

6a3d6c3 Fix wrongly silenced signing failure
  • Loading branch information
chalasr committed Jan 6, 2025
2 parents d40886d + 6a3d6c3 commit d64e176
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Services/JWSProvider/LcobucciJWSProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,9 @@ public function create(array $payload, array $header = []): CreatedJWS
$jws = $jws->withClaim($name, $value);
}

$e = $token = null;
try {
$token = $this->getSignedToken($jws);
} catch (\InvalidArgumentException) {
}
$token = $this->getSignedToken($jws);

return new CreatedJWS((string) $token, null === $e);
return new CreatedJWS((string) $token, true);
}

/**
Expand Down
16 changes: 16 additions & 0 deletions Tests/Services/JWSProvider/LcobucciJWSProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,20 @@ protected function createMultiplePublicKeysTestToken()

return $jwsProvider->create($payload)->getToken();
}

public function testUnSignedToken()
{
$keyLoaderMock = $this->getKeyLoaderMock();
$keyLoaderMock
->expects($this->once())
->method('loadKey')
->willThrowException($e = new \InvalidArgumentException("It was not possible to parse your key, reason:\n* error:1E08010C:DECODER routines::unsupported"));

$jwsProvider = new self::$providerClass($keyLoaderMock, 'RS256', 3600, 0);
$payload = ['username' => 'chalasr', 'iat' => time()];

$this->expectExceptionObject($e);

$create = $jwsProvider->create($payload);
}
}

0 comments on commit d64e176

Please sign in to comment.