@@ -1,8 +1,17 @@
|
||||
<?php
|
||||
|
||||
use App\Services\EvaluationAccess;
|
||||
use App\Services\EvaluationNavigation;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
test('local evaluation root opens the dashboard while other installations retain their home page', function () {
|
||||
$this->get('/')->assertOk();
|
||||
app()->instance('env', 'payable-testing');
|
||||
$this->get('http://127.0.0.1:8005/')->assertRedirect('/dashboard');
|
||||
$this->get('http://127.0.0.1:8015/')->assertOk();
|
||||
$this->get('http://compras.tempo.co.mz:8005/')->assertOk();
|
||||
});
|
||||
|
||||
test('local evaluation links send a guest to the existing password-free entry and retain the intended report', function () {
|
||||
app()->instance('env', 'payable-testing');
|
||||
$this->get('http://127.0.0.1:8005/relatorios?status=approved')->assertRedirect('/avaliar')
|
||||
@@ -11,10 +20,35 @@ test('local evaluation links send a guest to the existing password-free entry an
|
||||
});
|
||||
|
||||
test('normal application still uses its credential login', function () {
|
||||
$this->get('/dashboard')->assertRedirect('/login');
|
||||
$this->get('/relatorios')->assertRedirect('/login');
|
||||
$this->get('/login')->assertOk();
|
||||
});
|
||||
|
||||
test('automatic dashboard entry is restricted to the exact local evaluation address', function () {
|
||||
app()->instance('env', 'payable-testing');
|
||||
$access = new EvaluationAccess;
|
||||
foreach ([
|
||||
['http://127.0.0.1:8005/dashboard', 'GET', '127.0.0.1', true],
|
||||
['http://127.0.0.1:8015/dashboard', 'GET', '127.0.0.1', false],
|
||||
['http://localhost:8005/dashboard', 'GET', '127.0.0.1', false],
|
||||
['http://127.0.0.1:8005/empresa', 'GET', '127.0.0.1', false],
|
||||
['http://127.0.0.1:8005/dashboard', 'POST', '127.0.0.1', false],
|
||||
['http://127.0.0.1:8005/dashboard', 'GET', '192.0.2.1', false],
|
||||
['http://compras.tempo.co.mz:8005/dashboard', 'GET', '127.0.0.1', false],
|
||||
] as [$url, $method, $ip, $allowed]) {
|
||||
expect($access->dashboardEntry(Request::create($url, $method, [], [], [], ['REMOTE_ADDR' => $ip])))->toBe($allowed);
|
||||
}
|
||||
app()->instance('env', 'production');
|
||||
expect($access->dashboardEntry(Request::create('http://127.0.0.1:8005/dashboard', 'GET', [], [], [], ['REMOTE_ADDR' => '127.0.0.1'])))->toBeFalse();
|
||||
});
|
||||
|
||||
test('automatic entry fails closed outside the isolated evaluation database', function () {
|
||||
app()->instance('env', 'payable-testing');
|
||||
$this->get('http://127.0.0.1:8005/dashboard')->assertNotFound();
|
||||
$this->assertGuest();
|
||||
});
|
||||
|
||||
test('evaluation navigation requires both a local client and local host', function () {
|
||||
app()->instance('env', 'payable-testing');
|
||||
foreach ([['http://127.0.0.1:8005/relatorios', '127.0.0.1', true], ['http://compras.tempo.co.mz/relatorios', '127.0.0.1', false], ['http://localhost:8005/relatorios', '192.0.2.1', false]] as [$url, $ip, $allowed]) {
|
||||
|
||||
Reference in New Issue
Block a user