Skip to content

Commit 86d8310

Browse files
authored
chore: cleanup tests (firebase#372)
1 parent 7480196 commit 86d8310

16 files changed

+25
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ phpunit.phar
33
phpunit.phar.asc
44
composer.phar
55
composer.lock
6+
.phpunit.result.cache

tests/JWKTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testParsePrivateKey()
4040
);
4141

4242
$jwkSet = json_decode(
43-
file_get_contents(__DIR__ . '/rsa-jwkset.json'),
43+
file_get_contents(__DIR__ . '/data/rsa-jwkset.json'),
4444
true
4545
);
4646
$jwkSet['keys'][0]['d'] = 'privatekeyvalue';
@@ -56,7 +56,7 @@ public function testParsePrivateKeyWithoutAlg()
5656
);
5757

5858
$jwkSet = json_decode(
59-
file_get_contents(__DIR__ . '/rsa-jwkset.json'),
59+
file_get_contents(__DIR__ . '/data/rsa-jwkset.json'),
6060
true
6161
);
6262
unset($jwkSet['keys'][0]['alg']);
@@ -67,7 +67,7 @@ public function testParsePrivateKeyWithoutAlg()
6767
public function testParseKeyWithEmptyDValue()
6868
{
6969
$jwkSet = json_decode(
70-
file_get_contents(__DIR__ . '/rsa-jwkset.json'),
70+
file_get_contents(__DIR__ . '/data/rsa-jwkset.json'),
7171
true
7272
);
7373

@@ -81,7 +81,7 @@ public function testParseKeyWithEmptyDValue()
8181
public function testParseJwkKeySet()
8282
{
8383
$jwkSet = json_decode(
84-
file_get_contents(__DIR__ . '/rsa-jwkset.json'),
84+
file_get_contents(__DIR__ . '/data/rsa-jwkset.json'),
8585
true
8686
);
8787
$keys = JWK::parseKeySet($jwkSet);
@@ -109,7 +109,7 @@ public function testParseJwkKeySet_empty()
109109
*/
110110
public function testDecodeByJwkKeySetTokenExpired()
111111
{
112-
$privKey1 = file_get_contents(__DIR__ . '/rsa1-private.pem');
112+
$privKey1 = file_get_contents(__DIR__ . '/data/rsa1-private.pem');
113113
$payload = array('exp' => strtotime('-1 hour'));
114114
$msg = JWT::encode($payload, $privKey1, 'RS256', 'jwk1');
115115

@@ -123,7 +123,7 @@ public function testDecodeByJwkKeySetTokenExpired()
123123
*/
124124
public function testDecodeByJwkKeySet()
125125
{
126-
$privKey1 = file_get_contents(__DIR__ . '/rsa1-private.pem');
126+
$privKey1 = file_get_contents(__DIR__ . '/data/rsa1-private.pem');
127127
$payload = array('sub' => 'foo', 'exp' => strtotime('+10 seconds'));
128128
$msg = JWT::encode($payload, $privKey1, 'RS256', 'jwk1');
129129

@@ -137,7 +137,7 @@ public function testDecodeByJwkKeySet()
137137
*/
138138
public function testDecodeByMultiJwkKeySet()
139139
{
140-
$privKey2 = file_get_contents(__DIR__ . '/rsa2-private.pem');
140+
$privKey2 = file_get_contents(__DIR__ . '/data/rsa2-private.pem');
141141
$payload = array('sub' => 'bar', 'exp' => strtotime('+10 seconds'));
142142
$msg = JWT::encode($payload, $privKey2, 'RS256', 'jwk2');
143143

tests/JWTTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public function testInvalidEdDsaEncodeDecode()
312312
public function testRSEncodeDecodeWithPassphrase()
313313
{
314314
$privateKey = openssl_pkey_get_private(
315-
file_get_contents(__DIR__ . '/rsa-with-passphrase.pem'),
315+
file_get_contents(__DIR__ . '/data/rsa-with-passphrase.pem'),
316316
'passphrase'
317317
);
318318

@@ -343,18 +343,18 @@ public function testEncodeDecode($privateKeyFile, $publicKeyFile, $alg)
343343
public function provideEncodeDecode()
344344
{
345345
return array(
346-
array(__DIR__ . '/ecdsa-private.pem', __DIR__ . '/ecdsa-public.pem', 'ES256'),
347-
array(__DIR__ . '/ecdsa384-private.pem', __DIR__ . '/ecdsa384-public.pem', 'ES384'),
348-
array(__DIR__ . '/rsa1-private.pem', __DIR__ . '/rsa1-public.pub', 'RS512'),
349-
array(__DIR__ . '/ed25519-1.sec', __DIR__ . '/ed25519-1.pub', 'EdDSA'),
346+
array(__DIR__ . '/data/ecdsa-private.pem', __DIR__ . '/data/ecdsa-public.pem', 'ES256'),
347+
array(__DIR__ . '/data/ecdsa384-private.pem', __DIR__ . '/data/ecdsa384-public.pem', 'ES384'),
348+
array(__DIR__ . '/data/rsa1-private.pem', __DIR__ . '/data/rsa1-public.pub', 'RS512'),
349+
array(__DIR__ . '/data/ed25519-1.sec', __DIR__ . '/data/ed25519-1.pub', 'EdDSA'),
350350
);
351351
}
352352

353353
public function testEncodeDecodeWithResource()
354354
{
355-
$pem = file_get_contents(__DIR__ . '/rsa1-public.pub');
355+
$pem = file_get_contents(__DIR__ . '/data/rsa1-public.pub');
356356
$resource = openssl_pkey_get_public($pem);
357-
$privateKey = file_get_contents(__DIR__ . '/rsa1-private.pem');
357+
$privateKey = file_get_contents(__DIR__ . '/data/rsa1-private.pem');
358358

359359
$payload = array('foo' => 'bar');
360360
$encoded = JWT::encode($payload, $privateKey, 'RS512');

tests/autoload.php.dist

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/bootstrap.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<?php
22

3-
if (file_exists($file = __DIR__ . '/autoload.php')) {
4-
require_once $file;
5-
} elseif (file_exists($file = __DIR__ . '/autoload.php.dist')) {
3+
if (file_exists($file = __DIR__ . '/../vendor/autoload.php')) {
64
require_once $file;
5+
} else {
6+
die('Unable to find autoload.php file, please use composer to load dependencies:
7+
8+
wget http://getcomposer.org/composer.phar
9+
php composer.phar install
10+
11+
Visit http://getcomposer.org/ for more information.
12+
13+
');
714
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)