平台订单筛选表单:仅透传安全back(补测试)
This commit is contained in:
@@ -249,6 +249,9 @@
|
|||||||
<div class="card mb-20">
|
<div class="card mb-20">
|
||||||
<h3>筛选条件</h3>
|
<h3>筛选条件</h3>
|
||||||
<form method="get" action="/admin/platform-orders" class="grid-3">
|
<form method="get" action="/admin/platform-orders" class="grid-3">
|
||||||
|
@if($safeBackForLinks !== '')
|
||||||
|
<input type="hidden" name="back" value="{!! $safeBackForLinks !!}">
|
||||||
|
@endif
|
||||||
<select name="status">
|
<select name="status">
|
||||||
<option value="">全部订单状态</option>
|
<option value="">全部订单状态</option>
|
||||||
@foreach(($filterOptions['statuses'] ?? []) as $value => $label)
|
@foreach(($filterOptions['statuses'] ?? []) as $value => $label)
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderIndexFilterFormDropsUnsafeBackTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->seed();
|
||||||
|
|
||||||
|
$this->post('/admin/login', [
|
||||||
|
'email' => 'platform.admin@demo.local',
|
||||||
|
'password' => 'Platform@123456',
|
||||||
|
])->assertRedirect('/admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_filter_form_should_drop_unsafe_back_as_hidden_input(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
// 含引号的 back:必须丢弃
|
||||||
|
$back = "/admin/platform-leads?keyword=\"on\"";
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders?back=' . urlencode($back));
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$res->assertDontSee('name="back"', false);
|
||||||
|
$res->assertDontSee('value="' . $back . '"', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminPlatformOrderIndexFilterFormKeepsSafeBackTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function loginAsPlatformAdmin(): void
|
||||||
|
{
|
||||||
|
$this->seed();
|
||||||
|
|
||||||
|
$this->post('/admin/login', [
|
||||||
|
'email' => 'platform.admin@demo.local',
|
||||||
|
'password' => 'Platform@123456',
|
||||||
|
])->assertRedirect('/admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_index_filter_form_should_keep_safe_back_as_hidden_input(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$back = '/admin/platform-leads?status=new&keyword=demo';
|
||||||
|
|
||||||
|
$res = $this->get('/admin/platform-orders?back=' . urlencode($back));
|
||||||
|
$res->assertOk();
|
||||||
|
|
||||||
|
$res->assertSee('name="back" value="' . $back . '"', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user