mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-28 16:00:24 +05:30
Fixed tests, allow whitespace at the end of a key
This commit is contained in:
parent
2ec8d148b0
commit
91d9c11fb4
@ -14,7 +14,7 @@ namespace League\OAuth2\Server;
|
|||||||
class CryptKey
|
class CryptKey
|
||||||
{
|
{
|
||||||
const RSA_KEY_PATTERN =
|
const RSA_KEY_PATTERN =
|
||||||
'/^(-----BEGIN (RSA )?(PUBLIC|PRIVATE) KEY-----).+(-----END (RSA )?(PUBLIC|PRIVATE) KEY-----)$/s';
|
'/^(-----BEGIN (RSA )?(PUBLIC|PRIVATE) KEY-----).+(-----END (RSA )?(PUBLIC|PRIVATE) KEY-----)\s*$/s';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -21,12 +21,6 @@ class CryptKeyTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals('file://' . $keyFile, $key->getKeyPath());
|
$this->assertEquals('file://' . $keyFile, $key->getKeyPath());
|
||||||
$this->assertEquals('secret', $key->getPassPhrase());
|
$this->assertEquals('secret', $key->getPassPhrase());
|
||||||
|
|
||||||
$keyFile = __DIR__ . '/Stubs/private.key.crlf';
|
|
||||||
$key = new CryptKey($keyFile, 'secret');
|
|
||||||
|
|
||||||
$this->assertEquals('file://' . $keyFile, $key->getKeyPath());
|
|
||||||
$this->assertEquals('secret', $key->getPassPhrase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testKeyFileCreation()
|
public function testKeyFileCreation()
|
||||||
@ -38,5 +32,13 @@ class CryptKeyTest extends \PHPUnit_Framework_TestCase
|
|||||||
'file://' . sys_get_temp_dir() . '/' . sha1($keyContent) . '.key',
|
'file://' . sys_get_temp_dir() . '/' . sha1($keyContent) . '.key',
|
||||||
$key->getKeyPath()
|
$key->getKeyPath()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$keyContent = file_get_contents(__DIR__ . '/Stubs/private.key.crlf');
|
||||||
|
$key = new CryptKey($keyContent);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
'file://' . sys_get_temp_dir() . '/' . sha1($keyContent) . '.key',
|
||||||
|
$key->getKeyPath()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user