mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-01-14 03:16:51 +00:00
This change is discussed in #104 Currently, the library defaults to a QR Code Provider using an external service, thus leaking secrets. This change forces the definition of a QR Code Provider in the constructor. It is a breaking change. fixes #104
27 lines
767 B
PHP
27 lines
767 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace TestsDependency;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use RobThree\Auth\Algorithm;
|
|
use RobThree\Auth\Providers\Qr\EndroidQrCodeProvider;
|
|
use RobThree\Auth\Providers\Qr\HandlesDataUri;
|
|
use RobThree\Auth\TwoFactorAuth;
|
|
|
|
class EndroidQRCodeTest extends TestCase
|
|
{
|
|
use HandlesDataUri;
|
|
|
|
public function testDependency(): void
|
|
{
|
|
$qr = new EndroidQrCodeProvider();
|
|
$tfa = new TwoFactorAuth($qr, 'Test&Issuer', 6, 30, Algorithm::Sha1);
|
|
$data = $this->DecodeDataUri($tfa->getQRCodeImageAsDataUri('Test&Label', 'VMR466AB62ZBOKHE'));
|
|
$this->assertSame('image/png', $data['mimetype']);
|
|
$this->assertSame('base64', $data['encoding']);
|
|
$this->assertNotEmpty($data['data']);
|
|
}
|
|
}
|