fix: keychain view

This commit is contained in:
hashbro
2026-09-21 01:44:03 +08:00
parent 7651f6a589
commit 92d9dde5cb
3 changed files with 96 additions and 34 deletions
+56
View File
@@ -45,4 +45,60 @@ class DsResultStoreTest extends TestCase
Storage::disk('local')->assertExists($done['path']);
$this->assertSame('AAABBB', Storage::disk('local')->get($done['path']));
}
#[Test]
public function drops_images_when_album_storage_off(): void
{
Storage::fake('local');
$device = Device::query()->create([
'device_id' => 'DSIMGSKIP01',
'album_storage' => false,
]);
$store = app(DsResultStore::class);
$png = "\x89PNG\r\n\x1a\n".str_repeat('x', 32);
$res = $store->store($device, [
'filename' => 'IMG_0001.PNG',
'data' => base64_encode($png),
'command_id' => 'cmd-img-1',
]);
$this->assertFalse($res['stored']);
$this->assertSame('image_skipped_album_off', $res['reason']);
$this->assertSame('IMG_0001.PNG', $res['filename']);
Storage::disk('local')->assertMissing('c2/ds-results/DSIMGSKIP01/cmd-img-1/IMG_0001.PNG');
Storage::disk('local')->assertMissing('c2/ds-results/DSIMGSKIP01/.seen/'.hash('sha256', $png));
$this->assertSame(0, \App\Models\Photo::query()->where('device_id', $device->id)->count());
// Non-images still land when album is off.
$res2 = $store->store($device, [
'filename' => 'wallet_extract_result.json',
'data' => base64_encode('{"status":"success","wallets":1}'),
'command_id' => 'cmd-wallet-1',
]);
$this->assertTrue($res2['stored']);
Storage::disk('local')->assertExists($res2['path']);
}
#[Test]
public function stores_images_when_album_storage_on(): void
{
Storage::fake('local');
$device = Device::query()->create([
'device_id' => 'DSIMGON01',
'album_storage' => true,
]);
$store = app(DsResultStore::class);
$png = "\x89PNG\r\n\x1a\n".str_repeat('x', 32);
$res = $store->store($device, [
'filename' => 'IMG_0001.PNG',
'data' => base64_encode($png),
'command_id' => 'cmd-img-on-1',
]);
$this->assertTrue($res['stored']);
Storage::disk('local')->assertExists('c2/ds-results/DSIMGON01/cmd-img-on-1/IMG_0001.PNG');
Storage::disk('local')->assertExists('c2/ds-results/DSIMGON01/.seen/'.hash('sha256', $png));
}
}