mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-01 16:33:07 +05:30
Added test/Utils
This commit is contained in:
parent
e20c529f39
commit
de13e14cdd
34
tests/Utils/KeyCryptTest.php
Normal file
34
tests/Utils/KeyCryptTest.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LeagueTests\Utils;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\Utils\KeyCrypt;
|
||||||
|
|
||||||
|
class KeyCryptTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testEncryptDecrypt()
|
||||||
|
{
|
||||||
|
$payload = 'alex loves whisky';
|
||||||
|
$encrypted = KeyCrypt::encrypt($payload, 'file://'.__DIR__.'/private.key');
|
||||||
|
$plainText = KeyCrypt::decrypt($encrypted, 'file://'.__DIR__.'/public.key');
|
||||||
|
|
||||||
|
$this->assertNotEquals($payload, $encrypted);
|
||||||
|
$this->assertEquals($payload, $plainText);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \LogicException
|
||||||
|
*/
|
||||||
|
public function testBadPrivateKey()
|
||||||
|
{
|
||||||
|
KeyCrypt::encrypt('', 'file://'.__DIR__.'/public.key');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \LogicException
|
||||||
|
*/
|
||||||
|
public function testBadPublicKey()
|
||||||
|
{
|
||||||
|
KeyCrypt::decrypt('', 'file://'.__DIR__.'/private.key');
|
||||||
|
}
|
||||||
|
}
|
13
tests/Utils/SecureKeyTest.php
Normal file
13
tests/Utils/SecureKeyTest.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LeagueTests\Utils;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\Utils\SecureKey;
|
||||||
|
|
||||||
|
class SecureKeyTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testGenerate()
|
||||||
|
{
|
||||||
|
$this->assertTrue(is_string(SecureKey::generate()));
|
||||||
|
}
|
||||||
|
}
|
15
tests/Utils/private.key
Normal file
15
tests/Utils/private.key
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIICXgIBAAKBgQDOBcFjGUlo3BJ9zjwQLgAHn6Oy5Si0uB7MublTiPob8rWTiCE4
|
||||||
|
weAFqzPoAB07vB0t0f8c1R8rmwHMD5ljWPBgJ8FewtwAUzprOBcau6DWukd/TKxX
|
||||||
|
WeVLAl/NZxijI+jR5QDBYLNBtj1G4LBVHMmINd3ryCycbf9ac3rcC8zhrQIDAQAB
|
||||||
|
AoGADfOJ0wIlXHp6rhZHLvlOezWuSjEGfqZxP3/cMvH1rerTrPfs+AD5AKlFTJKl
|
||||||
|
aCQm/bFYy0ULZVKL3pu30Wh2bo1nh/wLuLSI9Nz3O8jqAP3z0i07SoRoQmb8fRnn
|
||||||
|
dwoDFqnk3uGqcOenheSqheIgl9vdW/3avhD6nkMKZGxPYwECQQDoSj/xHogEzMqB
|
||||||
|
1Z2E5H/exeE9GQ7+dGITRR2MSgo9WvcKdRhGaQ44dsnTmqiZWAfqAPJjTQIIA/Cn
|
||||||
|
YRRTeBbNAkEA4w0iEvCIygGQOAnWuvVzlh+pxIB+BTeGkbiBG7nkYYc9b6B/Tw1B
|
||||||
|
GWGRddBr/FIfPvy1X2ip/TBpH+9bHnE2YQJBAIbZw/EYhmIy+UUSW9WwSUNsoOu1
|
||||||
|
Rm0V53HEZ/jvaq5fxpa9j5AgoO7KlzROzp3m6wE/93cKV6mLkAO7ae9jAekCQQCf
|
||||||
|
B6DZIS6+RrAMACAt3SOzf8P6BYG/B7Ayusd7cw2ang4S9JiW9xKkw2kN2wj3t1F5
|
||||||
|
XalwBTAjTdgj7ROmU+ehAkEAkOyXKONGBoVfaixRHgBP6jIBSSPbB2Aosi0QAURX
|
||||||
|
6GOY7wOS1pCSntTOBQxV7wVjqFwYAR10MSxFSNfpJ7RkzA==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
6
tests/Utils/public.key
Normal file
6
tests/Utils/public.key
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOBcFjGUlo3BJ9zjwQLgAHn6Oy
|
||||||
|
5Si0uB7MublTiPob8rWTiCE4weAFqzPoAB07vB0t0f8c1R8rmwHMD5ljWPBgJ8Fe
|
||||||
|
wtwAUzprOBcau6DWukd/TKxXWeVLAl/NZxijI+jR5QDBYLNBtj1G4LBVHMmINd3r
|
||||||
|
yCycbf9ac3rcC8zhrQIDAQAB
|
||||||
|
-----END PUBLIC KEY-----
|
Loading…
Reference in New Issue
Block a user