Add Store icons to database feature

This commit is contained in:
Bubka
2024-10-18 14:28:45 +02:00
parent 51d6a6c649
commit f009b31a68
59 changed files with 3268 additions and 839 deletions

View File

@@ -5,6 +5,8 @@ namespace Tests\Unit;
use App\Exceptions\EncryptedMigrationException;
use App\Exceptions\InvalidMigrationDataException;
use App\Exceptions\UnsupportedMigrationException;
use App\Facades\Icons;
use App\Facades\IconStore;
use App\Factories\MigratorFactory;
use App\Models\TwoFAccount;
use App\Providers\MigrationServiceProvider;
@@ -72,10 +74,12 @@ class MigratorTest extends TestCase
{
parent::setUp();
$this->mock(SettingService::class, function (MockInterface $settingService) {
$settingService->allows()
->get('useEncryption')
->andReturn(false);
$this->mock(SettingService::class, function (MockInterface $iconStore) {
foreach (config('2fauth.settings') as $setting => $value) {
$iconStore->shouldReceive('get')
->with($setting)
->andReturn($value);
}
});
$this->totpTwofaccount = new TwoFAccount;
@@ -360,6 +364,7 @@ class MigratorTest extends TestCase
#[DataProvider('AegisWithIconMigrationProvider')]
public function test_migrate_aegis_payload_with_icon_sets_and_stores_the_icon($migration)
{
Icons::spy();
Storage::fake('icons');
$migrator = new AegisMigrator;
@@ -368,6 +373,7 @@ class MigratorTest extends TestCase
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
$this->assertCount(1, $accounts);
Icons::shouldHaveReceived('buildFromResource')->once();
Storage::disk('icons')->assertExists($accounts->first()->icon);
}
@@ -408,14 +414,16 @@ class MigratorTest extends TestCase
#[DataProvider('TwoFAuthWithIconMigrationProvider')]
public function test_migrate_2fauth_payload_with_icon_sets_and_stores_the_icon($migration)
{
Icons::spy();
Storage::fake('icons');
$migrator = new TwoFAuthMigrator;
$accounts = $migrator->migrate($migration);
$this->assertContainsOnlyInstancesOf(TwoFAccount::class, $accounts);
$this->assertCount(1, $accounts);
Icons::shouldHaveReceived('buildFromResource')->once();
Storage::disk('icons')->assertExists($accounts->first()->icon);
}