#feature: some update
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class HostAccessTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
config(['toolbox.admin_host' => 'toolbox.local']);
|
||||
}
|
||||
|
||||
public function test_admin_host_can_open_the_toolbox_menu(): void
|
||||
{
|
||||
$response = $this->get('http://toolbox.local/');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('<admin-dashboard>', false);
|
||||
}
|
||||
|
||||
public function test_ip_host_gets_the_standalone_production_diagnosis_page(): void
|
||||
{
|
||||
$response = $this->get('http://192.168.1.20/production-diagnosis');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('<production-diagnosis>', false);
|
||||
$response->assertDontSee('<admin-dashboard>', false);
|
||||
}
|
||||
|
||||
public function test_ip_host_cannot_open_other_toolbox_pages(): void
|
||||
{
|
||||
$this
|
||||
->get('http://192.168.1.20/')
|
||||
->assertNotFound();
|
||||
|
||||
$this
|
||||
->get('http://192.168.1.20/env')
|
||||
->assertNotFound();
|
||||
|
||||
$this
|
||||
->get('http://192.168.1.20/settings')
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_ip_host_can_only_call_the_production_diagnosis_api(): void
|
||||
{
|
||||
$this
|
||||
->postJson('http://192.168.1.20/api/production-diagnosis/diagnose', [])
|
||||
->assertUnprocessable();
|
||||
|
||||
$this
|
||||
->getJson('http://192.168.1.20/api/admin/meta')
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_unconfigured_hostname_is_rejected(): void
|
||||
{
|
||||
$this
|
||||
->get('http://attacker.example/production-diagnosis')
|
||||
->assertNotFound();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user