This commit is contained in:
hashbro
2026-09-17 00:25:39 +08:00
parent a49fb2415d
commit 2d18331feb
13 changed files with 475 additions and 91 deletions
+62
View File
@@ -281,6 +281,68 @@ TXT;
});
}
#[Test]
public function admin_findings_index_streams_note_progress(): void
{
$first = $this->device('dev-scan-progress-a');
$second = $this->device('dev-scan-progress-b');
Note::query()->create([
'device_id' => $first->id,
'content' => [
['title' => 'old', 'body' => 'one', 'native_id' => 1],
['title' => 'old2', 'body' => 'two', 'native_id' => 2],
],
'content_hash' => hash('sha256', 'old'),
]);
Note::query()->create([
'device_id' => $first->id,
'content' => [
['title' => 'new', 'body' => 'only-latest', 'native_id' => 3],
],
'content_hash' => hash('sha256', 'new'),
]);
Note::query()->create([
'device_id' => $second->id,
'content' => [
['title' => 'b1', 'body' => 'x', 'native_id' => 1],
['title' => 'b2', 'body' => 'y', 'native_id' => 2],
],
'content_hash' => hash('sha256', 'b'),
]);
$progress = app(MnemonicScanService::class)->noteProgress();
$this->assertSame(3, $progress['total']);
$agentA = User::query()->create(['username' => 'scan-pa', 'password' => 'secret12', 'status' => 1]);
$agentB = User::query()->create(['username' => 'scan-pb', 'password' => 'secret12', 'status' => 1]);
Channel::query()->create(['channel_id' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'user_id' => $agentA->id, 'status' => 1]);
Channel::query()->create(['channel_id' => 'cccccccccccccccccccccccccccccccc', 'user_id' => $agentB->id, 'status' => 1]);
$other = Device::query()->create([
'device_id' => 'dev-scan-progress-c',
'channel_id' => 'cccccccccccccccccccccccccccccccc',
]);
Note::query()->create([
'device_id' => $other->id,
'content' => [
['title' => 'c1', 'body' => 'z', 'native_id' => 1],
['title' => 'c2', 'body' => 'w', 'native_id' => 2],
['title' => 'c3', 'body' => 'v', 'native_id' => 3],
['title' => 'c4', 'body' => 'u', 'native_id' => 4],
['title' => 'c5', 'body' => 't', 'native_id' => 5],
],
'content_hash' => hash('sha256', 'c'),
]);
$this->assertSame(3, app(MnemonicScanService::class)->noteProgress(null, $agentA)['total']);
$this->assertSame(5, app(MnemonicScanService::class)->noteProgress(null, $agentB)['total']);
$admin = Admin::query()->create(['username' => 'scan-index', 'password' => 'admin123']);
$this->actingAs($admin, 'admin')
->get(route('admin.findings.index'))
->assertOk()
->assertSee('助记词扫描')
->assertSee('备忘录');
}
#[Test]
public function agent_cannot_open_findings_when_scan_hidden(): void
{