2016-07-19 20:45:36 +05:30
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace LeagueTests\Utils;
|
|
|
|
|
|
|
|
use League\OAuth2\Server\CryptKey;
|
|
|
|
|
|
|
|
class CryptKeyTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @expectedException \LogicException
|
|
|
|
*/
|
|
|
|
public function testNoFile()
|
|
|
|
{
|
|
|
|
new CryptKey('undefined file');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testKeyCreation()
|
|
|
|
{
|
|
|
|
$keyFile = __DIR__ . '/Stubs/public.key';
|
|
|
|
$key = new CryptKey($keyFile, 'secret');
|
|
|
|
|
|
|
|
$this->assertEquals('file://' . $keyFile, $key->getKeyPath());
|
|
|
|
$this->assertEquals('secret', $key->getPassPhrase());
|
2017-10-30 20:51:17 +05:30
|
|
|
|
2017-10-31 14:44:46 +05:30
|
|
|
$keyFile = __DIR__ . '/Stubs/private.key.crlf';
|
2017-10-30 20:51:17 +05:30
|
|
|
$key = new CryptKey($keyFile, 'secret');
|
|
|
|
|
|
|
|
$this->assertEquals('file://' . $keyFile, $key->getKeyPath());
|
|
|
|
$this->assertEquals('secret', $key->getPassPhrase());
|
2016-07-19 20:45:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
public function testKeyFileCreation()
|
|
|
|
{
|
|
|
|
$keyContent = file_get_contents(__DIR__ . '/Stubs/public.key');
|
|
|
|
$key = new CryptKey($keyContent);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'file://' . sys_get_temp_dir() . '/' . sha1($keyContent) . '.key',
|
|
|
|
$key->getKeyPath()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|