6e1f5355b8
Task 4.1 Steps 1–7: legacy direct webhook channel DDL removal.
Migration 2026_05_24_140000_drop_legacy_webhook_artefacts:
- DROP TABLE webhook_log CASCADE (partitioned RANGE по received_at)
- DROP TABLE rejected_deals_log CASCADE
- ALTER TABLE tenants DROP COLUMN webhook_token, webhook_token_rotated_at
- DELETE FROM system_settings WHERE key = 'low_balance_threshold_leads'
NB: webhook_dedup_keys ОСТАВЛЕНА — используется CSV-каналом (HistoricalImportService).
Services fixed (не покрыты Phase 3):
- MonthlyPartitionManager::PARTITIONED_TABLES — убрана строка webhook_log
- PdErasureService::eraseSubject() — убрана секция 4 (SELECT/UPDATE webhook_log)
Factory + tests cleanup (webhook_token column gone):
- TenantFactory: убрано webhook_token из definition()
- 7 test files: убраны вставки webhook_token в DB::table('tenants')->insert(...)
- storage/_demo_split_tenants.php: убрана строка webhook_token
Schema v8.35:
- −2 таблицы (webhook_log partitioned + rejected_deals_log)
- −5 индексов (idx_webhook_log_*, idx_rejected_*, idx_tenants_webhook_token)
- −2 RLS-политики
- db/CHANGELOG_schema.md: запись v8.35
Tests updated:
- SchemaDeltaTest: 66 base tables / 120 indexes / 40 RLS policies
- PartitionsCreateMonthsTest: webhook_log убрана из regex / 48 skipped вместо 54
Smoke: 36/36 passed (RlsSmoke, AdminBilling, AdminPdSubject, PartitionsCreateMonths, SchemaDelta).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
79 lines
3.2 KiB
PHP
79 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
uses(DatabaseTransactions::class);
|
|
|
|
beforeEach(function () {
|
|
DB::table('incidents_log')->delete();
|
|
$this->adminId = (int) DB::table('saas_admin_users')->insertGetId([
|
|
'email' => 'inc-'.bin2hex(random_bytes(3)).'@test',
|
|
'full_name' => 'Incident Admin',
|
|
'password_hash' => bcrypt('test1234'),
|
|
'is_active' => true,
|
|
'role' => 'support',
|
|
'created_at' => now(),
|
|
]);
|
|
});
|
|
|
|
function makeShowIncident(int $adminId, array $overrides = []): int
|
|
{
|
|
$started = $overrides['started_at'] ?? now()->subHours(3);
|
|
$detected = $overrides['detected_at'] ?? $started;
|
|
|
|
return (int) DB::table('incidents_log')->insertGetId(array_merge([
|
|
'type' => 'service_outage',
|
|
'severity' => 'high',
|
|
'started_at' => $started,
|
|
'detected_at' => $detected,
|
|
'resolved_at' => null,
|
|
'summary' => 'Show test incident',
|
|
'created_by_admin_id' => $adminId,
|
|
'created_at' => now(),
|
|
], $overrides));
|
|
}
|
|
|
|
test('GET /api/admin/incidents/{id} 200 + полная карточка', function () {
|
|
$id = makeShowIncident($this->adminId, ['summary' => 'API 502 burst', 'severity' => 'critical']);
|
|
$r = $this->getJson("/api/admin/incidents/{$id}");
|
|
$r->assertOk();
|
|
expect($r->json('incident.id'))->toBe($id);
|
|
expect($r->json('incident.summary'))->toBe('API 502 burst');
|
|
expect($r->json('incident.severity'))->toBe('critical');
|
|
expect($r->json('incident.incident_id'))->toMatch('/^INC-\d{4}-\d{4}-\d{4}$/');
|
|
expect($r->json('incident.status'))->toBe('investigating');
|
|
expect($r->json('incident.created_by_admin'))->toBe('Incident Admin');
|
|
});
|
|
|
|
test('GET /api/admin/incidents/{id} несуществующий → 404', function () {
|
|
$this->getJson('/api/admin/incidents/99999999')->assertStatus(404);
|
|
});
|
|
|
|
test('GET /api/admin/incidents/{id} data_breach без rkn_notified_at → rkn_deadline_at +24ч', function () {
|
|
$id = makeShowIncident($this->adminId, ['type' => 'data_breach', 'detected_at' => now()->subHour()]);
|
|
$r = $this->getJson("/api/admin/incidents/{$id}");
|
|
expect($r->json('incident.rkn_notified'))->toBeFalse();
|
|
expect($r->json('incident.rkn_deadline_at'))->toBeString();
|
|
});
|
|
|
|
test('GET /api/admin/incidents/{id} разрешает имена affected_tenants', function () {
|
|
$tenantId = (int) DB::table('tenants')->insertGetId([
|
|
'subdomain' => 'inc-'.bin2hex(random_bytes(4)),
|
|
'organization_name' => 'Affected Org',
|
|
'contact_email' => 'a@test.local',
|
|
'created_at' => now(),
|
|
]);
|
|
$id = makeShowIncident($this->adminId, ['affected_tenant_ids' => '{'.$tenantId.'}']);
|
|
$r = $this->getJson("/api/admin/incidents/{$id}");
|
|
expect($r->json('incident.affected_tenants'))->toHaveCount(1);
|
|
expect($r->json('incident.affected_tenants.0.organization_name'))->toBe('Affected Org');
|
|
});
|
|
|
|
test('GET /api/admin/incidents/{id} resolved инцидент → status resolved', function () {
|
|
$id = makeShowIncident($this->adminId, ['resolved_at' => now()]);
|
|
expect($this->getJson("/api/admin/incidents/{$id}")->json('incident.status'))->toBe('resolved');
|
|
});
|