-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Ekman/feature/tests
Add a unit test. Move "ext-gmp" to suggested dependency
- Loading branch information
Showing
5 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
/vendor | ||
/.idea | ||
.DS_Store | ||
phpunit.xml | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd" | ||
bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="unit tests"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
namespace CoderCat\JWKToPEM\Tests; | ||
|
||
use CoderCat\JWKToPEM\JWKConverter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class JWKConverterTest extends TestCase | ||
{ | ||
/** @var JWKConverter */ | ||
private $jwkConverter; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->jwkConverter = new JwkConverter(); | ||
} | ||
|
||
/** @dataProvider provideToPem */ | ||
public function testToPem($jwk, $expected) | ||
{ | ||
$this->assertEquals($expected, $this->jwkConverter->toPem($jwk)); | ||
} | ||
|
||
public function provideToPem() | ||
{ | ||
return [ | ||
[ | ||
[ | ||
"kty" => "RSA", | ||
"kid" => "zhA-H1DWOSgWQAIW7mewCYeaZLGpkgW_hXfq8jmV99I", | ||
"use" => "sig", | ||
"alg" => "RS256", | ||
"e" => "AQAB", | ||
"n" => "vdv73smpkrTIBSM8ka-pVXbNi7zYalm0R6WFBH4X8PQj8C7VfdckGsA6bTBseOVCTbu187_63yU2U7vqYiqwSLmkrBVAJjYMJY_XXfncxwqDWR_aa7eIJSKh22H_6yz6kFyF1h_ZSk68CPAEQpvd9VFAr4VLEwD32Ag6MwymSOxmFWJyddEtttdGcXLSrHcya3RWyG5KAW3Ti-HgNC-xo_C5LgEsUgjeUq-rc8NBXZrNCY-LJ_R-qtB_-5NkwlMJ_fUMBDcmZuciNOH71q7xyn0FGmGjrJXnyVJwyDiTrKRO36piMuiaJE2nIRJaLvhDN5M1K2VhSKPuaqUPyxLzBw" | ||
], | ||
"-----BEGIN PUBLIC KEY-----" . PHP_EOL | ||
. "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvdv73smpkrTIBSM8ka+p" . PHP_EOL | ||
. "VXbNi7zYalm0R6WFBH4X8PQj8C7VfdckGsA6bTBseOVCTbu187/63yU2U7vqYiqw" . PHP_EOL | ||
. "SLmkrBVAJjYMJY/XXfncxwqDWR/aa7eIJSKh22H/6yz6kFyF1h/ZSk68CPAEQpvd" . PHP_EOL | ||
. "9VFAr4VLEwD32Ag6MwymSOxmFWJyddEtttdGcXLSrHcya3RWyG5KAW3Ti+HgNC+x" . PHP_EOL | ||
. "o/C5LgEsUgjeUq+rc8NBXZrNCY+LJ/R+qtB/+5NkwlMJ/fUMBDcmZuciNOH71q7x" . PHP_EOL | ||
. "yn0FGmGjrJXnyVJwyDiTrKRO36piMuiaJE2nIRJaLvhDN5M1K2VhSKPuaqUPyxLz" . PHP_EOL | ||
. "BwIDAQAB" . PHP_EOL | ||
. "-----END PUBLIC KEY-----" | ||
] | ||
]; | ||
} | ||
} |