mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-05-31 14:12:07 +05:30
Added test/Utils
This commit is contained in:
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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user