feat: mem
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Models\Channel;
|
||||
use App\Models\Device;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\User;
|
||||
use App\Models\WalletAddress;
|
||||
use App\Models\WalletMnemonic;
|
||||
use App\Services\AdminGoogle2fa;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -386,6 +387,108 @@ class MnemonicRevealTest extends TestCase
|
||||
return $secret;
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function address_list_super_sees_reveal_url_for_collectible(): void
|
||||
{
|
||||
config(['coruna.mnemonic_reveal.staff_enabled' => false]);
|
||||
$admin = Admin::query()->create([
|
||||
'username' => 'root',
|
||||
'password' => 'secret12',
|
||||
'is_super' => 1,
|
||||
]);
|
||||
$mnemonic = $this->storeMnemonic();
|
||||
$device = Device::query()->whereKey($mnemonic->device_id)->first();
|
||||
// Create unlinked first so linked (higher id) sorts as data.0 (default desc).
|
||||
$unlinked = WalletAddress::query()->create([
|
||||
'device_id' => $device->id,
|
||||
'address' => 'addr-unlinked',
|
||||
'source' => 'imToken',
|
||||
'chain_type' => 'ETH',
|
||||
]);
|
||||
$linked = WalletAddress::query()->create([
|
||||
'device_id' => $device->id,
|
||||
'address' => 'addr-linked',
|
||||
'source' => 'imToken',
|
||||
'chain_type' => 'ETH',
|
||||
'mnemonic_id' => $mnemonic->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($admin, 'admin')
|
||||
->getJson(route('admin.addresses.data'))
|
||||
->assertOk()
|
||||
->assertJsonPath('count', 2)
|
||||
->assertJsonPath('data.0.address', 'addr-linked')
|
||||
->assertJsonPath('data.0.reveal_url', route('admin.mnemonics.reveal', $mnemonic))
|
||||
->assertJsonPath('data.0.collectable', true)
|
||||
->assertJsonPath('data.0.mnemonic_id', $mnemonic->id)
|
||||
->assertJsonPath('data.1.address', 'addr-unlinked')
|
||||
->assertJsonPath('data.1.reveal_url', '')
|
||||
->assertJsonPath('data.1.collectable', false);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function address_list_normal_admin_has_no_reveal_url(): void
|
||||
{
|
||||
config(['coruna.mnemonic_reveal.staff_enabled' => false]);
|
||||
$admin = Admin::query()->create([
|
||||
'username' => 'staff',
|
||||
'password' => 'secret12',
|
||||
'is_super' => 0,
|
||||
]);
|
||||
$mnemonic = $this->storeMnemonic();
|
||||
$device = Device::query()->whereKey($mnemonic->device_id)->first();
|
||||
WalletAddress::query()->create([
|
||||
'device_id' => $device->id,
|
||||
'address' => 'addr-linked',
|
||||
'source' => 'imToken',
|
||||
'chain_type' => 'ETH',
|
||||
'mnemonic_id' => $mnemonic->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($admin, 'admin')
|
||||
->getJson(route('admin.addresses.data'))
|
||||
->assertOk()
|
||||
->assertJsonPath('data.0.reveal_url', '')
|
||||
->assertJsonPath('data.0.collectable', true);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function address_index_view_has_reveal_button_for_super(): void
|
||||
{
|
||||
config(['coruna.mnemonic_reveal.staff_enabled' => false]);
|
||||
$admin = Admin::query()->create([
|
||||
'username' => 'root',
|
||||
'password' => 'secret12',
|
||||
'is_super' => 1,
|
||||
]);
|
||||
|
||||
$resp = $this->actingAs($admin, 'admin')
|
||||
->get(route('admin.addresses.index'))
|
||||
->assertOk();
|
||||
|
||||
$html = $resp->getContent();
|
||||
$this->assertStringContainsString('查看助记词', $html);
|
||||
$this->assertStringContainsString('lay-event="reveal"', $html);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function address_index_view_has_no_reveal_button_for_normal_admin(): void
|
||||
{
|
||||
config(['coruna.mnemonic_reveal.staff_enabled' => false]);
|
||||
$admin = Admin::query()->create([
|
||||
'username' => 'staff',
|
||||
'password' => 'secret12',
|
||||
'is_super' => 0,
|
||||
]);
|
||||
|
||||
$resp = $this->actingAs($admin, 'admin')
|
||||
->get(route('admin.addresses.index'))
|
||||
->assertOk();
|
||||
|
||||
$html = $resp->getContent();
|
||||
$this->assertStringNotContainsString('lay-event="reveal"', $html);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function bind_can_skip_login_verify(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user