Change the way we figure out zones in packets, some packet testing, fix Echomail import
This commit is contained in:
118
tests/Feature/PacketTest.php
Normal file
118
tests/Feature/PacketTest.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Symfony\Component\HttpFoundation\File\File;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Classes\FTN\Packet;
|
||||
use App\Models\{Address,Domain,System,Zone};
|
||||
|
||||
class PacketTest extends TestCase
|
||||
{
|
||||
private System $so;
|
||||
private Domain $do;
|
||||
|
||||
private function init()
|
||||
{
|
||||
System::unguard();
|
||||
Domain::unguard();
|
||||
$this->so = System::firstOrCreate(['name'=>'test','sysop'=>'sysop','location'=>'location','active'=>TRUE]);
|
||||
$this->do = Domain::firstOrCreate(['name'=>'test','active'=>TRUE]);
|
||||
}
|
||||
|
||||
public function test_nomsgid_origin()
|
||||
{
|
||||
$this->init();
|
||||
|
||||
Zone::unguard();
|
||||
Address::unguard();
|
||||
$zo = Zone::firstOrCreate(['zone_id'=>21,'default'=>TRUE,'active'=>TRUE,'domain_id'=>$this->do->id,'system_id'=>$this->so->id]);
|
||||
$src = Address::firstOrCreate(['zone_id'=>$zo->id,'region_id'=>0,'host_id'=>3,'node_id'=>151,'point_id'=>0,'active'=>TRUE,'system_id'=>$this->so->id]);
|
||||
$hub = Address::firstOrCreate(['zone_id'=>$zo->id,'region_id'=>0,'host_id'=>1,'node_id'=>1,'point_id'=>0,'active'=>TRUE,'system_id'=>$this->so->id]);
|
||||
$ao = Address::firstOrCreate(['zone_id'=>$zo->id,'region_id'=>0,'host_id'=>1,'node_id'=>4,'point_id'=>0,'active'=>TRUE,'system_id'=>$this->so->id]);
|
||||
|
||||
// This packet has an incorrect zone in the Origin
|
||||
$f = new File(__DIR__.'/data/test_nomsgid_origin.pkt');
|
||||
$pkt = Packet::open($f);
|
||||
|
||||
$this->assertEquals(1,$pkt->count());
|
||||
|
||||
$messages = FALSE;
|
||||
foreach ($pkt as $msg) {
|
||||
$messages = TRUE;
|
||||
$this->assertNotTrue($msg->isNetmail());
|
||||
|
||||
$this->assertNotFalse($msg->pathaddress->search($hub->id));
|
||||
|
||||
$this->assertCount(1,$msg->rogue_path);
|
||||
$this->assertNotFalse($msg->rogue_path->search('21:999/1'));
|
||||
|
||||
$this->assertCount(3,$msg->rogue_seen);
|
||||
$this->assertNotFalse($msg->rogue_seen->search('21:999/1'));
|
||||
$this->assertNotFalse($msg->rogue_seen->search('21:999/999'));
|
||||
}
|
||||
|
||||
$this->assertTrue($messages);
|
||||
}
|
||||
|
||||
public function test_nomsgid_noorigin()
|
||||
{
|
||||
$this->init();
|
||||
|
||||
Zone::unguard();
|
||||
Address::unguard();
|
||||
$zo = Zone::firstOrCreate(['zone_id'=>10,'default'=>TRUE,'active'=>TRUE,'domain_id'=>$this->do->id,'system_id'=>$this->so->id]);
|
||||
$src = Address::firstOrCreate(['zone_id'=>$zo->id,'region_id'=>0,'host_id'=>999,'node_id'=>1,'point_id'=>0,'active'=>TRUE,'system_id'=>$this->so->id]);
|
||||
|
||||
// This packet has an incorrect zone in the Origin
|
||||
$f = new File(__DIR__.'/data/test_nomsgid_noorigin.pkt');
|
||||
$pkt = Packet::open($f,$zo,TRUE);
|
||||
|
||||
$this->assertEquals(1,$pkt->count());
|
||||
|
||||
$messages = FALSE;
|
||||
foreach ($pkt as $msg) {
|
||||
$messages = TRUE;
|
||||
$this->assertNotTrue($msg->isNetmail());
|
||||
|
||||
$this->assertCount(1,$msg->rogue_path);
|
||||
$this->assertNotFalse($msg->rogue_path->search('10:1/1'));
|
||||
|
||||
$this->assertCount(0,$msg->rogue_seen);
|
||||
}
|
||||
|
||||
$this->assertTrue($messages);
|
||||
}
|
||||
|
||||
public function test_msgid_origin()
|
||||
{
|
||||
$this->init();
|
||||
|
||||
Zone::unguard();
|
||||
Address::unguard();
|
||||
$zo = Zone::firstOrCreate(['zone_id'=>10,'default'=>TRUE,'active'=>TRUE,'domain_id'=>$this->do->id,'system_id'=>$this->so->id]);
|
||||
$src = Address::firstOrCreate(['zone_id'=>$zo->id,'region_id'=>0,'host_id'=>999,'node_id'=>1,'point_id'=>0,'active'=>TRUE,'system_id'=>$this->so->id]);
|
||||
|
||||
// This packet has an incorrect zone in the Origin
|
||||
$f = new File(__DIR__.'/data/test_msgid_origin.pkt');
|
||||
$pkt = Packet::open($f,$zo,TRUE);
|
||||
|
||||
$this->assertEquals(1,$pkt->count());
|
||||
|
||||
$messages = FALSE;
|
||||
foreach ($pkt as $msg) {
|
||||
$messages = TRUE;
|
||||
$this->assertNotTrue($msg->isNetmail());
|
||||
$this->assertCount(0,$msg->rogue_path);
|
||||
|
||||
$this->assertCount(2,$msg->rogue_seen);
|
||||
$this->assertNotFalse($msg->rogue_seen->search('10:1/1'));
|
||||
$this->assertNotFalse($msg->rogue_seen->search('10:999/999'));
|
||||
|
||||
$this->assertNotFalse($msg->seenaddress->search($src->id));
|
||||
}
|
||||
|
||||
$this->assertTrue($messages);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user