Revisione blocchi 2 e 3: file protetti, ripristino atomico, import sicuri
Blocco 2 - Esiti delle azioni Livewire come avvisi (trait Avvisa) invece di flash che comparivano alla pagina dopo. - PDF, miniature e versioni dei territori non più serviti da nginx su /storage: TerritorioFileController con login, permessi e cache privata. - Ripristino tutto o niente: verifica dell'archivio, una transazione con import, piantine, blocco account e scambio dei file annullabile. - Backup formato 2 con piantine, storico PDF e area KML. - Posto unico preso in un passo (Cache::lock) e rispettato anche da import XML e PDF. - Import PDF da cartella: abbinamento corretto (1-A, 12 B, ambigui), caricamento a lotti, file non PDF ignorati, PDF sostituito nello storico. - L'import XML elimina i file dei territori che non usa più; comando territori:file-orfani per quelli accumulati prima. Blocco 3 - Password attuale richiesta al cambio volontario; AuthenticateSession chiude le sessioni aperte altrove. - Niente nomi dei proclamatori in chiaro nel registro attività. - Export XML senza remember_token; chi riceve l'hash dal file deve cambiare password. - Campagne: ultimo giorno incluso, percentuale sui territori distinti. - Coda: retry_after 960 s, stop_grace_period 16m, Redis volatile-lru, impostazioni rilette a ogni job. - Azzeramento che cancella anche piantine, area KML e anteprime. - Pulsanti profilo e menu che non si nascondevano; icona del sito. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -186,6 +186,41 @@ class XmlExchangeImportTest extends TestCase
|
||||
$this->assertTrue($altro->hasRole('assistente'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Le credenziali che arrivano da un file non sono più segrete: chi riceve
|
||||
* l'hash dal file deve cambiare password, e il "ricordami" non viaggia.
|
||||
*/
|
||||
public function test_le_credenziali_del_file_obbligano_a_cambiare_password(): void
|
||||
{
|
||||
$this->admin->forceFill(['remember_token' => 'token-attuale'])->save();
|
||||
$hash = Hash::make('password-del-file');
|
||||
$xml = $this->xmlMinimo(
|
||||
utenti: '<user legacy_id="9"><name>Amministratore</name><email>admin@example.test</email><password>' . $hash . '</password><remember_token>vecchio</remember_token><roles></roles></user>'
|
||||
. '<user legacy_id="10"><name>Altro</name><email>altro@example.test</email><password>' . $hash . '</password><remember_token>rubato</remember_token><roles><role>assistente</role></roles></user>',
|
||||
);
|
||||
|
||||
$this->assertArrayNotHasKey('error', $this->importa($xml));
|
||||
|
||||
$altro = User::where('email', 'altro@example.test')->sole();
|
||||
$this->assertTrue((bool) $altro->password_change_required);
|
||||
$this->assertNull($altro->remember_token);
|
||||
|
||||
// Chi importa resta com'era.
|
||||
$admin = $this->admin->fresh();
|
||||
$this->assertFalse((bool) $admin->password_change_required);
|
||||
$this->assertSame('token-attuale', $admin->getRememberToken());
|
||||
}
|
||||
|
||||
public function test_l_export_non_contiene_i_remember_token(): void
|
||||
{
|
||||
$this->admin->forceFill(['remember_token' => 'token-segreto'])->save();
|
||||
|
||||
$xml = (new XmlExchange())->currentXmlBackup();
|
||||
|
||||
$this->assertStringNotContainsString('remember_token', $xml);
|
||||
$this->assertStringNotContainsString('token-segreto', $xml);
|
||||
}
|
||||
|
||||
// ─── helper ─────────────────────────────────────────────────
|
||||
|
||||
private function reimporta(?string $xml = null): void
|
||||
|
||||
Reference in New Issue
Block a user