get('/shell/badges.json')->assertRedirect(); } public function test_admin_gets_the_firing_alert_count(): void { $this->actingAs(User::factory()->create(['must_change_password' => false])); $server = Server::create(['name' => 'box', 'ip' => '10.0.0.1', 'ssh_port' => 22, 'status' => 'online']); $rule = AlertRule::create(['name' => 'CPU', 'metric' => 'cpu', 'comparator' => 'gt', 'threshold' => 80, 'scope_type' => 'all', 'enabled' => true]); AlertIncident::create(['alert_rule_id' => $rule->id, 'server_id' => $server->id, 'state' => 'firing', 'value' => 95, 'firing_key' => $rule->id.':'.$server->id, 'started_at' => now()]); $this->getJson('/shell/badges.json') ->assertOk() ->assertJson(['alerts' => 1, 'threats' => 0]); } public function test_non_panel_roles_get_zeroed_alert_and_threat_counts(): void { // Operators/viewers don't see the Alerts/Threats nav items, so the endpoint must not leak // those counts to them either. $this->actingAs(User::factory()->operator()->create(['must_change_password' => false])); $this->getJson('/shell/badges.json') ->assertOk() ->assertJson(['alerts' => 0, 'threats' => 0]); } }