Start of processing packets - implemented PING Responce to Netmail
This commit is contained in:
94
tests/Feature/RoutingTest.php
Normal file
94
tests/Feature/RoutingTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\Domain;
|
||||
|
||||
class RoutingTest extends TestCase
|
||||
{
|
||||
private function zone(): Collection
|
||||
{
|
||||
$do = Domain::where('name','Domain A')->singleOrFail();
|
||||
$zo = $do->zones->where('zone_id',100)->pop();
|
||||
return $zo->addresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the ZC address.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_zc()
|
||||
{
|
||||
$nodes = $this->zone();
|
||||
$this->assertEquals(51,$nodes->count());
|
||||
|
||||
/*
|
||||
* ZCs addresses are not in the address table, so we cannot workout children
|
||||
$zc = $nodes->where('role',DomainController::NODE_ZC);
|
||||
$this->assertEquals(1,$zc->count());
|
||||
$zc = $zc->pop();
|
||||
|
||||
// ZC has 2 Region and 3 nodes as children
|
||||
$this->assertEquals(5,$zc->children());
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the RC address.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_rc()
|
||||
{
|
||||
$nodes = $this->zone();
|
||||
$rc = $nodes->where('role','Region');
|
||||
$this->assertEquals(2,$rc->count());
|
||||
|
||||
// First RC
|
||||
$rc = $rc->pop();
|
||||
|
||||
// RC has 3 nodes and 2 hosts as children
|
||||
$this->assertEquals(5,$rc->children->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the NC address.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_nc()
|
||||
{
|
||||
$nodes = $this->zone();
|
||||
$nc = $nodes->where('role','Host');
|
||||
$this->assertEquals(4,$nc->count());
|
||||
|
||||
// First NC
|
||||
$nc = $nc->pop();
|
||||
|
||||
// NC has 3 nodes and 2 hubs as children
|
||||
$this->assertEquals(5,$nc->children->count());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the HC address.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_hc()
|
||||
{
|
||||
$nodes = $this->zone();
|
||||
$hc = $nodes->where('role','Hub');
|
||||
//dd($hc->pluck('ftn'));
|
||||
$this->assertEquals(8,$hc->count());
|
||||
|
||||
// First HC
|
||||
$hc = $hc->pop();
|
||||
|
||||
// HC has 2 children
|
||||
$this->assertEquals(2,$hc->children->count());
|
||||
}
|
||||
}
|
@@ -28,15 +28,15 @@ class SiteAdminTest extends TestCase
|
||||
$this->get('ftn/zone')
|
||||
->assertRedirect('login');
|
||||
|
||||
$this->get('network/1')
|
||||
$this->get('network/999')
|
||||
->assertNotFound();
|
||||
|
||||
Domain::factory()->create([
|
||||
'id'=>1,
|
||||
'id'=>999,
|
||||
'name'=>'test',
|
||||
]);
|
||||
|
||||
$this->get('network/1')
|
||||
$this->get('network/999')
|
||||
->assertOK();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user