mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Add unit tests for signature creation and verification routines
This commit is contained in:
parent
910f7220e6
commit
2822a1d3e1
1 changed files with 11 additions and 0 deletions
|
|
@ -55,6 +55,17 @@ class SecurityTest extends \Codeception\TestCase\Test
|
|||
$this->assertEquals(false, $decrypted);
|
||||
}
|
||||
|
||||
public function testSignature()
|
||||
{
|
||||
$plaintext = Rhymix\Framework\Security::getRandom();
|
||||
|
||||
$signature = Rhymix\Framework\Security::createSignature($plaintext);
|
||||
$this->assertRegexp('/^[a-zA-Z0-9-_]{40}$/', $signature);
|
||||
$this->assertEquals(true, Rhymix\Framework\Security::verifySignature($plaintext, $signature));
|
||||
$this->assertEquals(false, Rhymix\Framework\Security::verifySignature($plaintext, $signature . 'x'));
|
||||
$this->assertEquals(false, Rhymix\Framework\Security::verifySignature($plaintext, 'x' . $signature));
|
||||
}
|
||||
|
||||
public function testGetRandom()
|
||||
{
|
||||
$this->assertRegExp('/^[0-9a-zA-Z]{32}$/', Rhymix\Framework\Security::getRandom());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue