mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add Crypto Unit Test
This commit is contained in:
parent
b3827566a2
commit
da27cc6ce3
1 changed files with 31 additions and 0 deletions
31
tests/Unit/CryptoTest.php
Normal file
31
tests/Unit/CryptoTest.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class CryptoTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test to check if PHPSecLib is installed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLibraryInstalled()
|
||||
{
|
||||
$this->assertTrue(class_exists('\phpseclib\Crypt\RSA'));
|
||||
}
|
||||
|
||||
public function testRSASigning()
|
||||
{
|
||||
$rsa = new \phpseclib\Crypt\RSA();
|
||||
extract($rsa->createKey());
|
||||
$rsa->loadKey($privatekey);
|
||||
$plaintext = 'pixelfed rsa test';
|
||||
$signature = $rsa->sign($plaintext);
|
||||
$rsa->loadKey($publickey);
|
||||
$this->assertTrue($rsa->verify($plaintext, $signature));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue