mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-11 09:40:43 +01:00
90 lines
18 KiB
PHP
90 lines
18 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Services;
|
|
|
|
use App\Facades\QrCode;
|
|
use App\Providers\TwoFAuthServiceProvider;
|
|
use App\Services\QrCodeService;
|
|
use Exception;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Tests\Classes\LocalFile;
|
|
use Tests\FeatureTestCase;
|
|
use Zxing\ChecksumException;
|
|
use Zxing\FormatException;
|
|
use Zxing\NotFoundException;
|
|
use Zxing\QrReader;
|
|
|
|
/**
|
|
* QrCodeServiceTest test class
|
|
*/
|
|
#[CoversClass(QrCodeService::class)]
|
|
#[CoversClass(QrCode::class)]
|
|
#[CoversClass(TwoFAuthServiceProvider::class)]
|
|
class QrCodeServiceTest extends FeatureTestCase
|
|
{
|
|
private const STRING_TO_ENCODE = 'x';
|
|
|
|
// private const STRING_ENCODED = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJxci1zdmcgcXJjb2RlIiB2aWV3Qm94PSIwIDAgMjUgMjUiIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj4KPHBhdGggY2xhc3M9InFyLWRhdGEgbGlnaHQgcXJjb2RlIiBmaWxsPSIjZmZmIiBkPSJNMTEgMiBoMSB2MSBoLTFaIE0xMyAyIGgxIHYxIGgtMVogTTExIDMgaDEgdjEgaC0xWiBNMTIgMyBoMSB2MSBoLTFaIE0xMyAzIGgxIHYxIGgtMVogTTExIDQgaDEgdjEgaC0xWiBNMTMgNCBoMSB2MSBoLTFaIE0xNCA0IGgxIHYxIGgtMVogTTExIDUgaDEgdjEgaC0xWiB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B2MSBoLTFaIE00IDYgaDEgdjEgaC0xWiBNNSA2IGgxIHYxIGgtMVogTTYgNiBoMSB2MSBoLTFaIE0xOCA2IGgxIHYxIGgtMVogTTE5IDYgaDEgdjEgaC0xWiBNMjAgNiBoMSB2MSBoLTFaIE00IDE4IGgxIHYxIGgtMVogTTUgMTggaDEgdjEgaC0xWiBNNiAxOCBoMSB2MSBoLTFaIE00IDE5IGgxIHYxIGgtMVogTTUgMTkgaDEgdjEgaC0xWiBNNiAxOSBoMSB2MSBoLTFaIE00IDIwIGgxIHYxIGgtMVogTTUgMjAgaDEgdjEgaC0xWiBNNiAyMCBoMSB2MSBoLTFaIi8+Cjwvc3ZnPgo=';
|
|
|
|
private const DECODED_IMAGE = 'otpauth://totp/test@test.com?secret=A4GRFHVIRBGY7UIW';
|
|
|
|
public function setUp() : void
|
|
{
|
|
parent::setUp();
|
|
}
|
|
|
|
// #[Test]
|
|
// public function test_encode_returns_correct_value()
|
|
// {
|
|
// $this->assertEquals(self::STRING_ENCODED, QrCode::encode(self::STRING_TO_ENCODE));
|
|
// }
|
|
|
|
#[Test]
|
|
public function test_decode_valid_image_returns_correct_value()
|
|
{
|
|
$file = LocalFile::fake()->validQrcode();
|
|
|
|
$this->assertEquals(self::DECODED_IMAGE, QrCode::decode($file));
|
|
}
|
|
|
|
#[Test]
|
|
public function test_decode_invalid_image_throws_an_exception()
|
|
{
|
|
$this->expectException(\App\Exceptions\InvalidQrCodeException::class);
|
|
|
|
QrCode::decode(LocalFile::fake()->invalidQrcode());
|
|
}
|
|
|
|
#[Test]
|
|
#[DataProvider('QrReaderExceptionProvider')]
|
|
public function test_decode_throws_an_exception($exception)
|
|
{
|
|
$this->expectException(\App\Exceptions\InvalidQrCodeException::class);
|
|
|
|
// QrReader is a final class, so we need to mock it here with a new object instance
|
|
// to then bind it to the container
|
|
$fileContent = LocalFile::fake()->validQrcode()->get();
|
|
$qrReader = \Mockery::mock(new QrReader($fileContent, QrReader::SOURCE_TYPE_BLOB))->makePartial();
|
|
$qrReader->shouldReceive('text')->andReturn('');
|
|
$qrReader->shouldReceive('getError')->andReturn($exception);
|
|
|
|
$this->app->bind(QrReader::class, function () use ($qrReader) {
|
|
return $qrReader;
|
|
});
|
|
|
|
QrCode::decode(LocalFile::fake()->validQrcode());
|
|
}
|
|
|
|
public static function QrReaderExceptionProvider()
|
|
{
|
|
return [
|
|
'NotFoundException' => [new NotFoundException],
|
|
'FormatException' => [new FormatException],
|
|
'ChecksumException' => [new ChecksumException],
|
|
'default' => [new Exception],
|
|
];
|
|
}
|
|
}
|